[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Linkage betwen Otcl and C++ code: problem not resolved (be patient please)
Hello everybody,
I'm using ns 2.1b5.
Someone knows because NS doesn't want to execute the linkage between the C++
code and Tcl code.
Look please this simple example and tell me what I miss.
~~~~
The error mesage is:
(_o11 cmd line 1)
invoked from within
"_o11 cmd hello"
invoked from within
"catch "$self cmd $args" ret"
(procedure "_o11" line 2)
(SplitObject unknown line 2)
invoked from within
"$p hello"
(file "prova_otcl_linkage.tcl" line 4)
~~~~
This is the Otcl script
# file "prova_otcl_linkage.tcl"
Class Agent/Prova -superclass Agent
set ns [new Simulator]
set p [new Agent/Prova]
$p hello
exit 1
~~~~
This is the simple C++ code
// file "prova_otcl_linkage.cc"
#include "agent.h"
#include <stdio.h>
#include "packet.h"
#include "tclcl.h"
#include "address.h"
#include "ip.h"
//-------- class definition -------------------------
class prova : public Agent {
public:
prova();
int command(int argc, const char*const* argv);
};
//-------- Otcl linkage -------------------------
static class provaClass : public TclClass {
public:
provaClass() : TclClass("Agent/Prova") {}
TclObject* create(int, const char*const*) {
return (new prova());
}
} class_prova;
//---------------------------------
prova::prova() : Agent(PT_NTYPE)
{
printf("@@@@@@@ I am here");
}
int prova::command(int argc, const char*const* argv)
{
Tcl& tcl = Tcl::instance();
if (argc == 2) {
if (strcmp(argv[1], "hello") == 0) {
printf("C++ prova : hello I am here");
tcl.evalc("puts Otcl Agent/Prova: Hello I am here");
return (TCL_OK);
}
}
return (Agent::command(argc, argv));
}
//------------------------------------
Thanks in advance to all NS comunitty.
Luca Liberti