Go Back   ZeroC Forums > Help Center

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old 03-10-2005
petrilli petrilli is offline
Registered User
 
 
Join Date: Mar 2005
Location: Alexandria, VA
Posts: 4
Send a message via AIM to petrilli
-->
Impact of include on on structs in modules(Python)

(Linux/i386 (FC3), Ice-2.1.0, Python 2.4)

I have a few struct definitions in my file struct.ice:

Code:
module Foo {
  struct MyStruct {
    ...
  };
};
I keep all my “types” (or structures) in the same file, all defined at this top level module level. I then import them into each place that needs them like this:

Code:
#include <struct.ice>

module Foo {
  interface Bar {
    MyStruct getStruct();
  };
};
You would think this works, and at least from my reading of the manual, it should, as it is possible to open and close a module and add new things into it. Unfortunately, this continually gave me an error:

Code:
sys:1: RuntimeWarning: invalid return value for operation `getStruct'
TestApplication.py: warning: dispatch exception: 
    Operation.cpp:870: Ice::MarshalException:
protocol error: error during marshaling or unmarshaling
Somewhat useful, I guess, but unfortuantely it didn’t seem to help me figure it out. When I finally moved the struct definition inside the other file, everything worked. Perhaps it was my running of the slice compiler, slice2py:

$ slice2py -I. --all --output-dir ../lib/ Foo.ice

Any thoughts? I'd like to keep these sort of common definitions in a separate file.

Last edited by petrilli : 03-10-2005 at 10:46 PM.
Reply With Quote
  #2 (permalink)  
Old 03-10-2005
matthew's Avatar
matthew matthew is offline
ZeroC Staff
 
Name: Matthew Newhook
Organization: ZeroC, Inc.
Project: Internet Communications Engine
 
Join Date: Feb 2003
Location: NL, Canada
Posts: 1,052
Hi,

I just created an example that I've attached to this post that uses a similar setup. I ran, manually:

slice2py -I. --output-dir generated Hello.ice
slice2py -I. --output-dir generated DemoBase.ice

then:

PYTHONPATH=$PYTHONPATH:generated python Server.py

and in another window:

PYTHONPATH=$PYTHONPATH:generated python Client.py

And everything worked as expected.

If you don't want to use slice2py as above then you can uncomment the

#Ice.loadSlice('--all -I. Hello.ice')
import Demo

At the top of Server.py and Client.py.

I also tried cleaning out the generated directory and running:

slice2py --all -I. --output-dir generated Hello.ice

and everything also worked as expected. Note that in this case I did not run slice2py on BOTH .ice files. In general if you are using static code generation using --all is not recommended.

If this example doesn't sort things out for you then please create a self-contained example that demonstrates the problem and we'll look into it for you!

Best Regards, Matthew
Attached Files
File Type: zip hello.zip (5.0 KB, 119 views)

Last edited by matthew : 03-10-2005 at 11:31 PM.
Reply With Quote
  #3 (permalink)  
Old 03-11-2005
petrilli petrilli is offline
Registered User
 
 
Join Date: Mar 2005
Location: Alexandria, VA
Posts: 4
Send a message via AIM to petrilli
-->
Fixed

Quote:
Originally Posted by matthew
In general if you are using static code generation using --all is not recommended.
Based on this, I re-ran everything using both multiple runs of slice2py and with a *.ice glob, and it worked great. It seems the problem is related to using the --all bit on the compiler. The help for slice2py says:

Quote:
--all Generate code for Slice definitions in included files.
It would probably be good to make a comment in both the documentation and the command line help that this is for dynamic generation, not static.

Thanks for the assistance! You guys are great.
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
docs: reference to other modules in slice n2503v Comments 2 11-20-2006 05:00 PM
Python: #include/import problem with slice2py hiasl Bug Reports 1 02-21-2006 10:59 AM
Creating dynamically loadable modules g00fy Help Center 3 12-13-2005 05:17 PM
Latency: structs vs. classes n2503v Help Center 7 10-09-2005 01:08 AM
Parameterized constructors for structs? shaver Comments 3 01-10-2004 07:59 PM


All times are GMT -4. The time now is 09:19 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0
(c) 2008 ZeroC, Inc.