object nesting
Javalin
Posts: 892
Hello!
How far can you nest objects?
I have an application running·one and·two layers deep.· Calls to PUB routines works to the first layer, but calls to the second layer to get first layer values do not return a value.· It looks like the "objectone" layer cannot get and pass back from "objecttwo"
The app structure is as follows:
··········· layerdemo.spin
············· │
············· ├──LCDObject.spin
············· │··· │
············· │··· └──Simple_Serial.spin
············· │
············· ├──objectone.spin
············· │··· │
············· │··· └──objecttwo.spin
············· │
············· └──objecttwo.spin
I know this isn't clear so I've attached the project achieve test code.
When the app runs it debugs to a serial LCD (-9600baud) on pin15·and outputs:
"one:125
·one_via_two:0
·two:5"
I've tried increasing the _stack, - am I missing something??
James
PS - SPIN rocks - I love my Propeller!!
How far can you nest objects?
I have an application running·one and·two layers deep.· Calls to PUB routines works to the first layer, but calls to the second layer to get first layer values do not return a value.· It looks like the "objectone" layer cannot get and pass back from "objecttwo"
The app structure is as follows:
··········· layerdemo.spin
············· │
············· ├──LCDObject.spin
············· │··· │
············· │··· └──Simple_Serial.spin
············· │
············· ├──objectone.spin
············· │··· │
············· │··· └──objecttwo.spin
············· │
············· └──objecttwo.spin
I know this isn't clear so I've attached the project achieve test code.
When the app runs it debugs to a serial LCD (-9600baud) on pin15·and outputs:
"one:125
·one_via_two:0
·two:5"
I've tried increasing the _stack, - am I missing something??
James
PS - SPIN rocks - I love my Propeller!!
Comments
Top_Object:
· -- Layer2
····· -- Layer3
There is no way for Top_Object to use methods in Layer3.· What you can do is create shell methods in Layer2 that call the desired methods in Layer3.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Post Edited (Jon Williams (Parallax)) : 5/6/2006 10:17:33 PM GMT
Ah. I think i've just figured it. I wasn't initializing the object within the object!
Thanks Jon!
James
This is working towards an I2C object and libraries. I hope to post tomorrow night!
Cheers,
James
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Was the question of 'how far?' answered? Just three levels? Or can you extend this quite far?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"When all think alike, no one is thinking very much.' - Walter Lippmann (1889-1974)
······································································ Warm regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Who says you have to have knowledge to use it?
I've killed a fly with my bare mind.
CJ: the issue is trying to access objects declared in the OBJ block of an object declared in a higher OBJ block. For instance, say you declare TV_terminal in your program, the TV_terminal itself declares the TV and graphics objects. Unless you provide special provisions, there is no way for your program to access the methods in the TV or Graphics object.
I have experienced issues with shelling, for instance I was trying to access the method for drawing a box declared withing the graphics object through the TV_terminal object. I was unable to do so, but was unable to figure out why exactly this was the case. I think it may have to do with accessing data structures several levels down, but this is only a guess.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
1+1=10
I do understand the Objects seem to talk only to the one above and the one below. In a nutshell, is that it?
Data seems to be intended to be Public or Private. Variables and such would have to move up and down the line.
Need to get back to reading the Propeller Docs.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"When all think alike, no one is thinking very much.' - Walter Lippmann (1889-1974)
······································································ Warm regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
A
-- B
··· -- C
"A" can call the PUBlic methods in "B" -- as well as any·PUBlic or PRIvate methods in "A"
"B" can call the PUBlic methods in "C" -- as well as any·PUBlic or PRIvate methods in "B"
"C" can call the PUBlic and PRIvate methods in "C"
It's important to understand that there is no method inheritance per se, i.e., just because "B" can call methods in "C" doesn't mean that "A" (which uses "B") has access to those methods.
To·me this concept is easier to understand than explain....
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
The first sentence may take a bit to fully sink in.
If that is all I need to know, can I forget about 'shelling'?
Everyone can disregard my questions about such as it appears muddled.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"When all think alike, no one is thinking very much.' - Walter Lippmann (1889-1974)
······································································ Warm regards,····· G. Herzog [noparse][[/noparse]·黃鶴 ]·in Taiwan
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
1+1=10
I dont know if this is of any use - but this is the working version of the code that started the thread!
The fix in my case was when "objectone" runs "objecttwo", it was not being initialized - so the parameter that I was requesting back was of course 0.
Jon:·
I posted the i2c object and examples - is it up to your standard?· Did it save you the work?
James
I looked at your I2C object and believe the are potential issues. Let me finish mine and then we'll compare notes. Don't be alarmed, I could be wrong about what I saw (in a very brief look).
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax