Omnimaga
Calculator Community => TI Calculators => Calculator C => Topic started by: compu on November 16, 2013, 06:09:32 pm
-
I am trying to make a C++ class for Nspire I/O that works like the standard iostream class.
For this purpose, I have the class console (https://github.com/compujuckel/nspire-io/blob/cpp-dev/niostream/console.hpp), which is just a simple C++ wrapper for Nspire I/O, and the class nio_base (https://github.com/compujuckel/nspire-io/blob/cpp-dev/niostream/nio_base.hpp), that provides stuff from the standard ios_base (http://www.cplusplus.com/reference/ios/ios_base/) class.
The class iostream (https://github.com/compujuckel/nspire-io/blob/cpp-dev/niostream/iostream.hpp) inherits from both console and nio_base, so we can use the <<, >> operators and more for Nspire I/O consoles.
My problem is, when I am trying to set the field width with the function width() (https://github.com/compujuckel/nspire-io/blob/cpp-dev/niostream/nio_base.cpp#L191) from nio_base to 10, it stays 0 when I read it from inside the iostream class (https://github.com/compujuckel/nspire-io/blob/cpp-dev/niostream/iostream.cpp#L84).
Also, using setf() (https://github.com/compujuckel/nspire-io/blob/cpp-dev/niostream/nio_base.cpp#L30) crashes the emulator.
This is the code I'm trying to run. (https://github.com/compujuckel/nspire-io/blob/cpp-dev/niostream/demo/demo.cpp)
Basically everything works, except the field width change and the unsetf/setf stuff.
The code works fine on the other branch (https://github.com/compujuckel/nspire-io/tree/cpp-support/niostream) where the nio_base stuff is integrated into iostream, but I wanted to separate it so I don't have to duplicate the code for RS232 communcication.
Download the code (https://github.com/compujuckel/nspire-io/archive/cpp-dev.zip)
To build, make lib install in the root dir
make lib install demo in niostream
Make sure there are no old versions of Nspire I/O in your Ndless SDK.
-
The class iostream (https://github.com/compujuckel/nspire-io/blob/cpp-dev/niostream/iostream.hpp) inherits from both console and nio_base, so we can use the <<, >> operators and more for Nspire I/O consoles.
I'm not a C++ master, but multiple inheritance has been a problem since beginning of POO, hasn't it ?
I know Java makes it different with interfaces, but what I learnt in C++ always made me feel this was impossible to achieve cleverly.
-
compu, were you able to fix that one?
-
Isn't this fixable with virtual inheritance? (I don't C++ much, so I'm not sure.)
-
I would check myself, but github gives me "500 internal server error"...
- bFLT? (Needed)
- Compile flags? (At least -fpic -mlong-calls)
- If you run elf2flt manually, what's the output?