Author: jisom
Date: Sat Jan 14 09:07:29 2006
New Revision: 11181

Modified:
   trunk/examples/library/getopt_demo.pir
   trunk/languages/m4/src/m4.pir
   trunk/languages/tcl/tcl.pir
   trunk/languages/tcl/tcl.pir_template
   trunk/runtime/parrot/library/Getopt/Obj.pir
   trunk/src/embed.c
Log:
Make argv be an ResizableStringArray instead of SArray
Update Getopt/Obj.pir for the change, as well as m4.
Have tcl use Getopt/Obj.pir instead of Getopt/Long.pir


Modified: trunk/examples/library/getopt_demo.pir
==============================================================================
--- trunk/examples/library/getopt_demo.pir      (original)
+++ trunk/examples/library/getopt_demo.pir      Sat Jan 14 09:07:29 2006
@@ -53,21 +53,9 @@ This is executed when you call F<getopt_
 
   # Make a copy of argv, because this can easier be handled in get_options
   # TODO: eliminate need for copy
-  .local pmc argv_pmc_arr
-  argv_pmc_arr = new .ResizablePMCArray
-  .local int k, argc
-  k = 0
-  argc = argv
-  beginfor:
-    unless k < argc goto endfor
-    $P0 = shift argv
-    push argv_pmc_arr, $P0
-    inc k
-    goto beginfor
-  endfor:
 
   .local pmc opt
-  opt = getopts."get_options"(argv_pmc_arr)
+  opt = getopts."get_options"(argv)
 
   # Now we do what the passed options tell
   .local int is_defined
@@ -129,10 +117,10 @@ This is executed when you call F<getopt_
   .local int    cnt_other_args
   cnt_other_args = 0
   .local int num_other_args
-  num_other_args = argv_pmc_arr
+  num_other_args = argv
   goto CHECK_OTHER_ARG_LOOP
   REDO_OTHER_ARG_LOOP:
-    other_arg = argv_pmc_arr[cnt_other_args]
+    other_arg = argv[cnt_other_args]
     print "You have passed the additional argument: '"
     print other_arg
     print "'.\n"

Modified: trunk/languages/m4/src/m4.pir
==============================================================================
--- trunk/languages/m4/src/m4.pir       (original)
+++ trunk/languages/m4/src/m4.pir       Sat Jan 14 09:07:29 2006
@@ -120,23 +120,8 @@ Looks at the command line arguments and 
   # --reload-state=m4.frozen, string
   push getopts, "reload-state=s"
 
-  # Make a copy of argv, because this can easier be handled in get_options
-  # TODO: eliminate need for copy
-  .local pmc argv_pmc_arr
-  argv_pmc_arr = new .ResizablePMCArray
-  .local int k, argc
-  k = 0
-  argc = argv
-  beginfor:
-    unless k < argc goto endfor
-    $P0 = shift argv
-    push argv_pmc_arr, $P0
-    inc k
-    goto beginfor
-  endfor:
-
   .local pmc opt
-  opt = getopts."get_options"(argv_pmc_arr)
+  opt = getopts."get_options"(argv)
 
   # Now dow what the options want
   .local int is_defined
@@ -284,7 +269,7 @@ NO_UNIMPLEMENTED_OPTION:
 
   # check argc, we need at least one input file
   .local int argc
-  argc = argv_pmc_arr
+  argc = argv
   if argc >= 1 goto ARGC_IS_OK
     usage( program_name )
     end
@@ -323,9 +308,9 @@ PATH_SEARCH:
   # Name of the input file, usually with extension '.m4'
   .local string filename
 REDO_FILENAME_LOOP:
-  argc = argv_pmc_arr
+  argc = argv
   unless argc > 0 goto LAST_FILENAME_LOOP
-    filename = shift argv_pmc_arr
+    filename = shift argv
     push_file( filename, state )
     goto REDO_FILENAME_LOOP
 LAST_FILENAME_LOOP:

Modified: trunk/languages/tcl/tcl.pir
==============================================================================
--- trunk/languages/tcl/tcl.pir (original)
+++ trunk/languages/tcl/tcl.pir Sat Jan 14 09:07:29 2006
@@ -119,18 +119,13 @@ open_file: 
   tcl_interactive = 0
  
   .local pmc get_options
-  get_options = find_global "Getopt::Long", "get_options"
-  
-  .local pmc opt_spec
-  opt_spec = new .Array
-  opt_spec = 2
-  opt_spec[0] = "pir"
-  opt_spec[1] = "e=s"
+  get_options = new "Getopt::Obj"
+  push get_options, 'pir'
+  push get_options, 'e=s'
 
-  .local pmc opt, argv_clone
-  $P1 = shift argv # drop program name.
-  argv_clone = clone argv
-  opt = get_options(argv_clone, opt_spec)
+  .local pmc opt
+  $S1 = shift argv # drop program name.
+  opt = get_options."get_options"(argv)
 
   .local int dump_only, execute
   dump_only = defined opt["pir"]
@@ -141,7 +136,7 @@ open_file: 
   .local pmc handle
   .local string chunk,contents
 file:
-  filename = shift argv_clone
+  filename = shift argv
   $S1="<"
   handle = open filename, $S1
   $I0 = typeof handle

Modified: trunk/languages/tcl/tcl.pir_template
==============================================================================
--- trunk/languages/tcl/tcl.pir_template        (original)
+++ trunk/languages/tcl/tcl.pir_template        Sat Jan 14 09:07:29 2006
@@ -88,7 +88,7 @@ providing a compreg-compatible method.
 .sub __prepare_lib :load :anon
 
   # Load any dependant libraries.
-  load_bytecode "Getopt/Long.pir"
+  load_bytecode "Getopt/Obj.pir"
 
   #_load_grammar()
 

Modified: trunk/runtime/parrot/library/Getopt/Obj.pir
==============================================================================
--- trunk/runtime/parrot/library/Getopt/Obj.pir (original)
+++ trunk/runtime/parrot/library/Getopt/Obj.pir Sat Jan 14 09:07:29 2006
@@ -117,8 +117,6 @@ wanted.
 
 .sub get_options :method
     .param pmc argv
-    # This is necessary to get access to some vtable methods
-    makeResizable(argv)
     .local pmc return, spec
     .local int i, j, argc
     .local string name, long, short, arg, key, val
@@ -280,8 +278,8 @@ optelse:
 array:
     $P0 = return[name]
     $I0 = typeof $P0
-    unless $I0 != .ResizablePMCArray goto endif_5
-    $P0 = new .ResizablePMCArray
+    unless $I0 != .ResizableStringArray goto endif_5
+    $P0 = new .ResizableStringArray
 endif_5:
     push $P0, val
     goto endifelse
@@ -347,30 +345,6 @@ finish:
     .return(return)
 .end
 
-=item C<makeResizable(PMC argv)>
-
-Converts the given array into a ResizablePMCArray...  Morph won't morph it
-and some of the things we do to it need certain vtable methods available.
-
-=cut
-
-.sub makeResizable
-    .param pmc argv
-    .local pmc argnew
-    .local int k, argc
-    argnew = new .ResizablePMCArray
-    k = 0
-    argc = argv
-beginfor:
-    unless k < argc goto endfor
-    $S0 = shift argv
-    push argnew, $S0
-    inc k
-    goto beginfor
-endfor:
-    assign argv, argnew
-.end
-
 =item C<__push_string(STRING format)>
 
 A vtable method, invoked by e.g. C<push getopts, "foo|f=s">.  The format is as 
such.

Modified: trunk/src/embed.c
==============================================================================
--- trunk/src/embed.c   (original)
+++ trunk/src/embed.c   Sat Jan 14 09:07:29 2006
@@ -459,12 +459,11 @@ setup_argv(Interp *interpreter, int argc
     }
 
     /* XXX @ARGS should propably be a ResizableStringArray */
-    userargv = pmc_new_noinit(interpreter, enum_class_SArray);
+    userargv = pmc_new_noinit(interpreter, enum_class_ResizableStringArray);
     /* immediately anchor pmc to root set */
     VTABLE_set_pmc_keyed_int(interpreter, interpreter->iglobals,
             (INTVAL)IGLOBALS_ARGV_LIST, userargv);
     VTABLE_init(interpreter, userargv);
-    VTABLE_set_integer_native(interpreter, userargv, argc);
 
     for (i = 0; i < argc; i++) {
         /* Run through argv, adding everything to @ARGS. */

Reply via email to