[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference tuxedo::dce-products

Title:DCE Product Information
Notice:Kit Info - See 2.*-4.*
Moderator:TUXEDO::MAZZAFERRO
Created:Fri Jun 26 1992
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:2269
Total number of notes:10003

2187.0. "idl compiler help with array pointer" by CSC32::C_JACOBSON () Wed Mar 12 1997 13:47

    Hello,
    
    I have a customer who is compiling his rpc code on both
    NT and Digital Unix. The following snippet compiles
    fine on NT but fails on the dunix:
    
    // Begin new test function with leading comma...
    unsigned long DoArrayOfStructures([in,out,ref] unsigned long *uNumItems,
                    [out,ref,size_is(,*uNumItems)] TST_RECORD **ptestRec);
    // End new test function with leading comma...
    // This works in NT, but not here. The leading comma is suppposed to move
    // the size_is attribute to the next level of indirection (the array of
    // structures). We're trying to achieve a pointer to
    // an array of structures, so in trying to better define that, I tried
    // this next line which gives me the incorrect syntax for pointer to
    // conformant array.
    // unsigned long DoArrayOfStructures([in,out,ref] unsigned long *uNumItems,
    //              [out,ref,size_is(*uNumItems)] TST_RECORD_ARR *ptestRec
    
    So, the customer wonders if the Digital Unix DCE (v2.0) idl has not
    implemented the leading comma attribute.
    
    -Chris Jacobson
T.RTitleUserPersonal
Name
DateLines
2187.1Looks like a user errorPTHRED::VIVENEYBob ViveneyThu Mar 13 1997 09:5940
The leading comma is a valid feature of idl.
    
// Begin new test function with leading comma...
unsigned long DoArrayOfStructures(
	[in,out,ref] unsigned long *uNumItems,
	[out,ref,size_is(,*uNumItems)] TST_RECORD **ptestRec
);

In this code fragment, if the intention is for ptestRec to be a 2 dimensional
array, the size of the first dimension is not specified. It should fail on
Unix and NT.

////////////////////////////////////////////////////////////////////////////////

// Begin new test function with leading comma...
unsigned long DoArrayOfStructures(
	[in,out,ref] unsigned long *uNumItems,
	[out,ref,size_is(*uNumItems)] TST_RECORD *ptestRec
);

In this code fragment, ptestRec is an array of *uNumItems elements. This should
compile on both Unix and NT.

////////////////////////////////////////////////////////////////////////////////

// Begin new test function with leading comma...
unsigned long DoArrayOfStructures(
	[in,out,ref] unsigned long *uNumItems,
	[out,ref,size_is(*uNumItems)] TST_RECORD *ptestRec[]
);

In this code fragment, ptestRec is a pointer to an array of *uNumItems elements,
which I believe is what you want.

You didn't specify what a TST_RECORD is but I got consistent results on the
above samples on both NT and Unix. You should also get consistent compiler
errors or success on NT and Unix. 

- Bob

2187.2IDL File IncludedCSC32::C_JACOBSONFri Mar 21 1997 14:18212
    Hello,
    
    Thanks for the help.
    
    I regret to have omitted the complete idl file which
    would have provided all of the necessary definitions
    to clarify what the customer is finding: he has the
    task of developing the DCE client portion of an
    application which already has the server written
    and running on an NT platform. The acl and idl files included
    below were used to build the server code with
    no problem. Sigh, but this will not even compile on the
    Digital Unix system ... Please help !
    
    Thanks again,
    Chris Jacobson
    
    ========================== idatasrv.acf ====================
    
    /*************************************************************/
    /**                                                         **/
    /**                 Microsoft RPC Examples                  **/
    /**                 OSF DCE Interop Application             **/
    /**          Copyright(c) Microsoft Corp. 1992-1995         **/
    /**                                                         **/
    /*************************************************************/
    
    [ implicit_handle(handle_t idatasrv_binding_handle) ]
    
    interface idatasrv
    {
    }
    
    ========================== idatasrv.idl ====================
    
    /*************************************************************/
    /**                                                         **/
    /**                                                         **/
    /**                                                         **/
    /*************************************************************/
    
    [
    uuid(0E8BDF58-B3BF-101A-A116-08002B2B8CD3),
    version(1.0)
    ]
    interface idatasrv
    {
    
    // begin data definitions...
    // PCD RECORD definition
    typedef struct PCD_RECORD_STRUC {
      double x;
      double y;
      double z;
      double a;
      double b;
      double c;
      double i;
      double j;
      double k;
    } PCD_RECORD;
    
    // TST RECORD definition
    typedef struct TST_RECORD_STRUC {
      double x;
      long   y;
      short  z;
    } TST_RECORD;
    
    // Arrayed Typed data definitions
    typedef struct ARRAY_HEADER_STRUC {
      unsigned long uNumEntries;
      unsigned char data[1];
    } ARRAY_HEADER;
    
    typedef struct INT_8_ARRAY_STRUC {
      unsigned long  uNumEntries;
      [size_is(uNumEntries)] char     data[];
    }  INT_8_ARRAY;
    
    typedef struct WORD_8_ARRAY_STRUC {
      unsigned long  uNumEntries;
      [size_is(uNumEntries)] unsigned char    data[];
    }  WORD_8_ARRAY;
    
    typedef struct INT_16_ARRAY_STRUC {
      unsigned long  uNumEntries;
      [size_is(uNumEntries)] short     data[];
    }  INT_16_ARRAY;
    
    typedef struct WORD_16_ARRAY_STRUC {
      unsigned long  uNumEntries;
      [size_is(uNumEntries)] unsigned short    data[];
    }  WORD_16_ARRAY;
    
    typedef struct INT_32_ARRAY_STRUC {
      unsigned long  uNumEntries;
      [size_is(uNumEntries)] long     data[];
    }  INT_32_ARRAY;
    
    typedef struct WORD_32_ARRAY_STRUC {
      unsigned long  uNumEntries;
      [size_is(uNumEntries)] unsigned long    data[];
    }  WORD_32_ARRAY;
    
    typedef struct FLOAT_32_ARRAY_STRUC {
      unsigned long  uNumEntries;
      [size_is(uNumEntries)] float   data[];
    }  FLOAT_32_ARRAY;
    
    typedef struct FLOAT_64_ARRAY_STRUC {
      unsigned long  uNumEntries;
      [size_is(uNumEntries)] double   data[];
    }  FLOAT_64_ARRAY;
    
    typedef struct PCD_REC_ARRAY_STRUC {
      unsigned long  uNumEntries;
      [size_is(uNumEntries)] PCD_RECORD data[];
    } PCD_REC_ARRAY;
    
    typedef struct TST_REC_ARRAY_STRUC {
      unsigned long  uNumEntries;
      [size_is(uNumEntries)] TST_RECORD data[];
    } TST_REC_ARRAY;
    
    // Typed pointer definitions
    typedef [ptr] INT_8_ARRAY           *PINT_8_ARRAY;
    typedef [ptr] WORD_8_ARRAY       *PWORD_8_ARRAY;
    typedef [ptr] INT_16_ARRAY       *PINT_16_ARRAY;
    typedef [ptr] WORD_16_ARRAY      *PWORD_16_ARRAY;
    typedef [ptr] INT_32_ARRAY       *PINT_32_ARRAY;
    typedef [ptr] WORD_32_ARRAY      *PWORD_32_ARRAY;
    typedef [ptr] FLOAT_32_ARRAY     *PFLOAT_32_ARRAY;
    typedef [ptr] FLOAT_64_ARRAY     *PFLOAT_64_ARRAY;
    typedef [ptr] PCD_REC_ARRAY         *PPCD_REC_ARRAY;
    typedef [ptr] TST_REC_ARRAY         *PTST_REC_ARRAY;
    typedef [ptr] ARRAY_HEADER          *PARRAY_HEADER;
    
    // DATA_ITEM definition
    typedef union switch(unsigned long uType) pData {
        case /*SYS_TYPE_INT_8      */    0:   PINT_8_ARRAY       pItemInt8;
        case /*SYS_TYPE_UINT_8     */    1:   PWORD_8_ARRAY      pItemWord8;
        case /*SYS_TYPE_INT_16     */    2:   PINT_16_ARRAY      pItemInt16;
        case /*SYS_TYPE_UINT_16    */    3:   PWORD_16_ARRAY     pItemWord16;
        case /*SYS_TYPE_INT_32     */    4:   PINT_32_ARRAY      pItemInt32;
        case /*SYS_TYPE_UINT_32    */    5:   PWORD_32_ARRAY     pItemWord32;
        case /*SYS_TYPE_FLOAT_32   */    8:   PFLOAT_32_ARRAY    pItemFloat32;
        case /*SYS_TYPE_FLOAT_64   */    9:   PFLOAT_64_ARRAY    pItemFloat64;
        case /*SYS_TYPE_PCD_RECORD */  100:   PPCD_REC_ARRAY     pItemPCDRec;
        case /*SYS_TYPE_TST_RECORD */  101:   PTST_REC_ARRAY     pItemTSTRec;
        case /*Header              */65535:   PARRAY_HEADER       pHeader;
    //  default:                              PARRAY_HEADER       pHeader;
    } DATA_ITEM;
    
    typedef [ptr] DATA_ITEM *PDATA_ITEM;
    
    // DATA_PACKET definition
    typedef struct DATA_PACKET_STRUC {
      unsigned long uNumEntries;
      [size_is(uNumEntries)] DATA_ITEM     data[];
    } DATA_PACKET;
    
    // End data defitions
    
    // Begin Oakley test functions
    
    typedef [ptr] DATA_PACKET  *PDATA_PACKET;
    typedef [ptr,string] char  *STRING_PTR;
    typedef [ptr] TST_RECORD  *TST_RECORD_PTR;
    typedef TST_RECORD  TST_RECORD_ARR[];
    
    typedef struct OPT_PTR_STRUC {
      STRING_PTR  pszString1;
      STRING_PTR  pszString2;
      STRING_PTR  pszString3;
    } OPT_PTR_TEST;
    
    unsigned long ReadDatum([in] unsigned long uNumEntries,
                            [in, ref,size_is(uNumEntries)] STRING_PTR pszName[],
                            [out] PDATA_PACKET *pItem);
    
    unsigned long WriteDatum([in] unsigned long uNumEntries,
                             [in, ref,size_is(uNumEntries)] STRING_PTR pszName[],
                             [in,ref] DATA_PACKET *pItem);
    
    void PutStringsTogether([in, ref] OPT_PTR_TEST *pStringData,
                                      [out, ref] STRING_PTR *pszReturn);
    
    // Begin new test function with leading comma...
    unsigned long DoArrayOfStructures([in,out,ref] unsigned long *uNumItems,
                                       [out,ref,size_is(,*uNumItems)]
    TST_RECORD **ptestRec);
    // End new test function with leading comma...
    // This works in NT, but not here. The leading comma is suppposed to move
    // the sizeis attribute to the next level of indirection (the array of
    // structures). We're trying to achieve a pointer to
    // an array of structures, so in trying to better define that, I tried
    // this next line which gives me the incorrect syntax for pointer to conformant
    // array.
    // unsigned long DoArrayOfStructures([in,out,ref] unsigned long *uNumItems,
    //                                    [out,ref,size_is(*uNumItems)]
    TST_RECORD_A
    RR *ptestRec);
    
    void ClientMessage([in, string, ref] unsigned char *pszMessage);
    
    void ShutdownServer(void);
    
    
    // End Oakley test functions
    }
    
2187.3This should helpPTHRED::VIVENEYBob ViveneyMon Mar 24 1997 15:3334
I get idl compiler errors on both NT and Unix, which is expected.
What version of idl (idl -version) is running on NT that successfully
compiles this example?

To make this work I made the following changes in the idl file which makes
the default pointer full (to get rid of warnings), defined a TST_RECORD_ARR
as a structure containing a conformant array and size field, and the operation
returns an out parameter which is a pointer to TST_RECORD_ARR structure that
contains an array of TST_RECORDs. According to the comments in your original
post, I believe this is what you want. These changes allow me to compile the
idl file on both NT and DUnix with no errors and no warning.s

	.
	.
	.
    [
    pointer_default(ptr),
    uuid(0E8BDF58-B3BF-101A-A116-08002B2B8CD3),
    version(1.0)
    ]

	.
	.
	.
    typedef struct {
        unsigned long size;
        [size_is(size)] TST_RECORD data[];
    } TST_RECORD_ARR;
	.
	.
	.
    unsigned long DoArrayOfStructures(
        [out] TST_RECORD_ARR **ptestRec
    );