[svn:mod_parrot] r262 - mod_parrot/trunk/lib/ModParrot/HLL

[email protected]
Newsgroups perl.cvs.mod_parrot
Message-ID <[email protected]>
Author: jhorwitz
Date: Thu Dec  6 20:28:11 2007
New Revision: 262

Added:
   mod_parrot/trunk/lib/ModParrot/HLL/plumhead.pir

Log:
added support for PHP using the Plumhead compiler


Added: mod_parrot/trunk/lib/ModParrot/HLL/plumhead.pir
==============================================================================
--- (empty file)
+++ mod_parrot/trunk/lib/ModParrot/HLL/plumhead.pir	Thu Dec  6 20:28:11 2007
@@ -0,0 +1,61 @@
+# $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.
+
+.namespace [ 'ModParrot::HLL::plumhead' ]
+
+.sub __onload :anon :load
+    load_bytecode 'languages/plumhead/plumhead.pbc'
+.end
+
+.sub run_php_file
+    .param string path
+
+    $P0 = compreg 'Plumhead'
+    $P1 = $P0.'evalfiles'(path)
+
+    .return($P1)
+.end
+
+#.sub _config
+
+# response handler
+.sub _handler
+    .param string php_file
+    .local pmc r
+    .local pmc ap_const
+    .local pmc pio
+    .local int status
+
+    # get the request_rec object
+    $P0 = get_class [ 'Apache'; 'RequestRec' ]
+    r = new $P0
+
+    php_file = r.'filename'()
+    pio = getstdout
+    push pio, "string"
+    status = run_php_file(php_file)
+    r.'content_type'("text/html")
+
+    # XXX limited to 1024 bytes of output for now
+    $S0 = read pio, 1024
+    $S1 = pop pio
+    r.'puts'($S0)
+
+    ap_const = get_root_global [ 'Apache'; 'Constants' ], 'ap_constants'
+    status = ap_const['OK']
+
+    .return(status)
+.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.