02.03.2014 Views

Tornado

Tornado

Tornado

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

5<br />

Shell<br />

5.4 C++ Interpretation<br />

<strong>Tornado</strong> supports both C and C++ as development languages; see VxWorks<br />

Programmer’s Guide: C++ Development for information about C++ development.<br />

Because C and C++ expressions are so similar, the WindSh C-expression<br />

interpreter supports many C++ expressions. The facilities explained in 5.3 The Shell<br />

C-Expression Interpreter, p.174 are all available regardless of whether your source<br />

language is C or C++. In addition, there are a few special facilities for C++<br />

extensions. This section describes those extensions.<br />

However, WindSh is not a complete interpreter for C++ expressions. In particular,<br />

the shell has no information about user-defined types; there is no support for the ::<br />

operator; constructors, destructors, and operator functions cannot be called<br />

directly from the shell; and member functions cannot be called with the . or -><br />

operators.<br />

To exercise C++ facilities that are missing from the C-expression interpreter, you<br />

can compile and download routines that encapsulate the special C++ syntax.<br />

Fortunately, the <strong>Tornado</strong> dynamic linker makes this relatively painless.<br />

5<br />

5.4.1 Overloaded Function Names<br />

If you have several C++ functions with the same name, distinguished by their<br />

argument lists, call any of them as usual with the name they share. When the shell<br />

detects the fact that several functions exist with the specified name, it lists them in<br />

an interactive dialogue, printing the matching functions’ signatures so that you<br />

can recall the different versions and make a choice among them.<br />

You make your choice by entering the number of the desired function. If you make<br />

an invalid choice, the list is repeated and you are prompted to choose again. If you<br />

enter 0 (zero), the shell stops evaluating the current command and prints a<br />

message like the following, with xxx replaced by the function name you entered:<br />

undefined symbol: xxx<br />

This can be useful, for example, if you misspelled the function name and you want<br />

to abandon the interactive dialogue. However, because WindSh is an interpreter,<br />

portions of the expression may already have executed (perhaps with side effects)<br />

before you abandon execution in this way.<br />

The following example shows how the support for overloaded names works. In<br />

this example, there are four versions of a function called xmin( ). Each version of<br />

191

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!