example_0070.cpp
См. документацию.
1 #include <iostream>
2 #include <pyhrol.h>
3 
4 using namespace std;
5 using namespace pyhrol;
6 
7 
9 {
10  uint8_t build_variant;
11  int i;
12  const char *pch;
13  double f;
14 
15  PYHROL_PARSE_TUPLE_1("\nvalue from range [0, 5)", _args, build_variant)
17  PYHROL_BUILD_VALUE_1(NULL, _args, i)
18  PYHROL_BUILD_VALUE_1(NULL, _args, pch)
19  PYHROL_BUILD_VALUE_1(NULL, _args, f)
20  PYHROL_BUILD_VALUE_0(NULL, _args)
21  PYHROL_BUILD_VALUE_3(NULL, _args, i, pch, f)
23 
24  cout
25  << __func__ << ": I am called" << endl
26  ;
27 
28  switch (build_variant)
29  {
30  case 0:
31  i = 1;
32  cout
33  << " Variant 0: i = " << i << endl
34  ;
35  break;
36  case 1:
37  pch = "One";
38  cout
39  << " Variant 1: pch = \"" << pch << "\"" << endl
40  ;
41  break;
42  case 2:
43  f = 2.72;
44  cout
45  << " Variant 2: f = " << f << endl
46  ;
47  break;
48  case 3:
49  cout
50  << " Variant 3: <no result>" << endl
51  ;
52  break;
53  case 4:
54  i = 3;
55  pch = "Three";
56  f = 3.14;
57  cout
58  << " Variant 4: i = " << i << ", pch = \"" << pch << "\", f = " << f << endl
59  ;
60  break;
61  }
62 
63  PYHROL_AFTER_EXECUTE(_args, build_variant)
64 }
65 
66 static void __on_load() __attribute__ ((constructor));
67 
68 void __on_load()
69 {
70  PYHROL_REGISTER_FUNCTION(function_with_overloaded_retvals, "Function returns different result types depend on argument value")
71 }
#define PYHROL_AFTER_BUILD_VALUE(container)
Definition: pyhrol_macro.h:18
void function_with_overloaded_retvals(Tuples &_args)
Definition: example_0070.cpp:8
#define PYHROL_AFTER_PARSE_TUPLE(container)
Definition: pyhrol_macro.h:9
#define PYHROL_PARSE_TUPLE_1(description, container, arg1)
#define PYHROL_BUILD_VALUE_1(description, container, arg1)
#define PYHROL_BUILD_VALUE_0(description, container)
static void __on_load() __attribute__((constructor))
#define PYHROL_AFTER_EXECUTE(container, variant)
Definition: pyhrol_macro.h:30
#define PYHROL_BUILD_VALUE_3(description, container, arg1, arg2, arg3)
#define PYHROL_REGISTER_FUNCTION(function, help)
Definition: pyhrol_macro.h:34