[svn:mod_parrot] r289 - in mod_parrot/trunk: . lib lib/ModParrot t/response t/response/TestAPI

[email protected]
Newsgroups perl.cvs.mod_parrot
Message-ID <[email protected]>
Author: jhorwitz
Date: Sat Dec 22 07:50:48 2007
New Revision: 289

Added:
   mod_parrot/trunk/lib/ModParrot/Interpreter.pir
   mod_parrot/trunk/t/response/
   mod_parrot/trunk/t/response/TestAPI/
   mod_parrot/trunk/t/response/TestAPI/interpreter.pir
Modified:
   mod_parrot/trunk/Makefile.in
   mod_parrot/trunk/lib/mod_parrot.pir

Log:
add ModParrot;Interpreter for interpreter introspection


Modified: mod_parrot/trunk/Makefile.in
==============================================================================
--- mod_parrot/trunk/Makefile.in	(original)
+++ mod_parrot/trunk/Makefile.in	Sat Dec 22 07:50:48 2007
@@ -40,6 +40,7 @@
 	lib/Apache/Constants \
 	lib/APR/Table \
 	lib/mod_parrot \
+	lib/ModParrot/Interpreter \
 	lib/ModParrot/HLL/pir \
 	lib/ModParrot/HLL/perl6 \
 	lib/ModParrot/HLL/plumhead \

Added: mod_parrot/trunk/lib/ModParrot/Interpreter.pir
==============================================================================
--- (empty file)
+++ mod_parrot/trunk/lib/ModParrot/Interpreter.pir	Sat Dec 22 07:50:48 2007
@@ -0,0 +1,156 @@
+# $Id$
+
+# Copyright (c) 2007 Jeff Horwitz
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+=head1 NAME
+
+Interpreter.pir
+
+=head1 SYNOPSIS
+
+interp = new [ 'ModParrot'; Interpreter' ]
+
+=head1 DESCRIPTION
+
+Interpreter introspection for mod_parrot handlers.
+
+=head2 Methods
+
+=cut
+
+.namespace [ 'ModParrot'; 'Interpreter' ]
+
+.include 'interpinfo.pasm'
+.include 'iglobals.pasm'
+
+.sub _initialize :load
+    .local pmc interp_class
+
+    newclass interp_class, [ 'ModParrot'; 'Interpreter' ]
+
+    # a proto-object will allow HLLs to create new instances of this class
+    $P0 = get_hll_global 'Protomaker'
+    $P0.'new_proto'(interp_class)
+.end
+
+=over 4
+
+=item C<include_path()>
+
+=item C<include_path_str()>
+
+=over 4
+
+Returns Parrot's include search path as an array, or a colon-delimited string
+if using include_path_str().  Unless you really know what you're doing, you
+probably want to use C<library_path()> instead.
+
+=back
+
+=cut
+
+.sub include_path :method
+    .local pmc interp
+
+    interp = getinterp
+    $P0 = interp[.IGLOBALS_LIB_PATHS]
+    $P1 = $P0[0]
+    .return($P1)
+.end
+
+.sub include_path_str :method
+    .local pmc interp
+
+    interp = getinterp
+    $P0 = interp[.IGLOBALS_LIB_PATHS]
+    $P1 = $P0[0]
+    $S0 = join ':', $P1
+    .return($S0)
+.end
+
+=item C<library_path()>
+
+=item C<library_path_str()>
+
+=over 4
+
+Returns Parrot's library search path as an array, or a colon-delimited string
+if using library_path_str().
+
+=back
+
+=cut
+
+.sub library_path :method
+    .local pmc interp
+
+    interp = getinterp
+    $P0 = interp[.IGLOBALS_LIB_PATHS]
+    $P1 = $P0[1]
+    .return($P1)
+.end
+
+.sub library_path_str :method
+    .local pmc interp
+
+    interp = getinterp
+    $P0 = interp[.IGLOBALS_LIB_PATHS]
+    $P1 = $P0[1]
+    $S0 = join ':', $P1
+    .return($S0)
+.end
+
+=item C<dynext_path()>
+
+=item C<dynext_path_str()>
+
+=over 4
+
+Returns Parrot's dynamic extension search path as an array, or a
+colon-delimited string if using dynext_path_str().
+
+=back
+
+=cut
+
+.sub dynext_path :method
+    .local pmc interp
+
+    interp = getinterp
+    $P0 = interp[.IGLOBALS_LIB_PATHS]
+    $P1 = $P0[2]
+    .return($P1)
+.end
+
+.sub dynext_path_str :method
+    .local pmc interp
+
+    interp = getinterp
+    $P0 = interp[.IGLOBALS_LIB_PATHS]
+    $P1 = $P0[2]
+    $S0 = join ':', $P1
+    .return($S0)
+.end
+
+=cut
+
+=back
+
+=head1 AUTHOR
+
+Jeff Horwitz
+
+=cut
+

Modified: mod_parrot/trunk/lib/mod_parrot.pir
==============================================================================
--- mod_parrot/trunk/lib/mod_parrot.pir	(original)
+++ mod_parrot/trunk/lib/mod_parrot.pir	Sat Dec 22 07:50:48 2007
@@ -77,6 +77,7 @@
 
     # load required libraries
     load_bytecode 'Protoobject.pbc'
+    load_bytecode 'ModParrot/Interpreter.pbc'
     load_bytecode 'Apache/Constants.pbc'
     load_bytecode 'Apache/RequestRec.pbc'
     load_bytecode 'APR/Table.pbc'

Added: mod_parrot/trunk/t/response/TestAPI/interpreter.pir
==============================================================================
--- (empty file)
+++ mod_parrot/trunk/t/response/TestAPI/interpreter.pir	Sat Dec 22 07:50:48 2007
@@ -0,0 +1,73 @@
+# $Id$
+
+.namespace [ 'TestAPI::interpreter' ]
+
+.sub handler
+    .param pmc r
+    .local pmc mpi, ap_const
+    .local string results
+
+    ap_const = get_root_global [ 'Apache'; 'Constants' ], 'ap_constants'
+
+    r.'puts'("1..7\n")
+
+  START_1:
+    mpi = new [ 'ModParrot'; 'Interpreter' ]
+    $S0 = typeof mpi
+    if $S0 == "ModParrot;Interpreter" goto OK_1
+    r.'puts'("not ")
+  OK_1:
+    r.'puts'("ok 1 - object\n")
+
+  START_2:
+    $P0 = mpi.'include_path'()
+    $S0 = typeof $P0
+    if $S0 == "ResizableStringArray" goto OK_2
+    r.'puts'("not ")
+  OK_2:
+    r.'puts'("ok 2 - object\n")
+
+  START_3:
+    $P0 = mpi.'include_path_str'()
+    $S0 = typeof $P0
+    if $S0 == "String" goto OK_3
+    r.'puts'("not ")
+  OK_3:
+    r.'puts'("ok 3 - object\n")
+
+  START_4:
+    $P0 = mpi.'library_path'()
+    $S0 = typeof $P0
+    if $S0 == "ResizableStringArray" goto OK_4
+    r.'puts'("not ")
+  OK_4:
+    r.'puts'("ok 4 - object\n")
+
+  START_5:
+    $P0 = mpi.'library_path_str'()
+    $S0 = typeof $P0
+    if $S0 == "String" goto OK_5
+    r.'puts'("not ")
+  OK_5:
+    r.'puts'("ok 5 - object\n")
+
+  START_6:
+    $P0 = mpi.'dynext_path'()
+    $S0 = typeof $P0
+    if $S0 == "ResizableStringArray" goto OK_6
+    r.'puts'("not ")
+  OK_6:
+    r.'puts'("ok 6 - object\n")
+
+  START_r76:
+    $P0 = mpi.'dynext_path_str'()
+    $S0 = typeof $P0
+    if $S0 == "String" goto OK_7
+    r.'puts'("not ")
+  OK_7:
+    r.'puts'("ok 7 - object\n")
+
+    $I0 = ap_const['OK']
+    .return($I0)
+.end
+
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.