hv.mod 2.88 KB
Newer Older
1 2
%module hv
%{
3 4
//
// Copyright (c) 2004 University of Utah and the Flux Group.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
// 
// {{{EMULAB-LICENSE
// 
// This file is part of the Emulab network testbed software.
// 
// This file is free software: you can redistribute it and/or modify it
// under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or (at
// your option) any later version.
// 
// This file 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 Affero General Public
// License for more details.
// 
// You should have received a copy of the GNU Affero General Public License
// along with this file.  If not, see <http://www.gnu.org/licenses/>.
// 
// }}}
Russ Fish's avatar
Russ Fish committed
24 25 26 27 28
//

#include <string>
NAMESPACEHACK

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
#include "HypView.h"
%}

/* Magic from /usr/local/share/doc/swig/Doc/Manual/Python.html
 * "19.8.2 Expanding a Python object into multiple arguments".
 */
%typemap(in) (int argc, char *argv[]) {
  /* Check if is a list */
  if (PyList_Check($input)) {
    int i;
    $1 = PyList_Size($input);
    $2 = (char **) malloc(($1/*size*/+1)*sizeof(char *));
    for (i = 0; i < $1; i++) {
      PyObject *o = PyList_GetItem($input,i);
      if (PyString_Check(o))
	$2[i] = PyString_AsString(PyList_GetItem($input,i));
      else {
	PyErr_SetString(PyExc_TypeError,"list must contain strings");
	free($2);
	return NULL;
      }
    }
    $2[i] = 0;
  } else {
    PyErr_SetString(PyExc_TypeError,"not a list");
    return NULL;
  }
}
%typemap(freearg) (int argc, char **argv) {
  free((char *) $2);
}

// It's easier to return the pointer to the HypView object rather than access the global.
Russ Fish's avatar
Russ Fish committed
62 63 64 65 66 67 68
//extern HypView  *hvmain(int argc, char *argv[], int window, int width, int height);

#ifndef WIN32
extern HypView *hvMain(int argc, char *argv[], void *window, int width, int height);
#else
extern HypView *hvMain(int argc, char *argv[], int window,  int width, int height);
#endif
69 70 71 72 73
//extern int hvmain(int argc, char *argv[]);
//%include "cpointer.i"
//%pointer_class(HypView,hvp)
//extern HypView *hv;

Russ Fish's avatar
Russ Fish committed
74 75
extern void hvKill(HypView *hv);

76
// Separate out file reading from the main program.
Russ Fish's avatar
Russ Fish committed
77
extern int hvReadFile(char *fname, int width, int height);
78 79

// Get the node id string last selected by the selectCB function.
80
extern char const *getSelected();
81

82 83 84
// Get the node id string at the graph center.
extern char *getGraphCenter();

85 86 87 88 89 90 91
// std::string is used for INPUT args to HypView methods.
%include "std_string.i"
// How come %apply doesn't work for std::string?  Workaround with sed instead.
///namespace std {
//%apply const std::string & INPUT { const string & id };
///}

92 93 94
// This callback is used in picking.  Call it to simulate picking.
extern void selectCB(const std::string & INPUT, int shift, int control);

95 96
//================================================================