mirror of
https://github.com/EttusResearch/uhd.git
synced 2026-10-25 17:36:10 +00:00
examples: rfnoc-gain: Add GR submodule
Add a GNU Radio module (gr-rfnoc_gain) which provides bindings for the gain block into GNU Radio. This is used as an example for how to write GNU Radio OOT modules. This GNU Radio OOT includes: - Native C++ block for the gain block controller - A generic version of the same block (available in GRC) - GRC bindings - GRC examples
This commit is contained in:
parent
563600521e
commit
1d8026bcfe
@ -29,6 +29,10 @@ out-of-tree blocks.
|
||||
(e.g., `/usr/share/uhd/rfnoc/fpga/gain`) so the image builder can find
|
||||
all the source files when compiling bitfiles that use multiple OOT modules.
|
||||
|
||||
* `gr-rfnoc_gain`: An out-of-tree module for GNU Radio, which depends on this
|
||||
RFNoC out-of-tree module and provides GNU Radio and GNU Radio Companion
|
||||
bindings for using the gain block from within GNU Radio.
|
||||
|
||||
* `icores`: Stores full image core files. YAML files in this directory get
|
||||
picked up by CMake and get turned into build targets. For example, here we
|
||||
include an image core file called `x310_rfnoc_image_core.yml` which defines
|
||||
|
||||
202
host/examples/rfnoc-gain/gr-rfnoc_gain/.clang-format
Normal file
202
host/examples/rfnoc-gain/gr-rfnoc_gain/.clang-format
Normal file
@ -0,0 +1,202 @@
|
||||
---
|
||||
Language: Cpp
|
||||
AccessModifierOffset: -4
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignArrayOfStructures: None
|
||||
AlignConsecutiveMacros: None
|
||||
AlignConsecutiveAssignments: None
|
||||
AlignConsecutiveBitFields: None
|
||||
AlignConsecutiveDeclarations: None
|
||||
AlignEscapedNewlines: Left
|
||||
AlignOperands: Align
|
||||
AlignTrailingComments: true
|
||||
AllowAllArgumentsOnNextLine: true
|
||||
AllowAllParametersOfDeclarationOnNextLine: true
|
||||
AllowShortEnumsOnASingleLine: true
|
||||
AllowShortBlocksOnASingleLine: Never
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: All
|
||||
AllowShortLambdasOnASingleLine: All
|
||||
AllowShortIfStatementsOnASingleLine: Never
|
||||
AllowShortLoopsOnASingleLine: false
|
||||
AlwaysBreakAfterDefinitionReturnType: None
|
||||
AlwaysBreakAfterReturnType: None
|
||||
AlwaysBreakBeforeMultilineStrings: false
|
||||
AlwaysBreakTemplateDeclarations: Yes
|
||||
AttributeMacros:
|
||||
- __capability
|
||||
BinPackArguments: false
|
||||
BinPackParameters: false
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: false
|
||||
AfterClass: true
|
||||
AfterControlStatement: Never
|
||||
AfterEnum: false
|
||||
AfterFunction: true
|
||||
AfterNamespace: false
|
||||
AfterObjCDeclaration: false
|
||||
AfterStruct: false
|
||||
AfterUnion: false
|
||||
AfterExternBlock: false
|
||||
BeforeCatch: false
|
||||
BeforeElse: false
|
||||
BeforeLambdaBody: false
|
||||
BeforeWhile: false
|
||||
IndentBraces: false
|
||||
SplitEmptyFunction: true
|
||||
SplitEmptyRecord: true
|
||||
SplitEmptyNamespace: true
|
||||
BreakBeforeBinaryOperators: None
|
||||
BreakBeforeConceptDeclarations: true
|
||||
BreakBeforeBraces: Custom
|
||||
BreakBeforeInheritanceComma: false
|
||||
BreakInheritanceList: BeforeColon
|
||||
BreakBeforeTernaryOperators: true
|
||||
BreakConstructorInitializersBeforeComma: false
|
||||
BreakConstructorInitializers: BeforeColon
|
||||
BreakAfterJavaFieldAnnotations: false
|
||||
BreakStringLiterals: true
|
||||
ColumnLimit: 90
|
||||
CommentPragmas: '^ IWYU pragma:'
|
||||
QualifierAlignment: Leave
|
||||
CompactNamespaces: false
|
||||
ConstructorInitializerIndentWidth: 4
|
||||
ContinuationIndentWidth: 4
|
||||
Cpp11BracedListStyle: false
|
||||
DeriveLineEnding: true
|
||||
DerivePointerAlignment: false
|
||||
DisableFormat: false
|
||||
EmptyLineAfterAccessModifier: Never
|
||||
EmptyLineBeforeAccessModifier: LogicalBlock
|
||||
ExperimentalAutoDetectBinPacking: false
|
||||
PackConstructorInitializers: NextLine
|
||||
BasedOnStyle: ''
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
||||
AllowAllConstructorInitializersOnNextLine: true
|
||||
FixNamespaceComments: true
|
||||
ForEachMacros:
|
||||
- foreach
|
||||
- Q_FOREACH
|
||||
- BOOST_FOREACH
|
||||
IfMacros:
|
||||
- KJ_IF_MAYBE
|
||||
IncludeBlocks: Preserve
|
||||
IncludeCategories:
|
||||
- Regex: '^"(gnuradio)/'
|
||||
Priority: 1
|
||||
SortPriority: 0
|
||||
CaseSensitive: false
|
||||
- Regex: '^<(gnuradio)/'
|
||||
Priority: 2
|
||||
SortPriority: 0
|
||||
CaseSensitive: false
|
||||
- Regex: '^<(boost)/'
|
||||
Priority: 98
|
||||
SortPriority: 0
|
||||
CaseSensitive: false
|
||||
- Regex: '^<[a-z]*>$'
|
||||
Priority: 99
|
||||
SortPriority: 0
|
||||
CaseSensitive: false
|
||||
- Regex: '^".*"$'
|
||||
Priority: 0
|
||||
SortPriority: 0
|
||||
CaseSensitive: false
|
||||
- Regex: '.*'
|
||||
Priority: 10
|
||||
SortPriority: 0
|
||||
CaseSensitive: false
|
||||
IncludeIsMainRegex: '(Test)?$'
|
||||
IncludeIsMainSourceRegex: ''
|
||||
IndentAccessModifiers: false
|
||||
IndentCaseLabels: false
|
||||
IndentCaseBlocks: false
|
||||
IndentGotoLabels: true
|
||||
IndentPPDirectives: None
|
||||
IndentExternBlock: AfterExternBlock
|
||||
IndentRequires: false
|
||||
IndentWidth: 4
|
||||
IndentWrappedFunctionNames: false
|
||||
InsertTrailingCommas: None
|
||||
JavaScriptQuotes: Leave
|
||||
JavaScriptWrapImports: true
|
||||
KeepEmptyLinesAtTheStartOfBlocks: true
|
||||
LambdaBodyIndentation: Signature
|
||||
MacroBlockBegin: ''
|
||||
MacroBlockEnd: ''
|
||||
MaxEmptyLinesToKeep: 2
|
||||
NamespaceIndentation: None
|
||||
ObjCBinPackProtocolList: Auto
|
||||
ObjCBlockIndentWidth: 2
|
||||
ObjCBreakBeforeNestedBlockParam: true
|
||||
ObjCSpaceAfterProperty: false
|
||||
ObjCSpaceBeforeProtocolList: true
|
||||
PenaltyBreakAssignment: 2
|
||||
PenaltyBreakBeforeFirstCallParameter: 19
|
||||
PenaltyBreakComment: 300
|
||||
PenaltyBreakFirstLessLess: 120
|
||||
PenaltyBreakOpenParenthesis: 0
|
||||
PenaltyBreakString: 1000
|
||||
PenaltyBreakTemplateDeclaration: 10
|
||||
PenaltyExcessCharacter: 1000000
|
||||
PenaltyReturnTypeOnItsOwnLine: 60
|
||||
PenaltyIndentedWhitespace: 0
|
||||
PointerAlignment: Left
|
||||
PPIndentWidth: -1
|
||||
ReferenceAlignment: Pointer
|
||||
ReflowComments: true
|
||||
RemoveBracesLLVM: false
|
||||
SeparateDefinitionBlocks: Leave
|
||||
ShortNamespaceLines: 1
|
||||
SortIncludes: CaseSensitive
|
||||
SortJavaStaticImport: Before
|
||||
SortUsingDeclarations: true
|
||||
SpaceAfterCStyleCast: false
|
||||
SpaceAfterLogicalNot: false
|
||||
SpaceAfterTemplateKeyword: true
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeCaseColon: false
|
||||
SpaceBeforeCpp11BracedList: false
|
||||
SpaceBeforeCtorInitializerColon: true
|
||||
SpaceBeforeInheritanceColon: true
|
||||
SpaceBeforeParens: ControlStatements
|
||||
SpaceBeforeParensOptions:
|
||||
AfterControlStatements: true
|
||||
AfterForeachMacros: true
|
||||
AfterFunctionDefinitionName: false
|
||||
AfterFunctionDeclarationName: false
|
||||
AfterIfMacros: true
|
||||
AfterOverloadedOperator: false
|
||||
BeforeNonEmptyParentheses: false
|
||||
SpaceAroundPointerQualifiers: Default
|
||||
SpaceBeforeRangeBasedForLoopColon: true
|
||||
SpaceInEmptyBlock: false
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesBeforeTrailingComments: 1
|
||||
SpacesInAngles: Never
|
||||
SpacesInConditionalStatement: false
|
||||
SpacesInContainerLiterals: true
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInLineCommentPrefix:
|
||||
Minimum: 1
|
||||
Maximum: -1
|
||||
SpacesInParentheses: false
|
||||
SpacesInSquareBrackets: false
|
||||
SpaceBeforeSquareBrackets: false
|
||||
BitFieldColonSpacing: Both
|
||||
Standard: Latest
|
||||
StatementAttributeLikeMacros:
|
||||
- Q_EMIT
|
||||
StatementMacros:
|
||||
- Q_UNUSED
|
||||
- QT_REQUIRE_VERSION
|
||||
TabWidth: 8
|
||||
UseCRLF: false
|
||||
UseTab: Never
|
||||
WhitespaceSensitiveMacros:
|
||||
- STRINGIZE
|
||||
- PP_STRINGIZE
|
||||
- BOOST_PP_STRINGIZE
|
||||
- NS_SWIFT_NAME
|
||||
- CF_SWIFT_NAME
|
||||
|
||||
62
host/examples/rfnoc-gain/gr-rfnoc_gain/.cmake-format.py
Normal file
62
host/examples/rfnoc-gain/gr-rfnoc_gain/.cmake-format.py
Normal file
@ -0,0 +1,62 @@
|
||||
# Copyright 2021 Marcus Müller
|
||||
# SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
class _clang_format_options:
|
||||
def __init__(self, clangfile=None):
|
||||
if not clangfile:
|
||||
clangfile = ".clang-format"
|
||||
self.lines = []
|
||||
with open(clangfile, encoding="utf-8") as opened:
|
||||
for line in opened:
|
||||
if line.strip().startswith("#"):
|
||||
continue
|
||||
self.lines.append(line.rstrip().split(":"))
|
||||
|
||||
def __getitem__(self, string):
|
||||
path = string.split(".")
|
||||
value = None
|
||||
for crumble in path:
|
||||
for line in self.lines:
|
||||
if line[0].strip() == crumble:
|
||||
if len(line) > 1:
|
||||
value = line[1].strip().rstrip()
|
||||
break
|
||||
return value
|
||||
|
||||
|
||||
_clang_format = _clang_format_options()
|
||||
|
||||
with section("parse"):
|
||||
additional_commands = {
|
||||
'gr_python_install': {
|
||||
'flags': [],
|
||||
'kwargs': {
|
||||
"PROGRAMS": "*",
|
||||
"FILES": "*",
|
||||
"DESTINATION": "*"
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
with section("markup"):
|
||||
first_comment_is_literal = True
|
||||
enable_markup = False
|
||||
|
||||
with section("format"):
|
||||
disable = False
|
||||
line_width = int(_clang_format["ColumnLimit"])
|
||||
tab_size = int(_clang_format["IndentWidth"])
|
||||
min_prefix_chars = tab_size
|
||||
max_prefix_chars = 3 * tab_size
|
||||
use_tabchars = _clang_format["UseTab"] in ("ForIndentation",
|
||||
"ForContinuationAndIndentation",
|
||||
"Always")
|
||||
separate_ctrl_name_with_space = False
|
||||
separate_fn_name_with_space = False
|
||||
dangle_parens = False
|
||||
command_case = 'canonical'
|
||||
keyword_case = 'upper'
|
||||
|
||||
with section("lint"):
|
||||
max_arguments = 6
|
||||
max_localvars = 20
|
||||
max_statements = 75
|
||||
110
host/examples/rfnoc-gain/gr-rfnoc_gain/.conda/README.md
Normal file
110
host/examples/rfnoc-gain/gr-rfnoc_gain/.conda/README.md
Normal file
@ -0,0 +1,110 @@
|
||||
# gr-rfnoc_gain conda recipe
|
||||
|
||||
This recipe is for creating a package that can be installed into a [conda](https://docs.conda.io/en/latest/) environment. See the [Conda GNU Radio Guide](https://wiki.gnuradio.org/index.php/CondaInstall) for more information on using GNU Radio with conda.
|
||||
|
||||
Packages for GNU Radio and some out-of-tree (OOT) modules are available through the [`conda-forge` channel](https://conda-forge.org/). If this OOT module is already available (search "gnuradio" on [anaconda.org](https://anaconda.org)), it is preferable to use that existing package rather than this recipe.
|
||||
|
||||
#### Users
|
||||
|
||||
- [Building the package](#building-the-package)
|
||||
|
||||
#### Developers
|
||||
|
||||
- [Modifying the recipe](#modifying-the-recipe)
|
||||
- [Continuous integration](#continuous-integration)
|
||||
|
||||
|
||||
## Building the package
|
||||
|
||||
(See the [Conda GNU Radio Guide](https://wiki.gnuradio.org/index.php/CondaInstall) if you are unfamiliar with how to use conda.)
|
||||
|
||||
1. Make sure that have `conda-build` and `conda-forge-pinning` installed and updated in your base environment:
|
||||
|
||||
conda activate base
|
||||
conda install -n base conda-build conda-forge-pinning
|
||||
conda upgrade -n base conda-build conda-forge-pinning
|
||||
|
||||
**Windows users only**: you will also need to have Microsoft's Visual C++ build tools installed. Usually you can do this by installing the [Community edition of Visual Studio](https://visualstudio.microsoft.com/free-developer-offers/) and then selecting a MSVC C++ x64/x86 build tools component under the list of "Individual Components". As of this writing, you will specifically need MSVC v142, i.e. the "MSVC v142 - VS 2019 C++ x64/x86 build tools" component. If the build fails to find the version of MSVC it is looking for, try installing other (newer) versions.
|
||||
|
||||
2. Download the source code for this OOT module (which includes this recipe). Typically, this is done by using `git` and cloning the module's repository:
|
||||
|
||||
git clone <repository_url>
|
||||
cd <repository_name>
|
||||
|
||||
3. Run `conda-build` on the recipe to create the package:
|
||||
|
||||
(Linux and macOS)
|
||||
|
||||
conda build .conda/recipe/ -m ${CONDA_PREFIX}/conda_build_config.yaml
|
||||
|
||||
(Windows)
|
||||
|
||||
conda build .conda\recipe\ -m %CONDA_PREFIX%\conda_build_config.yaml
|
||||
|
||||
If you plan on using this package within an existing environment which uses a specific version of Python, specify the version of Python using the `--python` flag. You must use a version string that matches one of the strings listed under `python` in the `${CONDA_PREFIX}/conda_build_config.yaml` file, e.g:
|
||||
|
||||
(Linux and macOS)
|
||||
|
||||
conda build .conda/recipe/ -m ${CONDA_PREFIX}/conda_build_config.yaml --python="3.9.* *_cpython"
|
||||
|
||||
(Windows)
|
||||
|
||||
conda build .conda\recipe\ -m %CONDA_PREFIX%\conda_build_config.yaml --python="3.9.* *_cpython"
|
||||
|
||||
If you encounter errors, consult with the OOT module maintainer or the maintainers of the [gnuradio feedstock](https://github.com/conda-forge/gnuradio-feedstock). It is possible that the recipe will need to be updated.
|
||||
|
||||
4. Install the package into an existing environment
|
||||
|
||||
conda install --use-local -n <environment_name> gnuradio-rfnoc_gain
|
||||
|
||||
or create a new environment that includes the package:
|
||||
|
||||
conda create -n test_env gnuradio-rfnoc_gain
|
||||
|
||||
|
||||
## Modifying the recipe
|
||||
|
||||
This recipe is derived from a template, and so it is best to check it and make any necessary modifications. Likely changes include:
|
||||
|
||||
- Populating metadata near the bottom of the `recipe/meta.yaml` file
|
||||
- Adding "host" (build-time) and "run" (run-time) dependencies specific to your module in `recipe/meta.yaml`
|
||||
- Adding special configuration flags or steps are necessary to carry out the build to the build scripts (`recipe/build.sh` for Linux/macOS and `recipe/bld.bat` for Windows)
|
||||
|
||||
Specifying the versions of GNU Radio that your OOT is compatible with is one of the most important modifications. Following the instructions below, the module will be built against the conda-forge "pinned" version of GNU Radio, which is usually the latest version.
|
||||
|
||||
- To override the pinned version of GNU Radio (e.g. for a branch that builds against an older version), specify the `gnuradio_core` key as instructed in `recipe/conda_build_config.yaml`.
|
||||
- If the module is compatible with multiple major versions of GNU Radio, and you want to build against multiple of them, you can also add extra versions to `recipe/conda_build_config.yaml` to expand the default build matrix.
|
||||
|
||||
See the [conda-build documentation](https://docs.conda.io/projects/conda-build/en/latest/index.html) for details on how to write a conda recipe.
|
||||
|
||||
|
||||
## Continuous integration
|
||||
|
||||
Only a few steps are needed to use this recipe to build and test this OOT module using CI services. It can also be used to upload packages to [anaconda.org](https://anaconda.org) for others to download and use.
|
||||
|
||||
1. Make sure that have `conda-smithy` installed in your base conda environment:
|
||||
|
||||
conda activate base
|
||||
conda install -n base conda-smithy
|
||||
conda upgrade -n base conda-smithy
|
||||
|
||||
2. Make any changes to the recipe and `conda-forge.yml` that are necessary. For example, if you plan on uploading packages to your own [anaconda.org](https://anaconda.org) channel, specify the channel name and label as the `channel_targets` key in `recipe/conda_build_config.yaml`. Commit the changes to your repository:
|
||||
|
||||
git commit -a
|
||||
|
||||
3. "Re-render" the CI scripts by running conda-smithy from the root of your repository:
|
||||
|
||||
conda-smithy rerender --feedstock_config .conda/conda-forge.yml -c auto
|
||||
|
||||
This will create a commit that adds or updates the CI scripts that have been configured with `conda-forge.yml`. If you want to minimize extraneous files, you can remove some of the newly-created files that are not necessary outside of a typical conda-forge feedstock:
|
||||
|
||||
git rm -f .github/workflows/automerge.yml .github/workflows/webservices.yml .circleci/config.yml
|
||||
git commit --amend -s
|
||||
|
||||
When the CI is executed (on a pull request or commit), it will run one job per configuration file in `.ci_support` to build packages for various platforms, Python versions, and optionally `gnuradio` versions (by adding to `gnuradio_extra_pin` in `recipe/conda_build_config.yaml`).
|
||||
|
||||
**You should repeat this step whenever the recipe is updated or when changes to the conda-forge infrastructure require all CI scripts to be updated.**
|
||||
|
||||
Since the newly created files will be rewritten whenever conda-smithy is run, you should not edit any of the automatically-generated files in e.g. `.ci_support`, `.scripts`, or `.github/workflows/conda-build.yml`.
|
||||
|
||||
4. (optional) If you want to enable uploads of the packages to [anaconda.org](https://anaconda.org) whenever the CI is run from a commit on the branch specified in `conda-forge.yml`, you need to set an Anaconda Cloud API token to the `BINSTAR_TOKEN` environment variable. To generate a token, follow the instructions [here](https://docs.anaconda.com/anacondaorg/user-guide/tasks/work-with-accounts/#creating-access-tokens). To populate the `BINSTAR_TOKEN` environment variable for CI jobs, add the token as a secret by following, for example, the [Github docs](https://docs.github.com/en/actions/reference/encrypted-secrets).
|
||||
@ -0,0 +1,33 @@
|
||||
# See https://conda-forge.org/docs/maintainer/conda_forge_yml.html for
|
||||
# documentation on possible keys and values.
|
||||
|
||||
# uncomment to enable cross-compiled builds
|
||||
#build_platform:
|
||||
# linux_aarch64: linux_64
|
||||
# linux_ppc64le: linux_64
|
||||
# osx_arm64: osx_64
|
||||
clone_depth: 0
|
||||
github_actions:
|
||||
cancel_in_progress: false
|
||||
store_build_artifacts: true
|
||||
os_version:
|
||||
linux_64: cos7
|
||||
provider:
|
||||
linux: github_actions
|
||||
osx: github_actions
|
||||
win: github_actions
|
||||
# uncomment to enable emulated builds for additional linux platforms
|
||||
#linux_aarch64: github_actions
|
||||
#linux_ppc64le: github_actions
|
||||
recipe_dir: .conda/recipe
|
||||
# skip unnecessary files since this is not a full-fledged conda-forge feedstock
|
||||
skip_render:
|
||||
- README.md
|
||||
- LICENSE.txt
|
||||
- .gitattributes
|
||||
- .gitignore
|
||||
- build-locally.py
|
||||
- LICENSE
|
||||
test: native_and_emulated
|
||||
# enable uploads to Anaconda Cloud from specified branches only
|
||||
upload_on_branch: main
|
||||
29
host/examples/rfnoc-gain/gr-rfnoc_gain/.conda/recipe/bld.bat
Normal file
29
host/examples/rfnoc-gain/gr-rfnoc_gain/.conda/recipe/bld.bat
Normal file
@ -0,0 +1,29 @@
|
||||
setlocal EnableDelayedExpansion
|
||||
@echo on
|
||||
|
||||
:: Make a build folder and change to it
|
||||
cmake -E make_directory buildconda
|
||||
cd buildconda
|
||||
|
||||
:: configure
|
||||
cmake -G "Ninja" ^
|
||||
-DCMAKE_BUILD_TYPE=Release ^
|
||||
-DCMAKE_INSTALL_PREFIX="%LIBRARY_PREFIX%" ^
|
||||
-DCMAKE_PREFIX_PATH="%LIBRARY_PREFIX%" ^
|
||||
-DGR_PYTHON_DIR="%SP_DIR%" ^
|
||||
-DENABLE_DOXYGEN=OFF ^
|
||||
-DENABLE_TESTING=ON ^
|
||||
..
|
||||
if errorlevel 1 exit 1
|
||||
|
||||
:: build
|
||||
cmake --build . --config Release -- -j%CPU_COUNT%
|
||||
if errorlevel 1 exit 1
|
||||
|
||||
:: install
|
||||
cmake --build . --config Release --target install
|
||||
if errorlevel 1 exit 1
|
||||
|
||||
:: test
|
||||
ctest --build-config Release --output-on-failure --timeout 120 -j%CPU_COUNT%
|
||||
if errorlevel 1 exit 1
|
||||
@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -ex
|
||||
|
||||
cmake -E make_directory buildconda
|
||||
cd buildconda
|
||||
|
||||
cmake_config_args=(
|
||||
-DCMAKE_BUILD_TYPE=Release
|
||||
-DCMAKE_INSTALL_PREFIX=$PREFIX
|
||||
-DLIB_SUFFIX=""
|
||||
-DENABLE_DOXYGEN=OFF
|
||||
-DENABLE_TESTING=ON
|
||||
)
|
||||
|
||||
cmake ${CMAKE_ARGS} -G "Ninja" .. "${cmake_config_args[@]}"
|
||||
cmake --build . --config Release -- -j${CPU_COUNT}
|
||||
cmake --build . --config Release --target install
|
||||
|
||||
if [[ "${CONDA_BUILD_CROSS_COMPILATION:-}" != "1" || "${CROSSCOMPILING_EMULATOR}" != "" ]]; then
|
||||
ctest --build-config Release --output-on-failure --timeout 120 -j${CPU_COUNT}
|
||||
fi
|
||||
@ -0,0 +1,14 @@
|
||||
# this is the channel and label where packages will be uploaded to if enabled
|
||||
# (see ../README.md)
|
||||
channel_targets:
|
||||
- gnuradio main
|
||||
# override the conda-forge pin for gnuradio-core by uncommenting
|
||||
# and specifying a different version here
|
||||
#gnuradio_core:
|
||||
#- "3.10.1"
|
||||
gnuradio_extra_pin:
|
||||
# always leave one entry with the empty string
|
||||
- ""
|
||||
# add version strings here like to get builds for versions other than
|
||||
# the conda-forge-wide default or version specified above for gnuradio_core
|
||||
#- "3.9.5"
|
||||
@ -0,0 +1,95 @@
|
||||
{% set oot_name = "rfnoc_gain" %}
|
||||
{% set name = "gnuradio-" + oot_name %}
|
||||
# Set package version from cleaned up git tags if possible,
|
||||
# otherwise fall back to date-based version.
|
||||
{% set tag_version = environ.get("GIT_DESCRIBE_TAG", "")|string|replace("-","_")|replace("v","")|replace("git","") %}
|
||||
{% set post_commit = environ.get("GIT_DESCRIBE_NUMBER", 0)|string %}
|
||||
{% set hash = environ.get("GIT_DESCRIBE_HASH", "local")|string %}
|
||||
{% set fallback_version = "0.0.0.{0}.dev+g{1}".format(datetime.datetime.now().strftime("%Y%m%d"), environ.get("GIT_FULL_HASH", "local")[:9]) %}
|
||||
{% set version = (tag_version if post_commit == "0" else "{0}.post{1}+{2}".format(tag_version, post_commit, hash)) if tag_version else fallback_version %}
|
||||
|
||||
package:
|
||||
name: {{ name|lower }}
|
||||
version: {{ version }}
|
||||
|
||||
source:
|
||||
# use local path or git repository depending on if the build is local or done on CI
|
||||
path: "../.." # [not os.environ.get("CI")]
|
||||
git_url: {{ environ.get('FEEDSTOCK_ROOT', "../..") }} # [os.environ.get("CI")]
|
||||
|
||||
build:
|
||||
number: 0
|
||||
|
||||
requirements:
|
||||
build:
|
||||
- {{ compiler("c") }}
|
||||
- {{ compiler("cxx") }}
|
||||
- cmake
|
||||
- git
|
||||
- ninja
|
||||
- pkg-config
|
||||
# cross-compilation requirements
|
||||
- python # [build_platform != target_platform]
|
||||
- cross-python_{{ target_platform }} # [build_platform != target_platform]
|
||||
- numpy # [build_platform != target_platform]
|
||||
- pybind11 # [build_platform != target_platform]
|
||||
# Add extra build tool dependencies here
|
||||
|
||||
host:
|
||||
- gmp # [linux]
|
||||
# the following two entries are for generating builds against specific GR versions
|
||||
- gnuradio-core # [not gnuradio_extra_pin]
|
||||
- gnuradio-core {{ gnuradio_extra_pin }}.* # [gnuradio_extra_pin]
|
||||
- libboost-headers
|
||||
- pip # [win]
|
||||
- pybind11
|
||||
- python
|
||||
- numpy
|
||||
- volk
|
||||
# Add/remove library dependencies here
|
||||
|
||||
run:
|
||||
- numpy
|
||||
- python
|
||||
# Add/remove runtime dependencies here
|
||||
|
||||
test:
|
||||
commands:
|
||||
# Add a list of commands to run to check that the package works. Examples below.
|
||||
|
||||
## verify that commands run
|
||||
#- COMMAND --help
|
||||
|
||||
## verify that (some) headers get installed
|
||||
- test -f $PREFIX/include/gnuradio/{{ oot_name }}/api.h # [not win]
|
||||
- if not exist %PREFIX%\\Library\\include\\gnuradio\\{{ oot_name }}\\api.h exit 1 # [win]
|
||||
|
||||
## verify that libraries get installed
|
||||
#- test -f $PREFIX/lib/lib{{ name }}${SHLIB_EXT} # [not win]
|
||||
#- if not exist %PREFIX%\\Library\\bin\\{{ name }}.dll exit 1 # [win]
|
||||
#- if not exist %PREFIX%\\Library\\lib\\{{ name }}.lib exit 1 # [win]
|
||||
|
||||
## verify that (some) GRC blocks get installed
|
||||
#{% set blocks = ["LIST", "OF", "GRC", "BLOCK", "NAMES"] %}
|
||||
#{% for block in blocks %}
|
||||
#- test -f $PREFIX/share/gnuradio/grc/blocks/{{ block }}.block.yml # [not win]
|
||||
#- if not exist %PREFIX%\\Library\\share\\gnuradio\\grc\\blocks\\{{ block }}.block.yml exit 1 # [win]
|
||||
#{% endfor %}
|
||||
|
||||
imports:
|
||||
# verify that the python module imports
|
||||
- gnuradio.{{ oot_name }}
|
||||
|
||||
about:
|
||||
# For licenses, use the SPDX identifier, e.g: "GPL-2.0-only" instead of
|
||||
# "GNU General Public License version 2.0". See https://spdx.org/licenses/.
|
||||
# Include the license text by using the license_file entry set to the path
|
||||
# of the license text file within the source directory, e.g. "LICENSE".
|
||||
# See https://docs.conda.io/projects/conda-build/en/latest/resources/define-metadata.html#license-file
|
||||
|
||||
#home: https://github.com/<FIXME>/gr-rfnoc_gain
|
||||
#license: GPL-3.0-or-later
|
||||
#license_file: LICENSE
|
||||
#summary: GNU Radio rfnoc_gain module
|
||||
#description: >
|
||||
# Short description of the gr-rfnoc_gain module.
|
||||
157
host/examples/rfnoc-gain/gr-rfnoc_gain/CMakeLists.txt
Normal file
157
host/examples/rfnoc-gain/gr-rfnoc_gain/CMakeLists.txt
Normal file
@ -0,0 +1,157 @@
|
||||
# Copyright 2011-2020 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file was generated by gr_modtool, a tool from the GNU Radio framework
|
||||
# This file is a part of gr-rfnoc_gain
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#
|
||||
|
||||
# Select the release build type by default to get optimization flags.
|
||||
# This has to come before project() which otherwise initializes it.
|
||||
# Build type can still be overridden by setting -DCMAKE_BUILD_TYPE=
|
||||
set(CMAKE_BUILD_TYPE
|
||||
"Release"
|
||||
CACHE STRING "")
|
||||
|
||||
########################################################################
|
||||
# Project setup
|
||||
########################################################################
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
project(gr-rfnoc_gain CXX C)
|
||||
enable_testing()
|
||||
|
||||
# Install to PyBOMBS target prefix if defined
|
||||
if(DEFINED ENV{PYBOMBS_PREFIX})
|
||||
set(CMAKE_INSTALL_PREFIX
|
||||
$ENV{PYBOMBS_PREFIX}
|
||||
CACHE PATH "")
|
||||
message(
|
||||
STATUS
|
||||
"PyBOMBS installed GNU Radio. Defaulting CMAKE_INSTALL_PREFIX to $ENV{PYBOMBS_PREFIX}"
|
||||
)
|
||||
endif()
|
||||
|
||||
# Make sure our local CMake Modules path comes first
|
||||
list(INSERT CMAKE_MODULE_PATH 0 ${PROJECT_SOURCE_DIR}/cmake/Modules)
|
||||
# Find gnuradio to get access to the cmake modules
|
||||
find_package(Gnuradio "3.10" REQUIRED COMPONENTS uhd)
|
||||
|
||||
# Set the version information here
|
||||
# cmake-format: off
|
||||
set(VERSION_MAJOR 4)
|
||||
set(VERSION_API 7)
|
||||
set(VERSION_ABI 0)
|
||||
set(VERSION_PATCH 0)
|
||||
# cmake-format: on
|
||||
|
||||
cmake_policy(SET CMP0011 NEW)
|
||||
|
||||
# Enable generation of compile_commands.json for code completion engines
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
########################################################################
|
||||
# Minimum Version Requirements
|
||||
########################################################################
|
||||
|
||||
include(GrMinReq)
|
||||
|
||||
########################################################################
|
||||
# Compiler settings
|
||||
########################################################################
|
||||
|
||||
include(GrCompilerSettings)
|
||||
|
||||
########################################################################
|
||||
# Install directories
|
||||
########################################################################
|
||||
include(GrVersion)
|
||||
|
||||
include(GrPlatform) #define LIB_SUFFIX
|
||||
|
||||
if(NOT CMAKE_MODULES_DIR)
|
||||
set(CMAKE_MODULES_DIR lib${LIB_SUFFIX}/cmake)
|
||||
endif(NOT CMAKE_MODULES_DIR)
|
||||
|
||||
set(GR_INCLUDE_DIR include/gnuradio/rfnoc_gain)
|
||||
set(GR_CMAKE_DIR ${CMAKE_MODULES_DIR}/gnuradio-rfnoc_gain)
|
||||
set(GR_PKG_DATA_DIR ${GR_DATA_DIR}/${CMAKE_PROJECT_NAME})
|
||||
set(GR_PKG_DOC_DIR ${GR_DOC_DIR}/${CMAKE_PROJECT_NAME})
|
||||
set(GR_PKG_CONF_DIR ${GR_CONF_DIR}/${CMAKE_PROJECT_NAME}/conf.d)
|
||||
set(GR_PKG_LIBEXEC_DIR ${GR_LIBEXEC_DIR}/${CMAKE_PROJECT_NAME})
|
||||
|
||||
########################################################################
|
||||
# On Apple only, set install name and use rpath correctly, if not already set
|
||||
########################################################################
|
||||
if(APPLE)
|
||||
if(NOT CMAKE_INSTALL_NAME_DIR)
|
||||
set(CMAKE_INSTALL_NAME_DIR
|
||||
${CMAKE_INSTALL_PREFIX}/${GR_LIBRARY_DIR}
|
||||
CACHE PATH "Library Install Name Destination Directory" FORCE)
|
||||
endif(NOT CMAKE_INSTALL_NAME_DIR)
|
||||
if(NOT CMAKE_INSTALL_RPATH)
|
||||
set(CMAKE_INSTALL_RPATH
|
||||
${CMAKE_INSTALL_PREFIX}/${GR_LIBRARY_DIR}
|
||||
CACHE PATH "Library Install RPath" FORCE)
|
||||
endif(NOT CMAKE_INSTALL_RPATH)
|
||||
if(NOT CMAKE_BUILD_WITH_INSTALL_RPATH)
|
||||
set(CMAKE_BUILD_WITH_INSTALL_RPATH
|
||||
ON
|
||||
CACHE BOOL "Do Build Using Library Install RPath" FORCE)
|
||||
endif(NOT CMAKE_BUILD_WITH_INSTALL_RPATH)
|
||||
endif(APPLE)
|
||||
|
||||
########################################################################
|
||||
# Find gnuradio build dependencies
|
||||
########################################################################
|
||||
find_package(Doxygen)
|
||||
|
||||
########################################################################
|
||||
# Setup doxygen option
|
||||
########################################################################
|
||||
if(DOXYGEN_FOUND)
|
||||
option(ENABLE_DOXYGEN "Build docs using Doxygen" ON)
|
||||
else(DOXYGEN_FOUND)
|
||||
option(ENABLE_DOXYGEN "Build docs using Doxygen" OFF)
|
||||
endif(DOXYGEN_FOUND)
|
||||
|
||||
########################################################################
|
||||
# Create uninstall target
|
||||
########################################################################
|
||||
configure_file(${PROJECT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake @ONLY)
|
||||
|
||||
add_custom_target(uninstall ${CMAKE_COMMAND} -P
|
||||
${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
|
||||
|
||||
########################################################################
|
||||
# Add subdirectories
|
||||
########################################################################
|
||||
add_subdirectory(include/gnuradio/rfnoc_gain)
|
||||
add_subdirectory(lib)
|
||||
add_subdirectory(apps)
|
||||
add_subdirectory(examples)
|
||||
add_subdirectory(docs)
|
||||
# NOTE: manually update below to use GRC to generate C++ flowgraphs w/o python
|
||||
if(ENABLE_PYTHON)
|
||||
message(STATUS "PYTHON and GRC components are enabled")
|
||||
add_subdirectory(python/rfnoc_gain)
|
||||
add_subdirectory(grc)
|
||||
else(ENABLE_PYTHON)
|
||||
message(STATUS "PYTHON and GRC components are disabled")
|
||||
endif(ENABLE_PYTHON)
|
||||
|
||||
########################################################################
|
||||
# Install cmake search helper for this library
|
||||
########################################################################
|
||||
|
||||
install(FILES cmake/Modules/gnuradio-rfnoc_gainConfig.cmake DESTINATION ${GR_CMAKE_DIR})
|
||||
|
||||
include(CMakePackageConfigHelpers)
|
||||
configure_package_config_file(
|
||||
${PROJECT_SOURCE_DIR}/cmake/Modules/targetConfig.cmake.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/cmake/Modules/${target}Config.cmake
|
||||
INSTALL_DESTINATION ${GR_CMAKE_DIR})
|
||||
|
||||
install(FILES MANIFEST.yml
|
||||
RENAME MANIFEST-${VERSION_MAJOR}.${VERSION_API}.${VERSION_ABI}${VERSION_PATCH}.yml
|
||||
DESTINATION share/gnuradio/manifests/rfnoc_gain)
|
||||
19
host/examples/rfnoc-gain/gr-rfnoc_gain/MANIFEST.yml
Normal file
19
host/examples/rfnoc-gain/gr-rfnoc_gain/MANIFEST.yml
Normal file
@ -0,0 +1,19 @@
|
||||
title: The RFNOC_GAIN OOT Module
|
||||
version: 1.0
|
||||
brief: This is an example OOT module for RFNoC-based GNU Radio bindings.
|
||||
tags: # Tags are arbitrary, but look at CGRAN what other authors are using
|
||||
- sdr
|
||||
- rfnoc
|
||||
author:
|
||||
- Ettus Research <packages@ettus.com>
|
||||
copyright_owner:
|
||||
- NI
|
||||
license:
|
||||
gr_supported_version:
|
||||
- 3.10
|
||||
repo: # Put the URL of the repository here
|
||||
website: # If you have a separate project website, put it here
|
||||
#icon: # Put a URL to a square image here that will be used as an icon
|
||||
description: |-
|
||||
This OOT Module contains GNU Radio bindings for the rfnoc-gain block.
|
||||
file_format: 1
|
||||
11
host/examples/rfnoc-gain/gr-rfnoc_gain/apps/CMakeLists.txt
Normal file
11
host/examples/rfnoc-gain/gr-rfnoc_gain/apps/CMakeLists.txt
Normal file
@ -0,0 +1,11 @@
|
||||
# Copyright 2011 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file was generated by gr_modtool, a tool from the GNU Radio framework
|
||||
# This file is a part of gr-rfnoc_gain
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#
|
||||
|
||||
include(GrPython)
|
||||
|
||||
gr_python_install(PROGRAMS DESTINATION bin)
|
||||
@ -0,0 +1,138 @@
|
||||
# CMAKE_PARSE_ARGUMENTS(<prefix> <options> <one_value_keywords> <multi_value_keywords> args...)
|
||||
#
|
||||
# CMAKE_PARSE_ARGUMENTS() is intended to be used in macros or functions for
|
||||
# parsing the arguments given to that macro or function.
|
||||
# It processes the arguments and defines a set of variables which hold the
|
||||
# values of the respective options.
|
||||
#
|
||||
# The <options> argument contains all options for the respective macro,
|
||||
# i.e. keywords which can be used when calling the macro without any value
|
||||
# following, like e.g. the OPTIONAL keyword of the install() command.
|
||||
#
|
||||
# The <one_value_keywords> argument contains all keywords for this macro
|
||||
# which are followed by one value, like e.g. DESTINATION keyword of the
|
||||
# install() command.
|
||||
#
|
||||
# The <multi_value_keywords> argument contains all keywords for this macro
|
||||
# which can be followed by more than one value, like e.g. the TARGETS or
|
||||
# FILES keywords of the install() command.
|
||||
#
|
||||
# When done, CMAKE_PARSE_ARGUMENTS() will have defined for each of the
|
||||
# keywords listed in <options>, <one_value_keywords> and
|
||||
# <multi_value_keywords> a variable composed of the given <prefix>
|
||||
# followed by "_" and the name of the respective keyword.
|
||||
# These variables will then hold the respective value from the argument list.
|
||||
# For the <options> keywords this will be TRUE or FALSE.
|
||||
#
|
||||
# All remaining arguments are collected in a variable
|
||||
# <prefix>_UNPARSED_ARGUMENTS, this can be checked afterwards to see whether
|
||||
# your macro was called with unrecognized parameters.
|
||||
#
|
||||
# As an example here a my_install() macro, which takes similar arguments as the
|
||||
# real install() command:
|
||||
#
|
||||
# function(MY_INSTALL)
|
||||
# set(options OPTIONAL FAST)
|
||||
# set(oneValueArgs DESTINATION RENAME)
|
||||
# set(multiValueArgs TARGETS CONFIGURATIONS)
|
||||
# cmake_parse_arguments(MY_INSTALL "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
|
||||
# ...
|
||||
#
|
||||
# Assume my_install() has been called like this:
|
||||
# my_install(TARGETS foo bar DESTINATION bin OPTIONAL blub)
|
||||
#
|
||||
# After the cmake_parse_arguments() call the macro will have set the following
|
||||
# variables:
|
||||
# MY_INSTALL_OPTIONAL = TRUE
|
||||
# MY_INSTALL_FAST = FALSE (this option was not used when calling my_install()
|
||||
# MY_INSTALL_DESTINATION = "bin"
|
||||
# MY_INSTALL_RENAME = "" (was not used)
|
||||
# MY_INSTALL_TARGETS = "foo;bar"
|
||||
# MY_INSTALL_CONFIGURATIONS = "" (was not used)
|
||||
# MY_INSTALL_UNPARSED_ARGUMENTS = "blub" (no value expected after "OPTIONAL"
|
||||
#
|
||||
# You can the continue and process these variables.
|
||||
#
|
||||
# Keywords terminate lists of values, e.g. if directly after a one_value_keyword
|
||||
# another recognized keyword follows, this is interpreted as the beginning of
|
||||
# the new option.
|
||||
# E.g. my_install(TARGETS foo DESTINATION OPTIONAL) would result in
|
||||
# MY_INSTALL_DESTINATION set to "OPTIONAL", but MY_INSTALL_DESTINATION would
|
||||
# be empty and MY_INSTALL_OPTIONAL would be set to TRUE therefore.
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2010 Alexander Neundorf <neundorf@kde.org>
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
|
||||
|
||||
if(__CMAKE_PARSE_ARGUMENTS_INCLUDED)
|
||||
return()
|
||||
endif()
|
||||
set(__CMAKE_PARSE_ARGUMENTS_INCLUDED TRUE)
|
||||
|
||||
|
||||
function(CMAKE_PARSE_ARGUMENTS prefix _optionNames _singleArgNames _multiArgNames)
|
||||
# first set all result variables to empty/FALSE
|
||||
foreach(arg_name ${_singleArgNames} ${_multiArgNames})
|
||||
set(${prefix}_${arg_name})
|
||||
endforeach(arg_name)
|
||||
|
||||
foreach(option ${_optionNames})
|
||||
set(${prefix}_${option} FALSE)
|
||||
endforeach(option)
|
||||
|
||||
set(${prefix}_UNPARSED_ARGUMENTS)
|
||||
|
||||
set(insideValues FALSE)
|
||||
set(currentArgName)
|
||||
|
||||
# now iterate over all arguments and fill the result variables
|
||||
foreach(currentArg ${ARGN})
|
||||
list(FIND _optionNames "${currentArg}" optionIndex) # ... then this marks the end of the arguments belonging to this keyword
|
||||
list(FIND _singleArgNames "${currentArg}" singleArgIndex) # ... then this marks the end of the arguments belonging to this keyword
|
||||
list(FIND _multiArgNames "${currentArg}" multiArgIndex) # ... then this marks the end of the arguments belonging to this keyword
|
||||
|
||||
if(${optionIndex} EQUAL -1 AND ${singleArgIndex} EQUAL -1 AND ${multiArgIndex} EQUAL -1)
|
||||
if(insideValues)
|
||||
if("${insideValues}" STREQUAL "SINGLE")
|
||||
set(${prefix}_${currentArgName} ${currentArg})
|
||||
set(insideValues FALSE)
|
||||
elseif("${insideValues}" STREQUAL "MULTI")
|
||||
list(APPEND ${prefix}_${currentArgName} ${currentArg})
|
||||
endif()
|
||||
else(insideValues)
|
||||
list(APPEND ${prefix}_UNPARSED_ARGUMENTS ${currentArg})
|
||||
endif(insideValues)
|
||||
else()
|
||||
if(NOT ${optionIndex} EQUAL -1)
|
||||
set(${prefix}_${currentArg} TRUE)
|
||||
set(insideValues FALSE)
|
||||
elseif(NOT ${singleArgIndex} EQUAL -1)
|
||||
set(currentArgName ${currentArg})
|
||||
set(${prefix}_${currentArgName})
|
||||
set(insideValues "SINGLE")
|
||||
elseif(NOT ${multiArgIndex} EQUAL -1)
|
||||
set(currentArgName ${currentArg})
|
||||
set(${prefix}_${currentArgName})
|
||||
set(insideValues "MULTI")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
endforeach(currentArg)
|
||||
|
||||
# propagate the result variables to the caller:
|
||||
foreach(arg_name ${_singleArgNames} ${_multiArgNames} ${_optionNames})
|
||||
set(${prefix}_${arg_name} ${${prefix}_${arg_name}} PARENT_SCOPE)
|
||||
endforeach(arg_name)
|
||||
set(${prefix}_UNPARSED_ARGUMENTS ${${prefix}_UNPARSED_ARGUMENTS} PARENT_SCOPE)
|
||||
|
||||
endfunction(CMAKE_PARSE_ARGUMENTS _options _singleArgs _multiArgs)
|
||||
@ -0,0 +1,32 @@
|
||||
find_package(PkgConfig)
|
||||
|
||||
PKG_CHECK_MODULES(PC_GR_RFNOC_GAIN gnuradio-rfnoc_gain)
|
||||
|
||||
FIND_PATH(
|
||||
GR_RFNOC_GAIN_INCLUDE_DIRS
|
||||
NAMES gnuradio/rfnoc_gain/api.h
|
||||
HINTS $ENV{RFNOC_GAIN_DIR}/include
|
||||
${PC_RFNOC_GAIN_INCLUDEDIR}
|
||||
PATHS ${CMAKE_INSTALL_PREFIX}/include
|
||||
/usr/local/include
|
||||
/usr/include
|
||||
)
|
||||
|
||||
FIND_LIBRARY(
|
||||
GR_RFNOC_GAIN_LIBRARIES
|
||||
NAMES gnuradio-rfnoc_gain
|
||||
HINTS $ENV{RFNOC_GAIN_DIR}/lib
|
||||
${PC_RFNOC_GAIN_LIBDIR}
|
||||
PATHS ${CMAKE_INSTALL_PREFIX}/lib
|
||||
${CMAKE_INSTALL_PREFIX}/lib64
|
||||
/usr/local/lib
|
||||
/usr/local/lib64
|
||||
/usr/lib
|
||||
/usr/lib64
|
||||
)
|
||||
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/gnuradio-rfnoc_gainTarget.cmake")
|
||||
|
||||
INCLUDE(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GR_RFNOC_GAIN DEFAULT_MSG GR_RFNOC_GAIN_LIBRARIES GR_RFNOC_GAIN_INCLUDE_DIRS)
|
||||
MARK_AS_ADVANCED(GR_RFNOC_GAIN_LIBRARIES GR_RFNOC_GAIN_INCLUDE_DIRS)
|
||||
@ -0,0 +1,14 @@
|
||||
# Copyright 2018 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is part of GNU Radio
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#
|
||||
|
||||
include(CMakeFindDependencyMacro)
|
||||
|
||||
set(target_deps "@TARGET_DEPENDENCIES@")
|
||||
foreach(dep IN LISTS target_deps)
|
||||
find_dependency(${dep})
|
||||
endforeach()
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/@TARGET@Targets.cmake")
|
||||
@ -0,0 +1,32 @@
|
||||
# http://www.vtk.org/Wiki/CMake_FAQ#Can_I_do_.22make_uninstall.22_with_CMake.3F
|
||||
|
||||
IF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
|
||||
MESSAGE(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"")
|
||||
ENDIF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
|
||||
|
||||
FILE(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
|
||||
STRING(REGEX REPLACE "\n" ";" files "${files}")
|
||||
FOREACH(file ${files})
|
||||
MESSAGE(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"")
|
||||
IF(EXISTS "$ENV{DESTDIR}${file}")
|
||||
EXEC_PROGRAM(
|
||||
"@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
|
||||
OUTPUT_VARIABLE rm_out
|
||||
RETURN_VALUE rm_retval
|
||||
)
|
||||
IF(NOT "${rm_retval}" STREQUAL 0)
|
||||
MESSAGE(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"")
|
||||
ENDIF(NOT "${rm_retval}" STREQUAL 0)
|
||||
ELSEIF(IS_SYMLINK "$ENV{DESTDIR}${file}")
|
||||
EXEC_PROGRAM(
|
||||
"@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
|
||||
OUTPUT_VARIABLE rm_out
|
||||
RETURN_VALUE rm_retval
|
||||
)
|
||||
IF(NOT "${rm_retval}" STREQUAL 0)
|
||||
MESSAGE(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"")
|
||||
ENDIF(NOT "${rm_retval}" STREQUAL 0)
|
||||
ELSE(EXISTS "$ENV{DESTDIR}${file}")
|
||||
MESSAGE(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.")
|
||||
ENDIF(EXISTS "$ENV{DESTDIR}${file}")
|
||||
ENDFOREACH(file)
|
||||
24
host/examples/rfnoc-gain/gr-rfnoc_gain/docs/CMakeLists.txt
Normal file
24
host/examples/rfnoc-gain/gr-rfnoc_gain/docs/CMakeLists.txt
Normal file
@ -0,0 +1,24 @@
|
||||
# Copyright 2011 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file was generated by gr_modtool, a tool from the GNU Radio framework
|
||||
# This file is a part of gr-rfnoc_gain
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#
|
||||
|
||||
########################################################################
|
||||
# Setup dependencies
|
||||
########################################################################
|
||||
find_package(Doxygen)
|
||||
|
||||
########################################################################
|
||||
# Begin conditional configuration
|
||||
########################################################################
|
||||
if(ENABLE_DOXYGEN)
|
||||
|
||||
########################################################################
|
||||
# Add subdirectories
|
||||
########################################################################
|
||||
add_subdirectory(doxygen)
|
||||
|
||||
endif(ENABLE_DOXYGEN)
|
||||
@ -0,0 +1,11 @@
|
||||
This is the rfnoc_gain-write-a-block package meant as a guide to building
|
||||
out-of-tree packages. To use the rfnoc_gain blocks, the Python namespaces
|
||||
is in 'rfnoc_gain', which is imported as:
|
||||
|
||||
import rfnoc_gain
|
||||
|
||||
See the Doxygen documentation for details about the blocks available
|
||||
in this package. A quick listing of the details can be found in Python
|
||||
after importing by using:
|
||||
|
||||
help(rfnoc_gain)
|
||||
@ -0,0 +1,39 @@
|
||||
# Copyright 2011 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file was generated by gr_modtool, a tool from the GNU Radio framework
|
||||
# This file is a part of gr-rfnoc_gain
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#
|
||||
|
||||
########################################################################
|
||||
# Create the doxygen configuration file
|
||||
########################################################################
|
||||
file(TO_NATIVE_PATH ${PROJECT_SOURCE_DIR} top_srcdir)
|
||||
file(TO_NATIVE_PATH ${PROJECT_BINARY_DIR} top_builddir)
|
||||
file(TO_NATIVE_PATH ${PROJECT_SOURCE_DIR} abs_top_srcdir)
|
||||
file(TO_NATIVE_PATH ${PROJECT_BINARY_DIR} abs_top_builddir)
|
||||
|
||||
set(HAVE_DOT ${DOXYGEN_DOT_FOUND})
|
||||
set(enable_html_docs YES)
|
||||
set(enable_latex_docs NO)
|
||||
set(enable_mathjax NO)
|
||||
set(enable_xml_docs YES)
|
||||
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
|
||||
|
||||
set(BUILT_DIRS ${CMAKE_CURRENT_BINARY_DIR}/xml ${CMAKE_CURRENT_BINARY_DIR}/html)
|
||||
|
||||
########################################################################
|
||||
# Make and install doxygen docs
|
||||
########################################################################
|
||||
add_custom_command(
|
||||
OUTPUT ${BUILT_DIRS}
|
||||
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
COMMENT "Generating documentation with doxygen")
|
||||
|
||||
add_custom_target(doxygen_target ALL DEPENDS ${BUILT_DIRS})
|
||||
|
||||
install(DIRECTORY ${BUILT_DIRS} DESTINATION ${GR_PKG_DOC_DIR})
|
||||
1866
host/examples/rfnoc-gain/gr-rfnoc_gain/docs/doxygen/Doxyfile.in
Normal file
1866
host/examples/rfnoc-gain/gr-rfnoc_gain/docs/doxygen/Doxyfile.in
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,72 @@
|
||||
#
|
||||
# Copyright 2010 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file was generated by gr_modtool, a tool from the GNU Radio framework
|
||||
# This file is a part of gr-rfnoc_gain
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#
|
||||
#
|
||||
"""
|
||||
Python interface to contents of doxygen xml documentation.
|
||||
|
||||
Example use:
|
||||
See the contents of the example folder for the C++ and
|
||||
doxygen-generated xml used in this example.
|
||||
|
||||
>>> # Parse the doxygen docs.
|
||||
>>> import os
|
||||
>>> this_dir = os.path.dirname(globals()['__file__'])
|
||||
>>> xml_path = this_dir + "/example/xml/"
|
||||
>>> di = DoxyIndex(xml_path)
|
||||
|
||||
Get a list of all top-level objects.
|
||||
|
||||
>>> print([mem.name() for mem in di.members()])
|
||||
[u'Aadvark', u'aadvarky_enough', u'main']
|
||||
|
||||
Get all functions.
|
||||
|
||||
>>> print([mem.name() for mem in di.in_category(DoxyFunction)])
|
||||
[u'aadvarky_enough', u'main']
|
||||
|
||||
Check if an object is present.
|
||||
|
||||
>>> di.has_member(u'Aadvark')
|
||||
True
|
||||
>>> di.has_member(u'Fish')
|
||||
False
|
||||
|
||||
Get an item by name and check its properties.
|
||||
|
||||
>>> aad = di.get_member(u'Aadvark')
|
||||
>>> print(aad.brief_description)
|
||||
Models the mammal Aadvark.
|
||||
>>> print(aad.detailed_description)
|
||||
Sadly the model is incomplete and cannot capture all aspects of an aadvark yet.
|
||||
<BLANKLINE>
|
||||
This line is uninformative and is only to test line breaks in the comments.
|
||||
>>> [mem.name() for mem in aad.members()]
|
||||
[u'aadvarkness', u'print', u'Aadvark', u'get_aadvarkness']
|
||||
>>> aad.get_member(u'print').brief_description
|
||||
u'Outputs the vital aadvark statistics.'
|
||||
|
||||
"""
|
||||
|
||||
from .doxyindex import DoxyIndex, DoxyFunction, DoxyParam, DoxyClass, DoxyFile, DoxyNamespace, DoxyGroup, DoxyFriend, DoxyOther
|
||||
|
||||
|
||||
def _test():
|
||||
import os
|
||||
this_dir = os.path.dirname(globals()['__file__'])
|
||||
xml_path = this_dir + "/example/xml/"
|
||||
di = DoxyIndex(xml_path)
|
||||
# Get the Aadvark class
|
||||
aad = di.get_member('Aadvark')
|
||||
aad.brief_description
|
||||
import doctest
|
||||
return doctest.testmod()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
_test()
|
||||
@ -0,0 +1,208 @@
|
||||
#
|
||||
# Copyright 2010 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file was generated by gr_modtool, a tool from the GNU Radio framework
|
||||
# This file is a part of gr-rfnoc_gain
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#
|
||||
#
|
||||
"""
|
||||
A base class is created.
|
||||
|
||||
Classes based upon this are used to make more user-friendly interfaces
|
||||
to the doxygen xml docs than the generated classes provide.
|
||||
"""
|
||||
|
||||
import os
|
||||
import pdb
|
||||
|
||||
from xml.parsers.expat import ExpatError
|
||||
|
||||
from .generated import compound
|
||||
|
||||
|
||||
class Base(object):
|
||||
|
||||
class Duplicate(Exception):
|
||||
pass
|
||||
|
||||
class NoSuchMember(Exception):
|
||||
pass
|
||||
|
||||
class ParsingError(Exception):
|
||||
pass
|
||||
|
||||
def __init__(self, parse_data, top=None):
|
||||
self._parsed = False
|
||||
self._error = False
|
||||
self._parse_data = parse_data
|
||||
self._members = []
|
||||
self._dict_members = {}
|
||||
self._in_category = {}
|
||||
self._data = {}
|
||||
if top is not None:
|
||||
self._xml_path = top._xml_path
|
||||
# Set up holder of references
|
||||
else:
|
||||
top = self
|
||||
self._refs = {}
|
||||
self._xml_path = parse_data
|
||||
self.top = top
|
||||
|
||||
@classmethod
|
||||
def from_refid(cls, refid, top=None):
|
||||
""" Instantiate class from a refid rather than parsing object. """
|
||||
# First check to see if its already been instantiated.
|
||||
if top is not None and refid in top._refs:
|
||||
return top._refs[refid]
|
||||
# Otherwise create a new instance and set refid.
|
||||
inst = cls(None, top=top)
|
||||
inst.refid = refid
|
||||
inst.add_ref(inst)
|
||||
return inst
|
||||
|
||||
@classmethod
|
||||
def from_parse_data(cls, parse_data, top=None):
|
||||
refid = getattr(parse_data, 'refid', None)
|
||||
if refid is not None and top is not None and refid in top._refs:
|
||||
return top._refs[refid]
|
||||
inst = cls(parse_data, top=top)
|
||||
if refid is not None:
|
||||
inst.refid = refid
|
||||
inst.add_ref(inst)
|
||||
return inst
|
||||
|
||||
def add_ref(self, obj):
|
||||
if hasattr(obj, 'refid'):
|
||||
self.top._refs[obj.refid] = obj
|
||||
|
||||
mem_classes = []
|
||||
|
||||
def get_cls(self, mem):
|
||||
for cls in self.mem_classes:
|
||||
if cls.can_parse(mem):
|
||||
return cls
|
||||
raise Exception(("Did not find a class for object '%s'."
|
||||
% (mem.get_name())))
|
||||
|
||||
def convert_mem(self, mem):
|
||||
try:
|
||||
cls = self.get_cls(mem)
|
||||
converted = cls.from_parse_data(mem, self.top)
|
||||
if converted is None:
|
||||
raise Exception('No class matched this object.')
|
||||
self.add_ref(converted)
|
||||
return converted
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
@classmethod
|
||||
def includes(cls, inst):
|
||||
return isinstance(inst, cls)
|
||||
|
||||
@classmethod
|
||||
def can_parse(cls, obj):
|
||||
return False
|
||||
|
||||
def _parse(self):
|
||||
self._parsed = True
|
||||
|
||||
def _get_dict_members(self, cat=None):
|
||||
"""
|
||||
For given category a dictionary is returned mapping member names to
|
||||
members of that category. For names that are duplicated the name is
|
||||
mapped to None.
|
||||
"""
|
||||
self.confirm_no_error()
|
||||
if cat not in self._dict_members:
|
||||
new_dict = {}
|
||||
for mem in self.in_category(cat):
|
||||
if mem.name() not in new_dict:
|
||||
new_dict[mem.name()] = mem
|
||||
else:
|
||||
new_dict[mem.name()] = self.Duplicate
|
||||
self._dict_members[cat] = new_dict
|
||||
return self._dict_members[cat]
|
||||
|
||||
def in_category(self, cat):
|
||||
self.confirm_no_error()
|
||||
if cat is None:
|
||||
return self._members
|
||||
if cat not in self._in_category:
|
||||
self._in_category[cat] = [mem for mem in self._members
|
||||
if cat.includes(mem)]
|
||||
return self._in_category[cat]
|
||||
|
||||
def get_member(self, name, cat=None):
|
||||
self.confirm_no_error()
|
||||
# Check if it's in a namespace or class.
|
||||
bits = name.split('::')
|
||||
first = bits[0]
|
||||
rest = '::'.join(bits[1:])
|
||||
member = self._get_dict_members(cat).get(first, self.NoSuchMember)
|
||||
# Raise any errors that are returned.
|
||||
if member in set([self.NoSuchMember, self.Duplicate]):
|
||||
raise member()
|
||||
if rest:
|
||||
return member.get_member(rest, cat=cat)
|
||||
return member
|
||||
|
||||
def has_member(self, name, cat=None):
|
||||
try:
|
||||
mem = self.get_member(name, cat=cat)
|
||||
return True
|
||||
except self.NoSuchMember:
|
||||
return False
|
||||
|
||||
def data(self):
|
||||
self.confirm_no_error()
|
||||
return self._data
|
||||
|
||||
def members(self):
|
||||
self.confirm_no_error()
|
||||
return self._members
|
||||
|
||||
def process_memberdefs(self):
|
||||
mdtss = []
|
||||
for sec in self._retrieved_data.compounddef.sectiondef:
|
||||
mdtss += sec.memberdef
|
||||
# At the moment we lose all information associated with sections.
|
||||
# Sometimes a memberdef is in several sectiondef.
|
||||
# We make sure we don't get duplicates here.
|
||||
uniques = set([])
|
||||
for mem in mdtss:
|
||||
converted = self.convert_mem(mem)
|
||||
pair = (mem.name, mem.__class__)
|
||||
if pair not in uniques:
|
||||
uniques.add(pair)
|
||||
self._members.append(converted)
|
||||
|
||||
def retrieve_data(self):
|
||||
filename = os.path.join(self._xml_path, self.refid + '.xml')
|
||||
try:
|
||||
self._retrieved_data = compound.parse(filename)
|
||||
except ExpatError:
|
||||
print('Error in xml in file %s' % filename)
|
||||
self._error = True
|
||||
self._retrieved_data = None
|
||||
|
||||
def check_parsed(self):
|
||||
if not self._parsed:
|
||||
self._parse()
|
||||
|
||||
def confirm_no_error(self):
|
||||
self.check_parsed()
|
||||
if self._error:
|
||||
raise self.ParsingError()
|
||||
|
||||
def error(self):
|
||||
self.check_parsed()
|
||||
return self._error
|
||||
|
||||
def name(self):
|
||||
# first see if we can do it without processing.
|
||||
if self._parse_data is not None:
|
||||
return self._parse_data.name
|
||||
self.check_parsed()
|
||||
return self._retrieved_data.compounddef.name
|
||||
@ -0,0 +1,295 @@
|
||||
#
|
||||
# Copyright 2010 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file was generated by gr_modtool, a tool from the GNU Radio framework
|
||||
# This file is a part of gr-rfnoc_gain
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#
|
||||
#
|
||||
"""
|
||||
Classes providing more user-friendly interfaces to the doxygen xml
|
||||
docs than the generated classes provide.
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from .generated import index
|
||||
from .base import Base
|
||||
from .text import description
|
||||
|
||||
|
||||
class DoxyIndex(Base):
|
||||
"""
|
||||
Parses a doxygen xml directory.
|
||||
"""
|
||||
|
||||
__module__ = "gnuradio.utils.doxyxml"
|
||||
|
||||
def _parse(self):
|
||||
if self._parsed:
|
||||
return
|
||||
super(DoxyIndex, self)._parse()
|
||||
self._root = index.parse(os.path.join(self._xml_path, 'index.xml'))
|
||||
for mem in self._root.compound:
|
||||
converted = self.convert_mem(mem)
|
||||
# For files and namespaces we want the contents to be
|
||||
# accessible directly from the parent rather than having
|
||||
# to go through the file object.
|
||||
if self.get_cls(mem) == DoxyFile:
|
||||
if mem.name.endswith('.h'):
|
||||
self._members += converted.members()
|
||||
self._members.append(converted)
|
||||
elif self.get_cls(mem) == DoxyNamespace:
|
||||
self._members += converted.members()
|
||||
self._members.append(converted)
|
||||
else:
|
||||
self._members.append(converted)
|
||||
|
||||
|
||||
class DoxyCompMem(Base):
|
||||
|
||||
kind = None
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(DoxyCompMem, self).__init__(*args, **kwargs)
|
||||
|
||||
@classmethod
|
||||
def can_parse(cls, obj):
|
||||
return obj.kind == cls.kind
|
||||
|
||||
def set_descriptions(self, parse_data):
|
||||
bd = description(getattr(parse_data, 'briefdescription', None))
|
||||
dd = description(getattr(parse_data, 'detaileddescription', None))
|
||||
self._data['brief_description'] = bd
|
||||
self._data['detailed_description'] = dd
|
||||
|
||||
def set_parameters(self, data):
|
||||
vs = [ddc.value for ddc in data.detaileddescription.content_]
|
||||
pls = []
|
||||
for v in vs:
|
||||
if hasattr(v, 'parameterlist'):
|
||||
pls += v.parameterlist
|
||||
pis = []
|
||||
for pl in pls:
|
||||
pis += pl.parameteritem
|
||||
dpis = []
|
||||
for pi in pis:
|
||||
dpi = DoxyParameterItem(pi)
|
||||
dpi._parse()
|
||||
dpis.append(dpi)
|
||||
self._data['params'] = dpis
|
||||
|
||||
|
||||
class DoxyCompound(DoxyCompMem):
|
||||
pass
|
||||
|
||||
|
||||
class DoxyMember(DoxyCompMem):
|
||||
pass
|
||||
|
||||
|
||||
class DoxyFunction(DoxyMember):
|
||||
|
||||
__module__ = "gnuradio.utils.doxyxml"
|
||||
|
||||
kind = 'function'
|
||||
|
||||
def _parse(self):
|
||||
if self._parsed:
|
||||
return
|
||||
super(DoxyFunction, self)._parse()
|
||||
self.set_descriptions(self._parse_data)
|
||||
self.set_parameters(self._parse_data)
|
||||
if not self._data['params']:
|
||||
# If the params weren't set by a comment then just grab the names.
|
||||
self._data['params'] = []
|
||||
prms = self._parse_data.param
|
||||
for prm in prms:
|
||||
self._data['params'].append(DoxyParam(prm))
|
||||
|
||||
brief_description = property(lambda self: self.data()['brief_description'])
|
||||
detailed_description = property(
|
||||
lambda self: self.data()['detailed_description'])
|
||||
params = property(lambda self: self.data()['params'])
|
||||
|
||||
|
||||
Base.mem_classes.append(DoxyFunction)
|
||||
|
||||
|
||||
class DoxyParam(DoxyMember):
|
||||
|
||||
__module__ = "gnuradio.utils.doxyxml"
|
||||
|
||||
def _parse(self):
|
||||
if self._parsed:
|
||||
return
|
||||
super(DoxyParam, self)._parse()
|
||||
self.set_descriptions(self._parse_data)
|
||||
self._data['declname'] = self._parse_data.declname
|
||||
|
||||
@property
|
||||
def description(self):
|
||||
descriptions = []
|
||||
if self.brief_description:
|
||||
descriptions.append(self.brief_description)
|
||||
if self.detailed_description:
|
||||
descriptions.append(self.detailed_description)
|
||||
return '\n\n'.join(descriptions)
|
||||
|
||||
brief_description = property(lambda self: self.data()['brief_description'])
|
||||
detailed_description = property(
|
||||
lambda self: self.data()['detailed_description'])
|
||||
name = property(lambda self: self.data()['declname'])
|
||||
|
||||
|
||||
class DoxyParameterItem(DoxyMember):
|
||||
"""A different representation of a parameter in Doxygen."""
|
||||
|
||||
def _parse(self):
|
||||
if self._parsed:
|
||||
return
|
||||
super(DoxyParameterItem, self)._parse()
|
||||
names = []
|
||||
for nl in self._parse_data.parameternamelist:
|
||||
for pn in nl.parametername:
|
||||
names.append(description(pn))
|
||||
# Just take first name
|
||||
self._data['name'] = names[0]
|
||||
# Get description
|
||||
pd = description(self._parse_data.get_parameterdescription())
|
||||
self._data['description'] = pd
|
||||
|
||||
description = property(lambda self: self.data()['description'])
|
||||
name = property(lambda self: self.data()['name'])
|
||||
|
||||
|
||||
class DoxyClass(DoxyCompound):
|
||||
|
||||
__module__ = "gnuradio.utils.doxyxml"
|
||||
|
||||
kind = 'class'
|
||||
|
||||
def _parse(self):
|
||||
if self._parsed:
|
||||
return
|
||||
super(DoxyClass, self)._parse()
|
||||
self.retrieve_data()
|
||||
if self._error:
|
||||
return
|
||||
self.set_descriptions(self._retrieved_data.compounddef)
|
||||
self.set_parameters(self._retrieved_data.compounddef)
|
||||
# Sectiondef.kind tells about whether private or public.
|
||||
# We just ignore this for now.
|
||||
self.process_memberdefs()
|
||||
|
||||
brief_description = property(lambda self: self.data()['brief_description'])
|
||||
detailed_description = property(
|
||||
lambda self: self.data()['detailed_description'])
|
||||
params = property(lambda self: self.data()['params'])
|
||||
|
||||
|
||||
Base.mem_classes.append(DoxyClass)
|
||||
|
||||
|
||||
class DoxyFile(DoxyCompound):
|
||||
|
||||
__module__ = "gnuradio.utils.doxyxml"
|
||||
|
||||
kind = 'file'
|
||||
|
||||
def _parse(self):
|
||||
if self._parsed:
|
||||
return
|
||||
super(DoxyFile, self)._parse()
|
||||
self.retrieve_data()
|
||||
self.set_descriptions(self._retrieved_data.compounddef)
|
||||
if self._error:
|
||||
return
|
||||
self.process_memberdefs()
|
||||
|
||||
brief_description = property(lambda self: self.data()['brief_description'])
|
||||
detailed_description = property(
|
||||
lambda self: self.data()['detailed_description'])
|
||||
|
||||
|
||||
Base.mem_classes.append(DoxyFile)
|
||||
|
||||
|
||||
class DoxyNamespace(DoxyCompound):
|
||||
|
||||
__module__ = "gnuradio.utils.doxyxml"
|
||||
|
||||
kind = 'namespace'
|
||||
|
||||
def _parse(self):
|
||||
if self._parsed:
|
||||
return
|
||||
super(DoxyNamespace, self)._parse()
|
||||
self.retrieve_data()
|
||||
self.set_descriptions(self._retrieved_data.compounddef)
|
||||
if self._error:
|
||||
return
|
||||
self.process_memberdefs()
|
||||
|
||||
|
||||
Base.mem_classes.append(DoxyNamespace)
|
||||
|
||||
|
||||
class DoxyGroup(DoxyCompound):
|
||||
|
||||
__module__ = "gnuradio.utils.doxyxml"
|
||||
|
||||
kind = 'group'
|
||||
|
||||
def _parse(self):
|
||||
if self._parsed:
|
||||
return
|
||||
super(DoxyGroup, self)._parse()
|
||||
self.retrieve_data()
|
||||
if self._error:
|
||||
return
|
||||
cdef = self._retrieved_data.compounddef
|
||||
self._data['title'] = description(cdef.title)
|
||||
# Process inner groups
|
||||
grps = cdef.innergroup
|
||||
for grp in grps:
|
||||
converted = DoxyGroup.from_refid(grp.refid, top=self.top)
|
||||
self._members.append(converted)
|
||||
# Process inner classes
|
||||
klasses = cdef.innerclass
|
||||
for kls in klasses:
|
||||
converted = DoxyClass.from_refid(kls.refid, top=self.top)
|
||||
self._members.append(converted)
|
||||
# Process normal members
|
||||
self.process_memberdefs()
|
||||
|
||||
title = property(lambda self: self.data()['title'])
|
||||
|
||||
|
||||
Base.mem_classes.append(DoxyGroup)
|
||||
|
||||
|
||||
class DoxyFriend(DoxyMember):
|
||||
|
||||
__module__ = "gnuradio.utils.doxyxml"
|
||||
|
||||
kind = 'friend'
|
||||
|
||||
|
||||
Base.mem_classes.append(DoxyFriend)
|
||||
|
||||
|
||||
class DoxyOther(Base):
|
||||
|
||||
__module__ = "gnuradio.utils.doxyxml"
|
||||
|
||||
kinds = set(['variable', 'struct', 'union', 'define', 'typedef', 'enum',
|
||||
'dir', 'page', 'signal', 'slot', 'property'])
|
||||
|
||||
@classmethod
|
||||
def can_parse(cls, obj):
|
||||
return obj.kind in cls.kinds
|
||||
|
||||
|
||||
Base.mem_classes.append(DoxyOther)
|
||||
@ -0,0 +1,7 @@
|
||||
"""
|
||||
Contains generated files produced by generateDS.py.
|
||||
|
||||
These do the real work of parsing the doxygen xml files but the
|
||||
resultant classes are not very friendly to navigate so the rest of the
|
||||
doxyxml module processes them further.
|
||||
"""
|
||||
@ -0,0 +1,620 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
Generated Mon Feb 9 19:08:05 2009 by generateDS.py.
|
||||
"""
|
||||
|
||||
|
||||
from xml.dom import minidom
|
||||
from xml.dom import Node
|
||||
|
||||
import sys
|
||||
|
||||
from . import compoundsuper as supermod
|
||||
from .compoundsuper import MixedContainer
|
||||
|
||||
|
||||
class DoxygenTypeSub(supermod.DoxygenType):
|
||||
def __init__(self, version=None, compounddef=None):
|
||||
supermod.DoxygenType.__init__(self, version, compounddef)
|
||||
|
||||
def find(self, details):
|
||||
|
||||
return self.compounddef.find(details)
|
||||
|
||||
|
||||
supermod.DoxygenType.subclass = DoxygenTypeSub
|
||||
# end class DoxygenTypeSub
|
||||
|
||||
|
||||
class compounddefTypeSub(supermod.compounddefType):
|
||||
def __init__(self, kind=None, prot=None, id=None, compoundname='', title='', basecompoundref=None, derivedcompoundref=None, includes=None, includedby=None, incdepgraph=None, invincdepgraph=None, innerdir=None, innerfile=None, innerclass=None, innernamespace=None, innerpage=None, innergroup=None, templateparamlist=None, sectiondef=None, briefdescription=None, detaileddescription=None, inheritancegraph=None, collaborationgraph=None, programlisting=None, location=None, listofallmembers=None):
|
||||
supermod.compounddefType.__init__(self, kind, prot, id, compoundname, title, basecompoundref, derivedcompoundref, includes, includedby, incdepgraph, invincdepgraph, innerdir, innerfile, innerclass,
|
||||
innernamespace, innerpage, innergroup, templateparamlist, sectiondef, briefdescription, detaileddescription, inheritancegraph, collaborationgraph, programlisting, location, listofallmembers)
|
||||
|
||||
def find(self, details):
|
||||
|
||||
if self.id == details.refid:
|
||||
return self
|
||||
|
||||
for sectiondef in self.sectiondef:
|
||||
result = sectiondef.find(details)
|
||||
if result:
|
||||
return result
|
||||
|
||||
|
||||
supermod.compounddefType.subclass = compounddefTypeSub
|
||||
# end class compounddefTypeSub
|
||||
|
||||
|
||||
class listofallmembersTypeSub(supermod.listofallmembersType):
|
||||
def __init__(self, member=None):
|
||||
supermod.listofallmembersType.__init__(self, member)
|
||||
|
||||
|
||||
supermod.listofallmembersType.subclass = listofallmembersTypeSub
|
||||
# end class listofallmembersTypeSub
|
||||
|
||||
|
||||
class memberRefTypeSub(supermod.memberRefType):
|
||||
def __init__(self, virt=None, prot=None, refid=None, ambiguityscope=None, scope='', name=''):
|
||||
supermod.memberRefType.__init__(
|
||||
self, virt, prot, refid, ambiguityscope, scope, name)
|
||||
|
||||
|
||||
supermod.memberRefType.subclass = memberRefTypeSub
|
||||
# end class memberRefTypeSub
|
||||
|
||||
|
||||
class compoundRefTypeSub(supermod.compoundRefType):
|
||||
def __init__(self, virt=None, prot=None, refid=None, valueOf_='', mixedclass_=None, content_=None):
|
||||
supermod.compoundRefType.__init__(self, mixedclass_, content_)
|
||||
|
||||
|
||||
supermod.compoundRefType.subclass = compoundRefTypeSub
|
||||
# end class compoundRefTypeSub
|
||||
|
||||
|
||||
class reimplementTypeSub(supermod.reimplementType):
|
||||
def __init__(self, refid=None, valueOf_='', mixedclass_=None, content_=None):
|
||||
supermod.reimplementType.__init__(self, mixedclass_, content_)
|
||||
|
||||
|
||||
supermod.reimplementType.subclass = reimplementTypeSub
|
||||
# end class reimplementTypeSub
|
||||
|
||||
|
||||
class incTypeSub(supermod.incType):
|
||||
def __init__(self, local=None, refid=None, valueOf_='', mixedclass_=None, content_=None):
|
||||
supermod.incType.__init__(self, mixedclass_, content_)
|
||||
|
||||
|
||||
supermod.incType.subclass = incTypeSub
|
||||
# end class incTypeSub
|
||||
|
||||
|
||||
class refTypeSub(supermod.refType):
|
||||
def __init__(self, prot=None, refid=None, valueOf_='', mixedclass_=None, content_=None):
|
||||
supermod.refType.__init__(self, mixedclass_, content_)
|
||||
|
||||
|
||||
supermod.refType.subclass = refTypeSub
|
||||
# end class refTypeSub
|
||||
|
||||
|
||||
class refTextTypeSub(supermod.refTextType):
|
||||
def __init__(self, refid=None, kindref=None, external=None, valueOf_='', mixedclass_=None, content_=None):
|
||||
supermod.refTextType.__init__(self, mixedclass_, content_)
|
||||
|
||||
|
||||
supermod.refTextType.subclass = refTextTypeSub
|
||||
# end class refTextTypeSub
|
||||
|
||||
|
||||
class sectiondefTypeSub(supermod.sectiondefType):
|
||||
|
||||
def __init__(self, kind=None, header='', description=None, memberdef=None):
|
||||
supermod.sectiondefType.__init__(
|
||||
self, kind, header, description, memberdef)
|
||||
|
||||
def find(self, details):
|
||||
|
||||
for memberdef in self.memberdef:
|
||||
if memberdef.id == details.refid:
|
||||
return memberdef
|
||||
|
||||
return None
|
||||
|
||||
|
||||
supermod.sectiondefType.subclass = sectiondefTypeSub
|
||||
# end class sectiondefTypeSub
|
||||
|
||||
|
||||
class memberdefTypeSub(supermod.memberdefType):
|
||||
def __init__(self, initonly=None, kind=None, volatile=None, const=None, raise_=None, virt=None, readable=None, prot=None, explicit=None, new=None, final=None, writable=None, add=None, static=None, remove=None, sealed=None, mutable=None, gettable=None, inline=None, settable=None, id=None, templateparamlist=None, type_=None, definition='', argsstring='', name='', read='', write='', bitfield='', reimplements=None, reimplementedby=None, param=None, enumvalue=None, initializer=None, exceptions=None, briefdescription=None, detaileddescription=None, inbodydescription=None, location=None, references=None, referencedby=None):
|
||||
supermod.memberdefType.__init__(self, initonly, kind, volatile, const, raise_, virt, readable, prot, explicit, new, final, writable, add, static, remove, sealed, mutable, gettable, inline, settable, id, templateparamlist, type_,
|
||||
definition, argsstring, name, read, write, bitfield, reimplements, reimplementedby, param, enumvalue, initializer, exceptions, briefdescription, detaileddescription, inbodydescription, location, references, referencedby)
|
||||
|
||||
|
||||
supermod.memberdefType.subclass = memberdefTypeSub
|
||||
# end class memberdefTypeSub
|
||||
|
||||
|
||||
class descriptionTypeSub(supermod.descriptionType):
|
||||
def __init__(self, title='', para=None, sect1=None, internal=None, mixedclass_=None, content_=None):
|
||||
supermod.descriptionType.__init__(self, mixedclass_, content_)
|
||||
|
||||
|
||||
supermod.descriptionType.subclass = descriptionTypeSub
|
||||
# end class descriptionTypeSub
|
||||
|
||||
|
||||
class enumvalueTypeSub(supermod.enumvalueType):
|
||||
def __init__(self, prot=None, id=None, name='', initializer=None, briefdescription=None, detaileddescription=None, mixedclass_=None, content_=None):
|
||||
supermod.enumvalueType.__init__(self, mixedclass_, content_)
|
||||
|
||||
|
||||
supermod.enumvalueType.subclass = enumvalueTypeSub
|
||||
# end class enumvalueTypeSub
|
||||
|
||||
|
||||
class templateparamlistTypeSub(supermod.templateparamlistType):
|
||||
def __init__(self, param=None):
|
||||
supermod.templateparamlistType.__init__(self, param)
|
||||
|
||||
|
||||
supermod.templateparamlistType.subclass = templateparamlistTypeSub
|
||||
# end class templateparamlistTypeSub
|
||||
|
||||
|
||||
class paramTypeSub(supermod.paramType):
|
||||
def __init__(self, type_=None, declname='', defname='', array='', defval=None, briefdescription=None):
|
||||
supermod.paramType.__init__(
|
||||
self, type_, declname, defname, array, defval, briefdescription)
|
||||
|
||||
|
||||
supermod.paramType.subclass = paramTypeSub
|
||||
# end class paramTypeSub
|
||||
|
||||
|
||||
class linkedTextTypeSub(supermod.linkedTextType):
|
||||
def __init__(self, ref=None, mixedclass_=None, content_=None):
|
||||
supermod.linkedTextType.__init__(self, mixedclass_, content_)
|
||||
|
||||
|
||||
supermod.linkedTextType.subclass = linkedTextTypeSub
|
||||
# end class linkedTextTypeSub
|
||||
|
||||
|
||||
class graphTypeSub(supermod.graphType):
|
||||
def __init__(self, node=None):
|
||||
supermod.graphType.__init__(self, node)
|
||||
|
||||
|
||||
supermod.graphType.subclass = graphTypeSub
|
||||
# end class graphTypeSub
|
||||
|
||||
|
||||
class nodeTypeSub(supermod.nodeType):
|
||||
def __init__(self, id=None, label='', link=None, childnode=None):
|
||||
supermod.nodeType.__init__(self, id, label, link, childnode)
|
||||
|
||||
|
||||
supermod.nodeType.subclass = nodeTypeSub
|
||||
# end class nodeTypeSub
|
||||
|
||||
|
||||
class childnodeTypeSub(supermod.childnodeType):
|
||||
def __init__(self, relation=None, refid=None, edgelabel=None):
|
||||
supermod.childnodeType.__init__(self, relation, refid, edgelabel)
|
||||
|
||||
|
||||
supermod.childnodeType.subclass = childnodeTypeSub
|
||||
# end class childnodeTypeSub
|
||||
|
||||
|
||||
class linkTypeSub(supermod.linkType):
|
||||
def __init__(self, refid=None, external=None, valueOf_=''):
|
||||
supermod.linkType.__init__(self, refid, external)
|
||||
|
||||
|
||||
supermod.linkType.subclass = linkTypeSub
|
||||
# end class linkTypeSub
|
||||
|
||||
|
||||
class listingTypeSub(supermod.listingType):
|
||||
def __init__(self, codeline=None):
|
||||
supermod.listingType.__init__(self, codeline)
|
||||
|
||||
|
||||
supermod.listingType.subclass = listingTypeSub
|
||||
# end class listingTypeSub
|
||||
|
||||
|
||||
class codelineTypeSub(supermod.codelineType):
|
||||
def __init__(self, external=None, lineno=None, refkind=None, refid=None, highlight=None):
|
||||
supermod.codelineType.__init__(
|
||||
self, external, lineno, refkind, refid, highlight)
|
||||
|
||||
|
||||
supermod.codelineType.subclass = codelineTypeSub
|
||||
# end class codelineTypeSub
|
||||
|
||||
|
||||
class highlightTypeSub(supermod.highlightType):
|
||||
def __init__(self, class_=None, sp=None, ref=None, mixedclass_=None, content_=None):
|
||||
supermod.highlightType.__init__(self, mixedclass_, content_)
|
||||
|
||||
|
||||
supermod.highlightType.subclass = highlightTypeSub
|
||||
# end class highlightTypeSub
|
||||
|
||||
|
||||
class referenceTypeSub(supermod.referenceType):
|
||||
def __init__(self, endline=None, startline=None, refid=None, compoundref=None, valueOf_='', mixedclass_=None, content_=None):
|
||||
supermod.referenceType.__init__(self, mixedclass_, content_)
|
||||
|
||||
|
||||
supermod.referenceType.subclass = referenceTypeSub
|
||||
# end class referenceTypeSub
|
||||
|
||||
|
||||
class locationTypeSub(supermod.locationType):
|
||||
def __init__(self, bodystart=None, line=None, bodyend=None, bodyfile=None, file=None, valueOf_=''):
|
||||
supermod.locationType.__init__(
|
||||
self, bodystart, line, bodyend, bodyfile, file)
|
||||
|
||||
|
||||
supermod.locationType.subclass = locationTypeSub
|
||||
# end class locationTypeSub
|
||||
|
||||
|
||||
class docSect1TypeSub(supermod.docSect1Type):
|
||||
def __init__(self, id=None, title='', para=None, sect2=None, internal=None, mixedclass_=None, content_=None):
|
||||
supermod.docSect1Type.__init__(self, mixedclass_, content_)
|
||||
|
||||
|
||||
supermod.docSect1Type.subclass = docSect1TypeSub
|
||||
# end class docSect1TypeSub
|
||||
|
||||
|
||||
class docSect2TypeSub(supermod.docSect2Type):
|
||||
def __init__(self, id=None, title='', para=None, sect3=None, internal=None, mixedclass_=None, content_=None):
|
||||
supermod.docSect2Type.__init__(self, mixedclass_, content_)
|
||||
|
||||
|
||||
supermod.docSect2Type.subclass = docSect2TypeSub
|
||||
# end class docSect2TypeSub
|
||||
|
||||
|
||||
class docSect3TypeSub(supermod.docSect3Type):
|
||||
def __init__(self, id=None, title='', para=None, sect4=None, internal=None, mixedclass_=None, content_=None):
|
||||
supermod.docSect3Type.__init__(self, mixedclass_, content_)
|
||||
|
||||
|
||||
supermod.docSect3Type.subclass = docSect3TypeSub
|
||||
# end class docSect3TypeSub
|
||||
|
||||
|
||||
class docSect4TypeSub(supermod.docSect4Type):
|
||||
def __init__(self, id=None, title='', para=None, internal=None, mixedclass_=None, content_=None):
|
||||
supermod.docSect4Type.__init__(self, mixedclass_, content_)
|
||||
|
||||
|
||||
supermod.docSect4Type.subclass = docSect4TypeSub
|
||||
# end class docSect4TypeSub
|
||||
|
||||
|
||||
class docInternalTypeSub(supermod.docInternalType):
|
||||
def __init__(self, para=None, sect1=None, mixedclass_=None, content_=None):
|
||||
supermod.docInternalType.__init__(self, mixedclass_, content_)
|
||||
|
||||
|
||||
supermod.docInternalType.subclass = docInternalTypeSub
|
||||
# end class docInternalTypeSub
|
||||
|
||||
|
||||
class docInternalS1TypeSub(supermod.docInternalS1Type):
|
||||
def __init__(self, para=None, sect2=None, mixedclass_=None, content_=None):
|
||||
supermod.docInternalS1Type.__init__(self, mixedclass_, content_)
|
||||
|
||||
|
||||
supermod.docInternalS1Type.subclass = docInternalS1TypeSub
|
||||
# end class docInternalS1TypeSub
|
||||
|
||||
|
||||
class docInternalS2TypeSub(supermod.docInternalS2Type):
|
||||
def __init__(self, para=None, sect3=None, mixedclass_=None, content_=None):
|
||||
supermod.docInternalS2Type.__init__(self, mixedclass_, content_)
|
||||
|
||||
|
||||
supermod.docInternalS2Type.subclass = docInternalS2TypeSub
|
||||
# end class docInternalS2TypeSub
|
||||
|
||||
|
||||
class docInternalS3TypeSub(supermod.docInternalS3Type):
|
||||
def __init__(self, para=None, sect3=None, mixedclass_=None, content_=None):
|
||||
supermod.docInternalS3Type.__init__(self, mixedclass_, content_)
|
||||
|
||||
|
||||
supermod.docInternalS3Type.subclass = docInternalS3TypeSub
|
||||
# end class docInternalS3TypeSub
|
||||
|
||||
|
||||
class docInternalS4TypeSub(supermod.docInternalS4Type):
|
||||
def __init__(self, para=None, mixedclass_=None, content_=None):
|
||||
supermod.docInternalS4Type.__init__(self, mixedclass_, content_)
|
||||
|
||||
|
||||
supermod.docInternalS4Type.subclass = docInternalS4TypeSub
|
||||
# end class docInternalS4TypeSub
|
||||
|
||||
|
||||
class docURLLinkSub(supermod.docURLLink):
|
||||
def __init__(self, url=None, valueOf_='', mixedclass_=None, content_=None):
|
||||
supermod.docURLLink.__init__(self, mixedclass_, content_)
|
||||
|
||||
|
||||
supermod.docURLLink.subclass = docURLLinkSub
|
||||
# end class docURLLinkSub
|
||||
|
||||
|
||||
class docAnchorTypeSub(supermod.docAnchorType):
|
||||
def __init__(self, id=None, valueOf_='', mixedclass_=None, content_=None):
|
||||
supermod.docAnchorType.__init__(self, mixedclass_, content_)
|
||||
|
||||
|
||||
supermod.docAnchorType.subclass = docAnchorTypeSub
|
||||
# end class docAnchorTypeSub
|
||||
|
||||
|
||||
class docFormulaTypeSub(supermod.docFormulaType):
|
||||
def __init__(self, id=None, valueOf_='', mixedclass_=None, content_=None):
|
||||
supermod.docFormulaType.__init__(self, mixedclass_, content_)
|
||||
|
||||
|
||||
supermod.docFormulaType.subclass = docFormulaTypeSub
|
||||
# end class docFormulaTypeSub
|
||||
|
||||
|
||||
class docIndexEntryTypeSub(supermod.docIndexEntryType):
|
||||
def __init__(self, primaryie='', secondaryie=''):
|
||||
supermod.docIndexEntryType.__init__(self, primaryie, secondaryie)
|
||||
|
||||
|
||||
supermod.docIndexEntryType.subclass = docIndexEntryTypeSub
|
||||
# end class docIndexEntryTypeSub
|
||||
|
||||
|
||||
class docListTypeSub(supermod.docListType):
|
||||
def __init__(self, listitem=None):
|
||||
supermod.docListType.__init__(self, listitem)
|
||||
|
||||
|
||||
supermod.docListType.subclass = docListTypeSub
|
||||
# end class docListTypeSub
|
||||
|
||||
|
||||
class docListItemTypeSub(supermod.docListItemType):
|
||||
def __init__(self, para=None):
|
||||
supermod.docListItemType.__init__(self, para)
|
||||
|
||||
|
||||
supermod.docListItemType.subclass = docListItemTypeSub
|
||||
# end class docListItemTypeSub
|
||||
|
||||
|
||||
class docSimpleSectTypeSub(supermod.docSimpleSectType):
|
||||
def __init__(self, kind=None, title=None, para=None):
|
||||
supermod.docSimpleSectType.__init__(self, kind, title, para)
|
||||
|
||||
|
||||
supermod.docSimpleSectType.subclass = docSimpleSectTypeSub
|
||||
# end class docSimpleSectTypeSub
|
||||
|
||||
|
||||
class docVarListEntryTypeSub(supermod.docVarListEntryType):
|
||||
def __init__(self, term=None):
|
||||
supermod.docVarListEntryType.__init__(self, term)
|
||||
|
||||
|
||||
supermod.docVarListEntryType.subclass = docVarListEntryTypeSub
|
||||
# end class docVarListEntryTypeSub
|
||||
|
||||
|
||||
class docRefTextTypeSub(supermod.docRefTextType):
|
||||
def __init__(self, refid=None, kindref=None, external=None, valueOf_='', mixedclass_=None, content_=None):
|
||||
supermod.docRefTextType.__init__(self, mixedclass_, content_)
|
||||
|
||||
|
||||
supermod.docRefTextType.subclass = docRefTextTypeSub
|
||||
# end class docRefTextTypeSub
|
||||
|
||||
|
||||
class docTableTypeSub(supermod.docTableType):
|
||||
def __init__(self, rows=None, cols=None, row=None, caption=None):
|
||||
supermod.docTableType.__init__(self, rows, cols, row, caption)
|
||||
|
||||
|
||||
supermod.docTableType.subclass = docTableTypeSub
|
||||
# end class docTableTypeSub
|
||||
|
||||
|
||||
class docRowTypeSub(supermod.docRowType):
|
||||
def __init__(self, entry=None):
|
||||
supermod.docRowType.__init__(self, entry)
|
||||
|
||||
|
||||
supermod.docRowType.subclass = docRowTypeSub
|
||||
# end class docRowTypeSub
|
||||
|
||||
|
||||
class docEntryTypeSub(supermod.docEntryType):
|
||||
def __init__(self, thead=None, para=None):
|
||||
supermod.docEntryType.__init__(self, thead, para)
|
||||
|
||||
|
||||
supermod.docEntryType.subclass = docEntryTypeSub
|
||||
# end class docEntryTypeSub
|
||||
|
||||
|
||||
class docHeadingTypeSub(supermod.docHeadingType):
|
||||
def __init__(self, level=None, valueOf_='', mixedclass_=None, content_=None):
|
||||
supermod.docHeadingType.__init__(self, mixedclass_, content_)
|
||||
|
||||
|
||||
supermod.docHeadingType.subclass = docHeadingTypeSub
|
||||
# end class docHeadingTypeSub
|
||||
|
||||
|
||||
class docImageTypeSub(supermod.docImageType):
|
||||
def __init__(self, width=None, type_=None, name=None, height=None, valueOf_='', mixedclass_=None, content_=None):
|
||||
supermod.docImageType.__init__(self, mixedclass_, content_)
|
||||
|
||||
|
||||
supermod.docImageType.subclass = docImageTypeSub
|
||||
# end class docImageTypeSub
|
||||
|
||||
|
||||
class docDotFileTypeSub(supermod.docDotFileType):
|
||||
def __init__(self, name=None, valueOf_='', mixedclass_=None, content_=None):
|
||||
supermod.docDotFileType.__init__(self, mixedclass_, content_)
|
||||
|
||||
|
||||
supermod.docDotFileType.subclass = docDotFileTypeSub
|
||||
# end class docDotFileTypeSub
|
||||
|
||||
|
||||
class docTocItemTypeSub(supermod.docTocItemType):
|
||||
def __init__(self, id=None, valueOf_='', mixedclass_=None, content_=None):
|
||||
supermod.docTocItemType.__init__(self, mixedclass_, content_)
|
||||
|
||||
|
||||
supermod.docTocItemType.subclass = docTocItemTypeSub
|
||||
# end class docTocItemTypeSub
|
||||
|
||||
|
||||
class docTocListTypeSub(supermod.docTocListType):
|
||||
def __init__(self, tocitem=None):
|
||||
supermod.docTocListType.__init__(self, tocitem)
|
||||
|
||||
|
||||
supermod.docTocListType.subclass = docTocListTypeSub
|
||||
# end class docTocListTypeSub
|
||||
|
||||
|
||||
class docLanguageTypeSub(supermod.docLanguageType):
|
||||
def __init__(self, langid=None, para=None):
|
||||
supermod.docLanguageType.__init__(self, langid, para)
|
||||
|
||||
|
||||
supermod.docLanguageType.subclass = docLanguageTypeSub
|
||||
# end class docLanguageTypeSub
|
||||
|
||||
|
||||
class docParamListTypeSub(supermod.docParamListType):
|
||||
def __init__(self, kind=None, parameteritem=None):
|
||||
supermod.docParamListType.__init__(self, kind, parameteritem)
|
||||
|
||||
|
||||
supermod.docParamListType.subclass = docParamListTypeSub
|
||||
# end class docParamListTypeSub
|
||||
|
||||
|
||||
class docParamListItemSub(supermod.docParamListItem):
|
||||
def __init__(self, parameternamelist=None, parameterdescription=None):
|
||||
supermod.docParamListItem.__init__(
|
||||
self, parameternamelist, parameterdescription)
|
||||
|
||||
|
||||
supermod.docParamListItem.subclass = docParamListItemSub
|
||||
# end class docParamListItemSub
|
||||
|
||||
|
||||
class docParamNameListSub(supermod.docParamNameList):
|
||||
def __init__(self, parametername=None):
|
||||
supermod.docParamNameList.__init__(self, parametername)
|
||||
|
||||
|
||||
supermod.docParamNameList.subclass = docParamNameListSub
|
||||
# end class docParamNameListSub
|
||||
|
||||
|
||||
class docParamNameSub(supermod.docParamName):
|
||||
def __init__(self, direction=None, ref=None, mixedclass_=None, content_=None):
|
||||
supermod.docParamName.__init__(self, mixedclass_, content_)
|
||||
|
||||
|
||||
supermod.docParamName.subclass = docParamNameSub
|
||||
# end class docParamNameSub
|
||||
|
||||
|
||||
class docXRefSectTypeSub(supermod.docXRefSectType):
|
||||
def __init__(self, id=None, xreftitle=None, xrefdescription=None):
|
||||
supermod.docXRefSectType.__init__(self, id, xreftitle, xrefdescription)
|
||||
|
||||
|
||||
supermod.docXRefSectType.subclass = docXRefSectTypeSub
|
||||
# end class docXRefSectTypeSub
|
||||
|
||||
|
||||
class docCopyTypeSub(supermod.docCopyType):
|
||||
def __init__(self, link=None, para=None, sect1=None, internal=None):
|
||||
supermod.docCopyType.__init__(self, link, para, sect1, internal)
|
||||
|
||||
|
||||
supermod.docCopyType.subclass = docCopyTypeSub
|
||||
# end class docCopyTypeSub
|
||||
|
||||
|
||||
class docCharTypeSub(supermod.docCharType):
|
||||
def __init__(self, char=None, valueOf_=''):
|
||||
supermod.docCharType.__init__(self, char)
|
||||
|
||||
|
||||
supermod.docCharType.subclass = docCharTypeSub
|
||||
# end class docCharTypeSub
|
||||
|
||||
|
||||
class docParaTypeSub(supermod.docParaType):
|
||||
def __init__(self, char=None, valueOf_=''):
|
||||
supermod.docParaType.__init__(self, char)
|
||||
|
||||
self.parameterlist = []
|
||||
self.simplesects = []
|
||||
self.content = []
|
||||
|
||||
def buildChildren(self, child_, nodeName_):
|
||||
supermod.docParaType.buildChildren(self, child_, nodeName_)
|
||||
|
||||
if child_.nodeType == Node.TEXT_NODE:
|
||||
obj_ = self.mixedclass_(MixedContainer.CategoryText,
|
||||
MixedContainer.TypeNone, '', child_.nodeValue)
|
||||
self.content.append(obj_)
|
||||
elif child_.nodeType == Node.ELEMENT_NODE and \
|
||||
nodeName_ == "ref":
|
||||
obj_ = supermod.docRefTextType.factory()
|
||||
obj_.build(child_)
|
||||
self.content.append(obj_)
|
||||
elif child_.nodeType == Node.ELEMENT_NODE and \
|
||||
nodeName_ == 'parameterlist':
|
||||
obj_ = supermod.docParamListType.factory()
|
||||
obj_.build(child_)
|
||||
self.parameterlist.append(obj_)
|
||||
elif child_.nodeType == Node.ELEMENT_NODE and \
|
||||
nodeName_ == 'simplesect':
|
||||
obj_ = supermod.docSimpleSectType.factory()
|
||||
obj_.build(child_)
|
||||
self.simplesects.append(obj_)
|
||||
|
||||
|
||||
supermod.docParaType.subclass = docParaTypeSub
|
||||
# end class docParaTypeSub
|
||||
|
||||
|
||||
def parse(inFilename):
|
||||
doc = minidom.parse(inFilename)
|
||||
rootNode = doc.documentElement
|
||||
rootObj = supermod.DoxygenType.factory()
|
||||
rootObj.build(rootNode)
|
||||
return rootObj
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,80 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
Generated Mon Feb 9 19:08:05 2009 by generateDS.py.
|
||||
"""
|
||||
|
||||
from xml.dom import minidom
|
||||
|
||||
import os
|
||||
import sys
|
||||
from . import compound
|
||||
|
||||
from . import indexsuper as supermod
|
||||
|
||||
|
||||
class DoxygenTypeSub(supermod.DoxygenType):
|
||||
def __init__(self, version=None, compound=None):
|
||||
supermod.DoxygenType.__init__(self, version, compound)
|
||||
|
||||
def find_compounds_and_members(self, details):
|
||||
"""
|
||||
Returns a list of all compounds and their members which match details
|
||||
"""
|
||||
|
||||
results = []
|
||||
for compound in self.compound:
|
||||
members = compound.find_members(details)
|
||||
if members:
|
||||
results.append([compound, members])
|
||||
else:
|
||||
if details.match(compound):
|
||||
results.append([compound, []])
|
||||
|
||||
return results
|
||||
|
||||
|
||||
supermod.DoxygenType.subclass = DoxygenTypeSub
|
||||
# end class DoxygenTypeSub
|
||||
|
||||
|
||||
class CompoundTypeSub(supermod.CompoundType):
|
||||
def __init__(self, kind=None, refid=None, name='', member=None):
|
||||
supermod.CompoundType.__init__(self, kind, refid, name, member)
|
||||
|
||||
def find_members(self, details):
|
||||
"""
|
||||
Returns a list of all members which match details
|
||||
"""
|
||||
|
||||
results = []
|
||||
|
||||
for member in self.member:
|
||||
if details.match(member):
|
||||
results.append(member)
|
||||
|
||||
return results
|
||||
|
||||
|
||||
supermod.CompoundType.subclass = CompoundTypeSub
|
||||
# end class CompoundTypeSub
|
||||
|
||||
|
||||
class MemberTypeSub(supermod.MemberType):
|
||||
|
||||
def __init__(self, kind=None, refid=None, name=''):
|
||||
supermod.MemberType.__init__(self, kind, refid, name)
|
||||
|
||||
|
||||
supermod.MemberType.subclass = MemberTypeSub
|
||||
# end class MemberTypeSub
|
||||
|
||||
|
||||
def parse(inFilename):
|
||||
|
||||
doc = minidom.parse(inFilename)
|
||||
rootNode = doc.documentElement
|
||||
rootObj = supermod.DoxygenType.factory()
|
||||
rootObj.build(rootNode)
|
||||
|
||||
return rootObj
|
||||
@ -0,0 +1,581 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
#
|
||||
# Generated Thu Jun 11 18:43:54 2009 by generateDS.py.
|
||||
#
|
||||
|
||||
|
||||
import sys
|
||||
|
||||
from xml.dom import minidom
|
||||
from xml.dom import Node
|
||||
|
||||
#
|
||||
# User methods
|
||||
#
|
||||
# Calls to the methods in these classes are generated by generateDS.py.
|
||||
# You can replace these methods by re-implementing the following class
|
||||
# in a module named generatedssuper.py.
|
||||
|
||||
try:
|
||||
from generatedssuper import GeneratedsSuper
|
||||
except ImportError as exp:
|
||||
|
||||
class GeneratedsSuper(object):
|
||||
def format_string(self, input_data, input_name=''):
|
||||
return input_data
|
||||
|
||||
def format_integer(self, input_data, input_name=''):
|
||||
return '%d' % input_data
|
||||
|
||||
def format_float(self, input_data, input_name=''):
|
||||
return '%f' % input_data
|
||||
|
||||
def format_double(self, input_data, input_name=''):
|
||||
return '%e' % input_data
|
||||
|
||||
def format_boolean(self, input_data, input_name=''):
|
||||
return '%s' % input_data
|
||||
|
||||
|
||||
#
|
||||
# If you have installed IPython you can uncomment and use the following.
|
||||
# IPython is available from http://ipython.scipy.org/.
|
||||
#
|
||||
|
||||
## from IPython.Shell import IPShellEmbed
|
||||
## args = ''
|
||||
# ipshell = IPShellEmbed(args,
|
||||
## banner = 'Dropping into IPython',
|
||||
# exit_msg = 'Leaving Interpreter, back to program.')
|
||||
|
||||
# Then use the following line where and when you want to drop into the
|
||||
# IPython shell:
|
||||
# ipshell('<some message> -- Entering ipshell.\nHit Ctrl-D to exit')
|
||||
|
||||
#
|
||||
# Globals
|
||||
#
|
||||
|
||||
ExternalEncoding = 'ascii'
|
||||
|
||||
#
|
||||
# Support/utility functions.
|
||||
#
|
||||
|
||||
|
||||
def showIndent(outfile, level):
|
||||
for idx in range(level):
|
||||
outfile.write(' ')
|
||||
|
||||
|
||||
def quote_xml(inStr):
|
||||
s1 = (isinstance(inStr, str) and inStr or
|
||||
'%s' % inStr)
|
||||
s1 = s1.replace('&', '&')
|
||||
s1 = s1.replace('<', '<')
|
||||
s1 = s1.replace('>', '>')
|
||||
return s1
|
||||
|
||||
|
||||
def quote_attrib(inStr):
|
||||
s1 = (isinstance(inStr, str) and inStr or
|
||||
'%s' % inStr)
|
||||
s1 = s1.replace('&', '&')
|
||||
s1 = s1.replace('<', '<')
|
||||
s1 = s1.replace('>', '>')
|
||||
if '"' in s1:
|
||||
if "'" in s1:
|
||||
s1 = '"%s"' % s1.replace('"', """)
|
||||
else:
|
||||
s1 = "'%s'" % s1
|
||||
else:
|
||||
s1 = '"%s"' % s1
|
||||
return s1
|
||||
|
||||
|
||||
def quote_python(inStr):
|
||||
s1 = inStr
|
||||
if s1.find("'") == -1:
|
||||
if s1.find('\n') == -1:
|
||||
return "'%s'" % s1
|
||||
else:
|
||||
return "'''%s'''" % s1
|
||||
else:
|
||||
if s1.find('"') != -1:
|
||||
s1 = s1.replace('"', '\\"')
|
||||
if s1.find('\n') == -1:
|
||||
return '"%s"' % s1
|
||||
else:
|
||||
return '"""%s"""' % s1
|
||||
|
||||
|
||||
class MixedContainer(object):
|
||||
# Constants for category:
|
||||
CategoryNone = 0
|
||||
CategoryText = 1
|
||||
CategorySimple = 2
|
||||
CategoryComplex = 3
|
||||
# Constants for content_type:
|
||||
TypeNone = 0
|
||||
TypeText = 1
|
||||
TypeString = 2
|
||||
TypeInteger = 3
|
||||
TypeFloat = 4
|
||||
TypeDecimal = 5
|
||||
TypeDouble = 6
|
||||
TypeBoolean = 7
|
||||
|
||||
def __init__(self, category, content_type, name, value):
|
||||
self.category = category
|
||||
self.content_type = content_type
|
||||
self.name = name
|
||||
self.value = value
|
||||
|
||||
def getCategory(self):
|
||||
return self.category
|
||||
|
||||
def getContenttype(self, content_type):
|
||||
return self.content_type
|
||||
|
||||
def getValue(self):
|
||||
return self.value
|
||||
|
||||
def getName(self):
|
||||
return self.name
|
||||
|
||||
def export(self, outfile, level, name, namespace):
|
||||
if self.category == MixedContainer.CategoryText:
|
||||
outfile.write(self.value)
|
||||
elif self.category == MixedContainer.CategorySimple:
|
||||
self.exportSimple(outfile, level, name)
|
||||
else: # category == MixedContainer.CategoryComplex
|
||||
self.value.export(outfile, level, namespace, name)
|
||||
|
||||
def exportSimple(self, outfile, level, name):
|
||||
if self.content_type == MixedContainer.TypeString:
|
||||
outfile.write('<%s>%s</%s>' % (self.name, self.value, self.name))
|
||||
elif self.content_type == MixedContainer.TypeInteger or \
|
||||
self.content_type == MixedContainer.TypeBoolean:
|
||||
outfile.write('<%s>%d</%s>' % (self.name, self.value, self.name))
|
||||
elif self.content_type == MixedContainer.TypeFloat or \
|
||||
self.content_type == MixedContainer.TypeDecimal:
|
||||
outfile.write('<%s>%f</%s>' % (self.name, self.value, self.name))
|
||||
elif self.content_type == MixedContainer.TypeDouble:
|
||||
outfile.write('<%s>%g</%s>' % (self.name, self.value, self.name))
|
||||
|
||||
def exportLiteral(self, outfile, level, name):
|
||||
if self.category == MixedContainer.CategoryText:
|
||||
showIndent(outfile, level)
|
||||
outfile.write('MixedContainer(%d, %d, "%s", "%s"),\n' %
|
||||
(self.category, self.content_type, self.name, self.value))
|
||||
elif self.category == MixedContainer.CategorySimple:
|
||||
showIndent(outfile, level)
|
||||
outfile.write('MixedContainer(%d, %d, "%s", "%s"),\n' %
|
||||
(self.category, self.content_type, self.name, self.value))
|
||||
else: # category == MixedContainer.CategoryComplex
|
||||
showIndent(outfile, level)
|
||||
outfile.write('MixedContainer(%d, %d, "%s",\n' %
|
||||
(self.category, self.content_type, self.name,))
|
||||
self.value.exportLiteral(outfile, level + 1)
|
||||
showIndent(outfile, level)
|
||||
outfile.write(')\n')
|
||||
|
||||
|
||||
class _MemberSpec(object):
|
||||
def __init__(self, name='', data_type='', container=0):
|
||||
self.name = name
|
||||
self.data_type = data_type
|
||||
self.container = container
|
||||
|
||||
def set_name(self, name): self.name = name
|
||||
def get_name(self): return self.name
|
||||
def set_data_type(self, data_type): self.data_type = data_type
|
||||
def get_data_type(self): return self.data_type
|
||||
def set_container(self, container): self.container = container
|
||||
def get_container(self): return self.container
|
||||
|
||||
|
||||
#
|
||||
# Data representation classes.
|
||||
#
|
||||
|
||||
class DoxygenType(GeneratedsSuper):
|
||||
subclass = None
|
||||
superclass = None
|
||||
|
||||
def __init__(self, version=None, compound=None):
|
||||
self.version = version
|
||||
if compound is None:
|
||||
self.compound = []
|
||||
else:
|
||||
self.compound = compound
|
||||
|
||||
def factory(*args_, **kwargs_):
|
||||
if DoxygenType.subclass:
|
||||
return DoxygenType.subclass(*args_, **kwargs_)
|
||||
else:
|
||||
return DoxygenType(*args_, **kwargs_)
|
||||
factory = staticmethod(factory)
|
||||
def get_compound(self): return self.compound
|
||||
def set_compound(self, compound): self.compound = compound
|
||||
def add_compound(self, value): self.compound.append(value)
|
||||
def insert_compound(self, index, value): self.compound[index] = value
|
||||
def get_version(self): return self.version
|
||||
def set_version(self, version): self.version = version
|
||||
|
||||
def export(self, outfile, level, namespace_='', name_='DoxygenType', namespacedef_=''):
|
||||
showIndent(outfile, level)
|
||||
outfile.write('<%s%s %s' % (namespace_, name_, namespacedef_, ))
|
||||
self.exportAttributes(outfile, level, namespace_, name_='DoxygenType')
|
||||
if self.hasContent_():
|
||||
outfile.write('>\n')
|
||||
self.exportChildren(outfile, level + 1, namespace_, name_)
|
||||
showIndent(outfile, level)
|
||||
outfile.write('</%s%s>\n' % (namespace_, name_))
|
||||
else:
|
||||
outfile.write(' />\n')
|
||||
|
||||
def exportAttributes(self, outfile, level, namespace_='', name_='DoxygenType'):
|
||||
outfile.write(' version=%s' % (self.format_string(quote_attrib(
|
||||
self.version).encode(ExternalEncoding), input_name='version'), ))
|
||||
|
||||
def exportChildren(self, outfile, level, namespace_='', name_='DoxygenType'):
|
||||
for compound_ in self.compound:
|
||||
compound_.export(outfile, level, namespace_, name_='compound')
|
||||
|
||||
def hasContent_(self):
|
||||
if (
|
||||
self.compound is not None
|
||||
):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def exportLiteral(self, outfile, level, name_='DoxygenType'):
|
||||
level += 1
|
||||
self.exportLiteralAttributes(outfile, level, name_)
|
||||
if self.hasContent_():
|
||||
self.exportLiteralChildren(outfile, level, name_)
|
||||
|
||||
def exportLiteralAttributes(self, outfile, level, name_):
|
||||
if self.version is not None:
|
||||
showIndent(outfile, level)
|
||||
outfile.write('version = %s,\n' % (self.version,))
|
||||
|
||||
def exportLiteralChildren(self, outfile, level, name_):
|
||||
showIndent(outfile, level)
|
||||
outfile.write('compound=[\n')
|
||||
level += 1
|
||||
for compound in self.compound:
|
||||
showIndent(outfile, level)
|
||||
outfile.write('model_.compound(\n')
|
||||
compound.exportLiteral(outfile, level, name_='compound')
|
||||
showIndent(outfile, level)
|
||||
outfile.write('),\n')
|
||||
level -= 1
|
||||
showIndent(outfile, level)
|
||||
outfile.write('],\n')
|
||||
|
||||
def build(self, node_):
|
||||
attrs = node_.attributes
|
||||
self.buildAttributes(attrs)
|
||||
for child_ in node_.childNodes:
|
||||
nodeName_ = child_.nodeName.split(':')[-1]
|
||||
self.buildChildren(child_, nodeName_)
|
||||
|
||||
def buildAttributes(self, attrs):
|
||||
if attrs.get('version'):
|
||||
self.version = attrs.get('version').value
|
||||
|
||||
def buildChildren(self, child_, nodeName_):
|
||||
if child_.nodeType == Node.ELEMENT_NODE and \
|
||||
nodeName_ == 'compound':
|
||||
obj_ = CompoundType.factory()
|
||||
obj_.build(child_)
|
||||
self.compound.append(obj_)
|
||||
# end class DoxygenType
|
||||
|
||||
|
||||
class CompoundType(GeneratedsSuper):
|
||||
subclass = None
|
||||
superclass = None
|
||||
|
||||
def __init__(self, kind=None, refid=None, name=None, member=None):
|
||||
self.kind = kind
|
||||
self.refid = refid
|
||||
self.name = name
|
||||
if member is None:
|
||||
self.member = []
|
||||
else:
|
||||
self.member = member
|
||||
|
||||
def factory(*args_, **kwargs_):
|
||||
if CompoundType.subclass:
|
||||
return CompoundType.subclass(*args_, **kwargs_)
|
||||
else:
|
||||
return CompoundType(*args_, **kwargs_)
|
||||
factory = staticmethod(factory)
|
||||
def get_name(self): return self.name
|
||||
def set_name(self, name): self.name = name
|
||||
def get_member(self): return self.member
|
||||
def set_member(self, member): self.member = member
|
||||
def add_member(self, value): self.member.append(value)
|
||||
def insert_member(self, index, value): self.member[index] = value
|
||||
def get_kind(self): return self.kind
|
||||
def set_kind(self, kind): self.kind = kind
|
||||
def get_refid(self): return self.refid
|
||||
def set_refid(self, refid): self.refid = refid
|
||||
|
||||
def export(self, outfile, level, namespace_='', name_='CompoundType', namespacedef_=''):
|
||||
showIndent(outfile, level)
|
||||
outfile.write('<%s%s %s' % (namespace_, name_, namespacedef_, ))
|
||||
self.exportAttributes(outfile, level, namespace_, name_='CompoundType')
|
||||
if self.hasContent_():
|
||||
outfile.write('>\n')
|
||||
self.exportChildren(outfile, level + 1, namespace_, name_)
|
||||
showIndent(outfile, level)
|
||||
outfile.write('</%s%s>\n' % (namespace_, name_))
|
||||
else:
|
||||
outfile.write(' />\n')
|
||||
|
||||
def exportAttributes(self, outfile, level, namespace_='', name_='CompoundType'):
|
||||
outfile.write(' kind=%s' % (quote_attrib(self.kind), ))
|
||||
outfile.write(' refid=%s' % (self.format_string(quote_attrib(
|
||||
self.refid).encode(ExternalEncoding), input_name='refid'), ))
|
||||
|
||||
def exportChildren(self, outfile, level, namespace_='', name_='CompoundType'):
|
||||
if self.name is not None:
|
||||
showIndent(outfile, level)
|
||||
outfile.write('<%sname>%s</%sname>\n' % (namespace_, self.format_string(
|
||||
quote_xml(self.name).encode(ExternalEncoding), input_name='name'), namespace_))
|
||||
for member_ in self.member:
|
||||
member_.export(outfile, level, namespace_, name_='member')
|
||||
|
||||
def hasContent_(self):
|
||||
if (
|
||||
self.name is not None or
|
||||
self.member is not None
|
||||
):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def exportLiteral(self, outfile, level, name_='CompoundType'):
|
||||
level += 1
|
||||
self.exportLiteralAttributes(outfile, level, name_)
|
||||
if self.hasContent_():
|
||||
self.exportLiteralChildren(outfile, level, name_)
|
||||
|
||||
def exportLiteralAttributes(self, outfile, level, name_):
|
||||
if self.kind is not None:
|
||||
showIndent(outfile, level)
|
||||
outfile.write('kind = "%s",\n' % (self.kind,))
|
||||
if self.refid is not None:
|
||||
showIndent(outfile, level)
|
||||
outfile.write('refid = %s,\n' % (self.refid,))
|
||||
|
||||
def exportLiteralChildren(self, outfile, level, name_):
|
||||
showIndent(outfile, level)
|
||||
outfile.write('name=%s,\n' % quote_python(
|
||||
self.name).encode(ExternalEncoding))
|
||||
showIndent(outfile, level)
|
||||
outfile.write('member=[\n')
|
||||
level += 1
|
||||
for member in self.member:
|
||||
showIndent(outfile, level)
|
||||
outfile.write('model_.member(\n')
|
||||
member.exportLiteral(outfile, level, name_='member')
|
||||
showIndent(outfile, level)
|
||||
outfile.write('),\n')
|
||||
level -= 1
|
||||
showIndent(outfile, level)
|
||||
outfile.write('],\n')
|
||||
|
||||
def build(self, node_):
|
||||
attrs = node_.attributes
|
||||
self.buildAttributes(attrs)
|
||||
for child_ in node_.childNodes:
|
||||
nodeName_ = child_.nodeName.split(':')[-1]
|
||||
self.buildChildren(child_, nodeName_)
|
||||
|
||||
def buildAttributes(self, attrs):
|
||||
if attrs.get('kind'):
|
||||
self.kind = attrs.get('kind').value
|
||||
if attrs.get('refid'):
|
||||
self.refid = attrs.get('refid').value
|
||||
|
||||
def buildChildren(self, child_, nodeName_):
|
||||
if child_.nodeType == Node.ELEMENT_NODE and \
|
||||
nodeName_ == 'name':
|
||||
name_ = ''
|
||||
for text__content_ in child_.childNodes:
|
||||
name_ += text__content_.nodeValue
|
||||
self.name = name_
|
||||
elif child_.nodeType == Node.ELEMENT_NODE and \
|
||||
nodeName_ == 'member':
|
||||
obj_ = MemberType.factory()
|
||||
obj_.build(child_)
|
||||
self.member.append(obj_)
|
||||
# end class CompoundType
|
||||
|
||||
|
||||
class MemberType(GeneratedsSuper):
|
||||
subclass = None
|
||||
superclass = None
|
||||
|
||||
def __init__(self, kind=None, refid=None, name=None):
|
||||
self.kind = kind
|
||||
self.refid = refid
|
||||
self.name = name
|
||||
|
||||
def factory(*args_, **kwargs_):
|
||||
if MemberType.subclass:
|
||||
return MemberType.subclass(*args_, **kwargs_)
|
||||
else:
|
||||
return MemberType(*args_, **kwargs_)
|
||||
factory = staticmethod(factory)
|
||||
def get_name(self): return self.name
|
||||
def set_name(self, name): self.name = name
|
||||
def get_kind(self): return self.kind
|
||||
def set_kind(self, kind): self.kind = kind
|
||||
def get_refid(self): return self.refid
|
||||
def set_refid(self, refid): self.refid = refid
|
||||
|
||||
def export(self, outfile, level, namespace_='', name_='MemberType', namespacedef_=''):
|
||||
showIndent(outfile, level)
|
||||
outfile.write('<%s%s %s' % (namespace_, name_, namespacedef_, ))
|
||||
self.exportAttributes(outfile, level, namespace_, name_='MemberType')
|
||||
if self.hasContent_():
|
||||
outfile.write('>\n')
|
||||
self.exportChildren(outfile, level + 1, namespace_, name_)
|
||||
showIndent(outfile, level)
|
||||
outfile.write('</%s%s>\n' % (namespace_, name_))
|
||||
else:
|
||||
outfile.write(' />\n')
|
||||
|
||||
def exportAttributes(self, outfile, level, namespace_='', name_='MemberType'):
|
||||
outfile.write(' kind=%s' % (quote_attrib(self.kind), ))
|
||||
outfile.write(' refid=%s' % (self.format_string(quote_attrib(
|
||||
self.refid).encode(ExternalEncoding), input_name='refid'), ))
|
||||
|
||||
def exportChildren(self, outfile, level, namespace_='', name_='MemberType'):
|
||||
if self.name is not None:
|
||||
showIndent(outfile, level)
|
||||
outfile.write('<%sname>%s</%sname>\n' % (namespace_, self.format_string(
|
||||
quote_xml(self.name).encode(ExternalEncoding), input_name='name'), namespace_))
|
||||
|
||||
def hasContent_(self):
|
||||
if (
|
||||
self.name is not None
|
||||
):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def exportLiteral(self, outfile, level, name_='MemberType'):
|
||||
level += 1
|
||||
self.exportLiteralAttributes(outfile, level, name_)
|
||||
if self.hasContent_():
|
||||
self.exportLiteralChildren(outfile, level, name_)
|
||||
|
||||
def exportLiteralAttributes(self, outfile, level, name_):
|
||||
if self.kind is not None:
|
||||
showIndent(outfile, level)
|
||||
outfile.write('kind = "%s",\n' % (self.kind,))
|
||||
if self.refid is not None:
|
||||
showIndent(outfile, level)
|
||||
outfile.write('refid = %s,\n' % (self.refid,))
|
||||
|
||||
def exportLiteralChildren(self, outfile, level, name_):
|
||||
showIndent(outfile, level)
|
||||
outfile.write('name=%s,\n' % quote_python(
|
||||
self.name).encode(ExternalEncoding))
|
||||
|
||||
def build(self, node_):
|
||||
attrs = node_.attributes
|
||||
self.buildAttributes(attrs)
|
||||
for child_ in node_.childNodes:
|
||||
nodeName_ = child_.nodeName.split(':')[-1]
|
||||
self.buildChildren(child_, nodeName_)
|
||||
|
||||
def buildAttributes(self, attrs):
|
||||
if attrs.get('kind'):
|
||||
self.kind = attrs.get('kind').value
|
||||
if attrs.get('refid'):
|
||||
self.refid = attrs.get('refid').value
|
||||
|
||||
def buildChildren(self, child_, nodeName_):
|
||||
if child_.nodeType == Node.ELEMENT_NODE and \
|
||||
nodeName_ == 'name':
|
||||
name_ = ''
|
||||
for text__content_ in child_.childNodes:
|
||||
name_ += text__content_.nodeValue
|
||||
self.name = name_
|
||||
# end class MemberType
|
||||
|
||||
|
||||
USAGE_TEXT = """
|
||||
Usage: python <Parser>.py [ -s ] <in_xml_file>
|
||||
Options:
|
||||
-s Use the SAX parser, not the minidom parser.
|
||||
"""
|
||||
|
||||
|
||||
def usage():
|
||||
print(USAGE_TEXT)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def parse(inFileName):
|
||||
doc = minidom.parse(inFileName)
|
||||
rootNode = doc.documentElement
|
||||
rootObj = DoxygenType.factory()
|
||||
rootObj.build(rootNode)
|
||||
# Enable Python to collect the space used by the DOM.
|
||||
doc = None
|
||||
sys.stdout.write('<?xml version="1.0" ?>\n')
|
||||
rootObj.export(sys.stdout, 0, name_="doxygenindex",
|
||||
namespacedef_='')
|
||||
return rootObj
|
||||
|
||||
|
||||
def parseString(inString):
|
||||
doc = minidom.parseString(inString)
|
||||
rootNode = doc.documentElement
|
||||
rootObj = DoxygenType.factory()
|
||||
rootObj.build(rootNode)
|
||||
# Enable Python to collect the space used by the DOM.
|
||||
doc = None
|
||||
sys.stdout.write('<?xml version="1.0" ?>\n')
|
||||
rootObj.export(sys.stdout, 0, name_="doxygenindex",
|
||||
namespacedef_='')
|
||||
return rootObj
|
||||
|
||||
|
||||
def parseLiteral(inFileName):
|
||||
doc = minidom.parse(inFileName)
|
||||
rootNode = doc.documentElement
|
||||
rootObj = DoxygenType.factory()
|
||||
rootObj.build(rootNode)
|
||||
# Enable Python to collect the space used by the DOM.
|
||||
doc = None
|
||||
sys.stdout.write('from index import *\n\n')
|
||||
sys.stdout.write('rootObj = doxygenindex(\n')
|
||||
rootObj.exportLiteral(sys.stdout, 0, name_="doxygenindex")
|
||||
sys.stdout.write(')\n')
|
||||
return rootObj
|
||||
|
||||
|
||||
def main():
|
||||
args = sys.argv[1:]
|
||||
if len(args) == 1:
|
||||
parse(args[0])
|
||||
else:
|
||||
usage()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
#import pdb
|
||||
# pdb.run('main()')
|
||||
@ -0,0 +1,49 @@
|
||||
#
|
||||
# Copyright 2010 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file was generated by gr_modtool, a tool from the GNU Radio framework
|
||||
# This file is a part of gr-rfnoc_gain
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#
|
||||
#
|
||||
"""
|
||||
Utilities for extracting text from generated classes.
|
||||
"""
|
||||
|
||||
|
||||
def is_string(txt):
|
||||
if isinstance(txt, str):
|
||||
return True
|
||||
try:
|
||||
if isinstance(txt, str):
|
||||
return True
|
||||
except NameError:
|
||||
pass
|
||||
return False
|
||||
|
||||
|
||||
def description(obj):
|
||||
if obj is None:
|
||||
return None
|
||||
return description_bit(obj).strip()
|
||||
|
||||
|
||||
def description_bit(obj):
|
||||
if hasattr(obj, 'content'):
|
||||
contents = [description_bit(item) for item in obj.content]
|
||||
result = ''.join(contents)
|
||||
elif hasattr(obj, 'content_'):
|
||||
contents = [description_bit(item) for item in obj.content_]
|
||||
result = ''.join(contents)
|
||||
elif hasattr(obj, 'value'):
|
||||
result = description_bit(obj.value)
|
||||
elif is_string(obj):
|
||||
return obj
|
||||
else:
|
||||
raise Exception(
|
||||
'Expecting a string or something with content, content_ or value attribute')
|
||||
# If this bit is a paragraph then add one some line breaks.
|
||||
if hasattr(obj, 'name') and obj.name == 'para':
|
||||
result += "\n\n"
|
||||
return result
|
||||
@ -0,0 +1,446 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
|
||||
__applicationName__ = "doxypy"
|
||||
__blurb__ = """
|
||||
doxypy is an input filter for Doxygen. It preprocesses python
|
||||
files so that docstrings of classes and functions are reformatted
|
||||
into Doxygen-conform documentation blocks.
|
||||
"""
|
||||
|
||||
__doc__ = __blurb__ + \
|
||||
"""
|
||||
In order to make Doxygen preprocess files through doxypy, simply
|
||||
add the following lines to your Doxyfile:
|
||||
FILTER_SOURCE_FILES = YES
|
||||
INPUT_FILTER = "python /path/to/doxypy.py"
|
||||
"""
|
||||
|
||||
__version__ = "0.4.2"
|
||||
__date__ = "5th December 2008"
|
||||
__website__ = "http://code.foosel.org/doxypy"
|
||||
|
||||
__author__ = (
|
||||
"Philippe 'demod' Neumann (doxypy at demod dot org)",
|
||||
"Gina 'foosel' Haeussge (gina at foosel dot net)"
|
||||
)
|
||||
|
||||
__licenseName__ = "GPL v2"
|
||||
__license__ = """This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
import sys
|
||||
import re
|
||||
|
||||
from argparse import ArgumentParser
|
||||
|
||||
|
||||
class FSM(object):
|
||||
"""Implements a finite state machine.
|
||||
|
||||
Transitions are given as 4-tuples, consisting of an origin state, a target
|
||||
state, a condition for the transition (given as a reference to a function
|
||||
which gets called with a given piece of input) and a pointer to a function
|
||||
to be called upon the execution of the given transition.
|
||||
"""
|
||||
|
||||
"""
|
||||
@var transitions holds the transitions
|
||||
@var current_state holds the current state
|
||||
@var current_input holds the current input
|
||||
@var current_transition hold the currently active transition
|
||||
"""
|
||||
|
||||
def __init__(self, start_state=None, transitions=[]):
|
||||
self.transitions = transitions
|
||||
self.current_state = start_state
|
||||
self.current_input = None
|
||||
self.current_transition = None
|
||||
|
||||
def setStartState(self, state):
|
||||
self.current_state = state
|
||||
|
||||
def addTransition(self, from_state, to_state, condition, callback):
|
||||
self.transitions.append([from_state, to_state, condition, callback])
|
||||
|
||||
def makeTransition(self, input):
|
||||
""" Makes a transition based on the given input.
|
||||
|
||||
@param input input to parse by the FSM
|
||||
"""
|
||||
for transition in self.transitions:
|
||||
[from_state, to_state, condition, callback] = transition
|
||||
if from_state == self.current_state:
|
||||
match = condition(input)
|
||||
if match:
|
||||
self.current_state = to_state
|
||||
self.current_input = input
|
||||
self.current_transition = transition
|
||||
if args.debug:
|
||||
print("# FSM: executing (%s -> %s) for line '%s'" %
|
||||
(from_state, to_state, input), file=sys.stderr)
|
||||
callback(match)
|
||||
return
|
||||
|
||||
|
||||
class Doxypy(object):
|
||||
def __init__(self):
|
||||
string_prefixes = "[uU]?[rR]?"
|
||||
|
||||
self.start_single_comment_re = re.compile(
|
||||
r"^\s*%s(''')" % string_prefixes)
|
||||
self.end_single_comment_re = re.compile(r"(''')\s*$")
|
||||
|
||||
self.start_double_comment_re = re.compile(
|
||||
r'^\s*%s(""")' % string_prefixes)
|
||||
self.end_double_comment_re = re.compile(r'(""")\s*$')
|
||||
|
||||
self.single_comment_re = re.compile(
|
||||
r"^\s*%s(''').*(''')\s*$" % string_prefixes)
|
||||
self.double_comment_re = re.compile(
|
||||
r'^\s*%s(""").*(""")\s*$' % string_prefixes)
|
||||
|
||||
self.defclass_re = re.compile(r"^(\s*)(def .+:|class .+:)")
|
||||
self.empty_re = re.compile(r"^\s*$")
|
||||
self.hashline_re = re.compile(r"^\s*#.*$")
|
||||
self.importline_re = re.compile(r"^\s*(import |from .+ import)")
|
||||
|
||||
self.multiline_defclass_start_re = re.compile(
|
||||
r"^(\s*)(def|class)(\s.*)?$")
|
||||
self.multiline_defclass_end_re = re.compile(r":\s*$")
|
||||
|
||||
# Transition list format
|
||||
# ["FROM", "TO", condition, action]
|
||||
transitions = [
|
||||
# FILEHEAD
|
||||
|
||||
# single line comments
|
||||
["FILEHEAD", "FILEHEAD", self.single_comment_re.search,
|
||||
self.appendCommentLine],
|
||||
["FILEHEAD", "FILEHEAD", self.double_comment_re.search,
|
||||
self.appendCommentLine],
|
||||
|
||||
# multiline comments
|
||||
["FILEHEAD", "FILEHEAD_COMMENT_SINGLE",
|
||||
self.start_single_comment_re.search, self.appendCommentLine],
|
||||
["FILEHEAD_COMMENT_SINGLE", "FILEHEAD",
|
||||
self.end_single_comment_re.search, self.appendCommentLine],
|
||||
["FILEHEAD_COMMENT_SINGLE", "FILEHEAD_COMMENT_SINGLE",
|
||||
self.catchall, self.appendCommentLine],
|
||||
["FILEHEAD", "FILEHEAD_COMMENT_DOUBLE",
|
||||
self.start_double_comment_re.search, self.appendCommentLine],
|
||||
["FILEHEAD_COMMENT_DOUBLE", "FILEHEAD",
|
||||
self.end_double_comment_re.search, self.appendCommentLine],
|
||||
["FILEHEAD_COMMENT_DOUBLE", "FILEHEAD_COMMENT_DOUBLE",
|
||||
self.catchall, self.appendCommentLine],
|
||||
|
||||
# other lines
|
||||
["FILEHEAD", "FILEHEAD", self.empty_re.search, self.appendFileheadLine],
|
||||
["FILEHEAD", "FILEHEAD", self.hashline_re.search, self.appendFileheadLine],
|
||||
["FILEHEAD", "FILEHEAD", self.importline_re.search,
|
||||
self.appendFileheadLine],
|
||||
["FILEHEAD", "DEFCLASS", self.defclass_re.search, self.resetCommentSearch],
|
||||
["FILEHEAD", "DEFCLASS_MULTI",
|
||||
self.multiline_defclass_start_re.search, self.resetCommentSearch],
|
||||
["FILEHEAD", "DEFCLASS_BODY", self.catchall, self.appendFileheadLine],
|
||||
|
||||
# DEFCLASS
|
||||
|
||||
# single line comments
|
||||
["DEFCLASS", "DEFCLASS_BODY",
|
||||
self.single_comment_re.search, self.appendCommentLine],
|
||||
["DEFCLASS", "DEFCLASS_BODY",
|
||||
self.double_comment_re.search, self.appendCommentLine],
|
||||
|
||||
# multiline comments
|
||||
["DEFCLASS", "COMMENT_SINGLE",
|
||||
self.start_single_comment_re.search, self.appendCommentLine],
|
||||
["COMMENT_SINGLE", "DEFCLASS_BODY",
|
||||
self.end_single_comment_re.search, self.appendCommentLine],
|
||||
["COMMENT_SINGLE", "COMMENT_SINGLE",
|
||||
self.catchall, self.appendCommentLine],
|
||||
["DEFCLASS", "COMMENT_DOUBLE",
|
||||
self.start_double_comment_re.search, self.appendCommentLine],
|
||||
["COMMENT_DOUBLE", "DEFCLASS_BODY",
|
||||
self.end_double_comment_re.search, self.appendCommentLine],
|
||||
["COMMENT_DOUBLE", "COMMENT_DOUBLE",
|
||||
self.catchall, self.appendCommentLine],
|
||||
|
||||
# other lines
|
||||
["DEFCLASS", "DEFCLASS", self.empty_re.search, self.appendDefclassLine],
|
||||
["DEFCLASS", "DEFCLASS", self.defclass_re.search, self.resetCommentSearch],
|
||||
["DEFCLASS", "DEFCLASS_MULTI",
|
||||
self.multiline_defclass_start_re.search, self.resetCommentSearch],
|
||||
["DEFCLASS", "DEFCLASS_BODY", self.catchall, self.stopCommentSearch],
|
||||
|
||||
# DEFCLASS_BODY
|
||||
|
||||
["DEFCLASS_BODY", "DEFCLASS",
|
||||
self.defclass_re.search, self.startCommentSearch],
|
||||
["DEFCLASS_BODY", "DEFCLASS_MULTI",
|
||||
self.multiline_defclass_start_re.search, self.startCommentSearch],
|
||||
["DEFCLASS_BODY", "DEFCLASS_BODY", self.catchall, self.appendNormalLine],
|
||||
|
||||
# DEFCLASS_MULTI
|
||||
["DEFCLASS_MULTI", "DEFCLASS",
|
||||
self.multiline_defclass_end_re.search, self.appendDefclassLine],
|
||||
["DEFCLASS_MULTI", "DEFCLASS_MULTI",
|
||||
self.catchall, self.appendDefclassLine],
|
||||
]
|
||||
|
||||
self.fsm = FSM("FILEHEAD", transitions)
|
||||
self.outstream = sys.stdout
|
||||
|
||||
self.output = []
|
||||
self.comment = []
|
||||
self.filehead = []
|
||||
self.defclass = []
|
||||
self.indent = ""
|
||||
|
||||
def __closeComment(self):
|
||||
"""Appends any open comment block and triggering block to the output."""
|
||||
|
||||
if args.autobrief:
|
||||
if len(self.comment) == 1 \
|
||||
or (len(self.comment) > 2 and self.comment[1].strip() == ''):
|
||||
self.comment[0] = self.__docstringSummaryToBrief(
|
||||
self.comment[0])
|
||||
|
||||
if self.comment:
|
||||
block = self.makeCommentBlock()
|
||||
self.output.extend(block)
|
||||
|
||||
if self.defclass:
|
||||
self.output.extend(self.defclass)
|
||||
|
||||
def __docstringSummaryToBrief(self, line):
|
||||
"""Adds \\brief to the docstrings summary line.
|
||||
|
||||
A \\brief is prepended, provided no other doxygen command is at the
|
||||
start of the line.
|
||||
"""
|
||||
stripped = line.strip()
|
||||
if stripped and not stripped[0] in ('@', '\\'):
|
||||
return "\\brief " + line
|
||||
else:
|
||||
return line
|
||||
|
||||
def __flushBuffer(self):
|
||||
"""Flushes the current outputbuffer to the outstream."""
|
||||
if self.output:
|
||||
try:
|
||||
if args.debug:
|
||||
print("# OUTPUT: ", self.output, file=sys.stderr)
|
||||
print("\n".join(self.output), file=self.outstream)
|
||||
self.outstream.flush()
|
||||
except IOError:
|
||||
# Fix for FS#33. Catches "broken pipe" when doxygen closes
|
||||
# stdout prematurely upon usage of INPUT_FILTER, INLINE_SOURCES
|
||||
# and FILTER_SOURCE_FILES.
|
||||
pass
|
||||
self.output = []
|
||||
|
||||
def catchall(self, input):
|
||||
"""The catchall-condition, always returns true."""
|
||||
return True
|
||||
|
||||
def resetCommentSearch(self, match):
|
||||
"""Restarts a new comment search for a different triggering line.
|
||||
|
||||
Closes the current commentblock and starts a new comment search.
|
||||
"""
|
||||
if args.debug:
|
||||
print("# CALLBACK: resetCommentSearch", file=sys.stderr)
|
||||
self.__closeComment()
|
||||
self.startCommentSearch(match)
|
||||
|
||||
def startCommentSearch(self, match):
|
||||
"""Starts a new comment search.
|
||||
|
||||
Saves the triggering line, resets the current comment and saves
|
||||
the current indentation.
|
||||
"""
|
||||
if args.debug:
|
||||
print("# CALLBACK: startCommentSearch", file=sys.stderr)
|
||||
self.defclass = [self.fsm.current_input]
|
||||
self.comment = []
|
||||
self.indent = match.group(1)
|
||||
|
||||
def stopCommentSearch(self, match):
|
||||
"""Stops a comment search.
|
||||
|
||||
Closes the current commentblock, resets the triggering line and
|
||||
appends the current line to the output.
|
||||
"""
|
||||
if args.debug:
|
||||
print("# CALLBACK: stopCommentSearch", file=sys.stderr)
|
||||
self.__closeComment()
|
||||
|
||||
self.defclass = []
|
||||
self.output.append(self.fsm.current_input)
|
||||
|
||||
def appendFileheadLine(self, match):
|
||||
"""Appends a line in the FILEHEAD state.
|
||||
|
||||
Closes the open comment block, resets it and appends the current line.
|
||||
"""
|
||||
if args.debug:
|
||||
print("# CALLBACK: appendFileheadLine", file=sys.stderr)
|
||||
self.__closeComment()
|
||||
self.comment = []
|
||||
self.output.append(self.fsm.current_input)
|
||||
|
||||
def appendCommentLine(self, match):
|
||||
"""Appends a comment line.
|
||||
|
||||
The comment delimiter is removed from multiline start and ends as
|
||||
well as singleline comments.
|
||||
"""
|
||||
if args.debug:
|
||||
print("# CALLBACK: appendCommentLine", file=sys.stderr)
|
||||
(from_state, to_state, condition, callback) = self.fsm.current_transition
|
||||
|
||||
# single line comment
|
||||
if (from_state == "DEFCLASS" and to_state == "DEFCLASS_BODY") \
|
||||
or (from_state == "FILEHEAD" and to_state == "FILEHEAD"):
|
||||
# remove comment delimiter from begin and end of the line
|
||||
activeCommentDelim = match.group(1)
|
||||
line = self.fsm.current_input
|
||||
self.comment.append(line[line.find(
|
||||
activeCommentDelim) + len(activeCommentDelim):line.rfind(activeCommentDelim)])
|
||||
|
||||
if (to_state == "DEFCLASS_BODY"):
|
||||
self.__closeComment()
|
||||
self.defclass = []
|
||||
# multiline start
|
||||
elif from_state == "DEFCLASS" or from_state == "FILEHEAD":
|
||||
# remove comment delimiter from begin of the line
|
||||
activeCommentDelim = match.group(1)
|
||||
line = self.fsm.current_input
|
||||
self.comment.append(
|
||||
line[line.find(activeCommentDelim) + len(activeCommentDelim):])
|
||||
# multiline end
|
||||
elif to_state == "DEFCLASS_BODY" or to_state == "FILEHEAD":
|
||||
# remove comment delimiter from end of the line
|
||||
activeCommentDelim = match.group(1)
|
||||
line = self.fsm.current_input
|
||||
self.comment.append(line[0:line.rfind(activeCommentDelim)])
|
||||
if (to_state == "DEFCLASS_BODY"):
|
||||
self.__closeComment()
|
||||
self.defclass = []
|
||||
# in multiline comment
|
||||
else:
|
||||
# just append the comment line
|
||||
self.comment.append(self.fsm.current_input)
|
||||
|
||||
def appendNormalLine(self, match):
|
||||
"""Appends a line to the output."""
|
||||
if args.debug:
|
||||
print("# CALLBACK: appendNormalLine", file=sys.stderr)
|
||||
self.output.append(self.fsm.current_input)
|
||||
|
||||
def appendDefclassLine(self, match):
|
||||
"""Appends a line to the triggering block."""
|
||||
if args.debug:
|
||||
print("# CALLBACK: appendDefclassLine", file=sys.stderr)
|
||||
self.defclass.append(self.fsm.current_input)
|
||||
|
||||
def makeCommentBlock(self):
|
||||
"""Indents the current comment block with respect to the current
|
||||
indentation level.
|
||||
|
||||
@returns a list of indented comment lines
|
||||
"""
|
||||
doxyStart = "##"
|
||||
commentLines = self.comment
|
||||
|
||||
commentLines = ["%s# %s" % (self.indent, x) for x in commentLines]
|
||||
l = [self.indent + doxyStart]
|
||||
l.extend(commentLines)
|
||||
|
||||
return l
|
||||
|
||||
def parse(self, input):
|
||||
"""Parses a python file given as input string and returns the doxygen-
|
||||
compatible representation.
|
||||
|
||||
@param input the python code to parse
|
||||
@returns the modified python code
|
||||
"""
|
||||
lines = input.split("\n")
|
||||
|
||||
for line in lines:
|
||||
self.fsm.makeTransition(line)
|
||||
|
||||
if self.fsm.current_state == "DEFCLASS":
|
||||
self.__closeComment()
|
||||
|
||||
return "\n".join(self.output)
|
||||
|
||||
def parseFile(self, filename):
|
||||
"""Parses a python file given as input string and returns the doxygen-
|
||||
compatible representation.
|
||||
|
||||
@param input the python code to parse
|
||||
@returns the modified python code
|
||||
"""
|
||||
f = open(filename, 'r')
|
||||
|
||||
for line in f:
|
||||
self.parseLine(line.rstrip('\r\n'))
|
||||
if self.fsm.current_state == "DEFCLASS":
|
||||
self.__closeComment()
|
||||
self.__flushBuffer()
|
||||
f.close()
|
||||
|
||||
def parseLine(self, line):
|
||||
"""Parse one line of python and flush the resulting output to the
|
||||
outstream.
|
||||
|
||||
@param line the python code line to parse
|
||||
"""
|
||||
self.fsm.makeTransition(line)
|
||||
self.__flushBuffer()
|
||||
|
||||
|
||||
def argParse():
|
||||
"""Parses commandline args."""
|
||||
parser = ArgumentParser(prog=__applicationName__)
|
||||
|
||||
parser.add_argument("--version", action="version",
|
||||
version="%(prog)s " + __version__
|
||||
)
|
||||
parser.add_argument("--autobrief", action="store_true",
|
||||
help="use the docstring summary line as \\brief description"
|
||||
)
|
||||
parser.add_argument("--debug", action="store_true",
|
||||
help="enable debug output on stderr"
|
||||
)
|
||||
parser.add_argument("filename", metavar="FILENAME")
|
||||
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
def main():
|
||||
"""Starts the parser on the file given by the filename as the first
|
||||
argument on the commandline.
|
||||
"""
|
||||
global args
|
||||
args = argParse()
|
||||
fsm = Doxypy()
|
||||
fsm.parseFile(args.filename)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@ -0,0 +1,6 @@
|
||||
/*!
|
||||
* \defgroup block GNU Radio RFNOC_GAIN C++ Signal Processing Blocks
|
||||
* \brief All C++ blocks that can be used from the RFNOC_GAIN GNU Radio
|
||||
* module are listed here or in the subcategories below.
|
||||
*
|
||||
*/
|
||||
@ -0,0 +1,10 @@
|
||||
/*! \mainpage
|
||||
|
||||
Welcome to the GNU Radio RFNOC_GAIN Block
|
||||
|
||||
This is the intro page for the Doxygen manual generated for the RFNOC_GAIN
|
||||
block (docs/doxygen/other/main_page.dox). Edit it to add more detailed
|
||||
documentation about the new GNU Radio modules contained in this
|
||||
project.
|
||||
|
||||
*/
|
||||
@ -0,0 +1,19 @@
|
||||
#ifndef PYDOC_MACROS_H
|
||||
#define PYDOC_MACROS_H
|
||||
|
||||
#define __EXPAND(x) x
|
||||
#define __COUNT(_1, _2, _3, _4, _5, _6, _7, COUNT, ...) COUNT
|
||||
#define __VA_SIZE(...) __EXPAND(__COUNT(__VA_ARGS__, 7, 6, 5, 4, 3, 2, 1))
|
||||
#define __CAT1(a, b) a##b
|
||||
#define __CAT2(a, b) __CAT1(a, b)
|
||||
#define __DOC1(n1) __doc_##n1
|
||||
#define __DOC2(n1, n2) __doc_##n1##_##n2
|
||||
#define __DOC3(n1, n2, n3) __doc_##n1##_##n2##_##n3
|
||||
#define __DOC4(n1, n2, n3, n4) __doc_##n1##_##n2##_##n3##_##n4
|
||||
#define __DOC5(n1, n2, n3, n4, n5) __doc_##n1##_##n2##_##n3##_##n4##_##n5
|
||||
#define __DOC6(n1, n2, n3, n4, n5, n6) __doc_##n1##_##n2##_##n3##_##n4##_##n5##_##n6
|
||||
#define __DOC7(n1, n2, n3, n4, n5, n6, n7) \
|
||||
__doc_##n1##_##n2##_##n3##_##n4##_##n5##_##n6##_##n7
|
||||
#define DOC(...) __EXPAND(__EXPAND(__CAT2(__DOC, __VA_SIZE(__VA_ARGS__)))(__VA_ARGS__))
|
||||
|
||||
#endif // PYDOC_MACROS_H
|
||||
@ -0,0 +1,372 @@
|
||||
#
|
||||
# Copyright 2010-2012 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file was generated by gr_modtool, a tool from the GNU Radio framework
|
||||
# This file is a part of gnuradio
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#
|
||||
#
|
||||
"""
|
||||
Updates the *pydoc_h files for a module
|
||||
Execute using: python update_pydoc.py xml_path outputfilename
|
||||
|
||||
The file instructs Pybind11 to transfer the doxygen comments into the
|
||||
python docstrings.
|
||||
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import glob
|
||||
import re
|
||||
import json
|
||||
from argparse import ArgumentParser
|
||||
|
||||
from doxyxml import DoxyIndex, DoxyClass, DoxyFriend, DoxyFunction, DoxyFile
|
||||
from doxyxml import DoxyOther, base
|
||||
|
||||
|
||||
def py_name(name):
|
||||
bits = name.split('_')
|
||||
return '_'.join(bits[1:])
|
||||
|
||||
|
||||
def make_name(name):
|
||||
bits = name.split('_')
|
||||
return bits[0] + '_make_' + '_'.join(bits[1:])
|
||||
|
||||
|
||||
class Block(object):
|
||||
"""
|
||||
Checks if doxyxml produced objects correspond to a gnuradio block.
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def includes(cls, item):
|
||||
if not isinstance(item, DoxyClass):
|
||||
return False
|
||||
# Check for a parsing error.
|
||||
if item.error():
|
||||
return False
|
||||
friendname = make_name(item.name())
|
||||
is_a_block = item.has_member(friendname, DoxyFriend)
|
||||
# But now sometimes the make function isn't a friend so check again.
|
||||
if not is_a_block:
|
||||
is_a_block = di.has_member(friendname, DoxyFunction)
|
||||
return is_a_block
|
||||
|
||||
|
||||
class Block2(object):
|
||||
"""
|
||||
Checks if doxyxml produced objects correspond to a new style
|
||||
gnuradio block.
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def includes(cls, item):
|
||||
if not isinstance(item, DoxyClass):
|
||||
return False
|
||||
# Check for a parsing error.
|
||||
if item.error():
|
||||
return False
|
||||
is_a_block2 = item.has_member(
|
||||
'make', DoxyFunction) and item.has_member('sptr', DoxyOther)
|
||||
return is_a_block2
|
||||
|
||||
|
||||
def utoascii(text):
|
||||
"""
|
||||
Convert unicode text into ascii and escape quotes and backslashes.
|
||||
"""
|
||||
if text is None:
|
||||
return ''
|
||||
out = text.encode('ascii', 'replace')
|
||||
# swig will require us to replace blackslash with 4 backslashes
|
||||
# TODO: evaluate what this should be for pybind11
|
||||
out = out.replace(b'\\', b'\\\\\\\\')
|
||||
out = out.replace(b'"', b'\\"').decode('ascii')
|
||||
return str(out)
|
||||
|
||||
|
||||
def combine_descriptions(obj):
|
||||
"""
|
||||
Combines the brief and detailed descriptions of an object together.
|
||||
"""
|
||||
description = []
|
||||
bd = obj.brief_description.strip()
|
||||
dd = obj.detailed_description.strip()
|
||||
if bd:
|
||||
description.append(bd)
|
||||
if dd:
|
||||
description.append(dd)
|
||||
return utoascii('\n\n'.join(description)).strip()
|
||||
|
||||
|
||||
def format_params(parameteritems):
|
||||
output = ['Args:']
|
||||
template = ' {0} : {1}'
|
||||
for pi in parameteritems:
|
||||
output.append(template.format(pi.name, pi.description))
|
||||
return '\n'.join(output)
|
||||
|
||||
|
||||
entry_templ = '%feature("docstring") {name} "{docstring}"'
|
||||
|
||||
|
||||
def make_entry(obj, name=None, templ="{description}", description=None, params=[]):
|
||||
"""
|
||||
Create a docstring key/value pair, where the key is the object name.
|
||||
|
||||
obj - a doxyxml object from which documentation will be extracted.
|
||||
name - the name of the C object (defaults to obj.name())
|
||||
templ - an optional template for the docstring containing only one
|
||||
variable named 'description'.
|
||||
description - if this optional variable is set then it's value is
|
||||
used as the description instead of extracting it from obj.
|
||||
"""
|
||||
if name is None:
|
||||
name = obj.name()
|
||||
if hasattr(obj, '_parse_data') and hasattr(obj._parse_data, 'definition'):
|
||||
name = obj._parse_data.definition.split(' ')[-1]
|
||||
if "operator " in name:
|
||||
return ''
|
||||
if description is None:
|
||||
description = combine_descriptions(obj)
|
||||
if params:
|
||||
description += '\n\n'
|
||||
description += utoascii(format_params(params))
|
||||
docstring = templ.format(description=description)
|
||||
|
||||
return {name: docstring}
|
||||
|
||||
|
||||
def make_class_entry(klass, description=None, ignored_methods=[], params=None):
|
||||
"""
|
||||
Create a class docstring key/value pair.
|
||||
"""
|
||||
if params is None:
|
||||
params = klass.params
|
||||
output = {}
|
||||
output.update(make_entry(klass, description=description, params=params))
|
||||
for func in klass.in_category(DoxyFunction):
|
||||
if func.name() not in ignored_methods:
|
||||
name = klass.name() + '::' + func.name()
|
||||
output.update(make_entry(func, name=name))
|
||||
return output
|
||||
|
||||
|
||||
def make_block_entry(di, block):
|
||||
"""
|
||||
Create class and function docstrings of a gnuradio block
|
||||
"""
|
||||
descriptions = []
|
||||
# Get the documentation associated with the class.
|
||||
class_desc = combine_descriptions(block)
|
||||
if class_desc:
|
||||
descriptions.append(class_desc)
|
||||
# Get the documentation associated with the make function
|
||||
make_func = di.get_member(make_name(block.name()), DoxyFunction)
|
||||
make_func_desc = combine_descriptions(make_func)
|
||||
if make_func_desc:
|
||||
descriptions.append(make_func_desc)
|
||||
# Get the documentation associated with the file
|
||||
try:
|
||||
block_file = di.get_member(block.name() + ".h", DoxyFile)
|
||||
file_desc = combine_descriptions(block_file)
|
||||
if file_desc:
|
||||
descriptions.append(file_desc)
|
||||
except base.Base.NoSuchMember:
|
||||
# Don't worry if we can't find a matching file.
|
||||
pass
|
||||
# And join them all together to make a super duper description.
|
||||
super_description = "\n\n".join(descriptions)
|
||||
# Associate the combined description with the class and
|
||||
# the make function.
|
||||
output = {}
|
||||
output.update(make_class_entry(block, description=super_description))
|
||||
output.update(make_entry(make_func, description=super_description,
|
||||
params=block.params))
|
||||
return output
|
||||
|
||||
|
||||
def make_block2_entry(di, block):
|
||||
"""
|
||||
Create class and function docstrings of a new style gnuradio block
|
||||
"""
|
||||
# For new style blocks all the relevant documentation should be
|
||||
# associated with the 'make' method.
|
||||
class_description = combine_descriptions(block)
|
||||
make_func = block.get_member('make', DoxyFunction)
|
||||
make_description = combine_descriptions(make_func)
|
||||
description = class_description + \
|
||||
"\n\nConstructor Specific Documentation:\n\n" + make_description
|
||||
# Associate the combined description with the class and
|
||||
# the make function.
|
||||
output = {}
|
||||
output.update(make_class_entry(
|
||||
block, description=description,
|
||||
ignored_methods=['make'], params=make_func.params))
|
||||
makename = block.name() + '::make'
|
||||
output.update(make_entry(
|
||||
make_func, name=makename, description=description,
|
||||
params=make_func.params))
|
||||
return output
|
||||
|
||||
|
||||
def get_docstrings_dict(di, custom_output=None):
|
||||
|
||||
output = {}
|
||||
if custom_output:
|
||||
output.update(custom_output)
|
||||
|
||||
# Create docstrings for the blocks.
|
||||
blocks = di.in_category(Block)
|
||||
blocks2 = di.in_category(Block2)
|
||||
|
||||
make_funcs = set([])
|
||||
for block in blocks:
|
||||
try:
|
||||
make_func = di.get_member(make_name(block.name()), DoxyFunction)
|
||||
# Don't want to risk writing to output twice.
|
||||
if make_func.name() not in make_funcs:
|
||||
make_funcs.add(make_func.name())
|
||||
output.update(make_block_entry(di, block))
|
||||
except block.ParsingError:
|
||||
sys.stderr.write(
|
||||
'Parsing error for block {0}\n'.format(block.name()))
|
||||
raise
|
||||
|
||||
for block in blocks2:
|
||||
try:
|
||||
make_func = block.get_member('make', DoxyFunction)
|
||||
make_func_name = block.name() + '::make'
|
||||
# Don't want to risk writing to output twice.
|
||||
if make_func_name not in make_funcs:
|
||||
make_funcs.add(make_func_name)
|
||||
output.update(make_block2_entry(di, block))
|
||||
except block.ParsingError:
|
||||
sys.stderr.write(
|
||||
'Parsing error for block {0}\n'.format(block.name()))
|
||||
raise
|
||||
|
||||
# Create docstrings for functions
|
||||
# Don't include the make functions since they have already been dealt with.
|
||||
funcs = [f for f in di.in_category(DoxyFunction)
|
||||
if f.name() not in make_funcs and not f.name().startswith('std::')]
|
||||
for f in funcs:
|
||||
try:
|
||||
output.update(make_entry(f))
|
||||
except f.ParsingError:
|
||||
sys.stderr.write(
|
||||
'Parsing error for function {0}\n'.format(f.name()))
|
||||
|
||||
# Create docstrings for classes
|
||||
block_names = [block.name() for block in blocks]
|
||||
block_names += [block.name() for block in blocks2]
|
||||
klasses = [k for k in di.in_category(DoxyClass)
|
||||
if k.name() not in block_names and not k.name().startswith('std::')]
|
||||
for k in klasses:
|
||||
try:
|
||||
output.update(make_class_entry(k))
|
||||
except k.ParsingError:
|
||||
sys.stderr.write('Parsing error for class {0}\n'.format(k.name()))
|
||||
|
||||
# Docstrings are not created for anything that is not a function or a class.
|
||||
# If this excludes anything important please add it here.
|
||||
|
||||
return output
|
||||
|
||||
|
||||
def sub_docstring_in_pydoc_h(pydoc_files, docstrings_dict, output_dir, filter_str=None):
|
||||
if filter_str:
|
||||
docstrings_dict = {
|
||||
k: v for k, v in docstrings_dict.items() if k.startswith(filter_str)}
|
||||
|
||||
with open(os.path.join(output_dir, 'docstring_status'), 'w') as status_file:
|
||||
|
||||
for pydoc_file in pydoc_files:
|
||||
if filter_str:
|
||||
filter_str2 = "::".join((filter_str, os.path.split(
|
||||
pydoc_file)[-1].split('_pydoc_template.h')[0]))
|
||||
docstrings_dict2 = {
|
||||
k: v for k, v in docstrings_dict.items() if k.startswith(filter_str2)}
|
||||
else:
|
||||
docstrings_dict2 = docstrings_dict
|
||||
|
||||
file_in = open(pydoc_file, 'r').read()
|
||||
for key, value in docstrings_dict2.items():
|
||||
file_in_tmp = file_in
|
||||
try:
|
||||
doc_key = key.split("::")
|
||||
# if 'gr' in doc_key:
|
||||
# doc_key.remove('gr')
|
||||
doc_key = '_'.join(doc_key)
|
||||
regexp = r'(__doc_{} =\sR\"doc\()[^)]*(\)doc\")'.format(
|
||||
doc_key)
|
||||
regexp = re.compile(regexp, re.MULTILINE)
|
||||
|
||||
(file_in, nsubs) = regexp.subn(
|
||||
r'\1' + value + r'\2', file_in, count=1)
|
||||
if nsubs == 1:
|
||||
status_file.write("PASS: " + pydoc_file + "\n")
|
||||
except KeyboardInterrupt:
|
||||
raise KeyboardInterrupt
|
||||
except: # be permissive, TODO log, but just leave the docstring blank
|
||||
status_file.write("FAIL: " + pydoc_file + "\n")
|
||||
file_in = file_in_tmp
|
||||
|
||||
output_pathname = os.path.join(output_dir, os.path.basename(
|
||||
pydoc_file).replace('_template.h', '.h'))
|
||||
with open(output_pathname, 'w') as file_out:
|
||||
file_out.write(file_in)
|
||||
|
||||
|
||||
def copy_docstring_templates(pydoc_files, output_dir):
|
||||
with open(os.path.join(output_dir, 'docstring_status'), 'w') as status_file:
|
||||
for pydoc_file in pydoc_files:
|
||||
file_in = open(pydoc_file, 'r').read()
|
||||
output_pathname = os.path.join(output_dir, os.path.basename(
|
||||
pydoc_file).replace('_template.h', '.h'))
|
||||
with open(output_pathname, 'w') as file_out:
|
||||
file_out.write(file_in)
|
||||
status_file.write("DONE")
|
||||
|
||||
|
||||
def argParse():
|
||||
"""Parses commandline args."""
|
||||
desc = 'Scrape the doxygen generated xml for docstrings to insert into python bindings'
|
||||
parser = ArgumentParser(description=desc)
|
||||
|
||||
parser.add_argument("function", help="Operation to perform on docstrings", choices=[
|
||||
"scrape", "sub", "copy"])
|
||||
|
||||
parser.add_argument("--xml_path")
|
||||
parser.add_argument("--bindings_dir")
|
||||
parser.add_argument("--output_dir")
|
||||
parser.add_argument("--json_path")
|
||||
parser.add_argument("--filter", default=None)
|
||||
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Parse command line options and set up doxyxml.
|
||||
args = argParse()
|
||||
if args.function.lower() == 'scrape':
|
||||
di = DoxyIndex(args.xml_path)
|
||||
docstrings_dict = get_docstrings_dict(di)
|
||||
with open(args.json_path, 'w') as fp:
|
||||
json.dump(docstrings_dict, fp)
|
||||
elif args.function.lower() == 'sub':
|
||||
with open(args.json_path, 'r') as fp:
|
||||
docstrings_dict = json.load(fp)
|
||||
pydoc_files = glob.glob(os.path.join(
|
||||
args.bindings_dir, '*_pydoc_template.h'))
|
||||
sub_docstring_in_pydoc_h(
|
||||
pydoc_files, docstrings_dict, args.output_dir, args.filter)
|
||||
elif args.function.lower() == 'copy':
|
||||
pydoc_files = glob.glob(os.path.join(
|
||||
args.bindings_dir, '*_pydoc_template.h'))
|
||||
copy_docstring_templates(pydoc_files, args.output_dir)
|
||||
@ -0,0 +1,3 @@
|
||||
install(
|
||||
DIRECTORY grc/
|
||||
DESTINATION share/gnuradio/examples/rfnoc_gain)
|
||||
3
host/examples/rfnoc-gain/gr-rfnoc_gain/examples/README
Normal file
3
host/examples/rfnoc-gain/gr-rfnoc_gain/examples/README
Normal file
@ -0,0 +1,3 @@
|
||||
It is considered good practice to add examples in here to demonstrate the
|
||||
functionality of your OOT module. Python scripts, GRC flow graphs or other
|
||||
code can go here.
|
||||
12
host/examples/rfnoc-gain/gr-rfnoc_gain/grc/CMakeLists.txt
Normal file
12
host/examples/rfnoc-gain/gr-rfnoc_gain/grc/CMakeLists.txt
Normal file
@ -0,0 +1,12 @@
|
||||
# Copyright 2011 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file was generated by gr_modtool, a tool from the GNU Radio framework
|
||||
# This file is a part of gr-rfnoc_gain
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#
|
||||
|
||||
install(FILES
|
||||
rfnoc_gain_rfnoc_gain.block.yml
|
||||
rfnoc_gain_rfnoc_gain_generic.block.yml
|
||||
DESTINATION share/gnuradio/grc/blocks)
|
||||
@ -0,0 +1,44 @@
|
||||
id: rfnoc_gain_gain_native
|
||||
label: RFNoC Gain Block (Native C++ Version)
|
||||
category: '[rfnoc_gain]'
|
||||
|
||||
templates:
|
||||
imports: from gnuradio import rfnoc_gain
|
||||
make: rfnoc_gain.rfnoc_gain(
|
||||
self.rfnoc_graph,
|
||||
${gain},
|
||||
uhd.device_addr(""),
|
||||
${device_select},
|
||||
${instance_index})
|
||||
callbacks:
|
||||
- set_gain(${gain})
|
||||
|
||||
parameters:
|
||||
- id: gain
|
||||
label: Gain
|
||||
dtype: int
|
||||
default: 1
|
||||
- id: device_select
|
||||
label: Device Select
|
||||
dtype: int
|
||||
default: -1
|
||||
hide: ${ 'part' if device_select == -1 else 'none'}
|
||||
- id: instance_index
|
||||
label: Instance Select
|
||||
dtype: int
|
||||
default: -1
|
||||
hide: ${ 'part' if instance_index == -1 else 'none'}
|
||||
|
||||
inputs:
|
||||
- label: in
|
||||
domain: rfnoc
|
||||
dtype: sc16
|
||||
vlen: 1
|
||||
|
||||
outputs:
|
||||
- label: out
|
||||
domain: rfnoc
|
||||
dtype: sc16
|
||||
vlen: 1
|
||||
|
||||
file_format: 1
|
||||
@ -0,0 +1,49 @@
|
||||
id: rfnoc_gain_gain_generic
|
||||
label: RFNoC Gain Block (Generic Version)
|
||||
category: '[rfnoc_gain]'
|
||||
|
||||
templates:
|
||||
imports: from gnuradio import uhd
|
||||
make: |-
|
||||
uhd.rfnoc_block_generic(
|
||||
self.rfnoc_graph,
|
||||
uhd.device_addr("gain=${gain}"),
|
||||
"Gain",
|
||||
${device_select},
|
||||
${instance_index})
|
||||
|
||||
parameters:
|
||||
- id: gain
|
||||
label: Gain
|
||||
dtype: int
|
||||
default: 1
|
||||
- id: device_select
|
||||
label: Device Select
|
||||
dtype: int
|
||||
default: -1
|
||||
hide: ${ 'part' if device_select == -1 else 'none'}
|
||||
- id: instance_index
|
||||
label: Instance Select
|
||||
dtype: int
|
||||
default: -1
|
||||
hide: ${ 'part' if instance_index == -1 else 'none'}
|
||||
|
||||
inputs:
|
||||
- label: in
|
||||
domain: rfnoc
|
||||
dtype: sc16
|
||||
vlen: 1
|
||||
optional: false
|
||||
|
||||
outputs:
|
||||
- label: out
|
||||
domain: rfnoc
|
||||
dtype: sc16
|
||||
vlen: 1
|
||||
optional: false
|
||||
|
||||
documentation: |-
|
||||
RFNoC Gain Block:
|
||||
Multiplies the samples of the input stream with the gain value.
|
||||
|
||||
file_format: 1
|
||||
@ -0,0 +1,13 @@
|
||||
# Copyright 2011,2012 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file was generated by gr_modtool, a tool from the GNU Radio framework
|
||||
# This file is a part of gr-rfnoc_gain
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#
|
||||
|
||||
########################################################################
|
||||
# Install public header files
|
||||
########################################################################
|
||||
install(FILES api.h
|
||||
rfnoc_gain.h DESTINATION include/gnuradio/rfnoc_gain)
|
||||
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright 2011 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file was generated by gr_modtool, a tool from the GNU Radio framework
|
||||
* This file is a part of gr-rfnoc_gain
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef INCLUDED_RFNOC_GAIN_API_H
|
||||
#define INCLUDED_RFNOC_GAIN_API_H
|
||||
|
||||
#include <gnuradio/attributes.h>
|
||||
|
||||
#ifdef gnuradio_rfnoc_gain_EXPORTS
|
||||
#define RFNOC_GAIN_API __GR_ATTR_EXPORT
|
||||
#else
|
||||
#define RFNOC_GAIN_API __GR_ATTR_IMPORT
|
||||
#endif
|
||||
|
||||
#endif /* INCLUDED_RFNOC_GAIN_API_H */
|
||||
@ -0,0 +1,65 @@
|
||||
/* -*- c++ -*- */
|
||||
/*
|
||||
* Copyright 2024 Ettus Research, an NI Brand.
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
#ifndef INCLUDED_RFNOC_GAIN_RFNOC_GAIN_H
|
||||
#define INCLUDED_RFNOC_GAIN_RFNOC_GAIN_H
|
||||
|
||||
#include <gnuradio/rfnoc_gain/api.h>
|
||||
#include <gnuradio/uhd/rfnoc_block.h>
|
||||
#include <cstdint>
|
||||
|
||||
namespace gr {
|
||||
namespace rfnoc_gain {
|
||||
|
||||
/*! Block controller for the RFNoC "gain" block.
|
||||
*
|
||||
* This RFNoC block is a very simply block that multiplies the incoming sample
|
||||
* value with the integer gain value. It is used as an example for how to write
|
||||
* RFNoC blocks.
|
||||
*
|
||||
* This GNU Radio block is a C++ controller of the RFNoC gain block, which
|
||||
* allows using gain block in both C++ and Python GNU Radio applications
|
||||
* (including using it in GRC). In many cases, a C++ GNU Radio block is overkill
|
||||
* for such a simple block, and the better approach would be to use the generic
|
||||
* RFNoC block instead. There are also examples of this, much simpler approach
|
||||
* in the examples subdirectory of this GNU Radio OOT module.
|
||||
*
|
||||
* \ingroup rfnoc_gain
|
||||
*
|
||||
*/
|
||||
class RFNOC_GAIN_API rfnoc_gain : virtual public uhd::rfnoc_block
|
||||
{
|
||||
public:
|
||||
typedef std::shared_ptr<rfnoc_gain> sptr;
|
||||
|
||||
/*!
|
||||
* \param graph Reference to the rfnoc_graph object this block is attached to
|
||||
* \param gain The digital gain that will be applied (e.g., \p gain == 2
|
||||
* will double the signal)
|
||||
* \param block_args Additional block arguments
|
||||
* \param device_select Device Selection
|
||||
* \param instance Instance Selection
|
||||
*/
|
||||
static sptr make(uhd::rfnoc_graph::sptr graph,
|
||||
const uint32_t gain,
|
||||
const ::uhd::device_addr_t& block_args,
|
||||
const int device_select,
|
||||
const int instance);
|
||||
|
||||
/*! Set the gain value
|
||||
*/
|
||||
virtual void set_gain(const uint32_t gain) = 0;
|
||||
|
||||
/*! Read back the current gain value
|
||||
*/
|
||||
virtual uint32_t get_gain() = 0;
|
||||
};
|
||||
|
||||
} // namespace rfnoc_gain
|
||||
} // namespace gr
|
||||
|
||||
#endif /* INCLUDED_RFNOC_GAIN_RFNOC_GAIN_H */
|
||||
69
host/examples/rfnoc-gain/gr-rfnoc_gain/lib/CMakeLists.txt
Normal file
69
host/examples/rfnoc-gain/gr-rfnoc_gain/lib/CMakeLists.txt
Normal file
@ -0,0 +1,69 @@
|
||||
# Copyright 2011,2012,2016,2018,2019 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file was generated by gr_modtool, a tool from the GNU Radio framework
|
||||
# This file is a part of gr-rfnoc_gain
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#
|
||||
|
||||
########################################################################
|
||||
# Setup library
|
||||
########################################################################
|
||||
include(GrPlatform) #define LIB_SUFFIX
|
||||
|
||||
list(APPEND rfnoc_gain_sources
|
||||
rfnoc_gain_impl.cc)
|
||||
|
||||
set(rfnoc_gain_sources
|
||||
"${rfnoc_gain_sources}"
|
||||
PARENT_SCOPE)
|
||||
if(NOT rfnoc_gain_sources)
|
||||
message(STATUS "No C++ sources... skipping lib/")
|
||||
return()
|
||||
endif(NOT rfnoc_gain_sources)
|
||||
|
||||
add_library(gnuradio-rfnoc_gain SHARED ${rfnoc_gain_sources})
|
||||
target_link_libraries(gnuradio-rfnoc_gain gnuradio::gnuradio-runtime gnuradio::gnuradio-uhd)
|
||||
target_include_directories(
|
||||
gnuradio-rfnoc_gain
|
||||
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include>
|
||||
PUBLIC $<INSTALL_INTERFACE:include>)
|
||||
set_target_properties(gnuradio-rfnoc_gain PROPERTIES DEFINE_SYMBOL "gnuradio_rfnoc_gain_EXPORTS")
|
||||
|
||||
if(APPLE)
|
||||
set_target_properties(gnuradio-rfnoc_gain PROPERTIES INSTALL_NAME_DIR
|
||||
"${CMAKE_INSTALL_PREFIX}/lib")
|
||||
endif(APPLE)
|
||||
|
||||
########################################################################
|
||||
# Install built library files
|
||||
########################################################################
|
||||
include(GrMiscUtils)
|
||||
gr_library_foo(gnuradio-rfnoc_gain)
|
||||
|
||||
########################################################################
|
||||
# Print summary
|
||||
########################################################################
|
||||
message(STATUS "Using install prefix: ${CMAKE_INSTALL_PREFIX}")
|
||||
message(STATUS "Building for version: ${VERSION} / ${LIBVER}")
|
||||
|
||||
########################################################################
|
||||
# Build and register unit test
|
||||
########################################################################
|
||||
include(GrTest)
|
||||
|
||||
# If your unit tests require special include paths, add them here
|
||||
#include_directories()
|
||||
# List all files that contain Boost.UTF unit tests here
|
||||
list(APPEND test_rfnoc_gain_sources)
|
||||
# Anything we need to link to for the unit tests go here
|
||||
list(APPEND GR_TEST_TARGET_DEPS gnuradio-rfnoc_gain)
|
||||
|
||||
if(NOT test_rfnoc_gain_sources)
|
||||
message(STATUS "No C++ unit tests... skipping")
|
||||
return()
|
||||
endif(NOT test_rfnoc_gain_sources)
|
||||
|
||||
foreach(qa_file ${test_rfnoc_gain_sources})
|
||||
gr_add_cpp_test("rfnoc_gain_${qa_file}" ${CMAKE_CURRENT_SOURCE_DIR}/${qa_file})
|
||||
endforeach(qa_file)
|
||||
@ -0,0 +1,48 @@
|
||||
/* -*- c++ -*- */
|
||||
/*
|
||||
* Copyright 2024 Ettus Research, an NI Brand.
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
#include "rfnoc_gain_impl.h"
|
||||
#include <gnuradio/io_signature.h>
|
||||
|
||||
namespace gr {
|
||||
namespace rfnoc_gain {
|
||||
|
||||
rfnoc_gain::sptr rfnoc_gain::make(uhd::rfnoc_graph::sptr graph,
|
||||
const uint32_t gain,
|
||||
const ::uhd::device_addr_t& block_args,
|
||||
const int device_select,
|
||||
const int instance)
|
||||
{
|
||||
return gnuradio::make_block_sptr<rfnoc_gain_impl>(
|
||||
uhd::rfnoc_block::make_block_ref(
|
||||
graph, block_args, "Gain", device_select, instance),
|
||||
gain);
|
||||
}
|
||||
|
||||
|
||||
rfnoc_gain_impl::rfnoc_gain_impl(::uhd::rfnoc::noc_block_base::sptr block_ref,
|
||||
const uint32_t gain)
|
||||
: rfnoc_block(block_ref),
|
||||
d_gainblk_ref(get_block_ref<::rfnoc::gain::gain_block_control>())
|
||||
{
|
||||
d_gainblk_ref->set_gain_value(gain);
|
||||
}
|
||||
|
||||
rfnoc_gain_impl::~rfnoc_gain_impl() {}
|
||||
|
||||
/******************************************************************************
|
||||
* rfnoc_gain API
|
||||
*****************************************************************************/
|
||||
void rfnoc_gain_impl::set_gain(const uint32_t gain)
|
||||
{
|
||||
d_gainblk_ref->set_gain_value(gain);
|
||||
}
|
||||
|
||||
uint32_t rfnoc_gain_impl::get_gain() { return d_gainblk_ref->get_gain_value(); }
|
||||
|
||||
} /* namespace rfnoc_gain */
|
||||
} /* namespace gr */
|
||||
34
host/examples/rfnoc-gain/gr-rfnoc_gain/lib/rfnoc_gain_impl.h
Normal file
34
host/examples/rfnoc-gain/gr-rfnoc_gain/lib/rfnoc_gain_impl.h
Normal file
@ -0,0 +1,34 @@
|
||||
/* -*- c++ -*- */
|
||||
/*
|
||||
* Copyright 2024 Ettus Research, an NI Brand.
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
#ifndef INCLUDED_RFNOC_GAIN_RFNOC_GAIN_IMPL_H
|
||||
#define INCLUDED_RFNOC_GAIN_RFNOC_GAIN_IMPL_H
|
||||
|
||||
#include <gnuradio/rfnoc_gain/rfnoc_gain.h>
|
||||
#include <rfnoc/gain/gain_block_control.hpp>
|
||||
|
||||
namespace gr {
|
||||
namespace rfnoc_gain {
|
||||
|
||||
class rfnoc_gain_impl : public rfnoc_gain
|
||||
{
|
||||
public:
|
||||
rfnoc_gain_impl(::uhd::rfnoc::noc_block_base::sptr block_ref, const uint32_t gain);
|
||||
~rfnoc_gain_impl();
|
||||
|
||||
/*** API *****************************************************************/
|
||||
void set_gain(const uint32_t gain);
|
||||
uint32_t get_gain();
|
||||
|
||||
private:
|
||||
::rfnoc::gain::gain_block_control::sptr d_gainblk_ref;
|
||||
};
|
||||
|
||||
} // namespace rfnoc_gain
|
||||
} // namespace gr
|
||||
|
||||
#endif /* INCLUDED_RFNOC_GAIN_RFNOC_GAIN_IMPL_H */
|
||||
5
host/examples/rfnoc-gain/gr-rfnoc_gain/python/rfnoc_gain/.gitignore
vendored
Normal file
5
host/examples/rfnoc-gain/gr-rfnoc_gain/python/rfnoc_gain/.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
*~
|
||||
*.pyc
|
||||
*.pyo
|
||||
build*/
|
||||
examples/grc/*.py
|
||||
@ -0,0 +1,36 @@
|
||||
# Copyright 2011 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file was generated by gr_modtool, a tool from the GNU Radio framework
|
||||
# This file is a part of gr-rfnoc_gain
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#
|
||||
|
||||
########################################################################
|
||||
# Include python install macros
|
||||
########################################################################
|
||||
include(GrPython)
|
||||
if(NOT PYTHONINTERP_FOUND)
|
||||
return()
|
||||
endif()
|
||||
|
||||
add_subdirectory(bindings)
|
||||
|
||||
########################################################################
|
||||
# Install python sources
|
||||
########################################################################
|
||||
gr_python_install(FILES __init__.py DESTINATION ${GR_PYTHON_DIR}/gnuradio/rfnoc_gain)
|
||||
|
||||
########################################################################
|
||||
# Handle the unit tests
|
||||
########################################################################
|
||||
include(GrTest)
|
||||
|
||||
set(GR_TEST_TARGET_DEPS gnuradio-rfnoc_gain)
|
||||
|
||||
# Create a package directory that tests can import. It includes everything
|
||||
# from `python/`.
|
||||
add_custom_target(
|
||||
copy_module_for_tests ALL
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${PROJECT_BINARY_DIR}/test_modules/gnuradio/rfnoc_gain/)
|
||||
@ -0,0 +1,23 @@
|
||||
#
|
||||
# Copyright 2008,2009 Free Software Foundation, Inc.
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#
|
||||
|
||||
# The presence of this file turns this directory into a Python package
|
||||
|
||||
'''
|
||||
This is the GNU Radio RFNOC_GAIN module. Place your Python package
|
||||
description here (python/__init__.py).
|
||||
'''
|
||||
import os
|
||||
|
||||
# import pybind11 generated symbols into the rfnoc_gain namespace
|
||||
try:
|
||||
# this might fail if the module is python-only
|
||||
from .rfnoc_gain_python import *
|
||||
except ModuleNotFoundError:
|
||||
pass
|
||||
|
||||
# import any pure python here
|
||||
#
|
||||
@ -0,0 +1,42 @@
|
||||
# Copyright 2020 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is part of GNU Radio
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#
|
||||
|
||||
########################################################################
|
||||
# Check if there is C++ code at all
|
||||
########################################################################
|
||||
if(NOT rfnoc_gain_sources)
|
||||
message(STATUS "No C++ sources... skipping python bindings")
|
||||
return()
|
||||
endif(NOT rfnoc_gain_sources)
|
||||
|
||||
########################################################################
|
||||
# Check for pygccxml
|
||||
########################################################################
|
||||
gr_python_check_module_raw("pygccxml" "import pygccxml" PYGCCXML_FOUND)
|
||||
|
||||
include(GrPybind)
|
||||
|
||||
########################################################################
|
||||
# Python Bindings
|
||||
########################################################################
|
||||
|
||||
list(APPEND rfnoc_gain_python_files
|
||||
rfnoc_gain_python.cc python_bindings.cc)
|
||||
|
||||
gr_pybind_make_oot(rfnoc_gain ../../.. gr::rfnoc_gain "${rfnoc_gain_python_files}")
|
||||
|
||||
# copy bindings extension for use in QA test module
|
||||
add_custom_command(
|
||||
TARGET rfnoc_gain_python
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:rfnoc_gain_python>
|
||||
${PROJECT_BINARY_DIR}/test_modules/gnuradio/rfnoc_gain/)
|
||||
|
||||
install(
|
||||
TARGETS rfnoc_gain_python
|
||||
DESTINATION ${GR_PYTHON_DIR}/gnuradio/rfnoc_gain
|
||||
COMPONENT pythonapi)
|
||||
@ -0,0 +1,54 @@
|
||||
import warnings
|
||||
import argparse
|
||||
from gnuradio.bindtool import BindingGenerator
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
parser = argparse.ArgumentParser(description='Bind a GR Out of Tree Block')
|
||||
parser.add_argument('--module', type=str,
|
||||
help='Name of gr module containing file to bind (e.g. fft digital analog)')
|
||||
|
||||
parser.add_argument('--output_dir', default=tempfile.gettempdir(),
|
||||
help='Output directory of generated bindings')
|
||||
parser.add_argument('--prefix', help='Prefix of Installed GNU Radio')
|
||||
|
||||
parser.add_argument(
|
||||
'--filename', help="File to be parsed")
|
||||
|
||||
parser.add_argument(
|
||||
'--defines', help='Set additional defines for precompiler', default=(), nargs='*')
|
||||
parser.add_argument(
|
||||
'--include', help='Additional Include Dirs, separated', default=(), nargs='*')
|
||||
|
||||
parser.add_argument(
|
||||
'--status', help='Location of output file for general status (used during cmake)', default=None
|
||||
)
|
||||
parser.add_argument(
|
||||
'--flag_automatic', default='0'
|
||||
)
|
||||
parser.add_argument(
|
||||
'--flag_pygccxml', default='0'
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
prefix = args.prefix
|
||||
output_dir = args.output_dir
|
||||
defines = tuple([d for d in ','.join(args.defines).split(',') if d])
|
||||
includes = ','.join(args.include)
|
||||
name = args.module
|
||||
|
||||
namespace = ['gr', name]
|
||||
prefix_include_root = name
|
||||
|
||||
|
||||
with warnings.catch_warnings():
|
||||
warnings.filterwarnings("ignore", category=DeprecationWarning)
|
||||
|
||||
bg = BindingGenerator(prefix, namespace,
|
||||
prefix_include_root, output_dir, define_symbols=defines, addl_includes=includes,
|
||||
catch_exceptions=False, write_json_output=False, status_output=args.status,
|
||||
flag_automatic=True if args.flag_automatic.lower() in [
|
||||
'1', 'true'] else False,
|
||||
flag_pygccxml=True if args.flag_pygccxml.lower() in ['1', 'true'] else False)
|
||||
bg.gen_file_binding(args.filename)
|
||||
@ -0,0 +1 @@
|
||||
This directory stores templates for docstrings that are scraped from the include header files for each block
|
||||
@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright 2024 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of GNU Radio
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
*/
|
||||
#include "pydoc_macros.h"
|
||||
#define D(...) DOC(gr, rfnoc_gain, __VA_ARGS__)
|
||||
/*
|
||||
This file contains placeholders for docstrings for the Python bindings.
|
||||
Do not edit! These were automatically extracted during the binding process
|
||||
and will be overwritten during the build process
|
||||
*/
|
||||
|
||||
|
||||
static const char* __doc_gr_rfnoc_gain_rfnoc_gain = R"doc()doc";
|
||||
|
||||
|
||||
static const char* __doc_gr_rfnoc_gain_rfnoc_gain_rfnoc_gain_0 = R"doc()doc";
|
||||
|
||||
|
||||
static const char* __doc_gr_rfnoc_gain_rfnoc_gain_rfnoc_gain_1 = R"doc()doc";
|
||||
|
||||
|
||||
static const char* __doc_gr_rfnoc_gain_rfnoc_gain_make = R"doc()doc";
|
||||
|
||||
|
||||
static const char* __doc_gr_rfnoc_gain_rfnoc_gain_set_gain = R"doc()doc";
|
||||
|
||||
|
||||
static const char* __doc_gr_rfnoc_gain_rfnoc_gain_get_gain = R"doc()doc";
|
||||
@ -0,0 +1,80 @@
|
||||
# Utilities for reading values in header files
|
||||
|
||||
from argparse import ArgumentParser
|
||||
import re
|
||||
|
||||
|
||||
class PybindHeaderParser:
|
||||
def __init__(self, pathname):
|
||||
with open(pathname, 'r') as f:
|
||||
self.file_txt = f.read()
|
||||
|
||||
def get_flag_automatic(self):
|
||||
# p = re.compile(r'BINDTOOL_GEN_AUTOMATIC\(([^\s])\)')
|
||||
# m = p.search(self.file_txt)
|
||||
m = re.search(r'BINDTOOL_GEN_AUTOMATIC\(([^\s])\)', self.file_txt)
|
||||
if (m and m.group(1) == '1'):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def get_flag_pygccxml(self):
|
||||
# p = re.compile(r'BINDTOOL_USE_PYGCCXML\(([^\s])\)')
|
||||
# m = p.search(self.file_txt)
|
||||
m = re.search(r'BINDTOOL_USE_PYGCCXML\(([^\s])\)', self.file_txt)
|
||||
if (m and m.group(1) == '1'):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def get_header_filename(self):
|
||||
# p = re.compile(r'BINDTOOL_HEADER_FILE\(([^\s]*)\)')
|
||||
# m = p.search(self.file_txt)
|
||||
m = re.search(r'BINDTOOL_HEADER_FILE\(([^\s]*)\)', self.file_txt)
|
||||
if (m):
|
||||
return m.group(1)
|
||||
else:
|
||||
return None
|
||||
|
||||
def get_header_file_hash(self):
|
||||
# p = re.compile(r'BINDTOOL_HEADER_FILE_HASH\(([^\s]*)\)')
|
||||
# m = p.search(self.file_txt)
|
||||
m = re.search(r'BINDTOOL_HEADER_FILE_HASH\(([^\s]*)\)', self.file_txt)
|
||||
if (m):
|
||||
return m.group(1)
|
||||
else:
|
||||
return None
|
||||
|
||||
def get_flags(self):
|
||||
return f'{self.get_flag_automatic()};{self.get_flag_pygccxml()};{self.get_header_filename()};{self.get_header_file_hash()};'
|
||||
|
||||
|
||||
def argParse():
|
||||
"""Parses commandline args."""
|
||||
desc = 'Reads the parameters from the comment block in the pybind files'
|
||||
parser = ArgumentParser(description=desc)
|
||||
|
||||
parser.add_argument("function", help="Operation to perform on comment block of pybind file", choices=[
|
||||
"flag_auto", "flag_pygccxml", "header_filename", "header_file_hash", "all"])
|
||||
parser.add_argument(
|
||||
"pathname", help="Pathname of pybind c++ file to read, e.g. blockname_python.cc")
|
||||
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Parse command line options and set up doxyxml.
|
||||
args = argParse()
|
||||
|
||||
pbhp = PybindHeaderParser(args.pathname)
|
||||
|
||||
if args.function == "flag_auto":
|
||||
print(pbhp.get_flag_automatic())
|
||||
elif args.function == "flag_pygccxml":
|
||||
print(pbhp.get_flag_pygccxml())
|
||||
elif args.function == "header_filename":
|
||||
print(pbhp.get_header_filename())
|
||||
elif args.function == "header_file_hash":
|
||||
print(pbhp.get_header_file_hash())
|
||||
elif args.function == "all":
|
||||
print(pbhp.get_flags())
|
||||
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright 2020 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of GNU Radio
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
*/
|
||||
|
||||
#include <pybind11/pybind11.h>
|
||||
|
||||
#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
|
||||
#include <numpy/arrayobject.h>
|
||||
|
||||
namespace py = pybind11;
|
||||
|
||||
// Headers for binding functions
|
||||
/**************************************/
|
||||
// The following comment block is used for
|
||||
// gr_modtool to insert function prototypes
|
||||
// Please do not delete
|
||||
/**************************************/
|
||||
// BINDING_FUNCTION_PROTOTYPES(
|
||||
void bind_rfnoc_gain(py::module& m);
|
||||
// ) END BINDING_FUNCTION_PROTOTYPES
|
||||
|
||||
|
||||
// We need this hack because import_array() returns NULL
|
||||
// for newer Python versions.
|
||||
// This function is also necessary because it ensures access to the C API
|
||||
// and removes a warning.
|
||||
void* init_numpy()
|
||||
{
|
||||
import_array();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PYBIND11_MODULE(rfnoc_gain_python, m)
|
||||
{
|
||||
// Initialize the numpy C API
|
||||
// (otherwise we will see segmentation faults)
|
||||
init_numpy();
|
||||
|
||||
// Allow access to base block methods
|
||||
py::module::import("gnuradio.gr");
|
||||
py::module::import("gnuradio.uhd");
|
||||
|
||||
/**************************************/
|
||||
// The following comment block is used for
|
||||
// gr_modtool to insert binding function calls
|
||||
// Please do not delete
|
||||
/**************************************/
|
||||
// BINDING_FUNCTION_CALLS(
|
||||
bind_rfnoc_gain(m);
|
||||
// ) END BINDING_FUNCTION_CALLS
|
||||
}
|
||||
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright 2024 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of GNU Radio
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*
|
||||
*/
|
||||
|
||||
/***********************************************************************************/
|
||||
/* This file is automatically generated using bindtool and can be manually edited */
|
||||
/* The following lines can be configured to regenerate this file during cmake */
|
||||
/* If manual edits are made, the following tags should be modified accordingly. */
|
||||
/* BINDTOOL_GEN_AUTOMATIC(1) */
|
||||
/* BINDTOOL_USE_PYGCCXML(0) */
|
||||
/* BINDTOOL_HEADER_FILE(rfnoc_gain.h) */
|
||||
/* BINDTOOL_HEADER_FILE_HASH(3bb0f99d63eadb58a2ff22bf8688f0b8) */
|
||||
/***********************************************************************************/
|
||||
|
||||
#include <pybind11/complex.h>
|
||||
#include <pybind11/pybind11.h>
|
||||
#include <pybind11/stl.h>
|
||||
|
||||
namespace py = pybind11;
|
||||
|
||||
#include <gnuradio/rfnoc_gain/rfnoc_gain.h>
|
||||
// pydoc.h is automatically generated in the build directory
|
||||
#include <rfnoc_gain_pydoc.h>
|
||||
|
||||
void bind_rfnoc_gain(py::module& m)
|
||||
{
|
||||
|
||||
using rfnoc_gain = ::gr::rfnoc_gain::rfnoc_gain;
|
||||
|
||||
|
||||
py::class_<rfnoc_gain,
|
||||
gr::uhd::rfnoc_block,
|
||||
gr::block,
|
||||
gr::basic_block,
|
||||
std::shared_ptr<rfnoc_gain>>(m, "rfnoc_gain", D(rfnoc_gain))
|
||||
|
||||
.def(py::init(&rfnoc_gain::make),
|
||||
py::arg("graph"),
|
||||
py::arg("gain"),
|
||||
py::arg("block_args"),
|
||||
py::arg("device_select"),
|
||||
py::arg("instance"),
|
||||
D(rfnoc_gain, make))
|
||||
|
||||
|
||||
.def("set_gain", &rfnoc_gain::set_gain, py::arg("gain"), D(rfnoc_gain, set_gain))
|
||||
|
||||
|
||||
.def("get_gain", &rfnoc_gain::get_gain, D(rfnoc_gain, get_gain))
|
||||
|
||||
;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user