Home Help Center

IceTouch 1.3 mutable types (and more)

hofhauserhofhauser Member Stefan HofhauserOrganization: StudentProject: Thesis
Hello,

im new to Ice and Ice Touch and im using IceTouch 1.3 in an iOS application.

I have 2 problems that you can hopefully help me with.

1. mutable vs. immutable types

slice2objc emits both mutable and immutable versions of my custom types into the objc code as expected based on your documentation here:

Objective-C Mapping for Dictionaries - Ice 3.5 - ZeroC

in my example i end up with:
typedef NSArray BotPersonSeq;
typedef NSMutableArray BotMutablePersonSeq;

good.

the problem/question i have is how do i use the mutable version in my custom classes. in my case, my slice definition looks like this:

sequence<Person> PersonSeq;

class PersonModification {
        optional(0) PersonSeq newPersons;
}

and the generated code looks like this:
@interface EdbotIceV6Playlist : ICEObject
{
    BotPersonSeq* newPersons;
}


but what i want is:
@interface EdbotIceV6Playlist : ICEObject
{
    Bot[COLOR="#FF0000"]Mutable[/COLOR]PersonSeq* newPersons;
}

how do i do that? is there some meta data that i can give hist to slice2objc to use the mutable version?



2. slice2objc emits "id" instead of double type in initializers

i have the following slice definition:
class Person {
        string guid;
        string element;
        optional(0) string parent;
        int in;
        int out;
        bool enabled = true;
        optional(1) string filespec;
        optional(2) double speed;
    };


which generates the following objc code:
@interface BotPerson : ICEObject
{
    NSString *guid;
    NSString *element;
    NSString *parent;
    ICEInt in;
    ICEInt out;
    BOOL enabled;
    NSString *filespec;
    ICEDouble fps;
}

-(id) init:(NSString*)guid element:(NSString*)element parent:(id)parent in:(ICEInt)in out:(ICEInt)out enabled:(BOOL)enabled filespec:(id)filespec fps:([COLOR="#FF0000"][FONT=Arial Black]id[/FONT][/COLOR])fps;

note how fps type is "id" instead of ICEDouble! this seems clearly wrong.

Comments

  • xdmxdm La Coruña, SpainAdministrators, ZeroC Staff Jose Gutierrez de la ConchaOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    how do i do that? is there some meta data that i can give hist to slice2objc to use the mutable version?

    That is not possible data members always use the non mutable version.
    slice2objc emits "id" instead of double type in initializers

    That is expected, similar to what is done for optional parameters, you should use NSNumber, if we directly use ICEDouble wouldn't be possible to pass ICENone to init
  • benoitbenoit Rennes, FranceAdministrators, ZeroC Staff Benoit FoucherOrganization: ZeroC, Inc.Project: Ice ZeroC Staff
    Note that while the formal type of the data member is a non-mutable type, when Ice un-marshalls the class instance, the sequence is instantiated as a mutable array. So you can cast the array to a mutable array if you want to modify its content.

    We could eventually add a metadata to change the default mapping. The drawback of using a mutable data member formal type is that can no longer assign a non-mutable array to the member.

    For the init constructor, as José mentioned, its mapping is similar to the mapping of optionals parameters, see here in the Ice manual for more information.

    Cheers,
    Benoit.
  • hofhauserhofhauser Member Stefan HofhauserOrganization: StudentProject: Thesis
    benoit wrote: »
    We could eventually add a metadata to change the default mapping.

    that would be great. thanks.
Sign In or Register to comment.