From 1e2152d7063820d428deac0300b5eb530c09df08 Mon Sep 17 00:00:00 2001 From: "val4%cornell.edu" Date: Tue, 2 Mar 1999 22:53:16 +0000 Subject: [PATCH] Divided JS.pm into two modules to break dependencies between jsperl.c support functions and functions exporsed from Perl. test.pl fails one of the tests -- need to look at that. Worspace build settings also changed. --- js/src/perlconnect/JS.dsp | 23 +++-- js/src/perlconnect/JS.pm | 127 ++---------------------- js/src/perlconnect/PerlConnect.dsp | 29 +++--- js/src/perlconnect/PerlConnect.dsw | 2 +- js/src/perlconnect/PerlConnectShell.dsp | 11 +- js/src/perlconnect/jsperl.c | 2 +- js/src/perlconnect/test.pl | 4 +- 7 files changed, 46 insertions(+), 152 deletions(-) diff --git a/js/src/perlconnect/JS.dsp b/js/src/perlconnect/JS.dsp index 73f7069a7a30..1ad34c93409c 100644 --- a/js/src/perlconnect/JS.dsp +++ b/js/src/perlconnect/JS.dsp @@ -1,5 +1,5 @@ # Microsoft Developer Studio Project File - Name="JS" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 5.00 +# Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 @@ -22,6 +22,7 @@ CFG=JS - Win32 Debug !MESSAGE # Begin Project +# PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe @@ -42,8 +43,8 @@ RSC=rc.exe # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c # ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32 +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe @@ -67,10 +68,10 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I ".." /I "$(PERL_SRC)" /I "$(PERL_SRC)\win32" /I "$(PERL_SRC)\win32\include" /D "_WINDOWS" /D "WIN32" /D "_DEBUG" /D "XP_PC" /YX /FD /c +# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "d:\opc\ns\js\ref" /I "$(PERL_SRC)" /I "$(PERL_SRC)\win32" /I "$(PERL_SRC)\win32\include" /I ".." /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "XP_PC" /YX /FD /c # SUBTRACT CPP /Gy /Fr -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32 +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 /win32 # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe @@ -78,7 +79,7 @@ BSC32=bscmake.exe # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 js32.lib PerlConnect.lib perl.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /out:"e:\perl\lib\auto\JS\JS.dll" /pdbtype:sept /libpath:"..\Debug" /libpath:"$(PERL_SRC)" +# ADD LINK32 js32.lib perl.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /out:"z:\livshits\src\perl\lib\auto\JS\JS.dll" /pdbtype:sept /libpath:"..\Debug" /libpath:"$(PERL_SRC)" !ENDIF @@ -94,5 +95,13 @@ SOURCE=.\JS.c SOURCE=.\JS.def # End Source File +# Begin Source File + +SOURCE=.\jsperl.c +# End Source File +# Begin Source File + +SOURCE=.\jsperlpvt.h +# End Source File # End Target # End Project diff --git a/js/src/perlconnect/JS.pm b/js/src/perlconnect/JS.pm index ab60bf508fac..21c6935b792a 100644 --- a/js/src/perlconnect/JS.pm +++ b/js/src/perlconnect/JS.pm @@ -15,133 +15,20 @@ # Reserved. # -# -# PerlConnect support package. -# - ############################################################################ -# PerlConnect support package. 8/3/98 2:50PM -# See README.html and JS.xs for information about this module. +# JS.pm is a Perl interface to JavaScript 3/2/99 5:23PM +# The packages implemented here include +# JS, JS::Runtime, JS::Contents, JS::Object +# See README.html for more information about this module. ############################################################################ package JS; +$VERSION = '0.03'; require Exporter; require DynaLoader; @ISA = qw(Exporter DynaLoader); -@EXPORT_OK = qw(perl_eval perl_resolve perl_call $js $ver); -$VERSION = '0.02'; -# version string for the interpreter -$ver = "[Perl Interpreter: Version $] compiled under $^O]\n"; -$DEBUG = undef; - -############################################################################ -# TODO: This will be added -############################################################################ -sub AUTOLOAD #7/28/98 8:24PM -{ - print "\nJS::AUTOLOAD: $AUTOLOAD, not implemented yet\n" if $DEBUG; -} ##AUTOLOAD - -############################################################################ -# Evaluates the parameter and returns the return result of eval() as a -# reference -############################################################################ -sub perl_eval #7/15/98 5:13PM -{ - my($stmt) = shift; - package main; - my(@_js) = eval($stmt); - package JS; - my($_js) = (scalar(@_js)==1)?$_js[0]:\@_js; - undef $js; - $js = (ref $_js) ? $_js: \$_js; - print "Failure in perl_call!" unless ref $js; -} ##perl_eval - -############################################################################ -# Calls the procesure passed as the first parameter and passes the rest of -# the arguments to it. The return result is converted to a reference as -# before -############################################################################ -sub perl_call #7/21/98 2:16PM -{ - my($proc) = shift; - my($_js); - - $proc =~ s/main:://g; - #print "Calling $proc\n"; - package main; - my(@_js) = &$proc(@_); - package JS; - #print "here: ", @_js, "\n"; - $_js = (scalar(@_js)==1)?$_js[0]:\@_js; - undef $js; - $js = (ref $_js) ? $_js: \$_js; - #print ref $js; - print "Failure in perl_call!" unless ref $js; -} ##perl_call - -############################################################################ -# Takes the first parameter and tries to retrieve this variable -############################################################################ -sub perl_resolve #7/22/98 10:08AM -{ - my($name) = shift; - my(@parts) = split('::', $name); - my($last_part) = pop(@parts); - - # variable lookup -- variables must start with $, @, or % - if($last_part =~ /^([\$\@\%])(.+)/){ - my($resolved_name) = "$1".join('::', @parts)."::$2"; - package main; - my(@_js) = eval($resolved_name); - package JS; - my($_js) = (scalar(@_js)==1)?$_js[0]:\@_js; - undef $js; - $js = (ref $_js) ? $_js: \$_js; - }else{ - $name =~ s/main:://g; - # if this function exists - # function -- set $js to 1 to indicate this - if(eval "return defined(&main::$name)"){ - print "function $name\n" if $DEBUG; - $js = 1; - # module - }else{ - print "must be a module\n" if $DEBUG; - $js=2; - return; - # defined module -- try to do an eval and check $@ to trap errors - # as a result, the module is automatically pre-use'd if it exists - $name =~ s/main:://g; - if(eval "use $name; return !(defined($@));"){ - $js = 2; - # o.w. this module is undefined - }else{ - $js = 3; - } - } - } -} ##perl_resolve - -############################################################################ -# Validates package name -############################################################################ -sub perl_validate_package #7/22/98 10:15AM -{ - print "perl_validate_package\n" if $DEBUG; - my($name) = shift; - print $name if $DEBUG; - $js = $name?1:undef; -} ##perl_validate_package - -# test procedure -sub c{ - print "da!\n" if wantarray; - print "Called!\n"; - return @_; -} +#@ISA = qw(JS); ############################################################################ # Duplicates JS::Context::new is a way @@ -238,4 +125,4 @@ sub AUTOLOAD #7/28/98 8:24PM &JS::boot(); -1; +1; \ No newline at end of file diff --git a/js/src/perlconnect/PerlConnect.dsp b/js/src/perlconnect/PerlConnect.dsp index f106210c9240..a8efdf4f39f0 100644 --- a/js/src/perlconnect/PerlConnect.dsp +++ b/js/src/perlconnect/PerlConnect.dsp @@ -1,5 +1,5 @@ # Microsoft Developer Studio Project File - Name="PerlConnect" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 5.00 +# Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 @@ -7,23 +7,22 @@ CFG=PerlConnect - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run -!MESSAGE +!MESSAGE !MESSAGE NMAKE /f "PerlConnect.mak". -!MESSAGE +!MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE +!MESSAGE !MESSAGE NMAKE /f "PerlConnect.mak" CFG="PerlConnect - Win32 Debug" -!MESSAGE +!MESSAGE !MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "PerlConnect - Win32 Release" (based on\ - "Win32 (x86) Dynamic-Link Library") -!MESSAGE "PerlConnect - Win32 Debug" (based on\ - "Win32 (x86) Dynamic-Link Library") -!MESSAGE +!MESSAGE +!MESSAGE "PerlConnect - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "PerlConnect - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE # Begin Project +# PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe @@ -44,8 +43,8 @@ RSC=rc.exe # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c # ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32 +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe @@ -83,7 +82,7 @@ LINK32=link.exe # ADD LINK32 js32.lib perl.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /subsystem:windows /dll /pdb:none /debug /machine:I386 /out:"PerlConnect.dll" /implib:"PerlConnect.lib" /libpath:"..\Debug" /libpath:"$(PERL_SRC)" # SUBTRACT LINK32 /verbose -!ENDIF +!ENDIF # Begin Target @@ -102,4 +101,4 @@ SOURCE=.\jsperl.h SOURCE=.\jsperlpvt.h # End Source File # End Target -# End Project +# End Project \ No newline at end of file diff --git a/js/src/perlconnect/PerlConnect.dsw b/js/src/perlconnect/PerlConnect.dsw index 0f45a629454c..86b2c1f62501 100644 --- a/js/src/perlconnect/PerlConnect.dsw +++ b/js/src/perlconnect/PerlConnect.dsw @@ -1,4 +1,4 @@ -Microsoft Developer Studio Workspace File, Format Version 5.00 +Microsoft Developer Studio Workspace File, Format Version 6.00 # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! ############################################################################### diff --git a/js/src/perlconnect/PerlConnectShell.dsp b/js/src/perlconnect/PerlConnectShell.dsp index a2c1745a5d7f..4e1add885356 100644 --- a/js/src/perlconnect/PerlConnectShell.dsp +++ b/js/src/perlconnect/PerlConnectShell.dsp @@ -1,5 +1,5 @@ # Microsoft Developer Studio Project File - Name="PerlConnectShell" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 5.00 +# Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 @@ -17,13 +17,12 @@ CFG=PerlConnectShell - Win32 Debug !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE -!MESSAGE "PerlConnectShell - Win32 Release" (based on\ - "Win32 (x86) Console Application") -!MESSAGE "PerlConnectShell - Win32 Debug" (based on\ - "Win32 (x86) Console Application") +!MESSAGE "PerlConnectShell - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "PerlConnectShell - Win32 Debug" (based on "Win32 (x86) Console Application") !MESSAGE # Begin Project +# PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe @@ -66,7 +65,7 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I ".." /I "$(PERL_SRC)" /D "_CONSOLE" /D "_MBCS" /D "PERLCONNECT" /D "JSFILE" /D "_WIN32" /D "XP_PC" /D "WIN32" /D "_DEBUG" /Fr /YX /FD /c +# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "D:\OPC\ns\js\ref" /I "D:\OPC\ns\js\ref\perlconnect" /I "$(PERL_SRC)" /I ".." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "PERLCONNECT" /D "JSFILE" /D "_WIN32" /D "XP_PC" /Fr /YX /FD /c # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe diff --git a/js/src/perlconnect/jsperl.c b/js/src/perlconnect/jsperl.c index fd887451d3c5..33425876daa2 100644 --- a/js/src/perlconnect/jsperl.c +++ b/js/src/perlconnect/jsperl.c @@ -171,7 +171,7 @@ PerlConstruct(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *v) JSObject *perlObject; JSBool ok; char *embedding[] = {"", "-e", "0"}; - char *t = "use JS qw(perl_eval perl_resolve perl_call $js $ver);"; + char *t = "use PerlConnect qw(perl_eval perl_resolve perl_call $js $ver);"; /* create a new interpreter */ perl = perl_alloc(); diff --git a/js/src/perlconnect/test.pl b/js/src/perlconnect/test.pl index aeac133d342f..41cb1fc642eb 100644 --- a/js/src/perlconnect/test.pl +++ b/js/src/perlconnect/test.pl @@ -26,7 +26,7 @@ use JS; # int ($js->eval("100") == 100) or warn "Wrong value returned from eval()"; # and string -($js->eval("'test string'") == 'test string') or warn "Wrong value returned from eval()"; +($js->eval("'test string'") eq 'test string') or warn "Wrong value returned from eval()"; # double TODO: double comparison? ($js->eval("1.25") == 1.25) or warn "Wrong value returned from eval()"; # more complex eval: @@ -53,4 +53,4 @@ delete $hash{bar}; # exists/clear (exists $hash{foo}) or warn "\$hash{foo} should exist"; undef %hash; -(!exists $hash{foo}) or warn "\$hash{foo} should be deleted"; +(!exists $hash{foo}) or warn "\$hash{foo} should be deleted"; \ No newline at end of file