mirror of
https://github.com/nasa/trick.git
synced 2024-12-18 12:56:26 +00:00
Handle empty PYTHON_MODULE in header comment (#1432)
This commit is contained in:
parent
e11ff83051
commit
8821bac18a
@ -162,7 +162,7 @@ The `ICG IGNORE TYPES` field lists the structs or classes to be ignored. Any par
|
||||
|
||||
###### `PYTHON_MODULE`
|
||||
|
||||
Specifying a `python_module` name will place any class/struct and function definitions in this header file in a python module of the same name. All classes and functions are flattened into the python `trick` namespace by default. This capability allows users to avoid possible name collisions between names when they are flattened.
|
||||
Specifying a `python_module` name will place any class/struct and function definitions in this header file in a python module of the same name. All classes and functions are flattened into the python `trick` namespace by default. This capability allows users to avoid possible name collisions between names when they are flattened. An empty `python_module` statement will be ignored.
|
||||
|
||||
##### Compiler Directives
|
||||
|
||||
|
@ -31,7 +31,7 @@ sub extract_trick_header($$$$) {
|
||||
$header{icg_ignore} = $2 if $trick_header =~ /ICG[ _]IGNORE[ _]TYPE(S)?:[^(]*(.*?)\)([A-Z _\t\n\r]+:|[ \t\n\r]*$)/si ;
|
||||
$header{swig} = $1 if $trick_header =~ /SWIG:[^(]*\((.*?)\)([A-Z _\t\n\r]+:|[ \t\n\r]*$)/si ;
|
||||
$header{default_data} = $1 if $trick_header =~ /DEFAULT[ _]DATA:[^(]*(.*?)\)([A-Z _\t\n\r]+:|[ \t\n\r]*$)/si ;
|
||||
$header{python_module} = $1 if $trick_header =~ /PYTHON[ _]MODULE:[^(]*\((.*?)\)([A-Z _\t\n\r]+:|[ \t\n\r]*$)/si ;
|
||||
$header{python_module} = $1 if $trick_header =~ /PYTHON[ _]MODULE:[^(]*\((.+?)\)([A-Z _\t\n\r]+:|[ \t\n\r]*$)/si ;
|
||||
$header{programmers} = $1 if $trick_header =~ /PROGRAMMERS:[^(]*(.*?)\)([A-Z _\t\n\r]+:|[ \t\n\r]*$)/si ;
|
||||
$header{language} = $1 if $trick_header =~ /LANGUAGE:[^(]*(.*?)\)([A-Z _\t\n\r]+:|[ \t\n\r]*$)/si ;
|
||||
|
||||
|
@ -43,6 +43,13 @@ def main():
|
||||
yummy.yummy = trick.Foo.Doughnuts
|
||||
TRICK_EXPECT_EQ( yummy.yummy , 2, test_suite , "additional file in same namespace" )
|
||||
|
||||
# new class from TrickFood
|
||||
trickfood = trick.Food()
|
||||
trickfood.print_me()
|
||||
TRICK_EXPECT_EQ( trickfood.fast , 2, test_suite , "blank python_module statement" )
|
||||
trickfood.fast = trick.Pizza
|
||||
TRICK_EXPECT_EQ( trickfood.fast , 0, test_suite , "blank python_module statement" )
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/************************TRICK HEADER*************************
|
||||
PURPOSE:
|
||||
(blah blah blah)
|
||||
(Test different combinations of Python modules and C++ namespaces)
|
||||
*************************************************************/
|
||||
|
||||
#include "sim_objects/default_trick_sys.sm"
|
||||
@ -9,6 +9,7 @@ PURPOSE:
|
||||
##include "FooInnerFood.hh"
|
||||
##include "BarFood.hh"
|
||||
##include "FooYummyFood.hh"
|
||||
##include "TrickFood.hh"
|
||||
|
||||
class SimObj : public Trick::SimObject {
|
||||
|
||||
@ -17,6 +18,7 @@ class SimObj : public Trick::SimObject {
|
||||
Foo::Inner::Food foo_inner_food ;
|
||||
Bar::Food bar_food ;
|
||||
Foo::YummyFood foo_yummyfood ;
|
||||
Food trick_food;
|
||||
|
||||
/** Constructor to add the jobs */
|
||||
SimObj() {
|
||||
|
32
test/SIM_python_namespace/models/TrickFood.hh
Normal file
32
test/SIM_python_namespace/models/TrickFood.hh
Normal file
@ -0,0 +1,32 @@
|
||||
/**
|
||||
@file
|
||||
|
||||
@verbatim
|
||||
PURPOSE: (Test that an empty PYTHON_MODULE won't cause errors or have any effect.)
|
||||
PYTHON_MODULE: ()
|
||||
@endverbatim
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef TRICKFOOD_HH
|
||||
#define TRICKFOOD_HH
|
||||
|
||||
#include <iostream>
|
||||
|
||||
|
||||
|
||||
enum Fast {
|
||||
Pizza,
|
||||
Burger,
|
||||
Taco
|
||||
};
|
||||
|
||||
class Food {
|
||||
public:
|
||||
Food() : fast(Taco) {}
|
||||
void print_me() { std::cout << "Food::print_me!" << std::endl; }
|
||||
Fast fast;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user