From: Keith T. G. <kg...@kg...> - 2007-12-17 16:33:19
|
Since directors are supported for ruby, python, and C#/.NET, and those are the three languages I care about for the project I'm working on, I thought I'd give them a try rather than go and build a bunch of support classes for each language. I'm running into a problem where I think I'm not fully understanding swig or something swig is doing. Since I know ruby the best, I'm starting there. Here is the basics of what I have: %module(directors="1") test %feature("director") Logger; class Logger { public: enum Type { RECEIVED, SENT, INFORMATIONAL }; virtual ~Logger(); virtual void logData(Type type, std::string data) = 0; }; class Session { public: Session(); void setLogger(Logger* logger); }; After running swig and compiling the ruby module, I have the following ruby code. require 'test' class MyLogger < Logger def initialize() @file = File.open("/tmp/stuff", 'w') end def logData(type, data) @file << type << " " << data << "\n" end end session = Test::Session.new logger = MyLogger.new session.SetLogger(logger) Running that, I get the following error: ObjectPreviouslyDeleted: Expected argument 1 of type Logger *, but got MyLogger #<MyLogger:0x5aca6c> in SWIG method 'setLogger' from (irb):16:in `setLogger' from (irb):16 I know I'm missing something small but obvious that I just can't see. Any pointers on where I should look? Keith -- Keith T. Garner kg...@kg... "Make no little plans; they have no magic to stir men's blood." - Daniel H. Burnham |