cvsuser     04/05/09 01:45:14

  Modified:    .        libnci.def
               src      nci_test.c
               t/pmc    nci.t
  Log:
  another nci test
  Courtesy of Chromatic <[EMAIL PROTECTED]>
  
  - fix test code (leo)
  
  Revision  Changes    Path
  1.6       +1 -0      parrot/libnci.def
  
  Index: libnci.def
  ===================================================================
  RCS file: /cvs/public/parrot/libnci.def,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -w -r1.5 -r1.6
  --- libnci.def        4 May 2004 07:48:49 -0000       1.5
  +++ libnci.def        9 May 2004 08:45:06 -0000       1.6
  @@ -23,3 +23,4 @@
       nci_pip
       nci_i_33
       nci_v_pii
  +    nci_p_iiii
  
  
  
  1.28      +23 -2     parrot/src/nci_test.c
  
  Index: nci_test.c
  ===================================================================
  RCS file: /cvs/public/parrot/src/nci_test.c,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -w -r1.27 -r1.28
  --- nci_test.c        6 May 2004 15:07:11 -0000       1.27
  +++ nci_test.c        9 May 2004 08:45:10 -0000       1.28
  @@ -48,6 +48,7 @@
   void nci_pip (int count, Rect_Like *rects);
   int nci_i_33 (int *double_me, int *triple_me);
   void nci_v_pii (Outer *my_data, int my_x, int my_y);
  +void * nci_p_iiii (int alpha, int beta, int gamma, int delta);
   
   double nci_dd(double d) {
       return d * 2.0;
  @@ -320,6 +321,26 @@
   {
        my_data->x         = my_x;
        my_data->nested->y = my_y;
  +}
  +
  +static int my_array[4];
  +void * nci_p_iiii (int alpha, int beta, int gamma, int delta)
  +{
  +
  +     static struct array_container
  +     {
  +             int   x;
  +             int *array;
  +     } container;
  +
  +     my_array[0] = alpha;
  +     my_array[1] = beta;
  +     my_array[2] = gamma;
  +     my_array[3] = delta;
  +
  +        container.x = 4;
  +        container.array = my_array;
  +     return &container;
   }
   
   #ifdef TEST
  
  
  
  1.43      +70 -2     parrot/t/pmc/nci.t
  
  Index: nci.t
  ===================================================================
  RCS file: /cvs/public/parrot/t/pmc/nci.t,v
  retrieving revision 1.42
  retrieving revision 1.43
  diff -u -w -r1.42 -r1.43
  --- nci.t     7 May 2004 10:33:41 -0000       1.42
  +++ nci.t     9 May 2004 08:45:14 -0000       1.43
  @@ -1,6 +1,6 @@
   #! perl -w
   # Copyright: 2001-2003 The Perl Foundation.  All Rights Reserved.
  -# $Id: nci.t,v 1.42 2004/05/07 10:33:41 leo Exp $
  +# $Id: nci.t,v 1.43 2004/05/09 08:45:14 leo Exp $
   
   =head1 NAME
   
  @@ -17,7 +17,7 @@
   
   =cut
   
  -use Parrot::Test tests => 33;
  +use Parrot::Test tests => 34;
   use Parrot::Config;
   
   SKIP: {
  @@ -1256,6 +1256,74 @@
   X: 1
   Y: 2
   2
  +OUTPUT
  +
  +output_is(<<'CODE', <<'OUTPUT', 'nested array in a struct');
  +.include "datatypes.pasm"
  +  set I0, 1
  +  set I1, 4
  +  set I2, 0
  +  set I3, 0
  +  set I4, 0
  +  set I5, 100
  +  set I6, 200
  +  set I7, 400
  +  set I8, 800
  +
  +  loadlib P1, "libnci"
  +  dlfunc P0, P1, "nci_p_iiii", "piiii"
  +  invoke
  +
  +  new  P6, .OrderedHash
  +  set  P6[ 'count' ], .DATATYPE_INT
  +  push P6, 0
  +  push P6, 0
  +
  +  new  P7, .OrderedHash
  +  set  P7[ 'array' ], .DATATYPE_INT
  +  push P7, 0
  +  push P7, 0
  +  new P8, .UnManagedStruct, P7
  +  # yes, the array within the struct has _4_ elements
  +  # but with an UnManagedStruct, you can't always know the amount beforehand
  +  set  P6[ 'array' ], .DATATYPE_STRUCT_PTR
  +  set P9, P6[-1]
  +  setprop P9, "_struct", P8
  +  push P6, 0
  +  push P6, 0
  +
  +  assign P5, P6
  +  set    I0, P5[ 'count' ]
  +
  +  print "Count: "
  +  print I0
  +  print "\n"
  +
  +  # now that we do know, update the UnManagedStruct appropriately
  +  set    P7[ 1 ], I0
  +  assign P5, P6
  +
  +  set I0, P5[1; 'array'; 0 ]
  +  set I1, P5[ 1;'array'; 1 ]
  +  set I2, P5[ 1;'array'; 2 ]
  +  set I3, P5[ 1;'array'; 3 ]
  +  print "0: "
  +  print I0
  +  print "\n1: "
  +  print I1
  +  print "\n2: "
  +  print I2
  +  print "\n3: "
  +  print I3
  +  print "\n"
  +
  +  end
  +CODE
  +Count: 4
  +0: 100
  +1: 200
  +2: 400
  +3: 800
   OUTPUT
   
   } # SKIP
  
  
  

Reply via email to