File: _globals.i

package info (click to toggle)
gnucap-python 0.0.2-1.2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 2,668 kB
  • sloc: python: 7,873; sh: 4,384; cpp: 1,786; makefile: 249
file content (105 lines) | stat: -rw-r--r-- 2,711 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/* Copyright (C) 2018 Felix Salfelder
 * Author: Felix Salfelder <felix@salfelder.org>
 *
 * 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 3, 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, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 * 02110-1301, USA.
 *------------------------------------------------------------------
 */
%module(directors="0", allprotected="1") globals

// generate directors for all classes that have virtual methods
%feature("director");
%feature("nodirector") CARD;

%include stl.i
%include std_string.i
%include std_complex.i
%include e_card.i
%include std_shared_ptr.i

%{
#include "wrap.h"
#include <e_compon.h>
#include <e_node.h>
#include <globals.h>
%}


%exception {
    try {
        $action
    } catch (Exception& e) {
      PyErr_SetString(PyExc_Exception, e.message().c_str());
      return NULL;
    }
}
%allowexception;


%{
extern std::vector<CMD*> installed_commands;
%}

%inline %{

typedef DISPATCHER<CARD>::INSTALL card_install;
typedef std::shared_ptr< card_install > shared_card_installer;

shared_card_installer install_device(char const*name, CARD *card) {
   return std::make_shared<DISPATCHER<CARD>::INSTALL>(&device_dispatcher, name, card);
}

typedef DISPATCHER<CMD>::INSTALL cmd_install;
typedef std::shared_ptr< cmd_install > shared_command_installer;

shared_command_installer install_command(char *name, CMD *cmd) {
  installed_commands.push_back(cmd);
  auto x=std::make_shared<DISPATCHER<CMD>::INSTALL>(&command_dispatcher, name, cmd);
  return x;
}
%}

// these make destruction work

class shared_card_installer{
public:
  ~shared_card_installer();
};

class shared_command_installer{
public:
  // shared_command_installer(DISPATCHER<CMD>*, char *name, CMD *cmd); // ..
  ~shared_command_installer();
};

// later
//DISPATCHER<CMD> command_dispatcher;
//DISPATCHER<COMMON_COMPONENT> bm_dispatcher;
//DISPATCHER<MODEL_CARD> model_dispatcher;
//DISPATCHER<CARD> device_dispatcher;
//DISPATCHER<LANGUAGE> language_dispatcher;
//DISPATCHER<FUNCTION> function_dispatcher;

%{
extern bool have_default_plugins;
%}

%inline %{
bool need_default_plugins(){
  return !have_default_plugins;
}
%}

// vim:ts=8:sw=2:et: