Re: encoding over DO




"bycopy makes so much sense for certain classes-classes that are
intended to contain a collection of other objects, for instance-that
often these classes are written so that a copy is sent to a remote
receiver, instead of the usual reference. You can override this behavior
with byref, however, thereby specifying that objects passed to a method
or objects returned from a method should be passed or returned by
reference."

Therefore, your NSMutableArray, in all likelyhood, would be passed
bycopy and in that process have its encodeWithCoder: method messaged.
Did you specify byref in your DO protocol instead?

No-where's do I specify byref in my DO protocol.

I do query the object I pull off my NSMutableArray on the receiving
end for it's class and I get "class <NSDistantObject: 0xa2bdca18>".

I'm actually a bit confused on how it's sort of working because if my
encoder methods are not being called, how is the data on the receiving
end being received (it seems to know the correct size of the array,
but the objects in it aren't correct)?

I stuff 250 objects into an NSMutableArray on the sending side (that
would be the allPatterns instance below). Then I pass that array to
the receiver through DO with a line like [server setPatterns:patterns]
and on the receiving side where the pointer to this array just get's
stored.

Then the sending side sends a command over DO to operate on the array
on the receiving end. I can see that my NSMutableArray has the correct
size, but I'm pretty sure the data within it isn't correct.

And I do send other objects over DO and those classes do come through
fine w/ their correct data, but only because I think they are obj-c
objects all the way through. One thing about this array that I'm
populating before sending is that my objects are c++ classes and I'm
stuffing them in an obj-c wrapper class and trying to serialize them.

// Stuff c++ pattern objects into NSMutableArray
PatternWrapper *wrapper =
[[PatternWrapper alloc] initWithPattern:pattern];

[allPatterns addObject:wrapper];

// ---------

@interface PatternWrapper : NSObject {
AB::Pattern *pattern;
}

- (id)initWithPattern:(AB::Pattern *)nativePattern;
- (void)encodeWithCoder:(NSCoder *)encoder;
- (id)initWithCoder:(NSCoder *)decoder;

@implementation PatternWrapper

- (id)initWithPattern:(AB::Pattern *)nativePattern
{
if (self) {
pattern = new AB::Pattern(nativePattern);
}

return self;
}

// This method never get's called.
- (void)encodeWithCoder:(NSCoder *)encoder
{
NSLog(@"encodeWithCoder:");
NSLog(@"encoder isBycopy:%d", [encoder isBycopy]);
[super encodeWithCoder:encoder];

// this line calls the c++ class where I'm trying
// to natively serialize the object (for performance).
std::string pat = AB::pattern->str_pattern();

NSLog(@"pat:id = %@", pat);
NSLog(@"pat:id = %@", pat.c_str());
[encoder encodeBytes:pat.c_str() length:pat.size() + 1];
/*int serial = pattern.serial();
[coder encodeValueOfObjCType:@encode(int) at:&serial];
*/
}


Any help much appreciated.

.



Relevant Pages

  • Re: UDP Sending an array possible?
    ... Is the receiving application a .NET application? ... -Yes...its actually 1 exe... ... it opens a UDP port and listens. ... I build the recieving parts to an array and do stuff with those arrays ...
    (microsoft.public.dotnet.languages.vb)
  • Re: UDP Sending an array possible?
    ... Is it possible to send an array instead of a straight line of text? ... i can make a huge string and send it and then ... Is the receiving application a .NET application? ... Sockets break data up into packets, ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Array issue in vfp8?
    ... The array expcost stores the expected cost for that particular item and is displayed on the screen only. ... The qty received is entered and the receiving is now saved to a table and printed out. ... About 8 times in the last year, the expected cost field is exactly 10 times what it should be for only one of the lines on the receiving table and printout. ... I thought there may be a patch for array handling in VFP8 as there is no way this should be happening. ...
    (microsoft.public.fox.programmer.exchange)
  • Re: Array issue in vfp8?
    ... I will do a comparison with the sum and if it is ... and compare it to the sum calculated from expcost array: ... In the receiving screen, I select the desired P.O. and have ...
    (microsoft.public.fox.programmer.exchange)
  • Re: Array issue in vfp8?
    ... and compare it to the sum calculated from expcost array: ... The qty received is entered and the receiving is now saved to a table and printed out. ... About 8 times in the last year, the expected cost field is exactly 10 times what it should be for only one of the lines on the receiving table and printout. ... Mike Z. used his keyboard to write: ...
    (microsoft.public.fox.programmer.exchange)