Compare commits
92 Commits
NETSCAPE_7
...
SpiderMonk
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cf6db2abdd | ||
|
|
e973ce2e64 | ||
|
|
a7c924107a | ||
|
|
dd04b345a9 | ||
|
|
196840e43e | ||
|
|
f6cc728f7c | ||
|
|
b176dfdf14 | ||
|
|
306aeb02c4 | ||
|
|
0689998baf | ||
|
|
f82e1076b8 | ||
|
|
36f1b44c5a | ||
|
|
a01beb172e | ||
|
|
87244f2387 | ||
|
|
bb1700203f | ||
|
|
04f1117a20 | ||
|
|
d7c8c29308 | ||
|
|
75045483df | ||
|
|
eb4284dfe3 | ||
|
|
5f08e5453f | ||
|
|
297a92fed5 | ||
|
|
430ba8a25f | ||
|
|
d4c9e5196e | ||
|
|
92181cdedc | ||
|
|
d42fcb5d9a | ||
|
|
a75043737c | ||
|
|
ad5a6cbd9c | ||
|
|
b73c93ce31 | ||
|
|
74ac28f85b | ||
|
|
3d5bbbd416 | ||
|
|
a659fad23a | ||
|
|
0534335359 | ||
|
|
d9d9f76b42 | ||
|
|
2ce568f036 | ||
|
|
2feaadaafd | ||
|
|
4142a81ec0 | ||
|
|
4eba0d77e0 | ||
|
|
347f0232ad | ||
|
|
2fd0ae6b14 | ||
|
|
87f42c5a2a | ||
|
|
692d4446f3 | ||
|
|
ff9e7d1ae5 | ||
|
|
6faae76e7e | ||
|
|
472ac2feab | ||
|
|
e295e36d9e | ||
|
|
bf8d9a56ec | ||
|
|
73b18ade9c | ||
|
|
6122209dca | ||
|
|
e5b764e983 | ||
|
|
84611771f9 | ||
|
|
95cb9f8bb7 | ||
|
|
b667832a93 | ||
|
|
f2a087fb61 | ||
|
|
744a8a6402 | ||
|
|
2c19d573b9 | ||
|
|
44e18f453b | ||
|
|
e8ee11cc30 | ||
|
|
f97650ff4d | ||
|
|
6398fd3969 | ||
|
|
64bc56432a | ||
|
|
9c0688e086 | ||
|
|
1e17c44fbd | ||
|
|
02486bc176 | ||
|
|
74736d0aa2 | ||
|
|
e62feeeeb5 | ||
|
|
25629114ff | ||
|
|
f0dc15e6f1 | ||
|
|
767e2ceb35 | ||
|
|
444c87e0f5 | ||
|
|
6995e6db68 | ||
|
|
036f73d888 | ||
|
|
017f8429a6 | ||
|
|
a548931dc2 | ||
|
|
2edfbcee56 | ||
|
|
a2eaa7c8b9 | ||
|
|
4d96b37aed | ||
|
|
be859bc4a8 | ||
|
|
ce4a0d7dfa | ||
|
|
c8d156d137 | ||
|
|
afc0070e3a | ||
|
|
6757eb6507 | ||
|
|
921da2b46b | ||
|
|
774b05a64e | ||
|
|
eb37b3b03b | ||
|
|
c33d03c991 | ||
|
|
03091e4c57 | ||
|
|
d3f6fcb126 | ||
|
|
0351cf31cb | ||
|
|
6d3eca4275 | ||
|
|
0d867e309d | ||
|
|
4eae6b10bd | ||
|
|
e2462a0ad5 | ||
|
|
ba07bbb4d5 |
@@ -1,80 +0,0 @@
|
||||
#!perl
|
||||
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (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.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Simon Fraser <sfraser@netscape.com>
|
||||
#
|
||||
|
||||
require 5.004;
|
||||
|
||||
use strict;
|
||||
|
||||
use Cwd;
|
||||
use Moz::BuildUtils;
|
||||
use Moz::BuildCore;
|
||||
|
||||
#-------------------------------------------------------------
|
||||
# Where have the build options gone?
|
||||
#
|
||||
# The various build flags have been centralized into one place.
|
||||
# The master list of options is in MozBuildFlags.txt. However,
|
||||
# you should never need to edit that file, or this one.
|
||||
#
|
||||
# To customize what gets built, or where to start the build,
|
||||
# edit the $prefs_file_name file in
|
||||
# System Folder:Preferences:Mozilla build prefs:
|
||||
# Documentation is provided in that file.
|
||||
#-------------------------------------------------------------
|
||||
|
||||
my($prefs_file_name) = "Mozilla opt build prefs";
|
||||
my($config_header_file_name) = ":mozilla:config:mac:DefinesOptions.h";
|
||||
|
||||
#-------------------------------------------------------------
|
||||
# hashes to hold build options
|
||||
#-------------------------------------------------------------
|
||||
my(%build);
|
||||
my(%options);
|
||||
my(%filepaths);
|
||||
my(%optiondefines);
|
||||
|
||||
# Hash of input files for this build. Eventually, there will be
|
||||
# input files for manifests, and projects too.
|
||||
my(%inputfiles) = (
|
||||
"buildflags", "MozillaBuildFlags.txt",
|
||||
"checkoutdata", "MozillaCheckoutList.txt",
|
||||
"buildprogress", "¥ Mozilla opt progress",
|
||||
"buildmodule", "MozillaBuildList.pm",
|
||||
"checkouttime", "Mozilla last checkout"
|
||||
);
|
||||
#-------------------------------------------------------------
|
||||
# end build hashes
|
||||
#-------------------------------------------------------------
|
||||
|
||||
# set the build root directory, which is the the dir above mozilla
|
||||
SetupBuildRootDir(":mozilla:build:mac:build_scripts");
|
||||
|
||||
# Set up all the flags on $main::, like DEBUG, CARBON etc.
|
||||
# Override the defaults using the preferences files.
|
||||
SetupDefaultBuildOptions(0, ":mozilla:dist:viewer:", $config_header_file_name);
|
||||
|
||||
my($do_checkout) = 0;
|
||||
my($do_build) = 1;
|
||||
|
||||
RunBuild($do_checkout, $do_build, \%inputfiles, $prefs_file_name);
|
||||
@@ -1,80 +0,0 @@
|
||||
#!perl
|
||||
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (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.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Simon Fraser <sfraser@netscape.com>
|
||||
#
|
||||
|
||||
require 5.004;
|
||||
|
||||
use strict;
|
||||
|
||||
use Cwd;
|
||||
use Moz::BuildUtils;
|
||||
use Moz::BuildCore;
|
||||
|
||||
#-------------------------------------------------------------
|
||||
# Where have the build options gone?
|
||||
#
|
||||
# The various build flags have been centralized into one place.
|
||||
# The master list of options is in MozBuildFlags.txt. However,
|
||||
# you should never need to edit that file, or this one.
|
||||
#
|
||||
# To customize what gets built, or where to start the build,
|
||||
# edit the $prefs_file_name file in
|
||||
# System Folder:Preferences:Mozilla build prefs:
|
||||
# Documentation is provided in that file.
|
||||
#-------------------------------------------------------------
|
||||
|
||||
my($prefs_file_name) = "Mozilla debug build prefs";
|
||||
my($config_header_file_name) = ":mozilla:config:mac:DefinesOptionsDebug.h";
|
||||
|
||||
#-------------------------------------------------------------
|
||||
# hashes to hold build options
|
||||
#-------------------------------------------------------------
|
||||
my(%build);
|
||||
my(%options);
|
||||
my(%filepaths);
|
||||
my(%optiondefines);
|
||||
|
||||
# Hash of input files for this build. Eventually, there will be
|
||||
# input files for manifests, and projects too.
|
||||
my(%inputfiles) = (
|
||||
"buildflags", "MozillaBuildFlags.txt",
|
||||
"checkoutdata", "MozillaCheckoutList.txt",
|
||||
"buildprogress", "¥ Mozilla debug progress",
|
||||
"buildmodule", "MozillaBuildList.pm",
|
||||
"checkouttime", "Mozilla last checkout"
|
||||
);
|
||||
#-------------------------------------------------------------
|
||||
# end build hashes
|
||||
#-------------------------------------------------------------
|
||||
|
||||
# set the build root directory, which is the the dir above mozilla
|
||||
SetupBuildRootDir(":mozilla:build:mac:build_scripts");
|
||||
|
||||
# Set up all the flags on $main::, like DEBUG, CARBON etc.
|
||||
# Override the defaults using the preferences files.
|
||||
SetupDefaultBuildOptions(1, ":mozilla:dist:viewer_debug:", $config_header_file_name);
|
||||
|
||||
my($do_pull) = 0; # overridden by flags and prefs
|
||||
my($do_build) = 1;
|
||||
|
||||
RunBuild($do_pull, $do_build, \%inputfiles, $prefs_file_name);
|
||||
@@ -1,595 +0,0 @@
|
||||
#!perl -w
|
||||
package Moz::BuildCore;
|
||||
|
||||
require 5.004;
|
||||
require Exporter;
|
||||
|
||||
use strict;
|
||||
use vars qw( @ISA @EXPORT );
|
||||
|
||||
# perl includes
|
||||
use Cwd;
|
||||
use POSIX;
|
||||
use Time::Local;
|
||||
use File::Basename;
|
||||
use LWP::Simple;
|
||||
|
||||
# homegrown
|
||||
use Moz::Moz;
|
||||
use Moz::Jar;
|
||||
use Moz::BuildFlags;
|
||||
use Moz::BuildUtils;
|
||||
use Moz::CodeWarriorLib;
|
||||
|
||||
# use MozillaBuildList; # eventually, this should go away, and be replaced by data input
|
||||
|
||||
|
||||
@ISA = qw(Exporter);
|
||||
@EXPORT = qw(
|
||||
RunBuild
|
||||
);
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// DoPrebuildCheck
|
||||
#//
|
||||
#// Check the build tools etc before running the build.
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub DoPrebuildCheck()
|
||||
{
|
||||
SanityCheckBuildOptions();
|
||||
|
||||
# launch codewarrior and persist its location. Have to call this before first
|
||||
# call to getCodeWarriorPath().
|
||||
my($ide_path_file) = $main::filepaths{"idepath"};
|
||||
$ide_path_file = full_path_to($ide_path_file);
|
||||
LaunchCodeWarrior($ide_path_file);
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// SanityCheckBuildOptions
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub SanityCheckBuildOptions()
|
||||
{
|
||||
my($bad_options) = 0;
|
||||
|
||||
# Jar options
|
||||
if (!$main::options{chrome_jars} && !$main::options{chrome_files})
|
||||
{
|
||||
print "Warning: Both \$options{chrome_jars} and \$options{chrome_files} are off. You won't get any chrome.\n";
|
||||
$bad_options = 1;
|
||||
}
|
||||
|
||||
if (!$main::options{chrome_jars} && $main::options{use_jars})
|
||||
{
|
||||
print "Warning: \$options{chrome_jars} is off but \$options{use_jars} is on. Your build won't run (expects jars, got files).\n";
|
||||
$bad_options = 1;
|
||||
}
|
||||
|
||||
if (!$main::options{chrome_files} && !$main::options{use_jars})
|
||||
{
|
||||
print "Warning: \$options{chrome_jars} is off but \$options{chrome_files} is on. Your build won't run (expects files, got jars).\n";
|
||||
$bad_options = 1;
|
||||
}
|
||||
|
||||
if ($main::options{ldap_experimental} && !$main::options{ldap})
|
||||
{
|
||||
print "Warning: \$options{ldap_experimental} is on but \$options{ldap} is off. LDAP experimental features will not be built.\n";
|
||||
$bad_options = 1;
|
||||
}
|
||||
|
||||
if ($main::options{wsp} && !$main::options{xmlextras})
|
||||
{
|
||||
print "Warning: \$options{wsp} is on but \$options{xmlextras} is off. wsp will not be built.\n";
|
||||
$bad_options = 1;
|
||||
}
|
||||
|
||||
if ($bad_options) {
|
||||
print "Build will start in 5 seconds. Press command-. to stop\n";
|
||||
|
||||
DelayFor(5);
|
||||
}
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// GenBuildSystemInfo
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
|
||||
sub GenBuildSystemInfo()
|
||||
{
|
||||
# always rebuild the configuration program.
|
||||
BuildProjectClean(":mozilla:build:mac:tools:BuildSystemInfo:BuildSystemInfo.mcp", "BuildSystemInfo");
|
||||
|
||||
# delete the configuration file.
|
||||
unlink(":mozilla:build:mac:BuildSystemInfo.pm");
|
||||
|
||||
# run the program.
|
||||
system(":mozilla:build:mac:BuildSystemInfo");
|
||||
|
||||
# wait for the file to be created.
|
||||
while (!(-e ":mozilla:build:mac:BuildSystemInfo.pm")) { WaitNextEvent(); }
|
||||
|
||||
# wait for BuildSystemInfo to finish, so that we see correct results.
|
||||
while (IsProcessRunning("BuildSystemInfo")) { WaitNextEvent(); }
|
||||
|
||||
# now, evaluate the contents of the file.
|
||||
open(F, ":mozilla:build:mac:BuildSystemInfo.pm");
|
||||
while (<F>) { eval; }
|
||||
close(F);
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// Make library aliases
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
|
||||
sub MakeLibAliases()
|
||||
{
|
||||
my($dist_dir) = GetBinDirectory();
|
||||
|
||||
#// ProfilerLib
|
||||
if ($main::PROFILE)
|
||||
{
|
||||
my($profilerlibpath) = Moz::CodeWarriorLib::getCodeWarriorPath("MacOS Support:Profiler:Profiler Common:ProfilerLib");
|
||||
MakeAlias("$profilerlibpath", "$dist_dir"."Essential Files:");
|
||||
}
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// ConfigureBuildSystem
|
||||
#//
|
||||
#// defines some build-system configuration variables.
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub ConfigureBuildSystem()
|
||||
{
|
||||
#// In the future, we may want to do configurations based on the actual build system itself.
|
||||
#// GenBuildSystemInfo();
|
||||
|
||||
#// For now, if we discover a newer header file than existed in Universal Interfaces 3.2,
|
||||
#// we'll assume that 3.3 or later is in use.
|
||||
my($universal_interfaces) = Moz::CodeWarriorLib::getCodeWarriorPath("MacOS Support:Universal:Interfaces:CIncludes:");
|
||||
if (-e ($universal_interfaces . "ControlDefinitions.h")) {
|
||||
$main::UNIVERSAL_INTERFACES_VERSION = 0x0330;
|
||||
}
|
||||
|
||||
#// Rename IC SDK folder in the Mac OS Support folder
|
||||
my($ic_sdk_folder) = Moz::CodeWarriorLib::getCodeWarriorPath("MacOS Support:ICProgKit2.0.2");
|
||||
if( -e $ic_sdk_folder)
|
||||
{
|
||||
my($new_ic_folder_name) = Moz::CodeWarriorLib::getCodeWarriorPath("MacOS Support:(ICProgKit2.0.2)");
|
||||
rename ($ic_sdk_folder, $new_ic_folder_name);
|
||||
# note that CodeWarrior doesn't descend into folders with () the name
|
||||
print "Mozilla no longer needs the Internet Config SDK to build:\n Renaming the 'ICProgKit2.0.2' folder to '(ICProgKit2.0.2)'\n";
|
||||
}
|
||||
|
||||
printf("UNIVERSAL_INTERFACES_VERSION = 0x%04X\n", $main::UNIVERSAL_INTERFACES_VERSION);
|
||||
|
||||
# alias required CodeWarrior libs into the Essential Files folder (only the Profiler lib now)
|
||||
MakeLibAliases();
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// CheckOutModule. Takes variable number of args; first two are required
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub CheckOutModule($$$$)
|
||||
{
|
||||
my($session, $module, $revision, $date) = @_;
|
||||
|
||||
my($result) = $session->checkout($module, $revision, $date);
|
||||
|
||||
# result of 1 is success
|
||||
if ($result) { return; }
|
||||
|
||||
my($checkout_err) = $session->getLastError();
|
||||
if ($checkout_err == 708) {
|
||||
die "Error: Checkout was cancelled.\n";
|
||||
} elsif ($checkout_err == 911) {
|
||||
die "Error: CVS session settings are incorrect. Check your password, and the CVS root settings.\n";
|
||||
} elsif ($checkout_err == 703) {
|
||||
die "Error: CVS checkout failed. Unknown module, unknown tag, bad username, or other CVS error.\n";
|
||||
} elsif ($checkout_err == 711) {
|
||||
print "Checkout of '$module' failed.\n";
|
||||
}
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// getScriptFolder
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub getScriptFolder()
|
||||
{
|
||||
return dirname($0);
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// getScriptFolder
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub get_url_contents($)
|
||||
{
|
||||
my($url) = @_;
|
||||
|
||||
my($url_contents) = LWP::Simple::get($url);
|
||||
$url_contents =~ s/\r\n/\n/g; # normalize linebreaks
|
||||
$url_contents =~ s/\r/\n/g; # normalize linebreaks
|
||||
return $url_contents;
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// get_files_from_content
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub uniq
|
||||
{
|
||||
my $lastval;
|
||||
grep(($_ ne $lastval, $lastval = $_)[$[], @_);
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// get_files_from_content
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub get_files_from_content($)
|
||||
{
|
||||
my($content) = @_;
|
||||
|
||||
my(@jscalls) = grep (/return js_file_menu[^{]*/, split(/\n/, $content));
|
||||
my $i;
|
||||
|
||||
for ($i = 0; $i < @jscalls ; $i++)
|
||||
{
|
||||
$jscalls[$i] =~ s/.*\(|\).*//g;
|
||||
my(@callparams) = split(/,/, $jscalls[$i]);
|
||||
my ($repos, $dir, $file, $rev) = grep(s/['\s]//g, @callparams);
|
||||
$jscalls[$i] = "$dir/$file";
|
||||
}
|
||||
|
||||
&uniq(sort(@jscalls));
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// getLastUpdateTime
|
||||
#//
|
||||
#// Get the last time we updated. Return 0 on failure
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub getLastUpdateTime($)
|
||||
{
|
||||
my($timestamp_file) = @_;
|
||||
|
||||
my($time_string);
|
||||
|
||||
local(*TIMESTAMP_FILE);
|
||||
unless (open(TIMESTAMP_FILE, "< $timestamp_file")) { return 0; }
|
||||
|
||||
while (<TIMESTAMP_FILE>)
|
||||
{
|
||||
my($line) = $_;
|
||||
chomp($line);
|
||||
|
||||
# ignore comments and empty lines
|
||||
if ($line =~ /^\#/ || $line =~ /^\s*$/) {
|
||||
next;
|
||||
}
|
||||
|
||||
$time_string = $line;
|
||||
}
|
||||
|
||||
# get the epoch seconds
|
||||
my($last_update_secs) = $time_string;
|
||||
$last_update_secs =~ s/\s#.+$//;
|
||||
|
||||
print "FAST_UPDATE found that you last updated at ".localtime($last_update_secs)."\n";
|
||||
|
||||
# how long ago was this, in hours?
|
||||
my($gm_now) = time();
|
||||
my($update_hours) = 1 + ceil(($gm_now - $last_update_secs) / (60 * 60));
|
||||
|
||||
return $update_hours;
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// saveCheckoutTimestamp
|
||||
#//
|
||||
#// Create a file on disk containing the current time. Param is time(), which is an Epoch seconds
|
||||
#// (and therefore in GMT).
|
||||
#//
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub saveCheckoutTimestamp($$)
|
||||
{
|
||||
my($gm_secs, $timestamp_file) = @_;
|
||||
|
||||
local(*TIMESTAMP_FILE);
|
||||
open(TIMESTAMP_FILE, ">$timestamp_file") || die "Failed to open $timestamp_file\n";
|
||||
print(TIMESTAMP_FILE "# time of last checkout or update, in GMT. Used by FAST_UPDATE\n");
|
||||
print(TIMESTAMP_FILE "$gm_secs \# around ".localtime()." local time\n");
|
||||
close(TIMESTAMP_FILE);
|
||||
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// FastUpdate
|
||||
#//
|
||||
#// Use Bonsai url data to update only those dirs which have new files
|
||||
#//
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub FastUpdate($$)
|
||||
{
|
||||
my($modules, $timestamp_file) = @_; # list of modules to check out
|
||||
|
||||
my($num_hours) = getLastUpdateTime($timestamp_file);
|
||||
if ($num_hours == 0 || $num_hours > 170) {
|
||||
print "Can't fast_update; last update was too long ago, or never. Doing normal checkout.\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
print "Doing fast update, pulling files changed in the last $num_hours hours\n";
|
||||
|
||||
my($cvsfile) = AskAndPersistFile($main::filepaths{"sessionpath"});
|
||||
my($session) = Moz::MacCVS->new( $cvsfile );
|
||||
unless (defined($session)) { die "Error: Checkout aborted. Cannot create session file: $session" }
|
||||
|
||||
# activate MacCVS
|
||||
ActivateApplication('Mcvs');
|
||||
|
||||
my($checkout_start_time) = time();
|
||||
|
||||
#print "Time now is $checkout_start_time ($checkout_start_time + 0)\n";
|
||||
|
||||
my($this_co);
|
||||
foreach $this_co (@$modules)
|
||||
{
|
||||
my($module, $revision, $date) = ($this_co->[0], $this_co->[1], $this_co->[2]);
|
||||
|
||||
# assume that things pulled by date wont change
|
||||
if ($date ne "") {
|
||||
print "$module is pulled by date, so ignoring in FastUpdate.\n";
|
||||
next;
|
||||
}
|
||||
|
||||
my($search_type) = "hours";
|
||||
my($min_date) = "";
|
||||
my($max_date) = "";
|
||||
my($url) = "http://bonsai.mozilla.org/cvsquery.cgi?treeid=default&module=${module}&branch=${revision}&branchtype=match&dir=&file=&filetype=match&who=&whotype=match&sortby=Date&hours=${num_hours}&date=${search_type}&mindate=${min_date}&maxdate=${max_date}&cvsroot=%2Fcvsroot";
|
||||
|
||||
if ($revision eq "") {
|
||||
print "Getting list of checkins to $module from Bonsai...\n";
|
||||
} else {
|
||||
print "Getting list of checkins to $module on branch $revision from Bonsai...\n";
|
||||
}
|
||||
my(@files) = &get_files_from_content(&get_url_contents($url));
|
||||
|
||||
if ($#files > 0)
|
||||
{
|
||||
my(@cvs_co_list);
|
||||
|
||||
my($co_file);
|
||||
foreach $co_file (@files)
|
||||
{
|
||||
print "Updating $co_file\n";
|
||||
push(@cvs_co_list, $co_file);
|
||||
}
|
||||
|
||||
my($result) = $session->update($revision, \@cvs_co_list);
|
||||
# result of 1 is success
|
||||
if (!$result) { die "Error: Fast update failed\n"; }
|
||||
} else {
|
||||
print "No files in this module changed\n";
|
||||
}
|
||||
}
|
||||
|
||||
saveCheckoutTimestamp($checkout_start_time, $timestamp_file);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// Checkout
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub CheckoutModules($$$)
|
||||
{
|
||||
my($modules, $pull_date, $timestamp_file) = @_; # list of modules to check out
|
||||
|
||||
my($start_time) = TimeStart();
|
||||
|
||||
# assertRightDirectory();
|
||||
my($cvsfile) = AskAndPersistFile($main::filepaths{"sessionpath"});
|
||||
my($session) = Moz::MacCVS->new( $cvsfile );
|
||||
unless (defined($session)) { die "Error: Checkout aborted. Cannot create session file: $session" }
|
||||
|
||||
my($checkout_start_time) = time();
|
||||
|
||||
# activate MacCVS
|
||||
ActivateApplication('Mcvs');
|
||||
|
||||
my($this_co);
|
||||
foreach $this_co (@$modules)
|
||||
{
|
||||
my($module, $revision, $date) = ($this_co->[0], $this_co->[1], $this_co->[2]);
|
||||
if ($date eq "") {
|
||||
$date = $pull_date;
|
||||
}
|
||||
CheckOutModule($session, $module, $revision, $date);
|
||||
# print "Checking out $module with ref $revision, date $date\n";
|
||||
}
|
||||
|
||||
saveCheckoutTimestamp($checkout_start_time, $timestamp_file);
|
||||
TimeEnd($start_time, "Checkout");
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// ReadCheckoutModulesFile
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub ReadCheckoutModulesFile($$)
|
||||
{
|
||||
my($modules_file, $co_list) = @_;
|
||||
|
||||
my($checkout_file) = getScriptFolder().":".$modules_file;
|
||||
local(*CHECKOUT_FILE);
|
||||
open(CHECKOUT_FILE, "< $checkout_file") || die "Error: failed to open checkout list $checkout_file\n";
|
||||
while (<CHECKOUT_FILE>)
|
||||
{
|
||||
my($line) = $_;
|
||||
chomp($line);
|
||||
|
||||
# ignore comments and empty lines
|
||||
if ($line =~ /^\#/ || $line =~ /^\s*$/) {
|
||||
next;
|
||||
}
|
||||
|
||||
my(@cvs_co) = ["", "", ""];
|
||||
|
||||
my($module, $revision, $date) = (0, 1, 2);
|
||||
|
||||
if ($line =~ /\s*([^#,\s]+)\s*\,\s*([^#,\s]+)\s*\,\s*([^#]+)/)
|
||||
{
|
||||
@cvs_co[$module] = $1;
|
||||
@cvs_co[$revision] = $2;
|
||||
@cvs_co[$date] = $3;
|
||||
}
|
||||
elsif ($line =~ /\s*([^#,\s]+)\s*\,\s*([^#,\s]+)\s*(#.+)?/)
|
||||
{
|
||||
@cvs_co[$module] = $1;
|
||||
@cvs_co[$revision] = $2;
|
||||
}
|
||||
elsif ($line =~ /\s*([^#,\s]+)\s*\,\s*,\s*([^#,]+)/)
|
||||
{
|
||||
@cvs_co[$module] = $1;
|
||||
@cvs_co[$date] = $2;
|
||||
}
|
||||
elsif ($line =~ /\s*([^#,\s]+)/)
|
||||
{
|
||||
@cvs_co[$module] = $1;
|
||||
}
|
||||
else
|
||||
{
|
||||
die "Error: unrecognized line '$line' in $modules_file\n";
|
||||
}
|
||||
|
||||
# strip surrounding space from date
|
||||
@cvs_co[$date] =~ s/^\s*|\s*$//g;
|
||||
|
||||
# print "Going to check out '@cvs_co[$module]', '@cvs_co[$revision]', '@cvs_co[$date]'\n";
|
||||
push(@$co_list, \@cvs_co);
|
||||
}
|
||||
|
||||
close(CHECKOUT_FILE);
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// PullFromCVS
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub PullFromCVS($$)
|
||||
{
|
||||
unless ( $main::build{pull} ) { return; }
|
||||
|
||||
my($modules_file, $timestamp_file) = @_;
|
||||
|
||||
StartBuildModule("pull");
|
||||
|
||||
my(@cvs_co_list);
|
||||
ReadCheckoutModulesFile($modules_file, \@cvs_co_list);
|
||||
|
||||
if ($main::FAST_UPDATE && $main::options{pull_by_date})
|
||||
{
|
||||
die "Error: you can't use FAST_UPDATE if you are pulling by date.\n";
|
||||
}
|
||||
|
||||
my($did_fast_update) = $main::FAST_UPDATE && FastUpdate(\@cvs_co_list, $timestamp_file);
|
||||
if (!$did_fast_update)
|
||||
{
|
||||
my($pull_date) = "";
|
||||
if ($main::options{pull_by_date})
|
||||
{
|
||||
# acceptable CVS date formats are (in local time):
|
||||
# ISO8601 (e.g. "1972-09-24 20:05") and Internet (e.g. "24 Sep 1972 20:05").
|
||||
# Perl's localtime() string format also seems to work.
|
||||
$pull_date = localtime().""; # force string interp.
|
||||
print "Pulling by date $pull_date\n";
|
||||
}
|
||||
|
||||
CheckoutModules(\@cvs_co_list, $pull_date, $timestamp_file);
|
||||
}
|
||||
|
||||
EndBuildModule("pull");
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// RunBuild
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub RunBuild($$$$)
|
||||
{
|
||||
my($do_pull, $do_build, $input_files, $build_prefs) = @_;
|
||||
|
||||
InitBuildProgress($input_files->{"buildprogress"});
|
||||
|
||||
# if we are pulling, we probably want to do a full build, so clear the build progress
|
||||
if ($do_pull) {
|
||||
ClearBuildProgress();
|
||||
}
|
||||
|
||||
# read local prefs, and the build progress file, and set flags to say what to build
|
||||
SetupBuildParams(\%main::build,
|
||||
\%main::options,
|
||||
\%main::optiondefines,
|
||||
\%main::filepaths,
|
||||
$input_files->{"buildflags"},
|
||||
$build_prefs);
|
||||
|
||||
# If we were told to pull, make sure we do, overriding prefs etc.
|
||||
if ($do_pull)
|
||||
{
|
||||
$main::build{"pull"} = 1;
|
||||
}
|
||||
|
||||
# transfer this flag
|
||||
$CodeWarriorLib::CLOSE_PROJECTS_FIRST = $main::CLOSE_PROJECTS_FIRST;
|
||||
|
||||
# setup the build log
|
||||
SetupBuildLog($main::filepaths{"buildlogfilepath"}, $main::USE_TIMESTAMPED_LOGS);
|
||||
StopForErrors();
|
||||
|
||||
if ($main::LOG_TO_FILE) {
|
||||
RedirectOutputToFile($main::filepaths{"scriptlogfilepath"});
|
||||
}
|
||||
|
||||
# run a pre-build check to see that the tools etc are in order
|
||||
DoPrebuildCheck();
|
||||
|
||||
# do the pull
|
||||
PullFromCVS($input_files->{"checkoutdata"}, $input_files->{"checkouttime"});
|
||||
|
||||
unless ($do_build) { return; }
|
||||
|
||||
my($build_start) = TimeStart();
|
||||
|
||||
# check the build environment
|
||||
ConfigureBuildSystem();
|
||||
|
||||
# here we load and call methods in the build module indirectly.
|
||||
# we have to use indirection because the build module can be named
|
||||
# differently for different builds.
|
||||
chdir(dirname($0)); # change to the script dir
|
||||
my($build_module) = $input_files->{"buildmodule"};
|
||||
# load the build module
|
||||
require $build_module;
|
||||
{ # scope for no strict 'refs'
|
||||
no strict 'refs';
|
||||
|
||||
my($package_name) = $build_module;
|
||||
$package_name =~ s/\.pm$//;
|
||||
|
||||
chdir($main::MOZ_SRC);
|
||||
&{$package_name."::BuildDist"}();
|
||||
|
||||
chdir($main::MOZ_SRC);
|
||||
&{$package_name."::BuildProjects"}();
|
||||
}
|
||||
|
||||
# the build finished, so clear the build progress state
|
||||
ClearBuildProgress();
|
||||
|
||||
TimeEnd($build_start, "Build");
|
||||
print "Build complete\n";
|
||||
}
|
||||
|
||||
1;
|
||||
@@ -1,425 +0,0 @@
|
||||
#!perl -w
|
||||
package Moz::BuildFlags;
|
||||
|
||||
require 5.004;
|
||||
require Exporter;
|
||||
|
||||
# Package that attempts to read a file from the Preferences folder,
|
||||
# and get build settings out of it
|
||||
|
||||
use strict;
|
||||
use Exporter;
|
||||
|
||||
use Cwd;
|
||||
use File::Basename;
|
||||
|
||||
use Moz::Moz;
|
||||
use Moz::Prefs;
|
||||
|
||||
use vars qw(@ISA @EXPORT);
|
||||
|
||||
@ISA = qw(Exporter);
|
||||
@EXPORT = qw(
|
||||
SetupBuildParams
|
||||
InitBuildProgress
|
||||
WriteBuildProgress
|
||||
ClearBuildProgress
|
||||
ReadBuildProgress
|
||||
);
|
||||
|
||||
|
||||
my(@build_flags);
|
||||
my(@options_flags);
|
||||
my(@filepath_flags);
|
||||
|
||||
my(%arrays_list) = (
|
||||
"build_flags", \@build_flags,
|
||||
"options_flags", \@options_flags,
|
||||
"filepath_flags", \@filepath_flags
|
||||
);
|
||||
|
||||
my($progress_file) = "¥ÊBuild progress";
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# appendArrayFlag
|
||||
#
|
||||
# Set a flag in the array
|
||||
#-------------------------------------------------------------------------------
|
||||
sub appendArrayFlag(@)
|
||||
{
|
||||
my($array_name) = shift;
|
||||
my($setting) = shift;
|
||||
my($value) = shift;
|
||||
|
||||
my(@optional_values);
|
||||
foreach (@_) {
|
||||
push(@optional_values, $_);
|
||||
}
|
||||
|
||||
my(@this_flag) = [$setting, $value, @optional_values];
|
||||
my($flags_array) = $arrays_list{$array_name};
|
||||
if ($flags_array)
|
||||
{
|
||||
push(@{$flags_array}, @this_flag) || die "Failed to append\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
die "Error: unknown build flags array $array_name\n";
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# readFlagsFile
|
||||
#
|
||||
# Read the file of build flags from disk. File path is relative to the
|
||||
# script directory.
|
||||
#-------------------------------------------------------------------------------
|
||||
sub readFlagsFile($)
|
||||
{
|
||||
my($flags_file) = @_;
|
||||
|
||||
my($file_path) = $0;
|
||||
$file_path =~ s/[^:]+$/$flags_file/;
|
||||
|
||||
print "Reading build flags from '$file_path'\n";
|
||||
|
||||
local(*FLAGS_FILE);
|
||||
open(FLAGS_FILE, "< $file_path") || die "Error: failed to open flags file $file_path\n";
|
||||
|
||||
my($cur_array) = "";
|
||||
|
||||
while(<FLAGS_FILE>)
|
||||
{
|
||||
my($line) = $_;
|
||||
chomp($line);
|
||||
|
||||
# ignore comments and empty lines
|
||||
if ($line =~ /^\#/ || $line =~ /^\s*$/) {
|
||||
next;
|
||||
}
|
||||
|
||||
# 1-word line, probably array name
|
||||
if ($line =~ /^([^#\s]+)\s*$/)
|
||||
{
|
||||
$cur_array = $1;
|
||||
next;
|
||||
}
|
||||
elsif ($line =~ /^([^#\s]+)\s+\"(.+)\"(\s+#.+)?$/) # quoted option, possible comment
|
||||
{
|
||||
my($flag) = $1;
|
||||
my($setting) = $2;
|
||||
|
||||
appendArrayFlag($cur_array, $flag, $setting);
|
||||
}
|
||||
elsif ($line =~ /^([^#\s]+)((\s+[^#\s]+)+)(\s+#.+)?$/) # multiple word line, possible comment
|
||||
{
|
||||
my($flag) = $1;
|
||||
|
||||
appendArrayFlag($cur_array, $flag, split(' ', $2));
|
||||
}
|
||||
else
|
||||
{
|
||||
die "Error: unknown build flag at '$line'\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
close(FLAGS_FILE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# flagsArrayToHash
|
||||
#
|
||||
# Utility routine to migrate flag from a 2D array to a hash, where
|
||||
# item[n][0] is the hash entry name, and item[n][1] is the hash entry value.
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
sub flagsArrayToHash($$)
|
||||
{
|
||||
my($src_array, $dest_hash) = @_;
|
||||
|
||||
my($item);
|
||||
foreach $item (@$src_array)
|
||||
{
|
||||
$dest_hash->{$item->[0]} = $item->[1];
|
||||
}
|
||||
}
|
||||
|
||||
#-----------------------------------------------
|
||||
# printHash
|
||||
#
|
||||
# Utility routine to print a hash
|
||||
#-----------------------------------------------
|
||||
sub printHash($)
|
||||
{
|
||||
my($hash_ref) = @_;
|
||||
|
||||
print "Printing hash:\n";
|
||||
|
||||
my($key, $value);
|
||||
|
||||
while (($key, $value) = each (%$hash_ref))
|
||||
{
|
||||
print " $key $value\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#-----------------------------------------------
|
||||
# printBuildArray
|
||||
#
|
||||
# Utility routine to print a 2D array
|
||||
#-----------------------------------------------
|
||||
sub printBuildArray($)
|
||||
{
|
||||
my($build_array) = @_;
|
||||
|
||||
my($entry);
|
||||
foreach $entry (@$build_array)
|
||||
{
|
||||
print "$entry->[0] = $entry->[1]\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# SetBuildFlags
|
||||
#-------------------------------------------------------------------------------
|
||||
sub SetBuildFlags($)
|
||||
{
|
||||
my($build) = @_;
|
||||
|
||||
flagsArrayToHash(\@build_flags, $build);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# SetBuildOptions
|
||||
#-------------------------------------------------------------------------------
|
||||
sub SetBuildOptions($)
|
||||
{
|
||||
my($options) = @_;
|
||||
|
||||
flagsArrayToHash(\@options_flags, $options);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# SetFilepathFlags
|
||||
#-------------------------------------------------------------------------------
|
||||
sub SetFilepathFlags($)
|
||||
{
|
||||
my($filepath) = @_;
|
||||
|
||||
flagsArrayToHash(\@filepath_flags, $filepath);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# SetOptionDefines
|
||||
#-------------------------------------------------------------------------------
|
||||
sub SetOptionDefines($)
|
||||
{
|
||||
my($optiondefines) = @_;
|
||||
|
||||
foreach my $entry (@options_flags)
|
||||
{
|
||||
if (defined($entry->[2])) {
|
||||
$optiondefines->{$entry->[0]}{$entry->[2]} = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# PropagateAllFlags
|
||||
#-------------------------------------------------------------------------------
|
||||
sub PropagateAllFlags($)
|
||||
{
|
||||
my($build_array) = @_;
|
||||
|
||||
# if "all" is set, set all the flags to 1
|
||||
unless ($build_array->[0][0] eq "all") { die "Error: 'all' must come first in the flags array\n"; }
|
||||
|
||||
if ($build_array->[0][1] == 1)
|
||||
{
|
||||
my($index);
|
||||
foreach $index (@$build_array)
|
||||
{
|
||||
$index->[1] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// _getBuildProgressFile
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub _getBuildProgressFile()
|
||||
{
|
||||
return $progress_file;
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// setBuildProgressStart
|
||||
#//
|
||||
#// This automagically sets $build{"all"} to 0
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub setBuildProgressStart($$)
|
||||
{
|
||||
my($build_array, $name) = @_;
|
||||
|
||||
my($index);
|
||||
foreach $index (@$build_array)
|
||||
{
|
||||
$index->[1] = 0;
|
||||
if ($index->[0] eq $name) {
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
print "Building from module after $name, as specified by build progress\n";
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// InitBuildProgress
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub InitBuildProgress($)
|
||||
{
|
||||
my($prog_file) = @_;
|
||||
if ($prog_file ne "") {
|
||||
$progress_file = full_path_to($prog_file);
|
||||
print "Writing build progress to $progress_file\n";
|
||||
}
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// WriteBuildProgress
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub WriteBuildProgress($)
|
||||
{
|
||||
my($module_built) = @_;
|
||||
|
||||
my($progress_file) = _getBuildProgressFile();
|
||||
|
||||
if ($progress_file ne "")
|
||||
{
|
||||
open(PROGRESS_FILE, ">>$progress_file") || die "Failed to open $progress_file\n";
|
||||
print(PROGRESS_FILE "$module_built\n");
|
||||
close(PROGRESS_FILE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// ClearBuildProgress
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub ClearBuildProgress()
|
||||
{
|
||||
my($progress_file) = _getBuildProgressFile();
|
||||
if ($progress_file ne "") {
|
||||
unlink $progress_file;
|
||||
}
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// WipeBuildProgress
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub WipeBuildProgress()
|
||||
{
|
||||
print "Ignoring build progress\n";
|
||||
ClearBuildProgress();
|
||||
$progress_file = "";
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// ReadBuildProgress
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub ReadBuildProgress($)
|
||||
{
|
||||
my($build_array) = @_;
|
||||
my($progress_file) = _getBuildProgressFile();
|
||||
|
||||
my($last_module);
|
||||
|
||||
if (open(PROGRESS_FILE, "< $progress_file"))
|
||||
{
|
||||
print "Getting build progress from $progress_file\n";
|
||||
|
||||
while (<PROGRESS_FILE>)
|
||||
{
|
||||
my($line) = $_;
|
||||
chomp($line);
|
||||
$last_module = $line;
|
||||
}
|
||||
|
||||
close(PROGRESS_FILE);
|
||||
}
|
||||
|
||||
if ($last_module)
|
||||
{
|
||||
setBuildProgressStart($build_array, $last_module);
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# clearOldBuildSettings
|
||||
#-------------------------------------------------------------------------------
|
||||
sub clearOldBuildSettings($$$$)
|
||||
{
|
||||
my($build, $options, $optiondefines, $filepaths) = @_;
|
||||
|
||||
# empty the arrays in case we're being called twice
|
||||
@build_flags = ();
|
||||
@options_flags = ();
|
||||
@filepath_flags = ();
|
||||
|
||||
# and empty the hashes
|
||||
%$build = ();
|
||||
%$options = ();
|
||||
%$optiondefines = ();
|
||||
%$filepaths = ();
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# SetupBuildParams
|
||||
#-------------------------------------------------------------------------------
|
||||
sub SetupBuildParams($$$$$$)
|
||||
{
|
||||
my($build, $options, $optiondefines, $filepaths, $flags_file, $prefs_file) = @_;
|
||||
|
||||
# Empty the hashes and arrays, to wipe out any stale data.
|
||||
# Needed because these structures persist across two build scripts
|
||||
# called using 'do' from a parent script.
|
||||
clearOldBuildSettings($build, $options, $optiondefines, $filepaths);
|
||||
|
||||
# Read from the flags file, which sets up the various arrays
|
||||
readFlagsFile($flags_file);
|
||||
|
||||
# If 'all' is set in the build array, propagate that to all entries
|
||||
PropagateAllFlags(\@build_flags);
|
||||
|
||||
# read the user pref file, that can change values in the array
|
||||
ReadMozUserPrefs($prefs_file, \@build_flags, \@options_flags, \@filepath_flags);
|
||||
|
||||
# If build progress exists, this clears flags in the array up to a certain point
|
||||
if ($main::USE_BUILD_PROGRESS) {
|
||||
ReadBuildProgress(\@build_flags);
|
||||
} else {
|
||||
WipeBuildProgress();
|
||||
}
|
||||
|
||||
# printBuildArray(\@build_flags);
|
||||
# printBuildArray(\@options_flags);
|
||||
|
||||
SetBuildFlags($build);
|
||||
SetBuildOptions($options);
|
||||
SetOptionDefines($optiondefines);
|
||||
SetFilepathFlags($filepaths);
|
||||
|
||||
# printHash($build);
|
||||
# printHash($options);
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
@@ -1,786 +0,0 @@
|
||||
|
||||
package Moz::BuildUtils;
|
||||
|
||||
require 5.004;
|
||||
require Exporter;
|
||||
|
||||
# Package that contains build util functions specific to the Mozilla build
|
||||
# process.
|
||||
|
||||
use strict;
|
||||
use Exporter;
|
||||
|
||||
use Cwd;
|
||||
use File::Path;
|
||||
use File::Basename;
|
||||
|
||||
use Mac::Events;
|
||||
use Mac::StandardFile;
|
||||
|
||||
use Moz::Moz;
|
||||
use Moz::BuildFlags;
|
||||
use Moz::MacCVS;
|
||||
#use Moz::ProjectXML; #optional; required for static build only
|
||||
|
||||
use vars qw(@ISA @EXPORT);
|
||||
|
||||
@ISA = qw(Exporter);
|
||||
@EXPORT = qw(
|
||||
SetupDefaultBuildOptions
|
||||
SetupBuildRootDir
|
||||
StartBuildModule
|
||||
EndBuildModule
|
||||
GetBinDirectory
|
||||
BuildOneProjectWithOutput
|
||||
BuildOneProject
|
||||
BuildProject
|
||||
BuildProjectClean
|
||||
BuildIDLProject
|
||||
BuildFolderResourceAliases
|
||||
AskAndPersistFile
|
||||
DelayFor
|
||||
TimeStart
|
||||
TimeEnd
|
||||
EmptyTree
|
||||
SetupBuildLog
|
||||
SetBuildNumber
|
||||
SetTimeBomb
|
||||
UpdateConfigHeader
|
||||
);
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// SetupDefaultBuildOptions
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub SetupDefaultBuildOptions($$$)
|
||||
{
|
||||
my($debug, $bin_dir, $config_header_file_name) = @_;
|
||||
|
||||
# Here we set up defaults for the various build flags.
|
||||
# If you want to override any of these, it's best to do
|
||||
# so via the relevant preferences file, which lives in
|
||||
# System Folder:Preferences:Mozilla build prefs:{build prefs file}.
|
||||
# For the name of the prefs file, see the .pl script that you
|
||||
# run to start this build. The prefs files are created when
|
||||
# you run the build, and contain some documentation.
|
||||
|
||||
#-------------------------------------------------------------
|
||||
# configuration variables that globally affect what is built
|
||||
#-------------------------------------------------------------
|
||||
$main::DEBUG = $debug;
|
||||
$main::PROFILE = 0;
|
||||
$main::RUNTIME = 0; # turn on to just build runtime support and NSPR projects
|
||||
$main::GC_LEAK_DETECTOR = 0; # turn on to use GC leak detection
|
||||
$main::MOZILLA_OFFICIAL = 0; # generate build number
|
||||
$main::LOG_TO_FILE = 0; # write perl output to a file
|
||||
|
||||
#-------------------------------------------------------------
|
||||
# configuration variables that affect the manner of building,
|
||||
# but possibly affecting the outcome.
|
||||
#-------------------------------------------------------------
|
||||
$main::ALIAS_SYM_FILES = $main::DEBUG;
|
||||
$main::CLOBBER_LIBS = 1; # turn on to clobber existing libs and .xSYM files before
|
||||
# building each project
|
||||
# The following two options will delete all dist files (if you have $main::build{dist} turned on),
|
||||
# but leave the directory structure intact.
|
||||
$main::CLOBBER_DIST_ALL = 1; # turn on to clobber all aliases/files inside dist (headers/xsym/libs)
|
||||
$main::CLOBBER_DIST_LIBS = 0; # turn on to clobber only aliases/files for libraries/sym files in dist
|
||||
$main::CLOBBER_IDL_PROJECTS = 0; # turn on to clobber all IDL projects.
|
||||
$main::CLOBBER_PROJECTS = 0; # turn on to remove object code from each project before building it
|
||||
|
||||
$main::UNIVERSAL_INTERFACES_VERSION = 0x0320;
|
||||
|
||||
#-------------------------------------------------------------
|
||||
# configuration variables that are preferences for the build,
|
||||
# style and do not affect what is built.
|
||||
#-------------------------------------------------------------
|
||||
$main::CLOSE_PROJECTS_FIRST = 0;
|
||||
# 1 = close then make (for development),
|
||||
# 0 = make then close (for tinderbox).
|
||||
$main::USE_TIMESTAMPED_LOGS = 0;
|
||||
$main::USE_BUILD_PROGRESS = 1; # track build progress for restartable builds
|
||||
#-------------------------------------------------------------
|
||||
# END OF CONFIG SWITCHES
|
||||
#-------------------------------------------------------------
|
||||
|
||||
$main::BIN_DIRECTORY = $bin_dir;
|
||||
$main::DEFINESOPTIONS_FILE = $config_header_file_name;
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// SetupBuildRootDir
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub SetupBuildRootDir($)
|
||||
{
|
||||
my($rel_path_to_script) = @_;
|
||||
|
||||
my($cur_dir) = cwd();
|
||||
$cur_dir =~ s/$rel_path_to_script$//;
|
||||
chdir($cur_dir) || die "Error: failed to set build root directory to '$cur_dir'.\nYou probably need to put 'mozilla' one level down (in a folder).\n";
|
||||
$main::MOZ_SRC = cwd();
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// StartBuildModule
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub StartBuildModule($)
|
||||
{
|
||||
my($module) = @_;
|
||||
|
||||
print("---- Start of $module ----\n");
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// EndBuildModule
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub EndBuildModule($)
|
||||
{
|
||||
my($module) = @_;
|
||||
WriteBuildProgress($module);
|
||||
print("---- End of $module ----\n");
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------------------------------------------
|
||||
# GetBinDirectory
|
||||
#--------------------------------------------------------------------------------------------------
|
||||
sub GetBinDirectory()
|
||||
{
|
||||
if ($main::BIN_DIRECTORY eq "") { die "Dist directory not set\n"; }
|
||||
return $main::BIN_DIRECTORY;
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------------------------------------------
|
||||
# AskAndPersistFile stores the information about the user pick inside
|
||||
# the file $session_storage
|
||||
#--------------------------------------------------------------------------------------------------
|
||||
sub AskAndPersistFile($)
|
||||
{
|
||||
my ($sessionStorage) = @_;
|
||||
my $cvsfile;
|
||||
|
||||
if (( -e $sessionStorage) &&
|
||||
open( SESSIONFILE, $sessionStorage ))
|
||||
{
|
||||
# Read in the path if available
|
||||
$cvsfile = <SESSIONFILE>;
|
||||
chomp $cvsfile;
|
||||
close SESSIONFILE;
|
||||
if ( ! -e $cvsfile )
|
||||
{
|
||||
print STDERR "$cvsfile has disappeared\n";
|
||||
undef $cvsfile;
|
||||
}
|
||||
}
|
||||
unless (defined ($cvsfile))
|
||||
{
|
||||
# make sure that MacPerl is a front process
|
||||
ActivateApplication('McPL');
|
||||
MacPerl::Answer("Could not find your MacCVS session file. Please choose one", "OK");
|
||||
|
||||
# prompt user for the file name, and store it
|
||||
my $macFile = StandardGetFile( 0, "McvD");
|
||||
if ( $macFile->sfGood() )
|
||||
{
|
||||
$cvsfile = $macFile->sfFile();
|
||||
# save the choice if we can
|
||||
if ( open (SESSIONFILE, ">" . $sessionStorage))
|
||||
{
|
||||
printf SESSIONFILE $cvsfile, "\n";
|
||||
close SESSIONFILE;
|
||||
}
|
||||
else
|
||||
{
|
||||
print STDERR "Could not open storage file $sessionStorage for saving $cvsfile\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
return $cvsfile;
|
||||
}
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------------------------------
|
||||
# BuildIDLProject
|
||||
#
|
||||
#--------------------------------------------------------------------------------------------------
|
||||
|
||||
sub BuildIDLProject($$)
|
||||
{
|
||||
my ($project_path, $module_name) = @_;
|
||||
|
||||
if ($main::CLOBBER_IDL_PROJECTS)
|
||||
{
|
||||
my (@suffix_list) = (".mcp", ".xml");
|
||||
my ($project_name, $project_dir, $suffix) = fileparse($project_path, @suffix_list);
|
||||
if ($suffix eq "") { die "Error: Project, $project_path must end in .xml or .mcp\n"; }
|
||||
|
||||
my($datafolder_path);
|
||||
if ($suffix eq ".xml")
|
||||
{
|
||||
$datafolder_path = $project_dir . "_" . $project_name . " Data:";
|
||||
}
|
||||
else {
|
||||
$datafolder_path = $project_dir . $project_name . " Data:";
|
||||
}
|
||||
|
||||
print STDERR "Deleting IDL data folder: $datafolder_path\n";
|
||||
EmptyTree($datafolder_path);
|
||||
}
|
||||
|
||||
BuildOneProject($project_path, "headers", 0, 0, 0);
|
||||
BuildOneProject($project_path, $module_name.".xpt", 1, 0, 1);
|
||||
}
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------------------------------
|
||||
# CreateStaticLibTargets
|
||||
#
|
||||
#--------------------------------------------------------------------------------------------------
|
||||
sub CreateXMLStaticLibTargets($)
|
||||
{
|
||||
my($xml_path) = @_;
|
||||
|
||||
my (@suffix_list) = (".xml");
|
||||
my ($project_name, $project_dir, $suffix) = fileparse($xml_path, @suffix_list);
|
||||
if ($suffix eq "") { die "XML munging: $xml_path must end in .xml\n"; }
|
||||
|
||||
#sniff the file to see if we need to fix up broken Pro5-exported XML
|
||||
print "Parsing $xml_path\n";
|
||||
|
||||
my $ide_version = Moz::ProjectXML::SniffProjectXMLIDEVersion($xml_path);
|
||||
if ($ide_version eq "4.0")
|
||||
{
|
||||
my $new_file = $project_dir.$project_name."2.xml";
|
||||
|
||||
print "Cleaning up Pro 5 xml to $new_file\n";
|
||||
|
||||
Moz::ProjectXML::CleanupPro5XML($xml_path, $new_file);
|
||||
|
||||
unlink $xml_path;
|
||||
rename ($new_file, $xml_path);
|
||||
}
|
||||
|
||||
my $doc = Moz::ProjectXML::ParseXMLDocument($xml_path);
|
||||
my @target_list = Moz::ProjectXML::GetTargetsList($doc);
|
||||
my $target;
|
||||
|
||||
my %target_hash; # for easy lookups below
|
||||
foreach $target (@target_list) { $target_hash{$target} = 1; }
|
||||
|
||||
foreach $target (@target_list)
|
||||
{
|
||||
if ($target =~ /(.+).shlb$/) # if this is a shared lib target
|
||||
{
|
||||
my $target_base = $1;
|
||||
my $static_target = $target_base.".o";
|
||||
|
||||
# ensure that this does not exist already
|
||||
if ($target_hash{$static_target}) {
|
||||
print "Static target $static_target already exists in project. Not making\n";
|
||||
next;
|
||||
}
|
||||
|
||||
print "Making static target '$static_target' from target '$target'\n";
|
||||
|
||||
Moz::ProjectXML::CloneTarget($doc, $target, $static_target);
|
||||
Moz::ProjectXML::SetAsStaticLibraryTarget($doc, $static_target, $static_target);
|
||||
}
|
||||
}
|
||||
|
||||
print "Writing XML file to $xml_path\n";
|
||||
my $temp_path = $project_dir."_".$project_name.".xml";
|
||||
Moz::ProjectXML::WriteXMLDocument($doc, $temp_path, $ide_version);
|
||||
Moz::ProjectXML::DisposeXMLDocument($doc);
|
||||
|
||||
if (-e $temp_path)
|
||||
{
|
||||
unlink $xml_path;
|
||||
rename ($temp_path, $xml_path);
|
||||
}
|
||||
else
|
||||
{
|
||||
die "Error: Failed to add new targets to XML project\n";
|
||||
}
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// ProcessProjectXML
|
||||
#//
|
||||
#// Helper routine to allow for XML pre-processing. This should read in the XML, process it,
|
||||
#// and replace the original file with the processed version.
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub ProcessProjectXML($)
|
||||
{
|
||||
my($xml_path) = @_;
|
||||
|
||||
# we need to manually load Moz::ProjectXML, becaues not everyone will have the
|
||||
# required perl modules in their distro.
|
||||
my($cur_dir) = cwd();
|
||||
|
||||
chdir(dirname($0)); # change to the script dir
|
||||
eval "require Moz::ProjectXML";
|
||||
if ($@) { die "Error: could not do Project XML munging because you do not have the correct XML modules installed. Error is:\n################\n $@################"; }
|
||||
|
||||
chdir($cur_dir);
|
||||
|
||||
CreateXMLStaticLibTargets($xml_path);
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// Build one project, and make the alias. Parameters are project path, target name, shared library
|
||||
#// name, make shlb alias (boolean), make xSYM alias (boolean), and is component (boolean).
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
|
||||
sub BuildOneProjectWithOutput($$$$$$)
|
||||
{
|
||||
my ($project_path, $target_name, $output_name, $alias_lib, $alias_xSYM, $component) = @_;
|
||||
|
||||
unless ($project_path =~ m/^$main::BUILD_ROOT.+/) { return; }
|
||||
|
||||
my (@suffix_list) = (".mcp", ".xml");
|
||||
my ($project_name, $project_dir, $suffix) = fileparse($project_path, @suffix_list);
|
||||
if ($suffix eq "") { die "Error: Project, $project_path must end in .xml or .mcp\n"; }
|
||||
|
||||
my($dist_dir) = GetBinDirectory();
|
||||
|
||||
# Put libraries in "Essential Files" folder, Components in "Components" folder
|
||||
my($output_dir) = $component ? "Components:" : "Essential Files:";
|
||||
my($output_path) = $dist_dir.$output_dir;
|
||||
|
||||
if ($main::options{static_build})
|
||||
{
|
||||
if ($output_name =~ /\.o$/ || $output_name =~ /\.[Ll]ib$/)
|
||||
{
|
||||
$alias_xSYM = 0;
|
||||
$alias_lib = 1;
|
||||
$output_path = $main::DEBUG ? ":mozilla:dist:static_libs_debug:" : ":mozilla:dist:static_libs:";
|
||||
}
|
||||
}
|
||||
|
||||
# if the flag is on to export projects to XML, export and munge them
|
||||
if ($main::EXPORT_PROJECTS && !($project_path =~ /IDL\.mcp$/))
|
||||
{
|
||||
my $xml_out_path = $project_path;
|
||||
|
||||
$xml_out_path =~ s/\.mcp$/\.xml/;
|
||||
|
||||
# only do this if project is newer?
|
||||
if (! -e $xml_out_path)
|
||||
{
|
||||
ExportProjectToXML(full_path_to($project_path), full_path_to($xml_out_path));
|
||||
ProcessProjectXML($xml_out_path);
|
||||
}
|
||||
}
|
||||
|
||||
# if the flag is set to use XML projects, default to XML if the file
|
||||
# is present.
|
||||
if ($main::USE_XML_PROJECTS && !($project_path =~ /IDL\.mcp$/))
|
||||
{
|
||||
my $xml_project_path = $project_dir.$project_name.".xml";
|
||||
if (-e $xml_project_path)
|
||||
{
|
||||
$project_path = $xml_project_path;
|
||||
$suffix = ".xml";
|
||||
}
|
||||
}
|
||||
|
||||
if ($suffix eq ".xml")
|
||||
{
|
||||
my($xml_path) = $project_path;
|
||||
# Prepend an "_" onto the name of the generated project file so it doesn't conflict
|
||||
$project_path = $project_dir . "_" . $project_name . ".mcp";
|
||||
my($project_modtime) = (-e $project_path ? GetFileModDate($project_path) : 0);
|
||||
my($xml_modtime) = (-e $xml_path ? GetFileModDate($xml_path) : 0);
|
||||
|
||||
if ($xml_modtime > $project_modtime)
|
||||
{
|
||||
print("Importing $project_path from $project_name.xml.\n");
|
||||
unlink($project_path);
|
||||
# Might want to delete the "xxx.mcp Data" dir ???
|
||||
ImportXMLProject(full_path_to($xml_path), full_path_to($project_path));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($main::CLOBBER_LIBS)
|
||||
{
|
||||
unlink "$project_dir$output_name"; # it's OK if these fail
|
||||
unlink "$project_dir$output_name.xSYM";
|
||||
}
|
||||
|
||||
DoBuildProject($project_path, $target_name, $main::CLOBBER_PROJECTS);
|
||||
|
||||
$alias_lib ? MakeAlias("$project_dir$output_name", "$output_path") : 0;
|
||||
$alias_xSYM ? MakeAlias("$project_dir$output_name.xSYM", "$output_path") : 0;
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// For compatiblity with existing scripts, BuildOneProject now just calls
|
||||
#// BuildOneProjectWithOutput, with the output name and target name identical.
|
||||
#// Note that this routine assumes that the target name and the shared libary name
|
||||
#// are the same.
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
|
||||
sub BuildOneProject($$$$$)
|
||||
{
|
||||
my ($project_path, $target_name, $alias_lib, $alias_xSYM, $component) = @_;
|
||||
|
||||
BuildOneProjectWithOutput($project_path, $target_name, $target_name,
|
||||
$alias_lib, $alias_xSYM, $component);
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// For compatiblity with existing scripts, BuildProject now just calls
|
||||
#// BuildOneProjectWithOutput, with the output name and target name identical.
|
||||
#// Note that this routine assumes that the target name and the shared libary name
|
||||
#// are the same. No aliases of the output are made.
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
|
||||
sub BuildProject($$)
|
||||
{
|
||||
my ($project_path, $target_name) = @_;
|
||||
|
||||
BuildOneProjectWithOutput($project_path, $target_name, $target_name, 0, 0, 0);
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// Identical to BuildProject but clobbers the project before building it.
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
|
||||
sub BuildProjectClean($$)
|
||||
{
|
||||
my ($project_path, $target_name) = @_;
|
||||
my ($save_clobber_flag) = $main::CLOBBER_PROJECTS;
|
||||
$main::CLOBBER_PROJECTS = 1;
|
||||
BuildOneProjectWithOutput($project_path, $target_name, $target_name, 0, 0, 0);
|
||||
$main::CLOBBER_PROJECTS = $save_clobber_flag;
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// Make resource aliases for one directory
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
|
||||
sub BuildFolderResourceAliases($$)
|
||||
{
|
||||
my($src_dir, $dest_dir) = @_;
|
||||
|
||||
# get a list of all the resource files
|
||||
opendir(SRCDIR, $src_dir) || die("can't open $src_dir");
|
||||
my(@resource_files) = readdir(SRCDIR);
|
||||
closedir(SRCDIR);
|
||||
|
||||
# make aliases for each one into the dest directory
|
||||
print("Placing aliases to all files from $src_dir in $dest_dir\n");
|
||||
for ( @resource_files )
|
||||
{
|
||||
next if $_ eq "CVS";
|
||||
#print(" Doing $_\n");
|
||||
if (-l $src_dir.$_)
|
||||
{
|
||||
print(" $_ is an alias\n");
|
||||
next;
|
||||
}
|
||||
my($file_name) = $src_dir . $_;
|
||||
MakeAlias($file_name, $dest_dir);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// DelayFor
|
||||
#//
|
||||
#// Delay for the given number of seconds, allowing the script to be cancelled
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
|
||||
sub DelayFor($)
|
||||
{
|
||||
my($delay_secs) = @_;
|
||||
|
||||
STDOUT->autoflush(1);
|
||||
|
||||
my($end_time) = time() + $delay_secs;
|
||||
|
||||
my($last_time) = 0;
|
||||
my($cur_time) = time();
|
||||
|
||||
while ($cur_time < $end_time)
|
||||
{
|
||||
$cur_time = time();
|
||||
if ($cur_time > $last_time)
|
||||
{
|
||||
print ".";
|
||||
$last_time = $cur_time;
|
||||
}
|
||||
|
||||
WaitNextEvent();
|
||||
}
|
||||
|
||||
print "\n";
|
||||
STDOUT->autoflush(0);
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// TimeStart
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub TimeStart()
|
||||
{
|
||||
return time();
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// TimeEnd
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub TimeEnd($$)
|
||||
{
|
||||
use integer;
|
||||
|
||||
my($start_time, $operation_name) = @_;
|
||||
my($end_time) = time();
|
||||
|
||||
my($tot_sec) = $end_time - $start_time;
|
||||
|
||||
my($seconds) = $tot_sec;
|
||||
|
||||
my($hours) = $seconds / (60 * 60);
|
||||
$seconds -= $hours * (60 * 60);
|
||||
|
||||
my($minutes) = $seconds / 60;
|
||||
$seconds -= $minutes * 60;
|
||||
|
||||
print "$operation_name took $hours hours $minutes minutes and $seconds seconds\n";
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// Remove all files from a tree, leaving directories intact (except "CVS").
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
|
||||
sub EmptyTree($)
|
||||
{
|
||||
my ($root) = @_;
|
||||
#print "EmptyTree($root)\n";
|
||||
opendir(DIR, $root);
|
||||
my $sub;
|
||||
foreach $sub (readdir(DIR))
|
||||
{
|
||||
my $fullpathname = $root.$sub; # -f, -d only work on full paths
|
||||
|
||||
# Don't call empty tree for the alias of a directory.
|
||||
# -d returns true for the alias of a directory, false for a broken alias)
|
||||
|
||||
if (-d $fullpathname)
|
||||
{
|
||||
if (-l $fullpathname) # delete aliases
|
||||
{
|
||||
unlink $fullpathname;
|
||||
next;
|
||||
}
|
||||
EmptyTree($fullpathname.":");
|
||||
if ($sub eq "CVS")
|
||||
{
|
||||
#print "rmdir $fullpathname\n";
|
||||
rmdir $fullpathname;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
unless (unlink $fullpathname) { die "Failed to delete $fullpathname\n"; }
|
||||
}
|
||||
}
|
||||
closedir(DIR);
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// Recurse through a directory hierarchy, looking for MANIFEST files.
|
||||
#// Currently unused.
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
|
||||
sub ScanForManifestFiles($$$$)
|
||||
{
|
||||
my($dir, $theme_root, $theme_name, $dist_dir) = @_;
|
||||
|
||||
opendir(DIR, $dir) or die "Cannot open dir $dir\n";
|
||||
my @files = readdir(DIR);
|
||||
closedir DIR;
|
||||
|
||||
my $file;
|
||||
|
||||
foreach $file (@files)
|
||||
{
|
||||
my $filepath = $dir.":".$file;
|
||||
|
||||
if (-d $filepath)
|
||||
{
|
||||
# print "Looking for MANIFEST files in $filepath\n";
|
||||
ScanForManifestFiles($filepath, $theme_root, $theme_name, $dist_dir);
|
||||
}
|
||||
elsif ($file eq "MANIFEST")
|
||||
{
|
||||
# print "Doing manifest file $filepath\n";
|
||||
|
||||
# Get the dest path from the first line of the file
|
||||
|
||||
open(MANIFEST, $filepath) || die "Could not open file $file";
|
||||
# Read in the path if available
|
||||
my($dest_line) = <MANIFEST>;
|
||||
chomp $dest_line;
|
||||
close MANIFEST;
|
||||
|
||||
$dest_line =~ s|^#!dest[\t ]+|| || die "No destination line found in $filepath\n";
|
||||
|
||||
my($dest_path) = $dist_dir."chrome:skins:$theme_name:$dest_line";
|
||||
# print " Destination is $dest_path\n";
|
||||
|
||||
InstallResources($filepath, "$dest_path", 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#-----------------------------------------------
|
||||
# SetupBuildLog
|
||||
#-----------------------------------------------
|
||||
sub SetupBuildLog($$)
|
||||
{
|
||||
my($logfile_path, $timestamped_log) = @_;
|
||||
|
||||
my($logdir) = "";
|
||||
my($logfile) = $logfile_path;
|
||||
|
||||
if ($logfile_path =~ /(.+?:)([^:]+)$/) # ? for non-greedy match
|
||||
{
|
||||
$logdir = $1;
|
||||
$logfile = $2;
|
||||
|
||||
mkpath($logdir);
|
||||
}
|
||||
|
||||
if ($timestamped_log)
|
||||
{
|
||||
#Use time-stamped names so that you don't clobber your previous log file!
|
||||
my $now = localtime();
|
||||
while ($now =~ s@:@.@) {} # replace all colons by periods
|
||||
OpenErrorLog("${logdir}${now}");
|
||||
}
|
||||
else
|
||||
{
|
||||
OpenErrorLog("${logdir}${logfile}");
|
||||
}
|
||||
}
|
||||
|
||||
#-----------------------------------------------
|
||||
# SetBuildNumber
|
||||
#-----------------------------------------------
|
||||
sub SetBuildNumber($$)
|
||||
{
|
||||
my($build_num_file, $files_to_touch) = @_;
|
||||
|
||||
# Make sure we add the config dir to search, to pick up mozBDate.pm
|
||||
# Need to do this dynamically, because this module can be used before
|
||||
# mozilla/config has been checked out.
|
||||
|
||||
my ($inc_path) = $0; # $0 is the path to the parent script
|
||||
$inc_path =~ s/:build:mac:build_scripts:.+$/:config/;
|
||||
push(@INC, $inc_path);
|
||||
|
||||
require mozBDate;
|
||||
|
||||
mozBDate::UpdateBuildNumber($build_num_file, $main::MOZILLA_OFFICIAL);
|
||||
|
||||
my($file);
|
||||
foreach $file (@$files_to_touch)
|
||||
{
|
||||
print "Writing build number to $file from ${file}.in\n";
|
||||
mozBDate::SubstituteBuildNumber($file, $build_num_file, "${file}.in");
|
||||
}
|
||||
}
|
||||
|
||||
#-----------------------------------------------
|
||||
# SetTimeBomb
|
||||
#-----------------------------------------------
|
||||
sub SetTimeBomb($$)
|
||||
{
|
||||
my ($warn_days, $bomb_days) = @_;
|
||||
|
||||
system("perl :mozilla:config:mac-set-timebomb.pl $warn_days $bomb_days");
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// Regenerate a configuration header file if necessary
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub UpdateConfigHeader($)
|
||||
{
|
||||
my($config_path) = @_;
|
||||
|
||||
my($config, $oldconfig) = ("", "");
|
||||
my($define, $definevalue, $defines);
|
||||
my($k, $l,);
|
||||
|
||||
foreach $k (keys(%main::options))
|
||||
{
|
||||
if ($main::options{$k})
|
||||
{
|
||||
foreach $l (keys(%{$main::optiondefines{$k}}))
|
||||
{
|
||||
$my::defines{$l} = $main::optiondefines{$k}{$l};
|
||||
print "Setting up my::defines{$l}\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
my $config_headerfile = current_directory().$config_path;
|
||||
if (-e $config_headerfile)
|
||||
{
|
||||
open(CONFIG_HEADER, "< $config_headerfile") || die "$config_headerfile: $!\n";
|
||||
my($line);
|
||||
while ($line = <CONFIG_HEADER>)
|
||||
{
|
||||
if ($line =~ m/#define\s+([^\s]*)\s+([^\s]*)\s*\n/)
|
||||
{
|
||||
$define = $1;
|
||||
$definevalue = $2;
|
||||
|
||||
#canonicalize so that whitespace changes are not significant
|
||||
my $canon_value = "#define " . $define . " " . $definevalue . "\n";
|
||||
$oldconfig .= $canon_value;
|
||||
|
||||
if (exists ($my::defines{$define}) and ($my::defines{$define} == $definevalue))
|
||||
{
|
||||
delete $my::defines{$define};
|
||||
$config .= $canon_value;
|
||||
}
|
||||
}
|
||||
}
|
||||
close(CONFIG_HEADER);
|
||||
}
|
||||
|
||||
if (%my::defines)
|
||||
{
|
||||
foreach $k (keys(%my::defines))
|
||||
{
|
||||
$config .= "#define " . $k . " " . $my::defines{$k} . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
my $file_name = basename($config_headerfile);
|
||||
if (($config ne $oldconfig) || (!-e $config_headerfile))
|
||||
{
|
||||
printf("Writing new configuration header $file_name\n");
|
||||
open(CONFIG_HEADER, "> $config_headerfile") || die "$config_headerfile: $!\n";
|
||||
print(CONFIG_HEADER "/* This file is auto-generated based on build options. Do not edit. */\n");
|
||||
print CONFIG_HEADER ($config);
|
||||
close(CONFIG_HEADER);
|
||||
|
||||
MacPerl::SetFileInfo("CWIE", "TEXT", $config_headerfile);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Configuration header $file_name is up-to-date\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
|
||||
@@ -1,660 +0,0 @@
|
||||
#!perl
|
||||
package Moz::CodeWarriorLib;
|
||||
|
||||
=pod
|
||||
|
||||
=head1 NAME
|
||||
|
||||
CodeWarriorLib - supply interface to CodeWarrior
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
#!perl
|
||||
use CodeWarriorLib;
|
||||
CodeWarriorLib::activate();
|
||||
$had_errors = CodeWarriorLib::build_project(
|
||||
$project_path, $target_name, $recent_errors_file, $clean_build
|
||||
);
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
Replaces the AppleScript library I<CodeWarriorLib>.
|
||||
|
||||
=over 4
|
||||
|
||||
=cut
|
||||
|
||||
use strict;
|
||||
|
||||
use Cwd;
|
||||
use File::Basename;
|
||||
|
||||
use Mac::Types;
|
||||
use Mac::Events;
|
||||
use Mac::AppleEvents;
|
||||
use Mac::AppleEvents::Simple;
|
||||
use Mac::Processes;
|
||||
use Mac::MoreFiles;
|
||||
use Mac::StandardFile;
|
||||
|
||||
|
||||
use vars qw($VERSION);
|
||||
$VERSION = '1.02';
|
||||
|
||||
my($app) = 'CWIE';
|
||||
my($scriptDir) = cwd(); # could use $0 for this
|
||||
my($ide_loc_file) = "";
|
||||
|
||||
# 0 == don't switch CWIE to front app in do_event(), 1 == do switch
|
||||
# note: activate() still switches when called
|
||||
$Mac::AppleEvents::Simple::SWITCH = 0;
|
||||
# $Mac::AppleEvents::Simple::WARN = 1;
|
||||
|
||||
# supply your own path to the source here
|
||||
#_test('PowerPudgeIV:mozilla:mozilla:');
|
||||
|
||||
# If you want to understand the gobbldeygook that's used to build Apple Events,
|
||||
# you should start by reading the AEGizmos documentation.
|
||||
|
||||
=pod
|
||||
|
||||
=item _get_project($full_path)
|
||||
|
||||
A private routine returning a reference to the open project with the given name,
|
||||
or else the empty string (when that project is not open)
|
||||
|
||||
full_path is a string identifying the project to be built and is of the form,
|
||||
e.g., "HD:ProjectFolder:MyProject.mcp". It must be supplied.
|
||||
|
||||
=cut
|
||||
|
||||
sub _get_project ($) {
|
||||
my(
|
||||
$full_path, $candidate_projects
|
||||
) = @_;
|
||||
$candidate_projects = _doc_named(basename($full_path, '*'));
|
||||
if ($candidate_projects) {
|
||||
my($cps) = _get_dobj($candidate_projects);
|
||||
my($num) = AECountItems($cps);
|
||||
if ($num) { # is a list
|
||||
foreach (1 .. AECountItems($cps)) {
|
||||
my($cp) = AEGetNthDesc($cps, $_);
|
||||
if (lc $full_path eq lc _full_path($cp)) {
|
||||
return($cp);
|
||||
}
|
||||
}
|
||||
} else { # is only one, not a list
|
||||
if (lc $full_path eq lc _full_path($cps)) {
|
||||
return($cps);
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
=pod
|
||||
|
||||
=item build_project
|
||||
|
||||
Build a selected target of a project, saving any errors to a file, if supplied.
|
||||
|
||||
full_path is a string identifying the project to be built and is of the form,
|
||||
e.g., "HD:ProjectFolder:MyProject.mcp". It must be supplied.
|
||||
|
||||
If target_name is the empty string, the current target of the selected project
|
||||
will be built, else, target_name should be a string matching a target name in
|
||||
the selected project.
|
||||
|
||||
If error_path is the empty string, errors will not be saved to a file,
|
||||
else, error_path should be the full path of a file to save error messages into.
|
||||
|
||||
=cut
|
||||
|
||||
$CodeWarriorLib::CLOSE_PROJECTS_FIRST = 0; # If true we close then make. If false, make then close.
|
||||
my $last_project_built = "";
|
||||
my $last_project_was_closed = 0;
|
||||
|
||||
sub build_project ($;$$$) {
|
||||
my(
|
||||
$full_path, $target_name, $error_path,
|
||||
$remove_object, $p, $project_was_closed, $had_errors
|
||||
) = @_;
|
||||
_close_errors_window();
|
||||
|
||||
if ($CodeWarriorLib::CLOSE_PROJECTS_FIRST && ($last_project_built ne $full_path))
|
||||
{
|
||||
# If we're in "close first" mode, we don't close if the current project
|
||||
# is the same as the previous one.
|
||||
if ($last_project_was_closed) {
|
||||
$p = _get_project($last_project_built);
|
||||
_close($p);
|
||||
}
|
||||
$last_project_built = $full_path;
|
||||
$last_project_was_closed = 0; # now refers to the new project
|
||||
}
|
||||
$project_was_closed = 0;
|
||||
while (1) {
|
||||
$p = _get_project($full_path);
|
||||
if (!$p) {
|
||||
if ($project_was_closed) {
|
||||
print "### Error - request for project document failed after opening\n";
|
||||
die "### possibly CW Pro 4 bug: be sure to close your Find window\n";
|
||||
}
|
||||
$project_was_closed = 1;
|
||||
$last_project_was_closed = 1;
|
||||
_open_file($full_path);
|
||||
} else {
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
$had_errors = 0;
|
||||
if ($target_name eq '') {
|
||||
if ($remove_object) {_remove_object($p)}
|
||||
_build($p);
|
||||
} else {
|
||||
if ($remove_object) {_remove_object($p, $target_name)}
|
||||
_build($p, $target_name);
|
||||
}
|
||||
|
||||
if ($error_path ne '') {
|
||||
_save_errors_window($error_path);
|
||||
}
|
||||
$had_errors = _close_errors_window();
|
||||
|
||||
if (!$CodeWarriorLib::CLOSE_PROJECTS_FIRST)
|
||||
{
|
||||
if ($project_was_closed) {
|
||||
$p = _get_project($full_path);
|
||||
_close($p);
|
||||
}
|
||||
}
|
||||
|
||||
return($had_errors);
|
||||
}
|
||||
|
||||
=pod
|
||||
|
||||
=item appIsRunning()
|
||||
|
||||
=cut
|
||||
sub _appIsRunning($)
|
||||
{
|
||||
my ($appSignature) = @_;
|
||||
my ($psi);
|
||||
my ($found) = 0;
|
||||
my ($appPSN);
|
||||
|
||||
foreach $psi (values(%Process))
|
||||
{
|
||||
if ($psi->processSignature() eq $appSignature)
|
||||
{
|
||||
$appPSN = $psi->processNumber();
|
||||
$found = 1;
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
return $found;
|
||||
}
|
||||
|
||||
=pod
|
||||
|
||||
=item appIsFrontmost()
|
||||
|
||||
=cut
|
||||
sub _appIsFrontmost($)
|
||||
{
|
||||
my ($appSignature) = @_;
|
||||
my ($psi);
|
||||
my ($found) = 0;
|
||||
my ($appPSN);
|
||||
|
||||
foreach $psi (values(%Process))
|
||||
{
|
||||
if ($psi->processSignature() eq $appSignature)
|
||||
{
|
||||
$appPSN = $psi->processNumber();
|
||||
$found = 1;
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
return (GetFrontProcess() == $appPSN);
|
||||
}
|
||||
|
||||
|
||||
=pod
|
||||
|
||||
=item activate()
|
||||
|
||||
Launches CodeWarrior and brings it to the front.
|
||||
|
||||
Once found, path will be saved in $idepath_file for future reference.
|
||||
Edit or delete this file to change the location of the IDE. If app is
|
||||
moved, C<activate()> will prompt for a new location.
|
||||
|
||||
First looks for an open CodeWarrior app. Second, tries to open previously
|
||||
saved location in ':idepath.txt'. Third, tries to find it and allow user
|
||||
to choose it with Navigation Services (if present). Fourth, uses good old
|
||||
GUSI routines built-in to MacPerl for a Choose Directory dialog box.
|
||||
|
||||
=cut
|
||||
|
||||
sub activate ($) {
|
||||
|
||||
$ide_loc_file = $_[0]; # save in global
|
||||
|
||||
my($filepath, $appath, $psi) = ($ide_loc_file);
|
||||
|
||||
foreach $psi (values(%Process)) {
|
||||
if ($psi->processSignature() eq $app) {
|
||||
$appath = $psi->processAppSpec();
|
||||
_save_appath($filepath, $appath);
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$appath || !-x $appath) {
|
||||
$appath = _read_appath($filepath);
|
||||
}
|
||||
|
||||
if (!$appath || ! -x $appath)
|
||||
{
|
||||
# make sure that MacPerl is a front process
|
||||
#ActivateApplication('McPL');
|
||||
MacPerl::Answer("Please locate the CodeWarrior application.", "OK");
|
||||
|
||||
# prompt user for the file name, and store it
|
||||
my $macFile = StandardGetFile( 0, "APPL");
|
||||
if ( $macFile->sfGood() )
|
||||
{
|
||||
$appath = $macFile->sfFile();
|
||||
}
|
||||
else
|
||||
{
|
||||
die "Operation canceled\n";
|
||||
}
|
||||
|
||||
# if (eval {require Mac::Navigation}) {
|
||||
# my($options, $nav);
|
||||
# Mac::Navigation->import();
|
||||
# $options = NavGetDefaultDialogOptions();
|
||||
# $options->message('Where is CodeWarrior IDE?');
|
||||
# $options->windowTitle('Find CodeWarrior IDE');
|
||||
# $nav = NavChooseObject($Application{$app}, $options);
|
||||
# die "CodeWarrior IDE not found.\n" if (!$nav || !$nav->file(1));
|
||||
# $appath = $nav->file(1);
|
||||
# } else {
|
||||
# local(*D);
|
||||
# my $cwd = `pwd`;
|
||||
# $appath = _get_folder(
|
||||
# 'Where is the CW IDE folder?',
|
||||
# dirname($Application{$app})
|
||||
# );
|
||||
# die "CodeWarrior IDE not found.\n" if !$appath;
|
||||
# opendir(D, $appath) or die $!;
|
||||
# chdir($appath);
|
||||
# foreach my $file (sort readdir (D)) {
|
||||
# my(@app) = MacPerl::GetFileInfo($file);
|
||||
# if ($app[0] && $app[1] &&
|
||||
# $app[1] eq 'APPL' && $app[0] eq $app
|
||||
# ) {
|
||||
# $appath .= $file;
|
||||
# last;
|
||||
# }
|
||||
# }
|
||||
# chomp($cwd);
|
||||
# chdir($cwd);
|
||||
# }
|
||||
_save_appath($filepath, $appath);
|
||||
}
|
||||
|
||||
my($lp) = LaunchParam->new(
|
||||
launchAppSpec => $appath,
|
||||
launchControlFlags => launchContinue() + launchNoFileFlags()
|
||||
);
|
||||
|
||||
unless (LaunchApplication($lp)) {
|
||||
unlink($filepath);
|
||||
die $^E;
|
||||
}
|
||||
|
||||
# wait for CodeWarrior to show up in the list of processes
|
||||
while (!_appIsRunning('CWIE'))
|
||||
{
|
||||
WaitNextEvent();
|
||||
}
|
||||
|
||||
# wait for CodeWarrior to come to the front
|
||||
while (!_appIsFrontmost('CWIE'))
|
||||
{
|
||||
WaitNextEvent();
|
||||
}
|
||||
}
|
||||
|
||||
=pod
|
||||
|
||||
=item getCodeWarriorPath()
|
||||
|
||||
Returns a file path relative to the CodeWarrior folder
|
||||
|
||||
=cut
|
||||
|
||||
sub getCodeWarriorPath($)
|
||||
{
|
||||
my($subfolder)=@_;
|
||||
|
||||
my($app_path) = _read_appath($ide_loc_file);
|
||||
if ($app_path eq "") { die "Error: Failed to get CodeWarrior IDE path\n"; }
|
||||
|
||||
my($codewarrior_root) = $app_path;
|
||||
$codewarrior_root =~ s/[^:]*$//;
|
||||
return ($codewarrior_root . $subfolder);
|
||||
}
|
||||
|
||||
|
||||
=pod
|
||||
|
||||
=item getCodeWarriorIDEName()
|
||||
|
||||
Returns the name of the CodeWarrior application
|
||||
|
||||
=cut
|
||||
|
||||
sub getCodeWarriorIDEName()
|
||||
{
|
||||
my($subfolder)=@_;
|
||||
|
||||
my($app_path) = _read_appath($ide_loc_file);
|
||||
if ($app_path eq "") { die "Error: Failed to get CodeWarrior IDE path\n"; }
|
||||
|
||||
my(@codewarrior_path) = split(/:/, $app_path);
|
||||
return pop(@codewarrior_path);
|
||||
}
|
||||
|
||||
|
||||
=pod
|
||||
|
||||
=item quit()
|
||||
|
||||
Quits CodeWarrior.
|
||||
|
||||
=cut
|
||||
|
||||
sub quit() {
|
||||
|
||||
$last_project_built = "";
|
||||
$last_project_was_closed = 0;
|
||||
|
||||
my($evt) = do_event(qw/aevt quit/, $app);
|
||||
}
|
||||
|
||||
|
||||
sub _build ($;$) {
|
||||
my($evt);
|
||||
if ($_[1]) {
|
||||
my($prm) =
|
||||
q"'----':obj {form:name, want:type(TRGT), seld:TEXT(@), from:" .
|
||||
AEPrint($_[0]) . '}';
|
||||
$evt = do_event(qw/CWIE MAKE/, $app, $prm, $_[1]);
|
||||
} else {
|
||||
my($prm) = q"'----':" . AEPrint($_[0]);
|
||||
$evt = do_event(qw/CWIE MAKE/, $app, $prm);
|
||||
}
|
||||
}
|
||||
|
||||
sub _remove_object ($;$) {
|
||||
my($evt);
|
||||
if ($_[1]) {
|
||||
my($prm) =
|
||||
q"'----':obj {form:name, want:type(TRGT), seld:TEXT(@), from:" .
|
||||
AEPrint($_[0]) . '}';
|
||||
$evt = do_event(qw/CWIE RMOB/, $app, $prm, $_[1]);
|
||||
} else {
|
||||
my($prm) = q"'----':" . AEPrint($_[0]);
|
||||
$evt = do_event(qw/CWIE RMOB/, $app, $prm);
|
||||
}
|
||||
}
|
||||
|
||||
sub _open_file ($) {
|
||||
my($prm) =
|
||||
q"'----':obj {form:name, want:type(alis), " .
|
||||
q"seld:TEXT(@), from:'null'()}";
|
||||
|
||||
do_event(qw/aevt odoc/, $app, $prm, $_[0]);
|
||||
}
|
||||
|
||||
sub import_project ($$) {
|
||||
my($xml_file, $project_path) = @_;
|
||||
|
||||
my($prm) = "kocl:type(PRJD), rtyp:TEXT(@), data:TEXT(@), &subj:'null'()";
|
||||
|
||||
my($evt) = do_event(qw/core crel/, $app, $prm, $project_path, $xml_file);
|
||||
my($result) = _get_event_result($evt);
|
||||
|
||||
if ($result eq "") {
|
||||
_close(_get_project($project_path));
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
sub export_project ($$) {
|
||||
my($project_path, $xml_out_path) = @_;
|
||||
my($p, $project_was_closed);
|
||||
|
||||
$project_was_closed = 0;
|
||||
while (1) {
|
||||
$p = _get_project($project_path);
|
||||
if (!$p) {
|
||||
if ($project_was_closed) {
|
||||
print "### Error - request for project document failed after opening\n";
|
||||
die "### possibly CW bug: be sure to close your Find window\n";
|
||||
}
|
||||
$project_was_closed = 1;
|
||||
_open_file($project_path);
|
||||
} else {
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
# avoid problems with the Project Messages window
|
||||
_close_named_window("Project Messages");
|
||||
|
||||
my($prm) =
|
||||
q"'----':obj {form:indx, want:type(PRJD), " .
|
||||
q"seld:1, from:'null'()}, kfil:TEXT(@)";
|
||||
|
||||
my($evt) = do_event(qw/CWIE EXPT/, $app, $prm, $xml_out_path);
|
||||
|
||||
if ($project_was_closed) {
|
||||
$p = _get_project($project_path);
|
||||
_close($p);
|
||||
}
|
||||
|
||||
return _get_event_result($evt);
|
||||
}
|
||||
|
||||
sub _doc_named ($) {
|
||||
my($prm) =
|
||||
q"'----':obj {form:test, want:type(docu), from:'null'(), " .
|
||||
q"seld:cmpd{relo:'= ', 'obj1':obj {form:prop, want:type" .
|
||||
q"(prop), seld:type(pnam), from:'exmn'()}, 'obj2':TEXT(@)}}";
|
||||
|
||||
my($evt) = do_event(qw/core getd/, $app, $prm, $_[0]);
|
||||
return($evt->{REPLY} eq 'aevt\ansr{}' ? undef : $evt);
|
||||
}
|
||||
|
||||
sub _full_path ($) {
|
||||
my($obj) = $_[0];
|
||||
my($prm) =
|
||||
q"'----':obj {form:prop, want:type(prop), seld:type(FILE), " .
|
||||
q"from:" . AEPrint($_[0]) . q"}, rtyp:type(TEXT)";
|
||||
my($evt) = do_event(qw/core getd/, $app, $prm);
|
||||
|
||||
return MacPerl::MakePath(
|
||||
MacUnpack('fss ', (
|
||||
AEGetParamDesc($evt->{REP}, keyDirectObject()))->data()->get()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
sub _save_errors_window ($) {
|
||||
my($prm) =
|
||||
q"'----':obj {form:name, want:type(alis), seld:TEXT(@), from:'null'()}";
|
||||
do_event(qw/MMPR SvMs/, $app, $prm, $_[0]);
|
||||
}
|
||||
|
||||
|
||||
sub _close_errors_window () {
|
||||
return _close_named_window('Errors & Warnings');
|
||||
}
|
||||
|
||||
|
||||
sub _close_named_window ($) {
|
||||
my($window_name) = @_;
|
||||
|
||||
my($prm) =
|
||||
q"'----':obj {form:name, want:type(cwin), " .
|
||||
q"seld:TEXT(@), from:'null'()}";
|
||||
|
||||
my($evt) = do_event(qw/core clos/, $app, $prm, $window_name);
|
||||
return($evt->{REPLY} eq 'aevt\ansr{}' ? 1 : 0);
|
||||
}
|
||||
|
||||
sub _close () {
|
||||
my($prm) = q"'----':" . AEPrint($_[0]);
|
||||
do_event(qw/core clos/, $app, $prm);
|
||||
}
|
||||
|
||||
sub _get_dobj ($) {
|
||||
return(AEGetParamDesc($_[0]->{REP}, keyDirectObject()));
|
||||
}
|
||||
|
||||
sub _get_folder ($$) {
|
||||
require 'GUSI.ph';
|
||||
my($prompt, $default) = @_;
|
||||
MacPerl::Choose(
|
||||
GUSI::AF_FILE(), 0, $prompt, '',
|
||||
GUSI::CHOOSE_DIR() + ($default ? &GUSI::CHOOSE_DEFAULT : 0),
|
||||
$default
|
||||
);
|
||||
}
|
||||
|
||||
sub _get_event_result ($)
|
||||
{
|
||||
my($evt) = @_;
|
||||
|
||||
my($result) = $evt->{ERROR};
|
||||
|
||||
if ( $result eq "" && $evt->{ERRNO} != 0 )
|
||||
{
|
||||
$result = "unknown error (".$evt->{ERRNO}.")";
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
sub _save_appath ($$) {
|
||||
|
||||
my($cwd) = cwd(); # remember the current working dir
|
||||
chdir($scriptDir); # change dir to the script dir
|
||||
|
||||
local(*F);
|
||||
open(F, '>' . $_[0]) or die $!;
|
||||
print F $_[1];
|
||||
close(F);
|
||||
|
||||
chdir($cwd); # restore the cwd
|
||||
}
|
||||
|
||||
sub _read_appath ($) {
|
||||
|
||||
my($filepath) = @_;
|
||||
|
||||
my($cwd) = cwd(); # remember the current working dir
|
||||
chdir($scriptDir); # change dir to the script dir
|
||||
|
||||
if (! -e $filepath) {
|
||||
return "";
|
||||
}
|
||||
|
||||
local(*F);
|
||||
open(F, $filepath);
|
||||
my($appath) = <F>;
|
||||
close(F);
|
||||
|
||||
chdir($cwd); # restore the cwd
|
||||
return($appath);
|
||||
}
|
||||
|
||||
|
||||
sub _test ($) {
|
||||
activate($ide_loc_file);
|
||||
my($path) = $_[0];
|
||||
build_project(
|
||||
"${path}modules:xml:macbuild:XML.mcp", '',
|
||||
"${path}build:mac:Mozilla.BuildLog.part"
|
||||
);
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
=pod
|
||||
|
||||
=back
|
||||
|
||||
=head1 HISTORY
|
||||
|
||||
=over 4
|
||||
|
||||
=item v1.02, September 23, 1998
|
||||
|
||||
Made fixes in finding and saving location of CodeWarrior IDE.
|
||||
|
||||
=item v1.01, June 1, 1998
|
||||
|
||||
Made fixes to C<chdir()> in C<activate()>, made C<activate()> more robust
|
||||
in finding CodeWarrior IDE, added global variable to NOT switch to IDE
|
||||
for each sent event, a few other fixes.
|
||||
|
||||
=item v1.00, May 30, 1998
|
||||
|
||||
First shot
|
||||
|
||||
=back
|
||||
|
||||
|
||||
=head1 AUTHORS
|
||||
|
||||
Chris Nandor F<E<lt>pudge@pobox.comE<gt>>, and the author of the
|
||||
original I<CodeWarriorLib>, Scott Collins F<E<lt>scc@netscape.comE<gt>>.
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
BuildProject L<Moz>.
|
||||
|
||||
=head1 COPYRIGHT
|
||||
|
||||
The contents of this file are subject to the Netscape Public
|
||||
License Version 1.1 (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.mozilla.org/NPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS
|
||||
IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
implied. See the License for the specific language governing
|
||||
rights and limitations under the License.
|
||||
|
||||
The Original Code is Mozilla Communicator client code, released
|
||||
March 31, 1998.
|
||||
|
||||
The Initial Developer of the Original Code is Netscape
|
||||
Communications Corporation. Portions created by Netscape are
|
||||
Copyright (C) 1998-1999 Netscape Communications Corporation. All
|
||||
Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
|
||||
=cut
|
||||
@@ -1,573 +0,0 @@
|
||||
#!perl -w
|
||||
package Moz::Jar;
|
||||
|
||||
#
|
||||
# Module for creating jar files, either using a jar manifest, or
|
||||
# simply jarring up folders on disk.
|
||||
#
|
||||
|
||||
require 5.004;
|
||||
require Exporter;
|
||||
|
||||
use strict;
|
||||
use Archive::Zip;
|
||||
use File::Path;
|
||||
|
||||
use Mac::Files;
|
||||
|
||||
use Moz::Moz;
|
||||
|
||||
use vars qw( @ISA @EXPORT );
|
||||
|
||||
@ISA = qw(Exporter);
|
||||
@EXPORT = qw(
|
||||
CreateJarFileFromDirectory
|
||||
CreateJarFromManifest
|
||||
WriteOutJarFiles
|
||||
SanityCheckJarOptions
|
||||
);
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Add the contents of a directory to the zip file
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
sub _addDirToJar($$$$)
|
||||
{
|
||||
my($dir, $jar_root, $zip, $compress) = @_;
|
||||
|
||||
opendir(DIR, $dir) or die "Error: Cannot open dir $dir\n";
|
||||
my @files = readdir(DIR);
|
||||
closedir DIR;
|
||||
|
||||
my $unix_jar_root = $jar_root;
|
||||
$unix_jar_root =~ s|:|/|g; # colon to slash conversion
|
||||
|
||||
my $file;
|
||||
|
||||
foreach $file (@files)
|
||||
{
|
||||
my $filepath = $dir.":".$file;
|
||||
|
||||
if (-d $filepath)
|
||||
{
|
||||
print "Adding files to jar from $filepath\n";
|
||||
_addDirToJar($filepath, $jar_root, $zip, $compress);
|
||||
}
|
||||
else
|
||||
{
|
||||
my $member = Archive::Zip::Member->newFromFile($filepath);
|
||||
die "Error: Failed to create zip file member $filepath\n" unless $member;
|
||||
|
||||
my $unixName = $filepath;
|
||||
$unixName =~ s|:|/|g; # colon to slash conversion
|
||||
$unixName =~ s|^$unix_jar_root||; # relativise
|
||||
|
||||
$member->fileName($unixName);
|
||||
|
||||
# print "Adding $file as $unixName\n";
|
||||
|
||||
if ($compress) {
|
||||
$member->desiredCompressionMethod(Archive::Zip::COMPRESSION_DEFLATED);
|
||||
} else {
|
||||
$member->desiredCompressionMethod(Archive::Zip::COMPRESSION_STORED);
|
||||
}
|
||||
|
||||
$zip->addMember($member);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Add the contents of a directory to the zip file
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
sub CreateJarFileFromDirectory($$$)
|
||||
{
|
||||
my($srcdir, $jarpath, $compress) = @_;
|
||||
|
||||
my $zip = Archive::Zip->new();
|
||||
|
||||
_addDirToJar($srcdir, $srcdir, $zip, $compress);
|
||||
|
||||
print "Saving zip file...\n";
|
||||
my $status = $zip->writeToFileNamed($jarpath);
|
||||
if ($status == 0) {
|
||||
print "Zipping completed successfully\n";
|
||||
} else {
|
||||
print "Error saving zip file\n";
|
||||
}
|
||||
|
||||
# set the file type/creator to something reasonable
|
||||
MacPerl::SetFileInfo("ZIP ", "ZIP ", $jarpath);
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# printZipContents
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
sub printZipContents($)
|
||||
{
|
||||
my($zip) = @_;
|
||||
|
||||
my(@members) = $zip->memberNames();
|
||||
|
||||
print "Zip contains:\n";
|
||||
|
||||
my($member);
|
||||
foreach $member (@members)
|
||||
{
|
||||
print " $member\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# safeSaveJarFile
|
||||
#
|
||||
# Archive::Zip has a problem where you cannot save a zip file on top of
|
||||
# an existing zip file that it has open, because it holds references
|
||||
# into that zip. So we have to save to a temp file, then do a swap.
|
||||
#
|
||||
# Note that the zip will become invalid after this operation.
|
||||
# If you want to do further operations on it, you'll have to reread it.
|
||||
#-------------------------------------------------------------------------------
|
||||
sub safeSaveJarFile($$)
|
||||
{
|
||||
my($zip, $full_dest_path) = @_;
|
||||
|
||||
my($temp_file_name) = $full_dest_path."_temp";
|
||||
|
||||
($zip->writeToFileNamed($temp_file_name) == Archive::Zip::AZ_OK) || die "Error: died writing jar to temp file $temp_file_name\n";
|
||||
|
||||
unlink $full_dest_path;
|
||||
|
||||
(rename $temp_file_name, $full_dest_path) || die "Error: Failed to rename $temp_file_name\n";
|
||||
|
||||
MacPerl::SetFileInfo("ZIP ", "ZIP ", $full_dest_path);
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# addToJarFile
|
||||
#
|
||||
# Add a file to a jar file
|
||||
#
|
||||
# Parameters:
|
||||
# 1. Jar ID. Unix path of jar file inside chrome.
|
||||
# 2. Abs path to jar.mn file (i.e. source) (mac breaks)
|
||||
# 3. File source, relative to jar.mn path (mac breaks)
|
||||
# 4. Abs path to the resulting .jar file (mac breaks)
|
||||
# 5. Relative file path within the jar (unix breaks)
|
||||
# 6. Reference to hash of jar files
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
sub addToJarFile($$$$$$$)
|
||||
{
|
||||
my($jar_id, $jar_man_dir, $file_src, $jar_path, $file_jar_path, $override, $jars) = @_;
|
||||
|
||||
# print "addToJarFile with:\n $jar_man_dir\n $file_src\n $jar_path\n $file_jar_path\n";
|
||||
|
||||
unless ($jar_path =~ m/(.+:)([^:]+)$/) { die "Error: Bad jar path $jar_path\n"; }
|
||||
|
||||
my($target_dir) = $1;
|
||||
my($jar_name) = $2;
|
||||
|
||||
$target_dir =~ s/[^:]+$//;
|
||||
|
||||
# print "¥ $target_dir $jar_name\n";
|
||||
|
||||
# find the source file
|
||||
my($src) = $jar_man_dir.":".$file_src;
|
||||
if ((!-e $src) && ($file_src =~ m/.+:([^:]+)$/)) # src does not exist. Fall back to looking for src in jar.mn dir
|
||||
{
|
||||
$file_src = $1;
|
||||
$src = $jar_man_dir.":".$file_src;
|
||||
|
||||
if (!-e $src) {
|
||||
die "Error: Can't find chrome file $src\n";
|
||||
}
|
||||
}
|
||||
|
||||
if ($main::options{chrome_jars})
|
||||
{
|
||||
my($zip) = $jars->{$jar_id};
|
||||
unless ($zip) { die "Error: Can't find Zip entry for $jar_id\n"; }
|
||||
|
||||
# print "Adding $file_src to jar file $jar_path at $file_jar_path\n";
|
||||
my($member) = Archive::Zip::Member->newFromFile($src);
|
||||
unless ($member) { die "Error: Failed to create zip file member $src\n"; }
|
||||
|
||||
$member->fileName($file_jar_path);
|
||||
|
||||
my($compress) = 1;
|
||||
if ($compress) {
|
||||
$member->desiredCompressionMethod(Archive::Zip::COMPRESSION_DEFLATED);
|
||||
$member->desiredCompressionLevel(Archive::Zip::COMPRESSION_LEVEL_DEFAULT); # defaults to 6
|
||||
} else {
|
||||
$member->desiredCompressionMethod(Archive::Zip::COMPRESSION_STORED);
|
||||
}
|
||||
|
||||
my($old_member) = $zip->memberNamed($file_jar_path);
|
||||
|
||||
if ($override)
|
||||
{
|
||||
if ($old_member)
|
||||
{
|
||||
# print "Overriding $file_jar_path in jar file $jar_id\n";
|
||||
# need to compare mod dates or use the + here
|
||||
$zip->removeMember($old_member);
|
||||
}
|
||||
|
||||
$zip->addMember($member);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($old_member)
|
||||
{
|
||||
#compare dates here
|
||||
my($member_moddate) = $old_member->lastModTime();
|
||||
my($file_moddate) = GetFileModDate($src);
|
||||
|
||||
if ($file_moddate > $member_moddate)
|
||||
{
|
||||
print "Updating older file $file_jar_path in $jar_id\n";
|
||||
$zip->removeMember($old_member);
|
||||
$zip->addMember($member);
|
||||
}
|
||||
else
|
||||
{
|
||||
print "File $file_jar_path in $jar_id is more recent. Not updating.\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$zip->addMember($member);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($main::options{chrome_files}) # we install raw files too
|
||||
{
|
||||
my($rel_path) = $file_jar_path;
|
||||
$rel_path =~ s|/|:|g; # slash to colons
|
||||
|
||||
my($dir_name) = $jar_name;
|
||||
$dir_name =~ s/\.jar$//;
|
||||
|
||||
my($dst) = $target_dir.$dir_name.":".$rel_path;
|
||||
|
||||
# print "Aliassing $src\n to\n$dst\n";
|
||||
if ($override)
|
||||
{
|
||||
unlink $dst;
|
||||
MakeAlias($src, $dst); # don't check errors, otherwise we fail on replacement
|
||||
}
|
||||
else
|
||||
{
|
||||
if (-e $dst)
|
||||
{
|
||||
#compare dates here
|
||||
my($dst_moddate) = GetFileModDate($dst);
|
||||
my($file_moddate) = GetFileModDate($src);
|
||||
|
||||
if ($file_moddate > $dst_moddate)
|
||||
{
|
||||
print "Updating older file $rel_path in $dir_name\n";
|
||||
unlink $dst;
|
||||
MakeAlias($src, $dst);
|
||||
}
|
||||
else
|
||||
{
|
||||
print "File $file_jar_path in $jar_id is more recent. Not updating.\n";
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
MakeAlias($src, $dst);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# setupJarFile
|
||||
#
|
||||
# setup a zip for writing
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
sub setupJarFile($$$)
|
||||
{
|
||||
my($jar_id, $dest_path, $jar_hash) = @_;
|
||||
|
||||
# print "Creating jar file $jar_id at $jar_path\n";
|
||||
|
||||
my($jar_file) = $jar_id;
|
||||
$jar_file =~ s|/|:|g; # slash to colons
|
||||
my($full_jar_path) = full_path_to($dest_path.":".$jar_file);
|
||||
|
||||
if ($main::options{chrome_jars})
|
||||
{
|
||||
my($zip) = $jar_hash->{$jar_id};
|
||||
if (!$zip) # if we haven't made it already, do so
|
||||
{
|
||||
my($zip) = Archive::Zip->new();
|
||||
$jar_hash->{$jar_id} = $zip;
|
||||
|
||||
# does the jar file exist already? If so, read it in
|
||||
if (-e $full_jar_path)
|
||||
{
|
||||
print "Reading in jar file $jar_id\n";
|
||||
if ($zip->read($full_jar_path) != Archive::Zip::AZ_OK) { die "Error: Failed to re-read $full_jar_path\n"; }
|
||||
|
||||
# printZipContents($zip);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
# installing files.
|
||||
# nothing to do. MakeAlias creates dirs as needed.
|
||||
|
||||
# add this jar to the list
|
||||
$jar_hash->{$jar_id} = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# closeJarFile
|
||||
#
|
||||
# We're done with this jar file _for this jar.mn_. We may add more entries
|
||||
# to it later, so keep it open in the hash.
|
||||
#-------------------------------------------------------------------------------
|
||||
sub closeJarFile($$)
|
||||
{
|
||||
my($jar_path, $jar_hash) = @_;
|
||||
|
||||
# print "Closing jar file $jar_path\n";
|
||||
|
||||
if ($main::options{chrome_jars})
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
# installing files.
|
||||
# nothing to do
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# WriteOutJarFiles
|
||||
#
|
||||
# Now we dump out the jars
|
||||
#-------------------------------------------------------------------------------
|
||||
sub WriteOutJarFiles($$)
|
||||
{
|
||||
my($chrome_dir, $jars) = @_;
|
||||
|
||||
unless ($main::options{chrome_jars}) { return; }
|
||||
|
||||
my($full_chrome_path) = full_path_to($chrome_dir);
|
||||
|
||||
my($key);
|
||||
foreach $key (keys %$jars)
|
||||
{
|
||||
my($zip) = $jars->{$key};
|
||||
|
||||
my($rel_path) = $key;
|
||||
$rel_path =~ s/\//:/g;
|
||||
|
||||
my($output_path) = $full_chrome_path.":".$rel_path;
|
||||
|
||||
print "Writing zip file $key to $output_path\n";
|
||||
|
||||
# ensure the target dirs exist
|
||||
my($path) = $output_path;
|
||||
$path =~ s/[^:]+$//;
|
||||
mkpath($path);
|
||||
|
||||
# unlink $output_path; # remove any existing jar
|
||||
safeSaveJarFile($zip, $output_path);
|
||||
# $zip is invalid after this operation, so nuke it here
|
||||
$jars->{$key} = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# registerChromePackage
|
||||
#
|
||||
# Enter a chrome package into the installed-chrome.txt file
|
||||
#-------------------------------------------------------------------------------
|
||||
sub registerChromePackage($$$$$$)
|
||||
{
|
||||
my($jar_file, $file_path, $chrome_dir, $jar_hash, $chrome_type, $pkg_name) = @_;
|
||||
|
||||
my($manifest_subdir) = $jar_file;
|
||||
$manifest_subdir =~ s/:/\//g;
|
||||
|
||||
my($chrome_entry);
|
||||
|
||||
if ($main::options{use_jars}) {
|
||||
$chrome_entry = "$chrome_type,install,url,jar:resource:/chrome/$manifest_subdir!/$chrome_type/$pkg_name";
|
||||
} else {
|
||||
$manifest_subdir =~ s/\.jar$//;
|
||||
$chrome_entry = "$chrome_type,install,url,resource:/chrome/$manifest_subdir/$chrome_type/$pkg_name";
|
||||
}
|
||||
|
||||
# print "Entering $chrome_entry in installed-chrome.txt\n";
|
||||
|
||||
# ensure chrome_dir exists
|
||||
mkpath($chrome_dir);
|
||||
|
||||
my($inst_chrome) = ${chrome_dir}.":installed-chrome.txt";
|
||||
|
||||
if (open(CHROMEFILE, "<$inst_chrome")) {
|
||||
while (<CHROMEFILE>) {
|
||||
chomp;
|
||||
if ($_ eq $chrome_entry) {
|
||||
# $chrome_entry already appears in installed-chrome.txt file
|
||||
# just update the mod date
|
||||
my $now = time;
|
||||
utime($now, $now, $inst_chrome) || die "Error: Couldn't touch $inst_chrome";
|
||||
print "+++ updating chrome $inst_chrome\n+++\t\t$chrome_entry\n";
|
||||
close(CHROMEFILE) || die "Error: can't close $inst_chrome: $!";
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
close(CHROMEFILE) || die "Error: can't close $inst_chrome: $!";
|
||||
}
|
||||
open(CHROMEFILE, ">>${inst_chrome}") || die "Error: Failed to open $inst_chrome\n";
|
||||
print(CHROMEFILE "${chrome_entry}\n");
|
||||
close(CHROMEFILE) || die "Error: Failed to close $inst_chrome\n";
|
||||
print "+++ adding chrome $inst_chrome\n+++\t\t$chrome_entry\n";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Create or add to a jar file from a jar.mn file.
|
||||
# Both arguments are relative to the mozilla root dir.
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
sub CreateJarFromManifest($$$)
|
||||
{
|
||||
my($jar_man_path, $dest_path, $jars) = @_;
|
||||
|
||||
if ($main::options{chrome_jars}) {
|
||||
print "Jarring from $jar_man_path\n";
|
||||
}
|
||||
if ($main::options{chrome_files}) {
|
||||
print "Installing files from $jar_man_path\n";
|
||||
}
|
||||
|
||||
$jar_man_path = full_path_to($jar_man_path);
|
||||
$dest_path = full_path_to($dest_path);
|
||||
|
||||
# if the jars hash is empty, nuke installed-chrome.txt
|
||||
if (! scalar(%$jars))
|
||||
{
|
||||
print "Nuking installed-chrome.txt\n";
|
||||
my($installed_chrome) = $dest_path.":installed-chrome.txt";
|
||||
# unlink $installed_chrome;
|
||||
}
|
||||
|
||||
my $jar_man_dir = "";
|
||||
my $jar_man_file = "";
|
||||
|
||||
if ($jar_man_path =~ /(.+):([^:]+)$/)
|
||||
{
|
||||
$jar_man_dir = $1; # no trailing :
|
||||
$jar_man_file = $2;
|
||||
}
|
||||
|
||||
# Keep a hash of jar files, keyed on relative jar path (e.g. "packages/core.jar")
|
||||
# Entries are open Archive::Zips (if zipping), and installed-chrome entries.
|
||||
|
||||
my($jar_id) = ""; # Current foo/bar.jar from jar.mn file
|
||||
my($jar_file) = ""; # relative path to jar file (from $dest_path), with mac separators
|
||||
my($full_jar_path);
|
||||
|
||||
open(FILE, "<$jar_man_path") || die "Error: could not open \"$jar_man_path\": $!";
|
||||
while (<FILE>)
|
||||
{
|
||||
my($line) = $_;
|
||||
chomp($line);
|
||||
|
||||
# print "$line\n";
|
||||
|
||||
if ($line =~ /^\s*\#.*$/) { # skip comments
|
||||
next;
|
||||
}
|
||||
|
||||
if ($line =~/^([\w\d.\-\_\\\/]+)\:\s*$/) # line start jar file entries
|
||||
{
|
||||
$jar_id = $1;
|
||||
$jar_file = $jar_id;
|
||||
$jar_file =~ s|/|:|g; # slash to colons
|
||||
$full_jar_path = $dest_path.":".$jar_file;
|
||||
|
||||
setupJarFile($jar_id, $dest_path, $jars);
|
||||
|
||||
}
|
||||
elsif ($line =~ /^(\+?)\s+([\w\d.\-\_\\\/]+)\s*(\([\w\d.\-\_\\\/]+\))?$\s*/) # jar file entry
|
||||
{
|
||||
my($override) = ($1 eq "+");
|
||||
my($file_dest) = $2;
|
||||
my($file_src) = $3;
|
||||
|
||||
if ($file_src) {
|
||||
$file_src = substr($file_src, 1, -1); #strip the ()
|
||||
} else {
|
||||
$file_src = $file_dest;
|
||||
}
|
||||
|
||||
$file_src =~ s|/|:|g;
|
||||
|
||||
if ($jar_file ne "") # if jar is open, add to jar
|
||||
{
|
||||
if ($file_dest =~ /([\w\d.\-\_]+)\/([\w\d.\-\_\\\/]+)contents.rdf/)
|
||||
{
|
||||
my $chrome_type = $1;
|
||||
my $pkg_name = $2;
|
||||
registerChromePackage($jar_file, $file_dest, $dest_path, $jars, $chrome_type, $pkg_name);
|
||||
}
|
||||
|
||||
addToJarFile($jar_id, $jar_man_dir, $file_src, $full_jar_path, $file_dest, $override, $jars);
|
||||
}
|
||||
else
|
||||
{
|
||||
die "Error: bad jar.mn format at $line\n";
|
||||
}
|
||||
}
|
||||
elsif ($line =~ /^\s*$/ ) # blank line
|
||||
{
|
||||
if ($jar_file ne "") #if a jar file is open, close it
|
||||
{
|
||||
closeJarFile($full_jar_path, $jars);
|
||||
|
||||
$jar_file = "";
|
||||
$full_jar_path = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
close(FILE);
|
||||
|
||||
if ($jar_file ne "") #if a jar file is open, close it
|
||||
{
|
||||
closeJarFile($full_jar_path, $jars);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
1;
|
||||
@@ -1,228 +0,0 @@
|
||||
#!perl -w
|
||||
package Moz::MacCVS;
|
||||
|
||||
# package Mac::Apps::MacCVS; this should really be the name of the package
|
||||
# but due to our directory hierarchy in mozilla, I am not doing it
|
||||
|
||||
require 5.004;
|
||||
require Exporter;
|
||||
|
||||
use strict;
|
||||
use Exporter;
|
||||
|
||||
use vars qw($VERSION @ISA @EXPORT);
|
||||
|
||||
use Cwd;
|
||||
|
||||
use File::Basename;
|
||||
|
||||
use Mac::StandardFile;
|
||||
use Mac::AppleEvents;
|
||||
use Mac::AppleEvents::Simple;
|
||||
|
||||
@ISA = qw(Exporter);
|
||||
@EXPORT = qw(new describe checkout update);
|
||||
$VERSION = "1.00";
|
||||
|
||||
# If you want to understand the gobbldeygook that's used to build Apple Events,
|
||||
# you should start by reading the AEGizmos documentation.
|
||||
|
||||
|
||||
# Architecture:
|
||||
# cvs session object:
|
||||
# name - session name
|
||||
# session_file - session file
|
||||
#
|
||||
#
|
||||
|
||||
my($last_error) = 0;
|
||||
my($gAppSig) = 'Mcvs'; # MacCVS Pro
|
||||
|
||||
#
|
||||
# utility routines
|
||||
#
|
||||
|
||||
|
||||
sub _checkForEventError($)
|
||||
{
|
||||
my($evt) = @_;
|
||||
|
||||
if ($evt->{ERRNO} != 0)
|
||||
{
|
||||
print STDERR "Error. Script returned '$evt->{ERROR} (error $evt->{ERRNO})\n";
|
||||
$last_error = $evt->{ERRNO};
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1; # success
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# Session object methods
|
||||
#
|
||||
|
||||
sub new
|
||||
{
|
||||
my ( $proto, $session_file) = @_;
|
||||
my $class = ref($proto) || $proto;
|
||||
my $self = {};
|
||||
|
||||
if ( defined($session_file) && ( -e $session_file) )
|
||||
{
|
||||
$self->{"name"} = basename( $session_file );
|
||||
$self->{"session_file"} = $session_file;
|
||||
bless $self, $class;
|
||||
return $self;
|
||||
}
|
||||
else
|
||||
{
|
||||
print STDERR "MacCVS->new cvs file < $session_file > does not exist\n";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
# makes sure that the session is open
|
||||
# assertSessionOpen()
|
||||
# returns 1 on success
|
||||
sub assertSessionOpen()
|
||||
{
|
||||
my ($self) = shift;
|
||||
|
||||
$last_error = 0;
|
||||
|
||||
my($prm) =
|
||||
q"'----':obj {form:name, want:type(alis), seld:TEXT(@), from:'null'()}";
|
||||
|
||||
my($evt) = do_event(qw/aevt odoc/, $gAppSig, $prm, $self->{session_file});
|
||||
return _checkForEventError($evt);
|
||||
}
|
||||
|
||||
# prints the cvs object, used mostly for debugging
|
||||
sub describe
|
||||
{
|
||||
my($self) = shift;
|
||||
$last_error = 0;
|
||||
print "MacCVS:: name: ", $self->{name}, " session file: ", $self->{session_file}, "\n";
|
||||
}
|
||||
|
||||
# checkout( self, module, revision, date)
|
||||
# MacCVS checkout command
|
||||
# returns 1 on success.
|
||||
sub checkout()
|
||||
{
|
||||
my($self, $module, $revision, $date ) = @_;
|
||||
unless( defined ($module) ) { $module = ""; } # get rid of the pesky undefined warnings
|
||||
unless( defined ($revision) ) { $revision = ""; }
|
||||
unless( defined ($date) ) { $date = ""; }
|
||||
|
||||
$last_error = 0;
|
||||
|
||||
$self->assertSessionOpen() || die "Error: failed to open MacCVS session file at $self->{session_file}\n";
|
||||
|
||||
my($revstring) = ($revision ne "") ? $revision : "(none)";
|
||||
my($datestring) = ($date ne "") ? $date : "(none)";
|
||||
|
||||
print "Checking out $module with revision $revstring, date $datestring\n";
|
||||
|
||||
my($prm) =
|
||||
q"'----':obj {form:name, want:type(docu), seld:TEXT(@), from:'null'()}, ".
|
||||
q"modl:'TEXT'(@), tagr:'TEXT'(@), tagd:'TEXT'(@) ";
|
||||
|
||||
my($evt) = do_event(qw/MCvs cout/, $gAppSig, $prm, $self->{name}, $module, $revision, $date);
|
||||
return _checkForEventError($evt);
|
||||
}
|
||||
|
||||
|
||||
# update( self, branch tag, list of paths)
|
||||
# MacCVS udate command
|
||||
# returns 1 on success.
|
||||
# NOTE: MacCVS Pro does not correctly support this stuff yet (as of version 2.7d5).
|
||||
sub update()
|
||||
{
|
||||
my($self, $branch, $paths ) = @_;
|
||||
|
||||
$last_error = 0;
|
||||
|
||||
$self->assertSessionOpen() || die "Error: failed to open MacCVS session file at $self->{session_file}\n";
|
||||
|
||||
if ($branch eq "HEAD") {
|
||||
$branch = "";
|
||||
}
|
||||
|
||||
my($paths_list) = "";
|
||||
|
||||
my($path);
|
||||
foreach $path (@$paths)
|
||||
{
|
||||
if ($paths_list ne "") {
|
||||
$paths_list = $paths_list.", ";
|
||||
}
|
||||
|
||||
$paths_list = $paths_list."Ò".$path."Ó";
|
||||
}
|
||||
|
||||
my($prm) =
|
||||
q"'----':obj {form:name, want:type(docu), seld:TEXT(@), from:'null'()}, ".
|
||||
q"tagr:'TEXT'(@), tFls:[";
|
||||
|
||||
$prm = $prm.$paths_list."]";
|
||||
|
||||
my($evt) = do_event(qw/MCvs updt/, $gAppSig, $prm, $self->{name}, $branch);
|
||||
return _checkForEventError($evt);
|
||||
};
|
||||
|
||||
|
||||
sub getLastError()
|
||||
{
|
||||
return $last_error;
|
||||
}
|
||||
|
||||
1;
|
||||
=pod
|
||||
|
||||
=head1 NAME
|
||||
|
||||
MacCVS - Interface to MacCVS
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
use MacCVS;
|
||||
$session = MacCVS->new( <session_file_path>) || die "cannot create session";
|
||||
$session->checkout([module] [revision] [date]) || die "Could not check out";
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This is a MacCVS interface for talking to MacCVS Pro client.
|
||||
MacCVSSession is the class used to manipulate the session
|
||||
|
||||
=item new
|
||||
MacCVS->new( <cvs session file path>);
|
||||
|
||||
Creates a new session. Returns undef on failure.
|
||||
|
||||
=item checkout( <module> [revision] [date] )
|
||||
|
||||
cvs checkout command. Revision and date are optional
|
||||
returns 0 on failure
|
||||
|
||||
=cut
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
=over
|
||||
|
||||
=item MacCVS Home Page
|
||||
|
||||
http://www.maccvs.org/
|
||||
|
||||
=back
|
||||
|
||||
=head1 AUTHORS
|
||||
|
||||
Aleks Totic atotic@netscape.com
|
||||
Simon Fraser sfraser@netscape.com
|
||||
|
||||
=cut
|
||||
|
||||
__END__
|
||||
@@ -1,603 +0,0 @@
|
||||
=head1 NAME
|
||||
|
||||
B<Moz> - routines for automating CodeWarrior builds, and some extra-curricular
|
||||
activities related to building Mozilla
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
use Moz;
|
||||
|
||||
OpenErrorLog(":::BuildLog");
|
||||
StopForErrors();
|
||||
|
||||
$Moz::QUIET = 1;
|
||||
InstallFromManifest(":projects:MANIFEST", $dist_dir);
|
||||
|
||||
BuildProjectClean(":projects:SomeProject.mcp", "SomeTarget");
|
||||
MakeAlias(":projects:SomeProject.shlb", $dist_dir);
|
||||
|
||||
DontStopForErrors();
|
||||
|
||||
BuildProject(":projects:SomeOtherProject.mcp", "SomeTarget");
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
B<Moz> comprises the routines needed to slap CodeWarrior around, force it
|
||||
to build a sequence of projects, report the results, and a few other things.
|
||||
This module should only contain functions that are generic to any build,
|
||||
not just the Mozilla build.
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
package Moz::Moz;
|
||||
require Exporter;
|
||||
|
||||
use Cwd;
|
||||
|
||||
use File::Copy;
|
||||
use File::Path;
|
||||
use File::Basename;
|
||||
|
||||
use Mac::Types;
|
||||
use Mac::Events;
|
||||
use Mac::Processes;
|
||||
|
||||
use ExtUtils::Manifest 'maniread';
|
||||
|
||||
use Moz::CodeWarriorLib;
|
||||
|
||||
@ISA = qw(Exporter);
|
||||
|
||||
@EXPORT = qw( LaunchCodeWarrior
|
||||
GetCodeWarriorRelativePath
|
||||
current_directory
|
||||
full_path_to
|
||||
DoBuildProject
|
||||
ImportXMLProject
|
||||
ExportProjectToXML
|
||||
OpenErrorLog
|
||||
MakeAlias
|
||||
GetFileModDate
|
||||
StopForErrors
|
||||
DontStopForErrors
|
||||
InstallFromManifest
|
||||
InstallResources
|
||||
RedirectOutputToFile
|
||||
Delay
|
||||
ActivateApplication
|
||||
IsProcessRunning);
|
||||
|
||||
@EXPORT_OK = qw(CloseErrorLog QUIET);
|
||||
|
||||
|
||||
sub current_directory()
|
||||
{
|
||||
my $current_directory = cwd();
|
||||
chop($current_directory) if ( $current_directory =~ m/:$/ );
|
||||
return $current_directory;
|
||||
}
|
||||
|
||||
sub full_path_to($)
|
||||
{
|
||||
my ($path) = @_;
|
||||
if ( $path =~ m/^[^:]+$/ )
|
||||
{
|
||||
$path = ":" . $path;
|
||||
}
|
||||
|
||||
if ( $path =~ m/^:/ )
|
||||
{
|
||||
$path = current_directory() . $path;
|
||||
}
|
||||
|
||||
return $path;
|
||||
}
|
||||
|
||||
$logging = 0;
|
||||
$recent_errors_file = "";
|
||||
$stop_on_1st_error = 1;
|
||||
$QUIET = 0;
|
||||
|
||||
|
||||
|
||||
=head2 Logging all the errors and warnings - C<OpenErrorLog($log_file)>, C<CloseErrorLog()>
|
||||
|
||||
The warnings and errors generated in the course of building projects can be logged to a file.
|
||||
Tinderbox uses this facility to show why a remote build failed.
|
||||
|
||||
Logging is off by default.
|
||||
Start logging at any point in your build process with C<OpenErrorLog($log_file)>.
|
||||
Stop with C<CloseErrorLog()>.
|
||||
You never need to close the log explicitly, unless you want to just log a couple of projects in the middle of a big list.
|
||||
C<CloseErrorLog()> is not exported by default.
|
||||
|
||||
=cut
|
||||
|
||||
sub CloseErrorLog()
|
||||
{
|
||||
if ( $logging )
|
||||
{
|
||||
close(ERROR_LOG);
|
||||
$logging = 0;
|
||||
StopForErrors() if $stop_on_1st_error;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
sub OpenErrorLog($)
|
||||
{
|
||||
my ($log_file) = @_;
|
||||
|
||||
CloseErrorLog();
|
||||
if ( $log_file )
|
||||
{
|
||||
$log_file = full_path_to($log_file);
|
||||
|
||||
open(ERROR_LOG, ">$log_file") || die "Error: Can't open $log_file\n";
|
||||
MacPerl::SetFileInfo("CWIE", "TEXT", $log_file);
|
||||
|
||||
$log_file =~ m/.+:(.+)/;
|
||||
$recent_errors_file = full_path_to("$1.part");
|
||||
$logging = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
=head2 Stopping before it's too late - C<StopForErrors()>, C<DontStopForErrors()>
|
||||
|
||||
When building a long list of projects, you decide whether to continue building subsequent projects when one fails.
|
||||
By default, your build script will C<die> after the first project that generates an error while building.
|
||||
Change this behavior with C<DontStopForErrors()>.
|
||||
Re-enable it with C<StopForErrors()>.
|
||||
|
||||
=cut
|
||||
|
||||
sub StopForErrors()
|
||||
{
|
||||
$stop_on_1st_error = 1;
|
||||
|
||||
# Can't stop for errors unless we notice them.
|
||||
# Can't notice them unless we are logging.
|
||||
# If the user didn't explicitly request logging, log to a temporary file.
|
||||
|
||||
if ( ! $recent_errors_file )
|
||||
{
|
||||
OpenErrorLog("${TMPDIR}BuildResults");
|
||||
}
|
||||
}
|
||||
|
||||
sub DontStopForErrors()
|
||||
{
|
||||
$stop_on_1st_error = 0;
|
||||
}
|
||||
|
||||
sub log_message($)
|
||||
{
|
||||
if ( $logging )
|
||||
{
|
||||
my ($message) = @_;
|
||||
print ERROR_LOG $message;
|
||||
}
|
||||
}
|
||||
|
||||
sub log_message_with_time($)
|
||||
{
|
||||
if ( $logging )
|
||||
{
|
||||
my ($message) = @_;
|
||||
my $time_stamp = localtime();
|
||||
log_message("$message ($time_stamp)\n");
|
||||
}
|
||||
}
|
||||
|
||||
sub log_recent_errors($)
|
||||
{
|
||||
my ($project_name) = @_;
|
||||
my $found_errors = 0;
|
||||
|
||||
if ( $logging )
|
||||
{
|
||||
open(RECENT_ERRORS, "<$recent_errors_file");
|
||||
|
||||
while( <RECENT_ERRORS> )
|
||||
{
|
||||
if ( /^Error/ || /^CouldnÕt find project file/ || /^Link Error/ )
|
||||
{
|
||||
# if (!$found_errors)
|
||||
# print $_;
|
||||
$found_errors = 1;
|
||||
}
|
||||
print ERROR_LOG $_;
|
||||
}
|
||||
|
||||
close(RECENT_ERRORS);
|
||||
unlink("$recent_errors_file");
|
||||
}
|
||||
|
||||
if ( $stop_on_1st_error && $found_errors )
|
||||
{
|
||||
print ERROR_LOG "### Build failed.\n";
|
||||
die "### Errors encountered building \"$project_name\".\n";
|
||||
}
|
||||
}
|
||||
|
||||
sub DoBuildProject($$$)
|
||||
{
|
||||
my ($project_path, $target_name, $clean_build) = @_;
|
||||
$project_path = full_path_to($project_path);
|
||||
|
||||
# $project_path =~ m/.+:(.+)/;
|
||||
# my $project_name = $1;
|
||||
|
||||
log_message_with_time("### Building \"$project_path\"");
|
||||
|
||||
# Check that the given project exists
|
||||
if (! -e $project_path)
|
||||
{
|
||||
print ERROR_LOG "### Build failed.\n";
|
||||
die "### Can't find project file \"$project_path\".\n";
|
||||
}
|
||||
|
||||
print "Building \"$project_path\[$target_name\]\"\n";
|
||||
|
||||
$had_errors = Moz::CodeWarriorLib::build_project(
|
||||
$project_path, $target_name, $recent_errors_file, $clean_build
|
||||
);
|
||||
WaitNextEvent();
|
||||
|
||||
# $had_errors =
|
||||
#MacPerl::DoAppleScript(<<END_OF_APPLESCRIPT);
|
||||
# tell (load script file "$CodeWarriorLib") to BuildProject("$project_path", "$project_name", "$target_name", "$recent_errors_file", $clean_build)
|
||||
#END_OF_APPLESCRIPT
|
||||
|
||||
# Append any errors to the globally accumulated log file
|
||||
# if ( $had_errors ) # Removed this test, because we want warnings, too. -- jrm
|
||||
{
|
||||
log_recent_errors($project_path);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sub ImportXMLProject($$)
|
||||
{
|
||||
my ($xml_path, $project_path) = @_;
|
||||
|
||||
# my ($codewarrior_ide_name) = Moz::CodeWarriorLib::getCodeWarriorIDEName();
|
||||
# my $ascript = <<EOS;
|
||||
# tell application "$codewarrior_ide_name"
|
||||
# make new (project document) as ("$project_path") with data ("$xml_path")
|
||||
# end tell
|
||||
#EOS
|
||||
# print $ascript."\n";
|
||||
# my($result) = MacPerl::DoAppleScript($ascript);
|
||||
# unless ($result) { die "Error: ImportXMLProject AppleScript failed $^E $result\n"; }
|
||||
#
|
||||
|
||||
my($import_error) = Moz::CodeWarriorLib::import_project($xml_path, $project_path);
|
||||
if ($import_error ne "") {
|
||||
die "Error: ImportXMLProject failed with error $import_error\n";
|
||||
}
|
||||
}
|
||||
|
||||
sub ExportProjectToXML($$)
|
||||
{
|
||||
my ($project_path, $xml_path) = @_;
|
||||
|
||||
my (@suffix_list) = (".mcp");
|
||||
my ($project_name, $project_dir, $suffix) = fileparse($project_path, @suffix_list);
|
||||
if ($suffix eq "") { die "Project: $project_path doesn't look like a project file.\n"; }
|
||||
|
||||
if (-e $xml_path) {
|
||||
print "$xml_path exists - not exporting $project_path\n";
|
||||
}
|
||||
else {
|
||||
print "Exporting $project_path to $xml_path\n";
|
||||
my($export_error) = Moz::CodeWarriorLib::export_project($project_path, $xml_path);
|
||||
if ($export_error ne "") {
|
||||
die "Error: export_project failed with error '$export_error'\n";
|
||||
}
|
||||
|
||||
if (! -e $xml_path) {
|
||||
die "Error: XML export to $xml_path failed\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
=head2 Miscellaneous
|
||||
|
||||
C<MakeAlias($old_file, $new_file)> functions like C<symlink()>, except with better argument defaulting and more explicit error messages.
|
||||
|
||||
=cut
|
||||
|
||||
sub MakeAlias($$)
|
||||
{
|
||||
my ($old_file, $new_file) = @_;
|
||||
|
||||
# if the directory to hold $new_file doesn't exist, create it
|
||||
if ( ($new_file =~ m/(.+:)/) && !-d $1 )
|
||||
{
|
||||
mkpath($1);
|
||||
}
|
||||
|
||||
# if a leaf name wasn't specified for $new_file, use the leaf from $old_file
|
||||
if ( ($new_file =~ m/:$/) && ($old_file =~ m/.+:(.+)/) )
|
||||
{
|
||||
$new_file .= $1;
|
||||
}
|
||||
|
||||
my $message = "Can't create a Finder alias (at \"$new_file\")\n for \"$old_file\"; because ";
|
||||
|
||||
die "Error: $message \"$old_file\" doesn't exist.\n" unless -e $old_file;
|
||||
die "Error: $message I won't replace an existing (non-alias) file with an alias.\n" if ( -e $new_file && ! -l $new_file );
|
||||
|
||||
# now: $old_file exists; $new_file doesn't (or else, is an alias already)
|
||||
|
||||
if ( -l $new_file )
|
||||
{
|
||||
# ...then see if it already points to $old_file
|
||||
my $current_target = full_path_to(readlink($new_file));
|
||||
my $new_target = full_path_to($old_file);
|
||||
|
||||
return if ( $current_target eq $new_target );
|
||||
# if the desired alias already exists and points to the right thing, then we're done
|
||||
|
||||
unlink $new_file;
|
||||
}
|
||||
|
||||
symlink($old_file, $new_file) || die "Error: $message symlink returned an unexpected error.\n";
|
||||
}
|
||||
|
||||
|
||||
=pod
|
||||
|
||||
C<InstallFromManifest()>
|
||||
|
||||
=cut
|
||||
|
||||
sub InstallFromManifest($;$$)
|
||||
{
|
||||
my ($manifest_file, $dest_dir, $flat) = @_;
|
||||
|
||||
$flat = 0 unless defined($flat); # if $flat, all rel. paths in MANIFEST get aliased to the root of $dest_dir
|
||||
|
||||
$dest_dir ||= ":";
|
||||
|
||||
$manifest_file =~ m/(.+):/;
|
||||
my $source_dir = $1;
|
||||
|
||||
chop($dest_dir) if $dest_dir =~ m/:$/;
|
||||
|
||||
#Mac::Events->import();
|
||||
WaitNextEvent();
|
||||
if ($flat)
|
||||
{
|
||||
print "Doing manifest on \"$manifest_file\" FLAT\n" unless $QUIET;
|
||||
}
|
||||
else
|
||||
{
|
||||
print "Doing manifest on \"$manifest_file\"\n" unless $QUIET;
|
||||
}
|
||||
|
||||
my $read = maniread(full_path_to($manifest_file));
|
||||
foreach $file (keys %$read)
|
||||
{
|
||||
next unless $file;
|
||||
|
||||
$subdir = ":";
|
||||
if (!$flat && ($file =~ /:.+:/ ))
|
||||
{
|
||||
$subdir = $&;
|
||||
}
|
||||
|
||||
$file = ":$file" unless $file =~ m/^:/;
|
||||
MakeAlias("$source_dir$file", "$dest_dir$subdir");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
=pod
|
||||
|
||||
C<InstallResources()>
|
||||
|
||||
=cut
|
||||
|
||||
# parameters are path to MANIFEST file, destination dir, true (to make copies) or false (to make aliases)
|
||||
sub InstallResources($;$;$)
|
||||
{
|
||||
my ($manifest_file, $dest_dir, $copy_files) = @_;
|
||||
|
||||
$dest_dir ||= ":";
|
||||
mkpath($dest_dir) if !-d $dest_dir;
|
||||
|
||||
$manifest_file =~ m/(.+):/;
|
||||
my $source_dir = $1;
|
||||
|
||||
chop($dest_dir) if $dest_dir =~ m/:$/;
|
||||
|
||||
WaitNextEvent();
|
||||
print "Installing resources from \"$manifest_file\"\n" unless $QUIET;
|
||||
|
||||
my $read = maniread(full_path_to($manifest_file));
|
||||
foreach $file (keys %$read)
|
||||
{
|
||||
next unless $file;
|
||||
|
||||
if ($copy_files)
|
||||
{
|
||||
copy("$source_dir:$file", "$dest_dir:$file");
|
||||
}
|
||||
else
|
||||
{
|
||||
MakeAlias("$source_dir:$file", "$dest_dir:$file");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// Delay
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub Delay($)
|
||||
{
|
||||
my ($delay_seconds) = @_;
|
||||
|
||||
$now = time;
|
||||
|
||||
$exit_time = $now + $delay_seconds;
|
||||
|
||||
while ($exit_time > $now) {
|
||||
$now = time;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// GetFileModDate
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub GetFileModDate($)
|
||||
{
|
||||
my($filePath)=@_;
|
||||
my($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
|
||||
$atime,$mtime,$ctime,$blksize,$blocks) = stat($filePath);
|
||||
return $mtime;
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// LaunchCodeWarrior
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub LaunchCodeWarrior($)
|
||||
{
|
||||
my($idepath_file) = @_; # full path to IDE location file
|
||||
my($cur_dir) = cwd();
|
||||
|
||||
# this both launches and writes the IDE path file
|
||||
Moz::CodeWarriorLib::activate($idepath_file);
|
||||
|
||||
chdir($cur_dir);
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// GetCodeWarriorRelativePath
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub GetCodeWarriorRelativePath($)
|
||||
{
|
||||
my($rel_path) = @_;
|
||||
return Moz::CodeWarriorLib::getCodeWarriorPath($rel_path);
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// RedirectOutputToFile
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub RedirectOutputToFile($)
|
||||
{
|
||||
my($log_file) = @_;
|
||||
|
||||
# ensure that folders in the path exist
|
||||
my($logdir) = "";
|
||||
my($logfile) = $log_file;
|
||||
|
||||
if ($log_file =~ /(.+?:)([^:]+)$/) # ? for non-greedy match
|
||||
{
|
||||
$logdir = $1;
|
||||
$logfile = $2;
|
||||
|
||||
mkpath($logdir);
|
||||
}
|
||||
|
||||
print "Output is now being redirected to the file '$log_file'\n";
|
||||
|
||||
open(STDOUT, "> $log_file") || die "Can't redirect stdout";
|
||||
open(STDERR, ">&STDOUT") || die "Can't dup stdout";
|
||||
select(STDERR); $| = 1; # make unbuffered
|
||||
select(STDOUT); $| = 1; # make unbuffered
|
||||
|
||||
MacPerl::SetFileInfo("CWIE", "TEXT", $log_file);
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// ActivateApplication
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
|
||||
sub ActivateApplication($)
|
||||
{
|
||||
my ($appSignature) = @_;
|
||||
my ($psi, $found);
|
||||
my ($appPSN);
|
||||
|
||||
$found = 0;
|
||||
|
||||
foreach $psi (values(%Process))
|
||||
{
|
||||
if ($psi->processSignature() eq $appSignature)
|
||||
{
|
||||
$appPSN = $psi->processNumber();
|
||||
$found = 1;
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
if ($found == 0 || SameProcess($appPSN, GetFrontProcess()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SetFrontProcess($appPSN);
|
||||
|
||||
while (GetFrontProcess() != $appPSN)
|
||||
{
|
||||
WaitNextEvent();
|
||||
}
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// IsProcessRunning
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
|
||||
sub IsProcessRunning($)
|
||||
{
|
||||
my($processName, $psn, $psi) = @_;
|
||||
while ( ($psn, $psi) = each(%Process) ) {
|
||||
if ($psi->processName eq $processName) { return 1; }
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
|
||||
=head1 AUTHORS
|
||||
|
||||
Scott Collins <scc@netscape.com>, Simon Fraser <sfraser@netscape.com>, Chris Yeh <cyeh@netscape.com>
|
||||
|
||||
=head1 SEE ALSO
|
||||
|
||||
BuildMozillaDebug.pl (et al), BuildList.pm, CodeWarriorLib (an AppleScript library)
|
||||
|
||||
=head1 COPYRIGHT
|
||||
|
||||
The contents of this file are subject to the Netscape Public
|
||||
License Version 1.1 (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.mozilla.org/NPL/
|
||||
|
||||
Software distributed under the License is distributed on an "AS
|
||||
IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
implied. See the License for the specific language governing
|
||||
rights and limitations under the License.
|
||||
|
||||
The Original Code is Mozilla Communicator client code, released
|
||||
March 31, 1998.
|
||||
|
||||
The Initial Developer of the Original Code is Netscape
|
||||
Communications Corporation. Portions created by Netscape are
|
||||
Copyright (C) 1998-1999 Netscape Communications Corporation. All
|
||||
Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
|
||||
=cut
|
||||
@@ -1,272 +0,0 @@
|
||||
|
||||
package Moz::Prefs;
|
||||
|
||||
require 5.004;
|
||||
require Exporter;
|
||||
|
||||
# Package that attempts to read a file from the Preferences folder,
|
||||
# and get build settings out of it
|
||||
|
||||
use strict;
|
||||
|
||||
use Exporter;
|
||||
use File::Path;
|
||||
|
||||
use Mac::Files;
|
||||
|
||||
use vars qw(@ISA @EXPORT);
|
||||
|
||||
@ISA = qw(Exporter);
|
||||
@EXPORT = qw(ReadMozUserPrefs);
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
#
|
||||
# GetPrefsFolder
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
sub GetPrefsFolder()
|
||||
{
|
||||
my($prefs_folder) = FindFolder(kOnSystemDisk, kPreferencesFolderType, 1);
|
||||
return $prefs_folder.":Mozilla build prefs";
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
#
|
||||
# SetArrayValue
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
sub SetArrayValue($$$)
|
||||
{
|
||||
my($array_ref, $index1, $index2) = @_;
|
||||
|
||||
my($index);
|
||||
foreach $index (@$array_ref)
|
||||
{
|
||||
if ($index->[0] eq $index1)
|
||||
{
|
||||
$index->[1] = $index2;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
#
|
||||
# WriteDefaultPrefsFile
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
sub WriteDefaultPrefsFile($)
|
||||
{
|
||||
my($file_path) = @_;
|
||||
|
||||
my($file_contents);
|
||||
$file_contents = <<'EOS';
|
||||
% You can use this file to customize the Mozilla build system.
|
||||
% The following kinds of lines are allowable:
|
||||
% Comment lines, which start with a '%' in the first column
|
||||
% Lines which modify the default build settings. For the list of flags,
|
||||
% see MozBuildFlags.pm. Examples are:
|
||||
%
|
||||
% build pull 0 % don't pull
|
||||
% options mng 1 % turn mng on
|
||||
%
|
||||
% Line containing the special 'buildfrom' flag, which specifies
|
||||
% where to start the build. Example:
|
||||
%
|
||||
% buildfrom nglayout % where to start the build
|
||||
%
|
||||
% Lines which specify the location of the files used to store paths
|
||||
% to the CodeWarrior IDE, and the MacCVS Pro session file. Note quoting
|
||||
% of paths containing whitespace. Examples:
|
||||
%
|
||||
% filepath idepath ::codewarrior.txt
|
||||
% filepath sessionpath ":Some folder:MacCVS session path.txt"
|
||||
%
|
||||
% Lines which modify the build settings like %main::DEBUG.
|
||||
% Any lines which do not match either of the above are assumed
|
||||
% to set variables on $main::. Examples:
|
||||
%
|
||||
% MOZILLA_OFFICIAL 1
|
||||
%
|
||||
EOS
|
||||
|
||||
$file_contents =~ s/%/#/g;
|
||||
|
||||
local(*PREFS_FILE);
|
||||
|
||||
open(PREFS_FILE, "> $file_path") || die "Could not write default prefs file\n";
|
||||
print PREFS_FILE ($file_contents);
|
||||
close(PREFS_FILE);
|
||||
|
||||
MacPerl::SetFileInfo("McPL", "TEXT", $file_path);
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
#
|
||||
# HandlePrefSet
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
sub HandlePrefSet($$$$)
|
||||
{
|
||||
my($flags, $name, $value, $desc) = @_;
|
||||
|
||||
if (SetArrayValue($flags, $name, $value)) {
|
||||
print "Prefs set $desc flag '$name' to '$value'\n";
|
||||
} else {
|
||||
die "$desc setting '$name' is not a valid option\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
#
|
||||
# HandleBuildFromPref
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
sub HandleBuildFromPref($$)
|
||||
{
|
||||
my($build_array, $name) = @_;
|
||||
|
||||
my($setting) = 0;
|
||||
my($index);
|
||||
foreach $index (@$build_array)
|
||||
{
|
||||
if ($index->[0] eq $name) {
|
||||
$setting = 1;
|
||||
}
|
||||
|
||||
$index->[1] = $setting;
|
||||
}
|
||||
|
||||
if ($setting == 1) {
|
||||
print "Building from $name onwards, as specified by prefs\n";
|
||||
} else {
|
||||
printf "Failed to find buildfrom setting '$name'\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
#
|
||||
# ReadPrefsFile
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
sub ReadPrefsFile($$$$$)
|
||||
{
|
||||
my($file_path, $build_flags, $options_flags, $filepath_flags, $create_if_missing) = @_;
|
||||
|
||||
local(*PREFS_FILE);
|
||||
|
||||
if (open(PREFS_FILE, "< $file_path"))
|
||||
{
|
||||
print "Reading build prefs from '$file_path'\n";
|
||||
|
||||
while (<PREFS_FILE>)
|
||||
{
|
||||
my($line) = $_;
|
||||
chomp($line);
|
||||
|
||||
if ($line =~ /^\#/ || $line =~ /^\s*$/) { # ignore comments and empty lines
|
||||
next;
|
||||
}
|
||||
|
||||
if (($line =~ /^\s*([^#\s]+)\s+([^#\s]+)\s+\"(.+)\"(\s+#.+)?/) ||
|
||||
($line =~ /^\s*([^#\s]+)\s+([^#\s]+)\s+\'(.+)\'(\s+#.+)?/) ||
|
||||
($line =~ /^\s*([^#\s]+)\s+([^#\s]+)\s+([^#\s]+)(\s+#.+)?/))
|
||||
{
|
||||
my($array_name) = $1;
|
||||
my($option_name) = $2;
|
||||
my($option_value) = $3;
|
||||
|
||||
# print "Read '$array_name' '$option_name' '$option_value'\n";
|
||||
|
||||
if ($array_name eq "build")
|
||||
{
|
||||
HandlePrefSet($build_flags, $option_name, $option_value, "Build");
|
||||
}
|
||||
elsif ($array_name eq "options")
|
||||
{
|
||||
HandlePrefSet($options_flags, $option_name, $option_value, "Options");
|
||||
}
|
||||
elsif ($array_name eq "filepath" && $option_name && $option_value)
|
||||
{
|
||||
HandlePrefSet($filepath_flags, $option_name, $option_value, "Filepath");
|
||||
}
|
||||
else
|
||||
{
|
||||
print "Unknown pref option at $line\n";
|
||||
}
|
||||
}
|
||||
elsif ($line =~ /^\s*buildfrom\s+([^#\s]+)(\s+#.+)?/)
|
||||
{
|
||||
my($build_start) = $1;
|
||||
HandleBuildFromPref($build_flags, $build_start);
|
||||
}
|
||||
elsif ($line =~ /^\s*([^#\s]+)\s+([^#\s]+)(\s+#.+)?/)
|
||||
{
|
||||
my($build_var) = $1;
|
||||
my($var_setting) = $2;
|
||||
|
||||
print "Setting \$main::$build_var to $var_setting\n";
|
||||
eval "\$main::$build_var = \"$var_setting\"";
|
||||
}
|
||||
else
|
||||
{
|
||||
print "Unrecognized input line at $line\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
close(PREFS_FILE);
|
||||
}
|
||||
elsif ($create_if_missing)
|
||||
{
|
||||
print "No prefs file found at $file_path; using defaults\n";
|
||||
|
||||
my($folder_path) = $file_path;
|
||||
$folder_path =~ s/[^:]+$//;
|
||||
mkpath($folder_path);
|
||||
WriteDefaultPrefsFile($file_path);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
#
|
||||
# ReadMozUserPrefs
|
||||
#
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
sub ReadMozUserPrefs($$$$)
|
||||
{
|
||||
my($prefs_file_name, $build_flags, $options_flags, $filepath_flags) = @_;
|
||||
|
||||
if ($prefs_file_name eq "") { return; }
|
||||
|
||||
# if local prefs exist, just use those. Othewise, look in the prefs folder
|
||||
if (-e $prefs_file_name)
|
||||
{
|
||||
# read local prefs
|
||||
ReadPrefsFile($prefs_file_name, $build_flags, $options_flags, $filepath_flags, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
# first read prefs folder prefs
|
||||
my($prefs_path) = GetPrefsFolder();
|
||||
$prefs_path .= ":$prefs_file_name";
|
||||
|
||||
ReadPrefsFile($prefs_path, $build_flags, $options_flags, $filepath_flags, 1);
|
||||
}
|
||||
}
|
||||
|
||||
1;
|
||||
@@ -1,932 +0,0 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (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.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Simon Fraser <sfraser@netscape.com>
|
||||
#
|
||||
|
||||
package Moz::ProjectXML;
|
||||
|
||||
require 5.004;
|
||||
require Exporter;
|
||||
|
||||
use strict;
|
||||
use Exporter;
|
||||
|
||||
use Cwd;
|
||||
use XML::DOM;
|
||||
|
||||
use vars qw(@ISA @EXPORT);
|
||||
|
||||
@ISA = qw(Exporter);
|
||||
@EXPORT = qw(
|
||||
ParseXMLDocument
|
||||
DisposeXMLDocument
|
||||
WriteXMLDocument
|
||||
CleanupPro5XML
|
||||
GetTargetsList
|
||||
CloneTarget
|
||||
SetAsSharedLibraryTarget
|
||||
SetAsStaticLibraryTarget
|
||||
AddTarget
|
||||
RemoveTarget
|
||||
GetTargetSetting
|
||||
SetTargetSetting
|
||||
getChildElementTextContents
|
||||
);
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------------------------------
|
||||
# A module for reading, manipulating, and writing XML-format CodeWarrior project files.
|
||||
#
|
||||
# Sample usage:
|
||||
#
|
||||
# use ProjectXML;
|
||||
#
|
||||
# my $doc = ProjectXML::ParseXMLDocument("Test.mcp.xml");
|
||||
# ProjectXML::CloneTarget($doc, "Test.shlb", "Test.lib");
|
||||
# ProjectXML::SetAsStaticLibraryTarget($doc, "Test.lib", "TestOutput.lib");
|
||||
# ProjectXML::WriteXMLDocument($doc, "Test_out.xml");
|
||||
# ProjectXML::DisposeXMLDocument($doc);
|
||||
#
|
||||
#--------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// ParseXMLDocument
|
||||
#// Note that the caller must call DisposeXMLDocument on the returned doc
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub ParseXMLDocument($)
|
||||
{
|
||||
my($doc_path) = @_;
|
||||
|
||||
my $parser = new XML::DOM::Parser(ErrorContext => 2);
|
||||
my $doc = $parser->parsefile($doc_path);
|
||||
|
||||
return $doc;
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// DisposeXMLDocument
|
||||
#// Needed to avoid memory leaks - cleanup circular references for garbage collection
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub DisposeXMLDocument($)
|
||||
{
|
||||
my($doc) = @_;
|
||||
|
||||
$doc->dispose();
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// WriteXMLDocument
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
|
||||
sub _pro5_tag_compression($$)
|
||||
{
|
||||
return 1; # Pro 5 is broken and can't import XML with <foo/> style tags
|
||||
}
|
||||
|
||||
sub _pro6plus_tag_compression($$)
|
||||
{
|
||||
return 0; # Pro 6 can deal with empty XML tags like <foo/>
|
||||
}
|
||||
|
||||
sub WriteXMLDocument($$$)
|
||||
{
|
||||
my($doc, $file_path, $ide_version) = @_;
|
||||
|
||||
if ($ide_version eq "4.0")
|
||||
{
|
||||
XML::DOM::setTagCompression(\&_pro5_tag_compression);
|
||||
}
|
||||
else
|
||||
{
|
||||
XML::DOM::setTagCompression(\&_pro6plus_tag_compression);
|
||||
}
|
||||
|
||||
$doc->printToFile($file_path);
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// CleanupPro5XML
|
||||
#// XML Projects exported by Pro 5 contain garbage data under the MWMerge_MacOS_skipResources
|
||||
#// setting. This routine cleans this up, saving the result to a new file
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub CleanupPro5XML($$)
|
||||
{
|
||||
my($xml_path, $out_path) = @_;
|
||||
|
||||
local(*XML_FILE);
|
||||
open(XML_FILE, "< $xml_path") || die "Error: failed to open file $xml_path\n";
|
||||
|
||||
local(*CLEANED_FILE);
|
||||
open(CLEANED_FILE, "> $out_path") || die "Error: failed to open file $out_path for writing\n";
|
||||
|
||||
my $in_skip_resources_settings = 0;
|
||||
|
||||
while(<XML_FILE>)
|
||||
{
|
||||
my($line) = $_;
|
||||
|
||||
if ($line =~ /^<\?codewarrior/) # is processing inst line
|
||||
{
|
||||
my $test_line = $line;
|
||||
chomp($test_line);
|
||||
|
||||
my $out_line = $test_line;
|
||||
if ($test_line =~ /^<\?codewarrior\s+exportversion=\"(.+)\"\s+ideversion=\"(.+)\"\s*\?>$/)
|
||||
{
|
||||
my $export_version = $1;
|
||||
my $ide_version = $2;
|
||||
|
||||
$ide_version = "4.0_mozilla"; # pseudo IDE version so we know we touched it
|
||||
$out_line = "<?codewarrior exportversion=\"".$export_version."\" ideversion=\"".$ide_version."\"?>";
|
||||
}
|
||||
|
||||
print CLEANED_FILE "$out_line\n";
|
||||
next;
|
||||
}
|
||||
|
||||
if ($line =~ /MWMerge_MacOS_skipResources/)
|
||||
{
|
||||
$in_skip_resources_settings = 1;
|
||||
print CLEANED_FILE "$line";
|
||||
}
|
||||
elsif($in_skip_resources_settings && $line =~ /<!-- Settings for/)
|
||||
{
|
||||
# leaving bad settings lines. Write closing tag
|
||||
print CLEANED_FILE " <!-- Corrupted setting entries removed by script -->\n";
|
||||
print CLEANED_FILE " </SETTING>\n\n";
|
||||
|
||||
print CLEANED_FILE "$line";
|
||||
|
||||
$in_skip_resources_settings = 0;
|
||||
}
|
||||
elsif (!$in_skip_resources_settings)
|
||||
{
|
||||
print CLEANED_FILE "$line";
|
||||
}
|
||||
}
|
||||
|
||||
close(XML_FILE);
|
||||
close(CLEANED_FILE);
|
||||
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------------------------------------------
|
||||
# SniffProjectXMLIDEVersion
|
||||
#
|
||||
#--------------------------------------------------------------------------------------------------
|
||||
sub SniffProjectXMLIDEVersion($)
|
||||
{
|
||||
my($xml_path) = @_;
|
||||
|
||||
my $found_version = "";
|
||||
|
||||
local(*XML_FILE);
|
||||
open(XML_FILE, "< $xml_path") || die "Error: failed to open file $xml_path\n";
|
||||
|
||||
while(<XML_FILE>)
|
||||
{
|
||||
my($line) = $_;
|
||||
chomp($line);
|
||||
|
||||
if ($line =~ /^<\?codewarrior/) # is processing inst line
|
||||
{
|
||||
unless ($line =~ /^<\?codewarrior\s+exportversion=\"(.+)\"\s+ideversion=\"(.+)\"\s*\?>$/)
|
||||
{
|
||||
die "Error: Failed to find ideversion in $xml_path in line $line\n";
|
||||
}
|
||||
|
||||
my $export_version = $1;
|
||||
my $ide_version = $2;
|
||||
|
||||
$found_version = $ide_version;
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
close(XML_FILE);
|
||||
|
||||
return $found_version;
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// GetTargetsList
|
||||
#// Returns an array of target names
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub GetTargetsList($)
|
||||
{
|
||||
my($doc) = @_;
|
||||
|
||||
my $nodes = $doc->getElementsByTagName("TARGET");
|
||||
my $n = $nodes->getLength;
|
||||
|
||||
my @target_names;
|
||||
|
||||
for (my $i = 0; $i < $n; $i++)
|
||||
{
|
||||
my ($node) = $nodes->item($i);
|
||||
|
||||
my($target_name) = getChildElementTextContents($node, "NAME");
|
||||
push(@target_names, $target_name);
|
||||
}
|
||||
|
||||
return @target_names;
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// CloneTarget
|
||||
#// Clone the named target, renaming it to 'new_name'
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub CloneTarget($$$)
|
||||
{
|
||||
my($doc, $target_name, $new_name) = @_;
|
||||
|
||||
my $target_node = getTargetNode($doc, $target_name);
|
||||
|
||||
# clone here
|
||||
my $target_clone = $target_node->cloneNode(1); # deep clone
|
||||
|
||||
# -- munge target settings --
|
||||
|
||||
# set the target name field
|
||||
setChildElementTextContents($doc, $target_clone, "NAME", $new_name);
|
||||
|
||||
# set the targetname pref
|
||||
setTargetNodeSetting($doc, $target_clone, "Targetname", $new_name);
|
||||
|
||||
# -- insert new target subtree --
|
||||
|
||||
my $target_list = $target_node->getParentNode();
|
||||
$target_list->appendChild($target_clone);
|
||||
|
||||
# -- now add to targetorder --
|
||||
my (@target_order_nodes) = getChildOfDocument($doc, "TARGETORDER");
|
||||
|
||||
my $target_order = @target_order_nodes[0];
|
||||
|
||||
my $new_order = $doc->createElement("ORDEREDTARGET");
|
||||
my $order_name = $doc->createElement("NAME");
|
||||
|
||||
$new_order->appendChild($order_name);
|
||||
|
||||
setChildElementTextContents($doc, $new_order, "NAME", $new_name);
|
||||
$target_order->appendChild($new_order);
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// SetAsSharedLibraryTarget
|
||||
#//
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub SetAsSharedLibraryTarget($$$)
|
||||
{
|
||||
my($doc, $target_name, $output_name) = @_;
|
||||
|
||||
my $target_node = getTargetNode($doc, $target_name);
|
||||
|
||||
setTargetNodeSetting($doc, $target_node, "MWProject_PPC_type", "SharedLibrary");
|
||||
setTargetNodeSetting($doc, $target_node, "MWProject_PPC_filetype", "1936223330"); #'shlb'
|
||||
setTargetNodeSetting($doc, $target_node, "MWProject_PPC_outfile", $output_name);
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// AddFileToTarget
|
||||
#//
|
||||
#// Add a file to the specified target(s).
|
||||
#//
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub AddFileToTarget($$$)
|
||||
{
|
||||
my($doc, $target_list, $file_name) = @_;
|
||||
|
||||
# the file must be added in 3 places:
|
||||
# 1. in <TARGET><FILELIST><FILE> (with linkage flags if necessary)
|
||||
# 2. in <TARGET><LINKORDER><FILEREF>
|
||||
# 3. in <GROUPLIST><GROUP><FILEREF>
|
||||
die "Write me\n";
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// RemoveFileFromTarget
|
||||
#//
|
||||
#// Remove a file from the specified target, removing it from the entire project
|
||||
#// if no other targets reference it.
|
||||
#//
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub RemoveFileFromTarget($$$)
|
||||
{
|
||||
my($doc, $target_node, $file_name) = @_;
|
||||
|
||||
# the file must be removed in 3 places:
|
||||
# 1. in <TARGET><FILELIST><FILE>
|
||||
# 2. in <TARGET><LINKORDER><FILEREF>
|
||||
# 3. in <GROUPLIST><GROUP><FILEREF>
|
||||
|
||||
# first, remove from <FILELIST>
|
||||
my $filelist_node = getFirstChildElement($target_node, "FILELIST");
|
||||
unless ($filelist_node) { die "Error: failed to find FILELIST node\n"; }
|
||||
|
||||
my $file_node = getChildNodeByGrandchildContents($doc, $filelist_node, "FILE", "PATH", $file_name);
|
||||
unless ($file_node) { return; }
|
||||
|
||||
$filelist_node->removeChild($file_node);
|
||||
|
||||
# next, remove from <LINKORDER>
|
||||
my $linkorder_node = getFirstChildElement($target_node, "LINKORDER");
|
||||
unless ($linkorder_node) { die "Error: failed to find LINKORDER node\n"; }
|
||||
|
||||
my $fileref_node = getChildNodeByGrandchildContents($doc, $linkorder_node, "FILEREF", "PATH", $file_name);
|
||||
unless ($fileref_node) { die "Error: link order node for file $file_name not found\n"; }
|
||||
|
||||
$linkorder_node->removeChild($fileref_node);
|
||||
|
||||
# last, remove from <GROUPLIST>
|
||||
# <GROUPLIST> is cross-target, so we have to be careful here.
|
||||
my $grouplist_node = getChildOfDocument($doc, "GROUPLIST");
|
||||
unless ($grouplist_node) { die "Error: failed to find GROUPLIST node\n"; }
|
||||
|
||||
# if the file isn't in any other targets, remove it from the groups
|
||||
if (!GetFileInUse($doc, $file_name))
|
||||
{
|
||||
print "File $file_name is in no other targest. Removing from project\n";
|
||||
|
||||
my @group_nodes;
|
||||
getChildElementsOfType($doc, $grouplist_node, "GROUP", \@group_nodes);
|
||||
my $group_node;
|
||||
foreach $group_node (@group_nodes)
|
||||
{
|
||||
my @fileref_nodes;
|
||||
getChildElementsOfType($doc, $group_node, "FILEREF", \@fileref_nodes);
|
||||
|
||||
my $fileref_node;
|
||||
foreach $fileref_node (@fileref_nodes)
|
||||
{
|
||||
my $path_name = getChildElementTextContents($fileref_node, "PATH");
|
||||
if ($path_name eq $file_name)
|
||||
{
|
||||
print "Removing $file_name from project group list\n";
|
||||
$group_node->removeChild($fileref_node);
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
# can a file appear in more than one group?
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// SetAsStaticLibraryTarget
|
||||
#//
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub SetAsStaticLibraryTarget($$$)
|
||||
{
|
||||
my($doc, $target_name, $output_name) = @_;
|
||||
|
||||
my $target_node = getTargetNode($doc, $target_name);
|
||||
|
||||
setTargetNodeSetting($doc, $target_node, "MWProject_PPC_type", "Library");
|
||||
setTargetNodeSetting($doc, $target_node, "MWProject_PPC_filetype", "1061109567"); #'????'
|
||||
setTargetNodeSetting($doc, $target_node, "MWProject_PPC_outfile", $output_name);
|
||||
|
||||
# static targets don't need any library linkage, so we can remove linkage
|
||||
# with all .shlb and .Lib files.
|
||||
|
||||
my(@obsolete_files) = ("NSStdLibStubs", "InterfacesStubs", "InterfaceLib", "InternetConfigLib");
|
||||
|
||||
print " Removing libraries etc. from target\n";
|
||||
|
||||
# get all files in target
|
||||
my @target_files = GetTargetFilesList($doc, $target_name);
|
||||
my $target_file;
|
||||
foreach $target_file (@target_files)
|
||||
{
|
||||
if ($target_file =~ /(\.shlb|\.lib|\.Lib|\.o|\.exp)$/)
|
||||
{
|
||||
RemoveFileFromTarget($doc, $target_node, $target_file);
|
||||
}
|
||||
}
|
||||
|
||||
print " Removing stub libraries from target\n";
|
||||
|
||||
# then remove files with known names
|
||||
my $obs_file;
|
||||
foreach $obs_file (@obsolete_files)
|
||||
{
|
||||
RemoveFileFromTarget($doc, $target_node, $obs_file);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// AddTarget
|
||||
#//
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub AddTarget($$)
|
||||
{
|
||||
my($doc, $target_name) = @_;
|
||||
|
||||
die "Write me\n";
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// RemoveTarget
|
||||
#//
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub RemoveTarget($$)
|
||||
{
|
||||
my($doc, $target_name) = @_;
|
||||
|
||||
die "Write me\n";
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// GetTargetSetting
|
||||
#// Get the value for the specified setting in the specified target
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub GetTargetSetting($$$)
|
||||
{
|
||||
my($doc, $target_name, $setting_name) = @_;
|
||||
|
||||
my $target_node = getTargetNode($doc, $target_name);
|
||||
return getTargetNodeSetting($target_node, "VALUE");
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// SetTargetSetting
|
||||
#// Set the value for the specified setting in the specified target
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub SetTargetSetting($$$$)
|
||||
{
|
||||
my($doc, $target_name, $setting_name, $new_value) = @_;
|
||||
|
||||
my $target_node = getTargetNode($doc, $target_name);
|
||||
setTargetNodeSetting($doc, $target_node, "VALUE", $new_value);
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// GetTargetFilesList
|
||||
#// Return an array of the files in the target (in filelist order)
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub GetTargetFilesList($$)
|
||||
{
|
||||
my($doc, $target_name) = @_;
|
||||
|
||||
my $target_node = getTargetNode($doc, $target_name);
|
||||
|
||||
my @files_list;
|
||||
|
||||
my $filelist_node = getFirstChildElement($target_node, "FILELIST");
|
||||
unless ($filelist_node) { die "Error: failed to find FILELIST node\n"; }
|
||||
|
||||
my @file_nodes;
|
||||
getChildElementsOfType($doc, $filelist_node, "FILE", \@file_nodes);
|
||||
|
||||
my $node;
|
||||
foreach $node (@file_nodes)
|
||||
{
|
||||
my $file_name = getChildElementTextContents($node, "PATH");
|
||||
push(@files_list, $file_name);
|
||||
}
|
||||
|
||||
return @files_list;
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// FileIsInTarget
|
||||
#//
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub FileIsInTarget($$$)
|
||||
{
|
||||
my($doc, $file_name, $target_name) = @_;
|
||||
|
||||
my $target_node = getTargetNode($doc, $target_name);
|
||||
unless ($target_node) { die "Error: no target found called $target_name\n"; }
|
||||
|
||||
my $file_node = GetTargetFileNode($doc, $target_node, $file_name);
|
||||
if ($file_node) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// GetFileTargetsList
|
||||
#// Return an array of the targets that a file is in (expensive)
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub GetFileTargetsList($$)
|
||||
{
|
||||
my ($doc, $file_name) = @_;
|
||||
|
||||
my @target_list;
|
||||
|
||||
my @targets = GetTargetsList($doc);
|
||||
my $target;
|
||||
|
||||
foreach $target (@targets)
|
||||
{
|
||||
if (FileIsInTarget($doc, $file_name, $target))
|
||||
{
|
||||
push(@target_list, $target);
|
||||
}
|
||||
}
|
||||
|
||||
return @target_list;
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// GetTargetFileNode
|
||||
#//
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub GetTargetFileNode($$$)
|
||||
{
|
||||
my($doc, $target_node, $file_name) = @_;
|
||||
|
||||
my $filelist_node = getFirstChildElement($target_node, "FILELIST");
|
||||
unless ($filelist_node) { die "Error: failed to find FILELIST node\n"; }
|
||||
|
||||
my $file_node = getChildNodeByGrandchildContents($doc, $filelist_node, "FILE", "PATH", $file_name);
|
||||
|
||||
return $file_node;
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// GetFileInUse
|
||||
#// Return true if the file is used by any target
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub GetFileInUse($$)
|
||||
{
|
||||
my($doc, $file_name) = @_;
|
||||
|
||||
my $targetlist_node = getChildOfDocument($doc, "TARGETLIST");
|
||||
|
||||
my $target_node = $targetlist_node->getFirstChild();
|
||||
|
||||
while ($target_node)
|
||||
{
|
||||
if ($target_node->getNodeTypeName eq "ELEMENT_NODE" &&
|
||||
$target_node->getTagName() eq "TARGET")
|
||||
{
|
||||
# if this is a target node
|
||||
my $file_node = GetTargetFileNode($doc, $target_node, $file_name);
|
||||
if ($file_node) {
|
||||
return 1; # found it
|
||||
}
|
||||
}
|
||||
|
||||
$target_node = $target_node->getNextSibling();
|
||||
}
|
||||
|
||||
# not found
|
||||
return 0;
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// getChildOfDocument
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub getChildOfDocument($$)
|
||||
{
|
||||
my($doc, $child_type) = @_;
|
||||
|
||||
return getFirstChildElement($doc->getDocumentElement(), $child_type);
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// getFirstChildElement
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub getFirstChildElement($$)
|
||||
{
|
||||
my($node, $element_name) = @_;
|
||||
|
||||
my $found_node;
|
||||
|
||||
unless ($node) { die "getFirstChildElement called with empty node\n"; }
|
||||
|
||||
#look for the first "element_name" child
|
||||
|
||||
my $child_node = $node->getFirstChild();
|
||||
|
||||
while ($child_node)
|
||||
{
|
||||
if ($child_node->getNodeTypeName eq "ELEMENT_NODE" &&
|
||||
$child_node->getTagName() eq $element_name)
|
||||
{
|
||||
$found_node = $child_node;
|
||||
last;
|
||||
}
|
||||
|
||||
$child_node = $child_node->getNextSibling();
|
||||
}
|
||||
|
||||
return $found_node;
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// getChildElementsOfType
|
||||
#//
|
||||
#// Return an array of refs to child nodes of the given type
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub getChildElementsOfType($$$$)
|
||||
{
|
||||
my($doc, $node, $child_type, $array_ref) = @_;
|
||||
|
||||
my $child_node = $node->getFirstChild();
|
||||
|
||||
while ($child_node)
|
||||
{
|
||||
if ($child_node->getNodeTypeName eq "ELEMENT_NODE" &&
|
||||
$child_node->getTagName() eq $child_type)
|
||||
{
|
||||
push(@$array_ref, $child_node);
|
||||
}
|
||||
|
||||
$child_node = $child_node->getNextSibling();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// getChildElementTextContents
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#
|
||||
# Given <FOOPY><NERD>Hi!</NERD></FOOPY>, where $node is <FOOPY>,
|
||||
# returns "Hi!". If > 1 <NERD> node, returns the contents of the first.
|
||||
#
|
||||
sub getChildElementTextContents($$)
|
||||
{
|
||||
my($node, $tag_name) = @_;
|
||||
|
||||
my $first_element = getFirstChildElement($node, $tag_name);
|
||||
my $text_node = $first_element->getFirstChild();
|
||||
|
||||
my $text_contents = "";
|
||||
|
||||
# concat adjacent text nodes
|
||||
while ($text_node)
|
||||
{
|
||||
if ($text_node->getNodeTypeName() ne "TEXT_NODE")
|
||||
{
|
||||
last;
|
||||
}
|
||||
|
||||
$text_contents = $text_contents.$text_node->getData();
|
||||
$text_node = $text_node->getNextSibling();
|
||||
}
|
||||
|
||||
return $text_contents;
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// setChildElementTextContents
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub setChildElementTextContents($$$$)
|
||||
{
|
||||
my($doc, $node, $tag_name, $contents_text) = @_;
|
||||
|
||||
my $first_element = getFirstChildElement($node, $tag_name);
|
||||
my $new_text_node = $doc->createTextNode($contents_text);
|
||||
|
||||
# replace all child elements with a text element
|
||||
removeAllChildren($first_element);
|
||||
|
||||
$first_element->appendChild($new_text_node);
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// getChildNodeByContents
|
||||
#//
|
||||
#// Consider <foo><bar><baz>Foopy</baz></bar><bar><baz>Loopy</baz></bar></foo>
|
||||
#// This function, when called with getChildNodeByContents($foonode, "bar", "baz", "Loopy")
|
||||
#// returns the second <bar> node.
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub getChildNodeByGrandchildContents($$$$$)
|
||||
{
|
||||
my($doc, $node, $child_type, $gc_type, $gc_contents) = @_; # gc = grandchild
|
||||
|
||||
my $found_node;
|
||||
my $child_node = $node->getFirstChild();
|
||||
while ($child_node)
|
||||
{
|
||||
if ($child_node->getNodeTypeName eq "ELEMENT_NODE" &&
|
||||
$child_node->getTagName() eq $child_type)
|
||||
{
|
||||
# check for a child of this node of type
|
||||
my $child_contents = getChildElementTextContents($child_node, $gc_type);
|
||||
|
||||
if ($child_contents eq $gc_contents)
|
||||
{
|
||||
$found_node = $child_node;
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
$child_node = $child_node->getNextSibling();
|
||||
}
|
||||
|
||||
return $found_node;
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// getTargetNode
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub getTargetNode($$)
|
||||
{
|
||||
my($doc, $target_name) = @_;
|
||||
|
||||
my $targetlist_node = getChildOfDocument($doc, "TARGETLIST");
|
||||
return getChildNodeByGrandchildContents($doc, $targetlist_node, "TARGET", "NAME", $target_name);
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// getTargetNamedSettingNode
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub getTargetNamedSettingNode($$)
|
||||
{
|
||||
my($target_node, $setting_name) = @_;
|
||||
|
||||
my $setting_node;
|
||||
|
||||
my $settinglist_node = getFirstChildElement($target_node, "SETTINGLIST");
|
||||
my $child_node = $settinglist_node->getFirstChild();
|
||||
|
||||
while ($child_node)
|
||||
{
|
||||
if ($child_node->getNodeTypeName ne "ELEMENT_NODE")
|
||||
{
|
||||
$child_node = $child_node->getNextSibling();
|
||||
next;
|
||||
}
|
||||
|
||||
if ($child_node->getTagName() eq "SETTING")
|
||||
{
|
||||
my $set_name = getChildElementTextContents($child_node, "NAME");
|
||||
|
||||
if ($set_name eq $setting_name)
|
||||
{
|
||||
$setting_node = $child_node;
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
$child_node = $child_node->getNextSibling();
|
||||
}
|
||||
|
||||
return $setting_node;
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// getTargetNodeSetting
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub getTargetNodeSetting($$)
|
||||
{
|
||||
my($target_node, $setting_name) = @_;
|
||||
|
||||
my $setting_node = getTargetNamedSettingNode($target_node, $setting_name);
|
||||
return getChildElementTextContents($setting_node, "VALUE");
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// setTargetNodeSetting
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub setTargetNodeSetting($$$$)
|
||||
{
|
||||
my($doc, $target_node, $setting_name, $new_value) = @_;
|
||||
|
||||
my $setting_node = getTargetNamedSettingNode($target_node, $setting_name);
|
||||
|
||||
setChildElementTextContents($doc, $setting_node, "VALUE", $new_value);
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// elementInArray
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub elementInArray($$)
|
||||
{
|
||||
my($element, $array) = @_;
|
||||
my $test;
|
||||
foreach $test (@$array)
|
||||
{
|
||||
if ($test eq $element) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// removeAllChildren
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub removeAllChildren($)
|
||||
{
|
||||
my($node) = @_;
|
||||
|
||||
my $child_node = $node->getFirstChild();
|
||||
|
||||
while ($child_node)
|
||||
{
|
||||
$node->removeChild($child_node);
|
||||
$child_node = $node->getFirstChild();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// dumpNodeData
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub dumpNodeData($)
|
||||
{
|
||||
my($node) = @_;
|
||||
|
||||
unless ($node) { die "Null node passed to dumpNodeData\n"; }
|
||||
|
||||
print "Dumping node $node\n";
|
||||
|
||||
my($node_type) = $node->getNodeTypeName();
|
||||
|
||||
if ($node_type eq "ELEMENT_NODE")
|
||||
{
|
||||
my($node_name) = $node->getTagName();
|
||||
print "Element $node_name\n";
|
||||
}
|
||||
elsif ($node_type eq "TEXT_NODE")
|
||||
{
|
||||
my($node_data) = $node->getData;
|
||||
# my(@node_vals) = unpack("C*", $node_data);
|
||||
print "Text '$node_data'\n"; # may contain LF chars
|
||||
}
|
||||
else
|
||||
{
|
||||
print "Node $node_type\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
#// dumpNodeTree
|
||||
#//--------------------------------------------------------------------------------------------------
|
||||
sub dumpNodeTree($)
|
||||
{
|
||||
my($node) = @_;
|
||||
|
||||
my($child_node) = $node->getFirstChild();
|
||||
|
||||
unless ($child_node) { return; }
|
||||
|
||||
# recurse
|
||||
dumpNodeData($child_node);
|
||||
|
||||
# then go through child nodes
|
||||
while ($child_node)
|
||||
{
|
||||
dumpNodeTree($child_node);
|
||||
|
||||
$child_node = $child_node->getNextSibling();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
1;
|
||||
|
||||
@@ -1,90 +0,0 @@
|
||||
#-------------------------------------------------------------------------------
|
||||
# These 3 lists are the 'master lists' to control what gets built.
|
||||
#
|
||||
# Ordering in these arrays is important; it has to reflect the order in
|
||||
# which the build occurs.
|
||||
#
|
||||
# Setting containing spaces must be quoted with double quotes.
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
build_flags
|
||||
all 1
|
||||
pull 0
|
||||
dist 0
|
||||
config 0
|
||||
xpidl 0
|
||||
idl 0
|
||||
stubs 0
|
||||
runtime 0
|
||||
common 0
|
||||
imglib 0
|
||||
libimg2 0
|
||||
necko 0
|
||||
security 0
|
||||
browserutils 0
|
||||
intl 0
|
||||
nglayout 0
|
||||
accessiblity 0
|
||||
editor 0
|
||||
embedding 0
|
||||
viewer 0
|
||||
xpapp 0
|
||||
extensions 0
|
||||
plugins 0
|
||||
mailnews 0
|
||||
apprunner 0
|
||||
resources 0
|
||||
|
||||
options_flags
|
||||
pull_by_date 0
|
||||
chrome_jars 1
|
||||
chrome_files 0
|
||||
use_jars 1
|
||||
transformiix 1
|
||||
mathml 0 MOZ_MATHML
|
||||
svg 0 MOZ_SVG
|
||||
# svg requires libart, which is an lgpl library. You need to pull it
|
||||
# explicitly.
|
||||
libart_lgpl 0
|
||||
mng 1
|
||||
ldap 1 MOZ_LDAP_XPCOM
|
||||
ldap_experimental 0 MOZ_LDAP_XPCOM_EXPERIMENTAL
|
||||
xmlextras 1
|
||||
wsp 0 MOZ_WSP
|
||||
inspector 1
|
||||
mailextras 1
|
||||
xptlink 0
|
||||
psm 0 MOZ_PSM
|
||||
embedding_test 1
|
||||
embedding_chrome 0
|
||||
embedding_xulprefs 0
|
||||
embedding_xulsecurity 0
|
||||
carbon 0 TARGET_CARBON
|
||||
useimg2 1 USE_IMG2
|
||||
lowmem 0 MOZ_MAC_LOWMEM
|
||||
accessible 1 ACCESSIBILITY
|
||||
bidi 1 IBMBIDI
|
||||
p3p 0
|
||||
jsd 1
|
||||
venkman 1
|
||||
moz_logging 1 MOZ_LOGGING
|
||||
chatzilla 1
|
||||
content_packs 1
|
||||
xml_rpc 1
|
||||
cview 1
|
||||
help 1
|
||||
timeline 0 MOZ_TIMELINE
|
||||
static_build 0 MOZ_STATIC_COMPONENT_LIBS
|
||||
string_debug 0 DEBUG_STRING
|
||||
string_stats 0 DEBUG_STRING_STATS
|
||||
xpctools 0 XPC_TOOLS_SUPPORT
|
||||
smime 1
|
||||
mdn 1
|
||||
print_preview 1 NS_PRINT_PREVIEW
|
||||
moz_xul 1 MOZ_XUL
|
||||
|
||||
filepath_flags
|
||||
idepath ":CodeWarrior IDE Path.txt"
|
||||
sessionpath ":Mozilla session path.txt"
|
||||
buildlogfilepath ":Build Logs:Mozilla build log.txt" # this is a path
|
||||
scriptlogfilepath ":Build Logs:Mozilla script log.txt"
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,22 +0,0 @@
|
||||
# List of modules to check out. Format is
|
||||
# module, (tag), (date)
|
||||
# where tag and date are optional (non-trailing commas are required)
|
||||
#
|
||||
# Examples:
|
||||
# mozilla/nsprpub, NSPRPUB_CLIENT_TAG
|
||||
# mozilla/gc, , 10/25/2000 12:00:00
|
||||
#
|
||||
|
||||
mozilla/nsprpub, NETSCAPE_7_0_RTM
|
||||
mozilla/security/nss, NETSCAPE_7_0_RTM
|
||||
mozilla/security/manager, NETSCAPE_7_0_RTM
|
||||
mozilla/accessible, NETSCAPE_7_0_RTM
|
||||
mozilla/directory/c-sdk, NETSCAPE_7_0_RTM
|
||||
mozilla/lib/mac/Instrumentation, NETSCAPE_7_0_RTM
|
||||
mozilla/gfx2, NETSCAPE_7_0_RTM
|
||||
mozilla/modules/libpr0n, NETSCAPE_7_0_RTM
|
||||
SeaMonkeyAll, NETSCAPE_7_0_RTM
|
||||
|
||||
## You need this if you want to be able to use SVG
|
||||
## Note that this library is under the LGPL, not the MPL
|
||||
#mozilla/other-licenses/libart_lgpl
|
||||
@@ -1,79 +0,0 @@
|
||||
#!perl
|
||||
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (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.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Simon Fraser <sfraser@netscape.com>
|
||||
#
|
||||
|
||||
require 5.004;
|
||||
|
||||
use strict;
|
||||
|
||||
use Cwd;
|
||||
use Moz::BuildUtils;
|
||||
use Moz::BuildCore;
|
||||
|
||||
#-------------------------------------------------------------
|
||||
# Where have the build options gone?
|
||||
#
|
||||
# The various build flags have been centralized into one place.
|
||||
# The master list of options is in MozBuildFlags.txt. However,
|
||||
# you should never need to edit that file, or this one.
|
||||
#
|
||||
# To customize what gets built, or where to start the build,
|
||||
# edit the $prefs_file_name file in
|
||||
# System Folder:Preferences:Mozilla build prefs:
|
||||
# Documentation is provided in that file.
|
||||
#-------------------------------------------------------------
|
||||
|
||||
my($prefs_file_name) = "Mozilla pull prefs";
|
||||
|
||||
#-------------------------------------------------------------
|
||||
# hashes to hold build options
|
||||
#-------------------------------------------------------------
|
||||
my(%build);
|
||||
my(%options);
|
||||
my(%filepaths);
|
||||
my(%optiondefines);
|
||||
|
||||
# Hash of input files for this build. Eventually, there will be
|
||||
# input files for manifests, and projects too.
|
||||
my(%inputfiles) = (
|
||||
"buildflags", "MozillaBuildFlags.txt",
|
||||
"checkoutdata", "MozillaCheckoutList.txt",
|
||||
"buildprogress", "",
|
||||
"buildmodule", "MozillaBuildList.pm",
|
||||
"checkouttime", "Mozilla last checkout"
|
||||
);
|
||||
#-------------------------------------------------------------
|
||||
# end build hashes
|
||||
#-------------------------------------------------------------
|
||||
|
||||
# set the build root directory, which is the the dir above mozilla
|
||||
SetupBuildRootDir(":mozilla:build:mac:build_scripts");
|
||||
|
||||
# Set up all the flags on $main::, like DEBUG, CARBON etc.
|
||||
# Override the defaults using the preferences files.
|
||||
SetupDefaultBuildOptions(0, ":mozilla:dist:viewer:", "");
|
||||
|
||||
my($do_checkout) = 1;
|
||||
my($do_build) = 0;
|
||||
|
||||
RunBuild($do_checkout, $do_build, \%inputfiles, $prefs_file_name);
|
||||
@@ -1,511 +0,0 @@
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (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.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
|
||||
DEPTH=.
|
||||
|
||||
!if !defined(MOZ_TOP)
|
||||
#enable builds from changed top level directories
|
||||
MOZ_TOP=mozilla
|
||||
!endif
|
||||
|
||||
MOZ_SRC_FLIPPED = $(MOZ_SRC:\=/)
|
||||
MOZ_DIST_FLIPPED = $(MOZ_SRC_FLIPPED)/mozilla/dist
|
||||
!ifdef MOZ_DEBUG
|
||||
MOZ_OBJDIR = WIN32_D.OBJ
|
||||
!else
|
||||
MOZ_OBJDIR = WIN32_O.OBJ
|
||||
!endif
|
||||
|
||||
#
|
||||
# Command macro defines
|
||||
#
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#// Figure out how to do the pull.
|
||||
#//------------------------------------------------------------------------
|
||||
# uncomment these, modify branch tag, and check in to branch for milestones
|
||||
MOZ_BRANCH=NETSCAPE_7_0_RTM
|
||||
NSPR_CO_TAG=NETSCAPE_7_0_RTM
|
||||
PSM_CO_TAG=NETSCAPE_7_0_RTM
|
||||
NSS_CO_TAG=NETSCAPE_7_0_RTM
|
||||
LDAPCSDK_CO_TAG=NETSCAPE_7_0_RTM
|
||||
ACCESSIBLE_CO_TAG=NETSCAPE_7_0_RTM
|
||||
IMGLIB2_CO_TAG=NETSCAPE_7_0_RTM
|
||||
GFX2_CO_TAG=NETSCAPE_7_0_RTM
|
||||
|
||||
|
||||
!ifdef MOZ_BRANCH
|
||||
CVS_BRANCH=-r $(MOZ_BRANCH)
|
||||
!endif
|
||||
|
||||
!ifdef MOZ_DATE
|
||||
CVS_BRANCH=$(CVS_BRANCH) -D "$(MOZ_DATE)"
|
||||
!endif
|
||||
|
||||
# default pull is "quiet" but it can be overridden with MOZ_CVS_VERBOSE
|
||||
!ifndef MOZ_CVS_VERBOSE
|
||||
CVS_FLAGS=-q
|
||||
!endif
|
||||
|
||||
# honor any user-defined CVS flags
|
||||
!ifdef MOZ_CVS_FLAGS
|
||||
CVS_FLAGS=$(CVS_FLAGS) $(MOZ_CVS_FLAGS)
|
||||
!endif
|
||||
|
||||
# let's be explicit about CVSROOT... some windows cvs clients
|
||||
# are too stupid to correctly work without the -d option
|
||||
#
|
||||
# if they are too stupid, they should fail. I am
|
||||
# commenting this out because this does not work
|
||||
# under 4nt. (%'s are evaluted differently)
|
||||
#
|
||||
# If it breaks you, mail dougt@netscape.com
|
||||
# and leaf@mozilla.org
|
||||
#
|
||||
!if 0
|
||||
!if defined(CVSROOT)
|
||||
CVS_FLAGS=$(CVS_FLAGS) -d "$(CVSROOT)"
|
||||
!endif
|
||||
!endif
|
||||
|
||||
!ifndef MOZ_CO_FLAGS
|
||||
MOZ_CO_FLAGS = -P
|
||||
!endif
|
||||
|
||||
CVSCO = cvs $(CVS_FLAGS) co $(MOZ_CO_FLAGS) $(CVS_BRANCH)
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#// Figure out how to pull NSPR.
|
||||
#// If no NSPR_CO_TAG is specified, use the default static tag
|
||||
#//------------------------------------------------------------------------
|
||||
|
||||
!ifndef NSPR_CO_FLAGS
|
||||
NSPR_CO_FLAGS=$(MOZ_CO_FLAGS)
|
||||
!endif
|
||||
|
||||
NSPR_CO_FLAGS=$(NSPR_CO_FLAGS) $(CVS_BRANCH)
|
||||
|
||||
|
||||
CVSCO_NSPR = cvs $(CVS_FLAGS) co $(NSPR_CO_FLAGS)
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#// Figure out how to pull NSS and PSM libs.
|
||||
#// If no NSS_CO_TAG or PSM_CO_TAG is specified, use the default static tag
|
||||
#//------------------------------------------------------------------------
|
||||
|
||||
!ifndef NSS_CO_FLAGS
|
||||
NSS_CO_FLAGS=$(MOZ_CO_FLAGS)
|
||||
!endif
|
||||
|
||||
NSS_CO_FLAGS=$(NSS_CO_FLAGS) $(CVS_BRANCH)
|
||||
|
||||
CVSCO_NSS = cvs $(CVS_FLAGS) co $(NSS_CO_FLAGS)
|
||||
|
||||
!ifndef PSM_CO_FLAGS
|
||||
PSM_CO_FLAGS=$(MOZ_CO_FLAGS)
|
||||
!endif
|
||||
|
||||
PSM_CO_FLAGS=$(PSM_CO_FLAGS) $(CVS_BRANCH)
|
||||
|
||||
CVSCO_PSM = cvs $(CVS_FLAGS) co $(PSM_CO_FLAGS)
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#// Figure out how to pull LDAP C SDK client libs.
|
||||
#// If no LDAPCSDK_CO_TAG is specified, use the default tag
|
||||
#//------------------------------------------------------------------------
|
||||
|
||||
|
||||
!ifndef LDAPCSDK_CO_FLAGS
|
||||
LDAPCSDK_CO_FLAGS=$(MOZ_CO_FLAGS)
|
||||
!endif
|
||||
|
||||
LDAPCSDK_CO_FLAGS=$(LDAPCSDK_CO_FLAGS) $(CVS_BRANCH)
|
||||
|
||||
CVSCO_LDAPCSDK = cvs $(CVS_FLAGS) co $(LDAPCSDK_CO_FLAGS)
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#// Figure out how to pull accessibility libs.
|
||||
#// If no ACCESSIBLE_CO_TAG is specified, use the default tag
|
||||
#//------------------------------------------------------------------------
|
||||
|
||||
!ifndef ACCESSIBLE_CO_FLAGS
|
||||
ACCESSIBLE_CO_FLAGS=$(MOZ_CO_FLAGS)
|
||||
!endif
|
||||
|
||||
ACCESSIBLE_CO_FLAGS=$(ACCESSIBLE_CO_FLAGS) $(CVS_BRANCH)
|
||||
|
||||
CVSCO_ACCESSIBLE = cvs $(CVS_FLAGS) co $(ACCESSIBLE_CO_FLAGS)
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#// Figure out how to pull new image library.
|
||||
#// If no IMGLIB2_CO_TAG is specified, use the default tag
|
||||
#//------------------------------------------------------------------------
|
||||
|
||||
!ifndef IMGLIB2_CO_FLAGS
|
||||
IMGLIB2_CO_FLAGS=$(MOZ_CO_FLAGS)
|
||||
!endif
|
||||
|
||||
IMGLIB2_CO_FLAGS=$(IMGLIB2_CO_FLAGS) $(CVS_BRANCH)
|
||||
|
||||
CVSCO_IMGLIB2 = cvs $(CVS_FLAGS) co $(IMGLIB2_CO_FLAGS)
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#// Figure out how to pull new image library.
|
||||
#// If no GFX2_CO_TAG is specified, use the default tag
|
||||
#//------------------------------------------------------------------------
|
||||
|
||||
!ifndef GFX2_CO_FLAGS
|
||||
GFX2_CO_FLAGS=$(MOZ_CO_FLAGS)
|
||||
!endif
|
||||
|
||||
GFX2_CO_FLAGS=$(GFX2_CO_FLAGS) $(CVS_BRANCH)
|
||||
|
||||
CVSCO_GFX2 = cvs $(CVS_FLAGS) co $(GFX2_CO_FLAGS)
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#// Figure out how to pull the internal libart
|
||||
#// (only pulled and built if MOZ_INTERNAL_LIBART_LGPL is set)
|
||||
#// If no MOZ_INTERNAL_LIBART_CO_TAG is specified, use the default tag
|
||||
#//------------------------------------------------------------------------
|
||||
|
||||
!if defined(MOZ_SVG) && !defined(MOZ_INTERNAL_LIBART_LGPL)
|
||||
ERR_MESSAGE = ^
|
||||
You are trying to build Mozilla with SVG support (MOZ_SVG=1), but you ^
|
||||
haven not specified that mozilla/other-licenses/libart_lgpl should be ^
|
||||
pulled and built. At the moment Mozilla SVG builds need this patched ^
|
||||
version of libart. You either need to disable SVG support (unset MOZ_SVG) ^
|
||||
or enable pulling and building by setting MOZ_INTERNAL_LIBART_LGPL=1.^
|
||||
^
|
||||
If you choose to pull and build libart, note that it is only licensed^
|
||||
under the terms of the LGPL, not the MPL. (Which is why you have to opt^
|
||||
in explicitly.)
|
||||
!endif
|
||||
|
||||
!if defined(MOZ_INTERNAL_LIBART_LGPL)
|
||||
|
||||
!ifndef MOZ_INTERNAL_LIBART_CO_FLAGS
|
||||
MOZ_INTERNAL_LIBART_CO_FLAGS=$(MOZ_CO_FLAGS)
|
||||
!endif
|
||||
|
||||
!if "$(MOZ_INTERNAL_LIBART_CO_TAG)" != ""
|
||||
MOZ_INTERNAL_LIBART_CO_FLAGS=$(MOZ_INTERNAL_LIBART_CO_FLAGS) -r $(MOZ_INTERNAL_LIBART_CO_TAG)
|
||||
!else
|
||||
MOZ_INTERNAL_LIBART_CO_FLAGS=$(MOZ_INTERNAL_LIBART_CO_FLAGS) $(CVS_BRANCH)
|
||||
!endif
|
||||
|
||||
CVSCO_MOZ_INTERNAL_LIBART = cvs $(CVS_FLAGS) co $(MOZ_INTERNAL_LIBART_CO_FLAGS)
|
||||
|
||||
!endif
|
||||
|
||||
## The master target
|
||||
############################################################
|
||||
|
||||
pull_and_build_all: pull_all build_all_dep
|
||||
|
||||
|
||||
## Rules for pulling the source from the cvs repository
|
||||
############################################################
|
||||
|
||||
pull_clobber_and_build_all: pull_all clobber_all build_all
|
||||
|
||||
!if !defined(MOZ_INTERNAL_LIBART_LGPL)
|
||||
pull_all: pull_nspr pull_psm pull_ldapcsdk pull_accessible pull_gfx2 pull_imglib2 pull_seamonkey
|
||||
!else
|
||||
pull_all: pull_nspr pull_psm pull_ldapcsdk pull_accessible pull_gfx2 pull_imglib2 pull_moz_internal_libart pull_seamonkey
|
||||
!endif
|
||||
|
||||
pull_nspr: pull_clientmak
|
||||
cd $(MOZ_SRC)\.
|
||||
$(CVSCO_NSPR) mozilla/nsprpub
|
||||
|
||||
pull_nss:
|
||||
cd $(MOZ_SRC)\.
|
||||
$(CVSCO_NSS) mozilla/security/coreconf
|
||||
$(CVSCO_NSS) mozilla/security/nss
|
||||
|
||||
pull_psm: pull_nss
|
||||
cd $(MOZ_SRC)\.
|
||||
$(CVSCO_PSM) mozilla/security/manager
|
||||
$(CVSCO_PSM) mozilla/security/makefile.win
|
||||
|
||||
pull_ldapcsdk:
|
||||
cd $(MOZ_SRC)\.
|
||||
$(CVSCO_LDAPCSDK) mozilla/directory/c-sdk
|
||||
|
||||
pull_accessible:
|
||||
cd $(MOZ_SRC)\.
|
||||
$(CVSCO_ACCESSIBLE) mozilla/accessible
|
||||
|
||||
pull_gfx2:
|
||||
cd $(MOZ_SRC)\.
|
||||
$(CVSCO_GFX2) mozilla/gfx2
|
||||
|
||||
pull_imglib2:
|
||||
cd $(MOZ_SRC)\.
|
||||
$(CVSCO_IMGLIB2) mozilla/modules/libpr0n
|
||||
|
||||
!if defined(MOZ_INTERNAL_LIBART_LGPL)
|
||||
pull_moz_internal_libart:
|
||||
cd $(MOZ_SRC)\.
|
||||
$(CVSCO_MOZ_INTERNAL_LIBART) mozilla/other-licenses/libart_lgpl
|
||||
!endif
|
||||
|
||||
pull_xpconnect: pull_nspr
|
||||
cd $(MOZ_SRC)\.
|
||||
$(CVSCO) mozilla/include
|
||||
$(CVSCO) mozilla/config
|
||||
$(CVSCO) -l mozilla/js
|
||||
$(CVSCO) -l mozilla/js/src
|
||||
$(CVSCO) mozilla/js/src/fdlibm
|
||||
$(CVSCO) mozilla/js/src/xpconnect
|
||||
$(CVSCO) mozilla/modules/libreg
|
||||
$(CVSCO) mozilla/xpcom
|
||||
$(CVSCO) mozilla/string
|
||||
|
||||
# pull either layout only or seamonkey the browser
|
||||
pull_layout:
|
||||
cd $(MOZ_SRC)\.
|
||||
$(CVSCO) RaptorWin
|
||||
|
||||
pull_seamonkey: pull_clientmak
|
||||
cd $(MOZ_SRC)\.
|
||||
$(CVSCO) SeaMonkeyAll
|
||||
|
||||
pull_clientmak:
|
||||
cd $(MOZ_SRC)\.
|
||||
$(CVSCO) mozilla/client.mak
|
||||
|
||||
############################################################
|
||||
|
||||
# nmake has to be hardcoded, or we have to depend on mozilla/config
|
||||
# being pulled already to figure out what $(NMAKE) should be.
|
||||
|
||||
clobber_all: clobber_nspr clobber_ldapcsdk clobber_psm clobber_seamonkey
|
||||
|
||||
build_all: build_nspr build_ldapcsdk build_seamonkey
|
||||
|
||||
build_all_dep: depend libs
|
||||
|
||||
distclean:
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\directory\c-sdk
|
||||
gmake -f gmakefile.win distclean MOZ_SRC_FLIPPED=$(MOZ_SRC_FLIPPED)
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\nsprpub
|
||||
gmake -f gmakefile.win distclean MOZ_SRC_FLIPPED=$(MOZ_SRC_FLIPPED)
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)
|
||||
nmake /f client.mak clobber_psm
|
||||
nmake /f client.mak clobber_seamonkey
|
||||
|
||||
clobber_ldapcsdk:
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\directory\c-sdk
|
||||
gmake -f gmakefile.win clobber_all MOZ_SRC_FLIPPED=$(MOZ_SRC_FLIPPED) \
|
||||
SHELL=sh
|
||||
|
||||
clobber_nspr:
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\nsprpub
|
||||
gmake -f gmakefile.win clobber_all MOZ_SRC_FLIPPED=$(MOZ_SRC_FLIPPED)
|
||||
|
||||
clobber_psm:
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\security
|
||||
nmake -f makefile.win clobber_all
|
||||
|
||||
clobber_xpconnect:
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\.
|
||||
-rd /s /q dist
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\nsprpub
|
||||
gmake -f gmakefile.win clobber_all MOZ_SRC_FLIPPED=$(MOZ_SRC_FLIPPED)
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\include
|
||||
nmake -f makefile.win clobber_all
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\modules\libreg
|
||||
nmake -f makefile.win clobber_all
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\string
|
||||
nmake -f makefile.win clobber_all
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\xpcom
|
||||
nmake -f makefile.win clobber_all
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\js
|
||||
nmake -f makefile.win clobber_all
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\js\src\xpconnect
|
||||
nmake -f makefile.win clobber_all
|
||||
|
||||
clobber_seamonkey:
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\.
|
||||
-rd /s /q dist
|
||||
nmake -f makefile.win clobber_all
|
||||
|
||||
depend: export
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\.
|
||||
nmake -f makefile.win depend
|
||||
|
||||
depend_xpconnect:
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\include
|
||||
nmake -f makefile.win depend
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\modules\libreg
|
||||
nmake -f makefile.win depend
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\string
|
||||
nmake -f makefile.win depend
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\xpcom
|
||||
nmake -f makefile.win depend
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\js\src
|
||||
nmake -f makefile.win depend
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\js\src\xpconnect
|
||||
nmake -f makefile.win depend
|
||||
|
||||
build_nspr:
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\nsprpub
|
||||
gmake -f gmakefile.win MOZ_SRC_FLIPPED=$(MOZ_SRC_FLIPPED)
|
||||
|
||||
build_ldapcsdk:
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\directory\c-sdk
|
||||
gmake -f gmakefile.win MOZ_SRC_FLIPPED=$(MOZ_SRC_FLIPPED) SHELL=sh
|
||||
|
||||
build_psm:
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\security
|
||||
nmake -f makefile.win
|
||||
|
||||
build_xpconnect: build_nspr
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\include
|
||||
nmake -f makefile.win all
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\modules\libreg
|
||||
nmake -f makefile.win all
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\xpcom
|
||||
nmake -f makefile.win export
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\string
|
||||
nmake -f makefile.win all
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\xpcom
|
||||
nmake -f makefile.win libs
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\js\src
|
||||
nmake -f makefile.win all
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\js\src\xpconnect
|
||||
nmake -f makefile.win all
|
||||
|
||||
build_seamonkey:
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\.
|
||||
nmake -f makefile.win all
|
||||
|
||||
build_client:
|
||||
@cd $(MOZ_SRC)\mozilla\.
|
||||
nmake -f makefile.win all
|
||||
|
||||
build_layout:
|
||||
@cd $(MOZ_SRC)\mozilla\.
|
||||
nmake -f makefile.win all
|
||||
|
||||
build_dist:
|
||||
@cd $(MOZ_SRC)\mozilla\.
|
||||
nmake -f makefile.win all
|
||||
|
||||
libs:
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\.
|
||||
nmake -f makefile.win libs
|
||||
|
||||
export: build_nspr build_ldapcsdk
|
||||
@cd $(MOZ_SRC)\$(MOZ_TOP)\.
|
||||
nmake -f makefile.win export
|
||||
|
||||
clobber_dist:
|
||||
@cd $(MOZ_SRC)\mozilla\.
|
||||
nmake -f makefile.win clobber_all
|
||||
|
||||
clobber_client:
|
||||
@cd $(MOZ_SRC)\mozilla\.
|
||||
nmake -f makefile.win clobber_all
|
||||
|
||||
clobber_layout:
|
||||
@cd $(MOZ_SRC)\mozilla\.
|
||||
nmake -f makefile.win clobber_all
|
||||
|
||||
browse_info::
|
||||
cd $(MOZ_SRC)\$(MOZ_TOP)
|
||||
-dir /s /b *.sbr > sbrlist.tmp
|
||||
-bscmake /Es /o mozilla.bsc @sbrlist.tmp
|
||||
-rm sbrlist.tmp
|
||||
|
||||
regchrome::
|
||||
@cd $(MOZ_SRC)\mozilla\.
|
||||
nmake /f makefile.win regchrome
|
||||
|
||||
deliver::
|
||||
@cd $(MOZ_SRC)\mozilla\.
|
||||
nmake /f makefile.win splitsymbols
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#// Utility stuff...
|
||||
#//------------------------------------------------------------------------
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
# Verify that MOZ_SRC is set correctly
|
||||
#//------------------------------------------------------------------------
|
||||
|
||||
# Check to see if it is set at all
|
||||
!if "$(MOZ_SRC)"==""
|
||||
MOZ_SRC = $(MAKEDIR)\..
|
||||
!endif
|
||||
|
||||
#
|
||||
# create a temp file at the root and make sure it is visible from MOZ_SRC
|
||||
#
|
||||
!if [copy $(MAKEDIR)\client.mak $(MAKEDIR)\xyzzy.tmp > NUL] == 0
|
||||
!endif
|
||||
|
||||
!if !EXIST( $(MOZ_SRC)\mozilla\xyzzy.tmp )
|
||||
ERR_MESSAGE=$(ERR_MESSAGE)^
|
||||
MOZ_SRC isn't set correctly: [$(MOZ_SRC)\mozilla]!=[$(MAKEDIR)]
|
||||
!endif
|
||||
|
||||
!if [del $(MAKEDIR)\xyzzy.tmp]
|
||||
!endif
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
# Verify that MOZ_BITS is set
|
||||
#//------------------------------------------------------------------------
|
||||
!if !defined(MOZ_BITS)
|
||||
ERR_MESSAGE=$(ERR_MESSAGE)^
|
||||
Environment variable MOZ_BITS isn't set.
|
||||
!endif
|
||||
|
||||
!if !defined(MOZ_TOOLS)
|
||||
ERR_MESSAGE=$(ERR_MESSAGE)^
|
||||
Environment variable MOZ_TOOLS isn't set.
|
||||
!endif
|
||||
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#// Display error
|
||||
#//------------------------------------------------------------------------
|
||||
|
||||
!if "$(ERR_MESSAGE)" != ""
|
||||
ERR_MESSAGE = ^
|
||||
client.mak: ^
|
||||
$(ERR_MESSAGE) ^
|
||||
^
|
||||
client.mak: usage^
|
||||
^
|
||||
nmake -f client.mak [MOZ_BRANCH=<cvs_branch_name>] ^
|
||||
[MOZ_DATE=<cvs_date>]^
|
||||
[pull_and_build_all]^
|
||||
[pull_all]^
|
||||
[build_all]^
|
||||
^
|
||||
Environment variables:^
|
||||
^
|
||||
MOZ_BITS set to 32^
|
||||
MOZ_TOOLS set to the directory containing the needed tools ^
|
||||
|
||||
!ERROR $(ERR_MESSAGE)
|
||||
|
||||
!endif
|
||||
@@ -1,650 +0,0 @@
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (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.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s): Stephen Lamm
|
||||
|
||||
# Build the Mozilla client.
|
||||
#
|
||||
# This needs CVSROOT set to work, e.g.,
|
||||
# setenv CVSROOT :pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot
|
||||
# or
|
||||
# setenv CVSROOT :pserver:username%somedomain.org@cvs.mozilla.org:/cvsroot
|
||||
#
|
||||
# To checkout and build a tree,
|
||||
# 1. cvs co mozilla/client.mk
|
||||
# 2. cd mozilla
|
||||
# 3. gmake -f client.mk
|
||||
#
|
||||
# Other targets (gmake -f client.mk [targets...]),
|
||||
# checkout
|
||||
# build
|
||||
# clean (realclean is now the same as clean)
|
||||
# distclean
|
||||
#
|
||||
# See http://www.mozilla.org/build/unix.html for more information.
|
||||
#
|
||||
# Options:
|
||||
# MOZ_OBJDIR - Destination object directory
|
||||
# MOZ_CO_DATE - Date tag to use for checkout (default: none)
|
||||
# MOZ_CO_MODULE - Module to checkout (default: SeaMonkeyAll)
|
||||
# MOZ_CVS_FLAGS - Flags to pass cvs (default: -q -z3)
|
||||
# MOZ_CO_FLAGS - Flags to pass after 'cvs co' (default: -P)
|
||||
# MOZ_MAKE_FLAGS - Flags to pass to $(MAKE)
|
||||
# MOZ_CO_BRANCH - Branch tag (Deprecated. Use MOZ_CO_TAG below.)
|
||||
#
|
||||
|
||||
#######################################################################
|
||||
# Checkout Tags
|
||||
#
|
||||
# For branches, uncomment the MOZ_CO_TAG line with the proper tag,
|
||||
# and commit this file on that tag.
|
||||
MOZ_CO_TAG = NETSCAPE_7_0_RTM
|
||||
NSPR_CO_TAG = NETSCAPE_7_0_RTM
|
||||
PSM_CO_TAG = NETSCAPE_7_0_RTM
|
||||
NSS_CO_TAG = NETSCAPE_7_0_RTM
|
||||
LDAPCSDK_CO_TAG = NETSCAPE_7_0_RTM
|
||||
ACCESSIBLE_CO_TAG = NETSCAPE_7_0_RTM
|
||||
GFX2_CO_TAG = NETSCAPE_7_0_RTM
|
||||
IMGLIB2_CO_TAG = NETSCAPE_7_0_RTM
|
||||
BUILD_MODULES = all
|
||||
|
||||
#######################################################################
|
||||
# Defines
|
||||
#
|
||||
CVS = cvs
|
||||
|
||||
CWD := $(shell pwd)
|
||||
|
||||
ifeq "$(CWD)" "/"
|
||||
CWD := /.
|
||||
endif
|
||||
|
||||
ifneq (, $(wildcard client.mk))
|
||||
# Ran from mozilla directory
|
||||
ROOTDIR := $(shell dirname $(CWD))
|
||||
TOPSRCDIR := $(CWD)
|
||||
else
|
||||
# Ran from mozilla/.. directory (?)
|
||||
ROOTDIR := $(CWD)
|
||||
TOPSRCDIR := $(CWD)/mozilla
|
||||
endif
|
||||
|
||||
# on os2, TOPSRCDIR may have two forward slashes in a row, which doesn't
|
||||
# work; replace first instance with one forward slash
|
||||
TOPSRCDIR := $(shell echo "$(TOPSRCDIR)" | sed -e 's%//%/%')
|
||||
|
||||
ifndef TOPSRCDIR_MOZ
|
||||
TOPSRCDIR_MOZ=$(TOPSRCDIR)
|
||||
endif
|
||||
|
||||
# if ROOTDIR equals only drive letter (i.e. "C:"), set to "/"
|
||||
DIRNAME := $(shell echo "$(ROOTDIR)" | sed -e 's/^.://')
|
||||
ifeq ($(DIRNAME),)
|
||||
ROOTDIR := /.
|
||||
endif
|
||||
|
||||
AUTOCONF := autoconf
|
||||
MKDIR := mkdir
|
||||
SH := /bin/sh
|
||||
ifndef MAKE
|
||||
MAKE := gmake
|
||||
endif
|
||||
|
||||
CONFIG_GUESS_SCRIPT := $(wildcard $(TOPSRCDIR)/build/autoconf/config.guess)
|
||||
ifdef CONFIG_GUESS_SCRIPT
|
||||
CONFIG_GUESS = $(shell $(CONFIG_GUESS_SCRIPT))
|
||||
else
|
||||
_IS_FIRST_CHECKOUT := 1
|
||||
endif
|
||||
|
||||
####################################
|
||||
# CVS
|
||||
|
||||
# Add the CVS root to CVS_FLAGS if needed
|
||||
CVS_ROOT_IN_TREE := $(shell cat $(TOPSRCDIR)/CVS/Root 2>/dev/null)
|
||||
ifneq ($(CVS_ROOT_IN_TREE),)
|
||||
ifneq ($(CVS_ROOT_IN_TREE),$(CVSROOT))
|
||||
CVS_FLAGS := -d $(CVS_ROOT_IN_TREE)
|
||||
endif
|
||||
endif
|
||||
|
||||
CVSCO = $(strip $(CVS) $(CVS_FLAGS) co $(CVS_CO_FLAGS))
|
||||
CVSCO_LOGFILE := $(ROOTDIR)/cvsco.log
|
||||
CVSCO_LOGFILE := $(shell echo $(CVSCO_LOGFILE) | sed s%//%/%)
|
||||
|
||||
ifdef MOZ_CO_TAG
|
||||
CVS_CO_FLAGS := -r $(MOZ_CO_TAG)
|
||||
endif
|
||||
|
||||
####################################
|
||||
# Load mozconfig Options
|
||||
|
||||
# See build pages, http://www.mozilla.org/build/unix.html,
|
||||
# for how to set up mozconfig.
|
||||
MOZCONFIG_LOADER := mozilla/build/autoconf/mozconfig2client-mk
|
||||
MOZCONFIG_FINDER := mozilla/build/autoconf/mozconfig-find
|
||||
MOZCONFIG_MODULES := mozilla/build/unix/modules.mk
|
||||
run_for_side_effects := \
|
||||
$(shell cd $(ROOTDIR); \
|
||||
if test "$(_IS_FIRST_CHECKOUT)"; then \
|
||||
$(CVSCO) $(MOZCONFIG_FINDER) $(MOZCONFIG_LOADER) $(MOZCONFIG_MODULES); \
|
||||
else true; \
|
||||
fi; \
|
||||
$(MOZCONFIG_LOADER) $(TOPSRCDIR) mozilla/.mozconfig.mk > mozilla/.mozconfig.out)
|
||||
include $(TOPSRCDIR)/.mozconfig.mk
|
||||
include $(TOPSRCDIR)/build/unix/modules.mk
|
||||
|
||||
####################################
|
||||
# Options that may come from mozconfig
|
||||
|
||||
# Change CVS flags if anonymous root is requested
|
||||
ifdef MOZ_CO_USE_MIRROR
|
||||
CVS_FLAGS := -d :pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot
|
||||
endif
|
||||
|
||||
# MOZ_CVS_FLAGS - Basic CVS flags
|
||||
ifeq "$(origin MOZ_CVS_FLAGS)" "undefined"
|
||||
CVS_FLAGS := $(CVS_FLAGS) -q -z 3
|
||||
else
|
||||
CVS_FLAGS := $(MOZ_CVS_FLAGS)
|
||||
endif
|
||||
|
||||
# This option is deprecated. The best way to have client.mk pull a tag
|
||||
# is to set MOZ_CO_TAG (see above) and commit that change on the tag.
|
||||
ifdef MOZ_CO_BRANCH
|
||||
$(warning Use MOZ_CO_TAG instead of MOZ_CO_BRANCH)
|
||||
CVS_CO_FLAGS := -r $(MOZ_CO_BRANCH)
|
||||
endif
|
||||
|
||||
# MOZ_CO_FLAGS - Anything that we should use on all checkouts
|
||||
ifeq "$(origin MOZ_CO_FLAGS)" "undefined"
|
||||
CVS_CO_FLAGS := $(CVS_CO_FLAGS) -P
|
||||
else
|
||||
CVS_CO_FLAGS := $(CVS_CO_FLAGS) $(MOZ_CO_FLAGS)
|
||||
endif
|
||||
|
||||
ifdef MOZ_CO_DATE
|
||||
CVS_CO_DATE_FLAGS := -D "$(MOZ_CO_DATE)"
|
||||
endif
|
||||
|
||||
ifdef MOZ_OBJDIR
|
||||
OBJDIR := $(MOZ_OBJDIR)
|
||||
MOZ_MAKE := $(MAKE) $(MOZ_MAKE_FLAGS) -C $(OBJDIR)
|
||||
else
|
||||
OBJDIR := $(TOPSRCDIR)
|
||||
MOZ_MAKE := $(MAKE) $(MOZ_MAKE_FLAGS)
|
||||
endif
|
||||
|
||||
####################################
|
||||
# CVS defines for PSM
|
||||
#
|
||||
PSM_CO_MODULE= mozilla/security/manager
|
||||
PSM_CO_FLAGS := -P -A
|
||||
ifdef MOZ_CO_FLAGS
|
||||
PSM_CO_FLAGS := $(MOZ_CO_FLAGS)
|
||||
endif
|
||||
ifdef PSM_CO_TAG
|
||||
PSM_CO_FLAGS := $(PSM_CO_FLAGS) -r $(PSM_CO_TAG)
|
||||
endif
|
||||
CVSCO_PSM = $(CVS) $(CVS_FLAGS) co $(PSM_CO_FLAGS) $(CVS_CO_DATE_FLAGS) $(PSM_CO_MODULE)
|
||||
|
||||
####################################
|
||||
# CVS defines for NSS
|
||||
#
|
||||
NSS_CO_MODULE = mozilla/security/nss \
|
||||
mozilla/security/coreconf \
|
||||
$(NULL)
|
||||
|
||||
NSS_CO_FLAGS := -P
|
||||
ifdef MOZ_CO_FLAGS
|
||||
NSS_CO_FLAGS := $(MOZ_CO_FLAGS)
|
||||
endif
|
||||
ifdef NSS_CO_TAG
|
||||
NSS_CO_FLAGS := $(NSS_CO_FLAGS) -r $(NSS_CO_TAG)
|
||||
endif
|
||||
# Cannot pull static tags by date
|
||||
ifeq ($(NSS_CO_TAG),NSS_CLIENT_TAG)
|
||||
CVSCO_NSS = $(CVS) $(CVS_FLAGS) co $(NSS_CO_FLAGS) $(NSS_CO_MODULE)
|
||||
else
|
||||
CVSCO_NSS = $(CVS) $(CVS_FLAGS) co $(NSS_CO_FLAGS) $(CVS_CO_DATE_FLAGS) $(NSS_CO_MODULE)
|
||||
endif
|
||||
|
||||
####################################
|
||||
# CVS defines for NSPR
|
||||
#
|
||||
NSPR_CO_MODULE = mozilla/nsprpub
|
||||
NSPR_CO_FLAGS := -P
|
||||
ifdef MOZ_CO_FLAGS
|
||||
NSPR_CO_FLAGS := $(MOZ_CO_FLAGS)
|
||||
endif
|
||||
ifdef NSPR_CO_TAG
|
||||
NSPR_CO_FLAGS := $(NSPR_CO_FLAGS) -r $(NSPR_CO_TAG)
|
||||
endif
|
||||
# Cannot pull static tags by date
|
||||
ifeq ($(NSPR_CO_TAG),NSPRPUB_CLIENT_TAG)
|
||||
CVSCO_NSPR = $(CVS) $(CVS_FLAGS) co $(NSPR_CO_FLAGS) $(NSPR_CO_MODULE)
|
||||
else
|
||||
CVSCO_NSPR = $(CVS) $(CVS_FLAGS) co $(NSPR_CO_FLAGS) $(CVS_CO_DATE_FLAGS) $(NSPR_CO_MODULE)
|
||||
endif
|
||||
|
||||
####################################
|
||||
# CVS defines for the C LDAP SDK
|
||||
#
|
||||
LDAPCSDK_CO_MODULE = mozilla/directory/c-sdk
|
||||
LDAPCSDK_CO_FLAGS := -P
|
||||
ifdef MOZ_CO_FLAGS
|
||||
LDAPCSDK_CO_FLAGS := $(MOZ_CO_FLAGS)
|
||||
endif
|
||||
ifdef LDAPCSDK_CO_TAG
|
||||
LDAPCSDK_CO_FLAGS := $(LDAPCSDK_CO_FLAGS) -r $(LDAPCSDK_CO_TAG)
|
||||
endif
|
||||
CVSCO_LDAPCSDK = $(CVS) $(CVS_FLAGS) co $(LDAPCSDK_CO_FLAGS) $(CVS_CO_DATE_FLAGS) $(LDAPCSDK_CO_MODULE)
|
||||
|
||||
####################################
|
||||
# CVS defines for the C LDAP SDK
|
||||
#
|
||||
ACCESSIBLE_CO_MODULE = mozilla/accessible
|
||||
ACCESSIBLE_CO_FLAGS := -P
|
||||
ifdef MOZ_CO_FLAGS
|
||||
ACCESSIBLE_CO_FLAGS := $(MOZ_CO_FLAGS)
|
||||
endif
|
||||
ifdef ACCESSIBLE_CO_TAG
|
||||
ACCESSIBLE_CO_FLAGS := $(ACCESSIBLE_CO_FLAGS) -r $(ACCESSIBLE_CO_TAG)
|
||||
endif
|
||||
CVSCO_ACCESSIBLE = $(CVS) $(CVS_FLAGS) co $(ACCESSIBLE_CO_FLAGS) $(CVS_CO_DATE_FLAGS) $(ACCESSIBLE_CO_MODULE)
|
||||
|
||||
####################################
|
||||
# CVS defines for gfx2
|
||||
#
|
||||
GFX2_CO_MODULE = mozilla/gfx2
|
||||
GFX2_CO_FLAGS := -P
|
||||
ifdef MOZ_CO_FLAGS
|
||||
GFX2_CO_FLAGS := $(MOZ_CO_FLAGS)
|
||||
endif
|
||||
ifdef GFX2_CO_TAG
|
||||
GFX2_CO_FLAGS := $(GFX2_CO_FLAGS) -r $(GFX2_CO_TAG)
|
||||
endif
|
||||
CVSCO_GFX2 = $(CVS) $(CVS_FLAGS) co $(GFX2_CO_FLAGS) $(CVS_CO_DATE_FLAGS) $(GFX2_CO_MODULE)
|
||||
|
||||
####################################
|
||||
# CVS defines for new image library
|
||||
#
|
||||
IMGLIB2_CO_MODULE = mozilla/modules/libpr0n
|
||||
IMGLIB2_CO_FLAGS := -P
|
||||
ifdef MOZ_CO_FLAGS
|
||||
IMGLIB2_CO_FLAGS := $(MOZ_CO_FLAGS)
|
||||
endif
|
||||
ifdef IMGLIB2_CO_TAG
|
||||
IMGLIB2_CO_FLAGS := $(IMGLIB2_CO_FLAGS) -r $(IMGLIB2_CO_TAG)
|
||||
endif
|
||||
CVSCO_IMGLIB2 = $(CVS) $(CVS_FLAGS) co $(IMGLIB2_CO_FLAGS) $(CVS_CO_DATE_FLAGS) $(IMGLIB2_CO_MODULE)
|
||||
|
||||
####################################
|
||||
# CVS defines for standalone modules
|
||||
#
|
||||
ifneq ($(BUILD_MODULES),all)
|
||||
MOZ_CO_MODULE := $(filter-out $(NSPRPUB_DIR) security directory/c-sdk, $(BUILD_MODULE_CVS))
|
||||
MOZ_CO_MODULE += allmakefiles.sh client.mk aclocal.m4 configure configure.in
|
||||
MOZ_CO_MODULE += Makefile.in
|
||||
MOZ_CO_MODULE := $(addprefix mozilla/, $(MOZ_CO_MODULE))
|
||||
|
||||
NOSUBDIRS_MODULE := $(addprefix mozilla/, $(BUILD_MODULE_CVS_NS))
|
||||
ifneq ($(NOSUBDIRS_MODULE),)
|
||||
CVSCO_NOSUBDIRS := $(CVSCO) -l $(CVS_CO_DATE_FLAGS) $(NOSUBDIRS_MODULE)
|
||||
endif
|
||||
|
||||
ifeq (,$(filter $(NSPRPUB_DIR), $(BUILD_MODULE_CVS)))
|
||||
CVSCO_NSPR :=
|
||||
endif
|
||||
ifeq (,$(filter security security/manager, $(BUILD_MODULE_CVS)))
|
||||
CVSCO_PSM :=
|
||||
CVSCO_NSS :=
|
||||
endif
|
||||
ifeq (,$(filter directory/c-sdk, $(BUILD_MODULE_CVS)))
|
||||
CVSCO_LDAPCSDK :=
|
||||
endif
|
||||
ifeq (,$(filter accessible, $(BUILD_MODULE_CVS)))
|
||||
CVSCO_ACCESSIBLE :=
|
||||
endif
|
||||
ifeq (,$(filter gfx2, $(BUILD_MODULE_CVS)))
|
||||
CVSCO_GFX2 :=
|
||||
endif
|
||||
ifeq (,$(filter modules/libpr0n, $(BUILD_MODULE_CVS)))
|
||||
CVSCO_IMGLIB2 :=
|
||||
endif
|
||||
endif
|
||||
|
||||
####################################
|
||||
# CVS defines for SeaMonkey
|
||||
#
|
||||
ifeq ($(MOZ_CO_MODULE),)
|
||||
MOZ_CO_MODULE := SeaMonkeyAll
|
||||
endif
|
||||
CVSCO_SEAMONKEY := $(CVSCO) $(CVS_CO_DATE_FLAGS) $(MOZ_CO_MODULE)
|
||||
|
||||
####################################
|
||||
# CVS defined for libart (pulled and built if MOZ_INTERNAL_LIBART_LGPL is set)
|
||||
#
|
||||
CVSCO_LIBART := $(CVSCO) $(CVS_CO_DATE_FLAGS) mozilla/other-licenses/libart_lgpl
|
||||
|
||||
ifdef MOZ_INTERNAL_LIBART_LGPL
|
||||
FASTUPDATE_LIBART := fast_update $(CVSCO_LIBART)
|
||||
CHECKOUT_LIBART := cvs_co $(CVSCO_LIBART)
|
||||
else
|
||||
CHECKOUT_LIBART := true
|
||||
FASTUPDATE_LIBART := true
|
||||
endif
|
||||
|
||||
####################################
|
||||
# CVS defines for Calendar (pulled and built if MOZ_CALENDAR is set)
|
||||
#
|
||||
CVSCO_CALENDAR := $(CVSCO) $(CVS_CO_DATE_FLAGS) mozilla/calendar
|
||||
|
||||
ifdef MOZ_CALENDAR
|
||||
FASTUPDATE_CALENDAR := fast_update $(CVSCO_CALENDAR)
|
||||
CHECKOUT_CALENDAR := cvs_co $(CVSCO_CALENDAR)
|
||||
else
|
||||
CHECKOUT_CALENDAR := true
|
||||
FASTUPDATE_CALENDAR := true
|
||||
endif
|
||||
|
||||
|
||||
# because some cygwin tools can't handle native dos-drive paths & vice-versa
|
||||
# force configure to use a relative path for --srcdir
|
||||
# need a better check for win32
|
||||
# and we need to get OBJDIR earlier
|
||||
ifdef MOZ_TOOLS
|
||||
_tmpobjdir := $(shell cygpath -u $(OBJDIR))
|
||||
_abs2rel := $(shell cygpath -w $(TOPSRCDIR)/build/unix/abs2rel.pl | sed -e 's|\\|/|g')
|
||||
_OBJ2SRCPATH := $(shell $(_abs2rel) $(TOPSRCDIR) $(_tmpobjdir))
|
||||
endif
|
||||
|
||||
#######################################################################
|
||||
# Rules
|
||||
#
|
||||
|
||||
# Print out any options loaded from mozconfig.
|
||||
all build checkout clean depend distclean export libs install realclean::
|
||||
@if test -f .mozconfig.out; then \
|
||||
cat .mozconfig.out; \
|
||||
rm -f .mozconfig.out; \
|
||||
else true; \
|
||||
fi
|
||||
|
||||
ifdef _IS_FIRST_CHECKOUT
|
||||
all:: checkout build
|
||||
else
|
||||
all:: checkout alldep
|
||||
endif
|
||||
|
||||
# Windows equivalents
|
||||
pull_all: checkout
|
||||
build_all: build
|
||||
build_all_dep: alldep
|
||||
build_all_depend: alldep
|
||||
clobber clobber_all: clean
|
||||
pull_and_build_all: checkout alldep
|
||||
|
||||
# Do everything from scratch
|
||||
everything: checkout clean build
|
||||
|
||||
####################################
|
||||
# CVS checkout
|
||||
#
|
||||
checkout::
|
||||
# @: Backup the last checkout log.
|
||||
@if test -f $(CVSCO_LOGFILE) ; then \
|
||||
mv $(CVSCO_LOGFILE) $(CVSCO_LOGFILE).old; \
|
||||
else true; \
|
||||
fi
|
||||
ifdef RUN_AUTOCONF_LOCALLY
|
||||
@echo "Removing local configures" ; \
|
||||
cd $(ROOTDIR) && \
|
||||
$(RM) -f mozilla/configure mozilla/nsprpub/configure \
|
||||
mozilla/directory/c-sdk/configure
|
||||
endif
|
||||
@echo "checkout start: "`date` | tee $(CVSCO_LOGFILE)
|
||||
@echo '$(CVSCO) mozilla/client.mk mozilla/build/unix/modules.mk'; \
|
||||
cd $(ROOTDIR) && \
|
||||
$(CVSCO) mozilla/client.mk mozilla/build/unix/modules.mk
|
||||
@cd $(ROOTDIR) && $(MAKE) -f mozilla/client.mk real_checkout
|
||||
|
||||
real_checkout:
|
||||
# @: Start the checkout. Split the output to the tty and a log file. \
|
||||
# : If it fails, touch an error file because "tee" hides the error.
|
||||
@failed=.cvs-failed.tmp; rm -f $$failed*; \
|
||||
cvs_co() { echo "$$@" ; \
|
||||
("$$@" || touch $$failed) 2>&1 | tee -a $(CVSCO_LOGFILE) && \
|
||||
if test -f $$failed; then false; else true; fi; }; \
|
||||
cvs_co $(CVSCO_NSPR) && \
|
||||
cvs_co $(CVSCO_NSS) && \
|
||||
cvs_co $(CVSCO_PSM) && \
|
||||
cvs_co $(CVSCO_LDAPCSDK) && \
|
||||
cvs_co $(CVSCO_ACCESSIBLE) && \
|
||||
cvs_co $(CVSCO_GFX2) && \
|
||||
cvs_co $(CVSCO_IMGLIB2) && \
|
||||
$(CHECKOUT_CALENDAR) && \
|
||||
$(CHECKOUT_LIBART) && \
|
||||
cvs_co $(CVSCO_SEAMONKEY) && \
|
||||
cvs_co $(CVSCO_NOSUBDIRS)
|
||||
@echo "checkout finish: "`date` | tee -a $(CVSCO_LOGFILE)
|
||||
# @: Check the log for conflicts. ;
|
||||
@conflicts=`egrep "^C " $(CVSCO_LOGFILE)` ;\
|
||||
if test "$$conflicts" ; then \
|
||||
echo "$(MAKE): *** Conflicts during checkout." ;\
|
||||
echo "$$conflicts" ;\
|
||||
echo "$(MAKE): Refer to $(CVSCO_LOGFILE) for full log." ;\
|
||||
false; \
|
||||
else true; \
|
||||
fi
|
||||
ifdef RUN_AUTOCONF_LOCALLY
|
||||
@echo Generating configures using $(AUTOCONF) ; \
|
||||
cd $(TOPSRCDIR) && $(AUTOCONF) && \
|
||||
cd $(TOPSRCDIR)/nsprpub && $(AUTOCONF) && \
|
||||
cd $(TOPSRCDIR)/directory/c-sdk && $(AUTOCONF)
|
||||
endif
|
||||
|
||||
fast-update:
|
||||
# @: Backup the last checkout log.
|
||||
@if test -f $(CVSCO_LOGFILE) ; then \
|
||||
mv $(CVSCO_LOGFILE) $(CVSCO_LOGFILE).old; \
|
||||
else true; \
|
||||
fi
|
||||
ifdef RUN_AUTOCONF_LOCALLY
|
||||
@echo "Removing local configures" ; \
|
||||
cd $(ROOTDIR) && \
|
||||
$(RM) -f mozilla/configure mozilla/nsprpub/configure \
|
||||
mozilla/directory/c-sdk/configure
|
||||
endif
|
||||
@echo "checkout start: "`date` | tee $(CVSCO_LOGFILE)
|
||||
@echo '$(CVSCO) mozilla/client.mk mozilla/build/unix/modules.mk'; \
|
||||
cd $(ROOTDIR) && \
|
||||
$(CVSCO) mozilla/client.mk mozilla/build/unix/modules.mk
|
||||
@cd $(TOPSRCDIR) && \
|
||||
$(MAKE) -f client.mk real_fast-update
|
||||
|
||||
real_fast-update:
|
||||
# @: Start the update. Split the output to the tty and a log file. \
|
||||
# : If it fails, touch an error file because "tee" hides the error.
|
||||
@failed=.fast_update-failed.tmp; rm -f $$failed*; \
|
||||
fast_update() { (config/cvsco-fast-update.pl $$@ || touch $$failed) 2>&1 | tee -a $(CVSCO_LOGFILE) && \
|
||||
if test -f $$failed; then false; else true; fi; }; \
|
||||
cvs_co() { echo "$$@" ; \
|
||||
("$$@" || touch $$failed) 2>&1 | tee -a $(CVSCO_LOGFILE) && \
|
||||
if test -f $$failed; then false; else true; fi; }; \
|
||||
fast_update $(CVSCO_NSPR) && \
|
||||
cd $(ROOTDIR) && \
|
||||
failed=mozilla/.fast_update-failed.tmp && \
|
||||
cvs_co $(CVSCO_NSS) && \
|
||||
failed=.fast_update-failed.tmp && \
|
||||
cd mozilla && \
|
||||
fast_update $(CVSCO_PSM) && \
|
||||
fast_update $(CVSCO_LDAPCSDK) && \
|
||||
fast_update $(CVSCO_ACCESSIBLE) && \
|
||||
fast_update $(CVSCO_GFX2) && \
|
||||
fast_update $(CVSCO_IMGLIB2) && \
|
||||
$(FASTUPDATE_CALENDAR) && \
|
||||
$(FASTUPDATE_LIBART) && \
|
||||
fast_update $(CVSCO_SEAMONKEY) && \
|
||||
fast_update $(CVSCO_NOSUBDIRS)
|
||||
@echo "fast_update finish: "`date` | tee -a $(CVSCO_LOGFILE)
|
||||
# @: Check the log for conflicts. ;
|
||||
@conflicts=`egrep "^C " $(CVSCO_LOGFILE)` ;\
|
||||
if test "$$conflicts" ; then \
|
||||
echo "$(MAKE): *** Conflicts during fast-update." ;\
|
||||
echo "$$conflicts" ;\
|
||||
echo "$(MAKE): Refer to $(CVSCO_LOGFILE) for full log." ;\
|
||||
false; \
|
||||
else true; \
|
||||
fi
|
||||
ifdef RUN_AUTOCONF_LOCALLY
|
||||
@echo Generating configures using $(AUTOCONF) ; \
|
||||
cd $(TOPSRCDIR) && $(AUTOCONF) && \
|
||||
cd $(TOPSRCDIR)/nsprpub && $(AUTOCONF) && \
|
||||
cd $(TOPSRCDIR)/directory/c-sdk && $(AUTOCONF)
|
||||
endif
|
||||
|
||||
####################################
|
||||
# Web configure
|
||||
|
||||
WEBCONFIG_FILE := $(HOME)/.mozconfig
|
||||
|
||||
MOZCONFIG2CONFIGURATOR := build/autoconf/mozconfig2configurator
|
||||
webconfig:
|
||||
@cd $(TOPSRCDIR); \
|
||||
url=`$(MOZCONFIG2CONFIGURATOR) $(TOPSRCDIR)`; \
|
||||
echo Running mozilla with the following url: ;\
|
||||
echo ;\
|
||||
echo $$url ;\
|
||||
mozilla -remote "openURL($$url)" || \
|
||||
netscape -remote "openURL($$url)" || \
|
||||
mozilla $$url || \
|
||||
netscape $$url ;\
|
||||
echo ;\
|
||||
echo 1. Fill out the form on the browser. ;\
|
||||
echo 2. Save the results to $(WEBCONFIG_FILE)
|
||||
|
||||
#####################################################
|
||||
# First Checkout
|
||||
|
||||
ifdef _IS_FIRST_CHECKOUT
|
||||
# First time, do build target in a new process to pick up new files.
|
||||
build::
|
||||
$(MAKE) -f $(TOPSRCDIR)/client.mk build
|
||||
else
|
||||
|
||||
#####################################################
|
||||
# After First Checkout
|
||||
|
||||
|
||||
####################################
|
||||
# Configure
|
||||
|
||||
CONFIG_STATUS := $(wildcard $(OBJDIR)/config.status)
|
||||
CONFIG_CACHE := $(wildcard $(OBJDIR)/config.cache)
|
||||
|
||||
ifdef RUN_AUTOCONF_LOCALLY
|
||||
EXTRA_CONFIG_DEPS := \
|
||||
$(TOPSRCDIR)/aclocal.m4 \
|
||||
$(wildcard $(TOPSRCDIR)/build/autoconf/*.m4) \
|
||||
$(NULL)
|
||||
|
||||
$(TOPSRCDIR)/configure: $(TOPSRCDIR)/configure.in $(EXTRA_CONFIG_DEPS)
|
||||
@echo Generating $@ using autoconf
|
||||
cd $(TOPSRCDIR); $(AUTOCONF)
|
||||
endif
|
||||
|
||||
CONFIG_STATUS_DEPS_L10N := $(wildcard $(TOPSRCDIR)/l10n/makefiles.all)
|
||||
|
||||
CONFIG_STATUS_DEPS := \
|
||||
$(TOPSRCDIR)/configure \
|
||||
$(TOPSRCDIR)/allmakefiles.sh \
|
||||
$(TOPSRCDIR)/.mozconfig.mk \
|
||||
$(wildcard $(TOPSRCDIR)/nsprpub/configure) \
|
||||
$(wildcard $(TOPSRCDIR)/directory/c-sdk/configure) \
|
||||
$(wildcard $(TOPSRCDIR)/mailnews/makefiles) \
|
||||
$(CONFIG_STATUS_DEPS_L10N) \
|
||||
$(wildcard $(TOPSRCDIR)/themes/makefiles) \
|
||||
$(NULL)
|
||||
|
||||
# configure uses the program name to determine @srcdir@. Calling it without
|
||||
# $(TOPSRCDIR) will set @srcdir@ to "."; otherwise, it is set to the full
|
||||
# path of $(TOPSRCDIR).
|
||||
ifeq ($(TOPSRCDIR),$(OBJDIR))
|
||||
CONFIGURE := ./configure
|
||||
else
|
||||
CONFIGURE := $(TOPSRCDIR)/configure
|
||||
endif
|
||||
|
||||
ifdef _OBJ2SRCPATH
|
||||
CONFIGURE_ARGS := --srcdir=$(_OBJ2SRCPATH) $(CONFIGURE_ARGS)
|
||||
endif
|
||||
|
||||
$(OBJDIR)/Makefile $(OBJDIR)/config.status: $(CONFIG_STATUS_DEPS)
|
||||
@if test ! -d $(OBJDIR); then $(MKDIR) $(OBJDIR); else true; fi
|
||||
@echo cd $(OBJDIR);
|
||||
@echo $(CONFIGURE) $(CONFIGURE_ARGS)
|
||||
@cd $(OBJDIR) && $(CONFIGURE_ENV_ARGS) $(CONFIGURE) $(CONFIGURE_ARGS) \
|
||||
|| ( echo "*** Fix above errors and then restart with\
|
||||
\"$(MAKE) -f client.mk build\"" && exit 1 )
|
||||
@touch $(OBJDIR)/Makefile
|
||||
|
||||
ifdef CONFIG_STATUS
|
||||
$(OBJDIR)/config/autoconf.mk: $(TOPSRCDIR)/config/autoconf.mk.in
|
||||
cd $(OBJDIR); \
|
||||
CONFIG_FILES=config/autoconf.mk ./config.status
|
||||
endif
|
||||
|
||||
|
||||
####################################
|
||||
# Depend
|
||||
|
||||
depend:: $(OBJDIR)/Makefile $(OBJDIR)/config.status
|
||||
$(MOZ_MAKE) export && $(MOZ_MAKE) depend
|
||||
|
||||
####################################
|
||||
# Build it
|
||||
|
||||
build:: $(OBJDIR)/Makefile $(OBJDIR)/config.status
|
||||
$(MOZ_MAKE)
|
||||
|
||||
####################################
|
||||
# Other targets
|
||||
|
||||
# Pass these target onto the real build system
|
||||
install export libs clean realclean distclean alldep:: $(OBJDIR)/Makefile $(OBJDIR)/config.status
|
||||
$(MOZ_MAKE) $@
|
||||
|
||||
cleansrcdir:
|
||||
@cd $(TOPSRCDIR); \
|
||||
if [ -f webshell/embed/gtk/Makefile ]; then \
|
||||
$(MAKE) -C webshell/embed/gtk distclean; \
|
||||
fi; \
|
||||
if [ -f Makefile ]; then \
|
||||
$(MAKE) distclean ; \
|
||||
else \
|
||||
echo "Removing object files from srcdir..."; \
|
||||
rm -fr `find . -type d \( -name .deps -print -o -name CVS \
|
||||
-o -exec test ! -d {}/CVS \; \) -prune \
|
||||
-o \( -name '*.[ao]' -o -name '*.so' \) -type f -print`; \
|
||||
build/autoconf/clean-config.sh; \
|
||||
fi;
|
||||
|
||||
# (! IS_FIRST_CHECKOUT)
|
||||
endif
|
||||
|
||||
.PHONY: checkout real_checkout depend build export libs alldep install clean realclean distclean cleansrcdir pull_all build_all clobber clobber_all pull_and_build_all everything
|
||||
5
mozilla/js/jsd/MANIFEST
Normal file
5
mozilla/js/jsd/MANIFEST
Normal file
@@ -0,0 +1,5 @@
|
||||
#
|
||||
# This is a list of local files which get copied to the mozilla:dist directory
|
||||
#
|
||||
|
||||
jsdebug.h
|
||||
73
mozilla/js/jsd/Makefile
Normal file
73
mozilla/js/jsd/Makefile
Normal file
@@ -0,0 +1,73 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
|
||||
|
||||
DEPTH = ../..
|
||||
|
||||
MODULE = jsdebug
|
||||
LIBRARY_NAME = jsd
|
||||
|
||||
# Switching on MOZ_JAVA is a short-term hack. This is really for no Java/IFC
|
||||
ifdef MOZ_JAVA
|
||||
JAVA_OR_OJI = 1
|
||||
endif
|
||||
ifdef MOZ_OJI
|
||||
JAVA_OR_OJI = 1
|
||||
endif
|
||||
|
||||
ifdef JAVA_OR_OJI
|
||||
DIRS = classes
|
||||
endif
|
||||
|
||||
REQUIRES = java js nspr
|
||||
|
||||
EXPORTS = jsdebug.h
|
||||
|
||||
CSRCS = \
|
||||
jsdebug.c \
|
||||
jsd_high.c \
|
||||
jsd_hook.c \
|
||||
jsd_scpt.c \
|
||||
jsd_stak.c \
|
||||
jsd_text.c \
|
||||
jsd_lock.c \
|
||||
$(NULL)
|
||||
|
||||
ifndef MOZ_JSD
|
||||
CSRCS += jsdstubs.c jsd_java.c
|
||||
|
||||
JDK_GEN = \
|
||||
netscape.jsdebug.Script \
|
||||
netscape.jsdebug.DebugController \
|
||||
netscape.jsdebug.JSThreadState \
|
||||
netscape.jsdebug.JSStackFrameInfo \
|
||||
netscape.jsdebug.JSPC \
|
||||
netscape.jsdebug.JSSourceTextProvider \
|
||||
netscape.jsdebug.JSErrorReporter \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
include $(DEPTH)/config/rules.mk
|
||||
|
||||
$(OBJDIR)\jsdstubs.o: \
|
||||
$(JDK_STUB_DIR)\netscape_jsdebug_Script.c \
|
||||
$(JDK_STUB_DIR)\netscape_jsdebug_DebugController.c \
|
||||
$(JDK_STUB_DIR)\netscape_jsdebug_JSThreadState.c \
|
||||
$(JDK_STUB_DIR)\netscape_jsdebug_JSStackFrameInfo.c \
|
||||
$(JDK_STUB_DIR)\netscape_jsdebug_JSPC.c \
|
||||
$(JDK_STUB_DIR)\netscape_jsdebug_JSSourceTextProvider.c
|
||||
78
mozilla/js/jsd/Makefile.in
Normal file
78
mozilla/js/jsd/Makefile.in
Normal file
@@ -0,0 +1,78 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
|
||||
|
||||
DEPTH = ../..
|
||||
topsrcdir = @top_srcdir@
|
||||
VPATH = @srcdir@
|
||||
srcdir = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = jsdebug
|
||||
LIBRARY_NAME = jsd
|
||||
|
||||
# Switching on MOZ_JAVA is a short-term hack. This is really for no Java/IFC
|
||||
ifdef MOZ_JAVA
|
||||
JAVA_OR_OJI = 1
|
||||
endif
|
||||
ifdef MOZ_OJI
|
||||
JAVA_OR_OJI = 1
|
||||
endif
|
||||
|
||||
ifdef JAVA_OR_OJI
|
||||
DIRS = classes
|
||||
endif
|
||||
|
||||
REQUIRES = java js
|
||||
|
||||
EXPORTS = $(srcdir)/jsdebug.h
|
||||
|
||||
CSRCS = \
|
||||
jsdebug.c \
|
||||
jsd_high.c \
|
||||
jsd_hook.c \
|
||||
jsd_scpt.c \
|
||||
jsd_stak.c \
|
||||
jsd_text.c \
|
||||
jsd_lock.c \
|
||||
$(NULL)
|
||||
|
||||
ifndef MOZ_JSD
|
||||
CSRCS += jsdstubs.c jsd_java.c
|
||||
|
||||
JDK_GEN = \
|
||||
netscape.jsdebug.Script \
|
||||
netscape.jsdebug.DebugController \
|
||||
netscape.jsdebug.JSThreadState \
|
||||
netscape.jsdebug.JSStackFrameInfo \
|
||||
netscape.jsdebug.JSPC \
|
||||
netscape.jsdebug.JSSourceTextProvider \
|
||||
netscape.jsdebug.JSErrorReporter \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
$(OBJDIR)\jsdstubs.o: \
|
||||
$(JDK_STUB_DIR)\netscape_jsdebug_Script.c \
|
||||
$(JDK_STUB_DIR)\netscape_jsdebug_DebugController.c \
|
||||
$(JDK_STUB_DIR)\netscape_jsdebug_JSThreadState.c \
|
||||
$(JDK_STUB_DIR)\netscape_jsdebug_JSStackFrameInfo.c \
|
||||
$(JDK_STUB_DIR)\netscape_jsdebug_JSPC.c \
|
||||
$(JDK_STUB_DIR)\netscape_jsdebug_JSSourceTextProvider.c
|
||||
18
mozilla/js/jsd/README
Normal file
18
mozilla/js/jsd/README
Normal file
@@ -0,0 +1,18 @@
|
||||
/* jband - 10/26/98 - */
|
||||
|
||||
js/jsd contains code for debugging support for the C-based JavaScript engine
|
||||
in js/src.
|
||||
|
||||
Currently the makefiles are for Win32 only (using MS nmake.exe from MSDEV 4.2).
|
||||
jsd.mak will build a standalone dll. jsdshell.mak will build the dll and also
|
||||
a version of the js/src/js.c shell which will launch a Java VM and run the
|
||||
JavaSript Debugger (built in js/jsdj). This version assumes that you have a
|
||||
JRE compatible JVM installed. Only Windows is supported for this Java-based
|
||||
debugging.
|
||||
|
||||
Though only Windows makefiles are supplied, the basic code in js/jsd should
|
||||
compile for other platforms -- it is a newer version of code that builds and
|
||||
ships with Communicator 4.x on many platforms.
|
||||
|
||||
js/jsd/jsdb is a console debugger using only native code (see README in that
|
||||
directory)
|
||||
59
mozilla/js/jsd/classes/Makefile
Normal file
59
mozilla/js/jsd/classes/Makefile
Normal file
@@ -0,0 +1,59 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
|
||||
|
||||
DEPTH = ../../..
|
||||
|
||||
MODULE = java
|
||||
|
||||
JJSD = netscape/jsdebug
|
||||
|
||||
#
|
||||
# JDIRS is dependant on JAVA_DESTPATH in config/rules.m[a]k.
|
||||
# Be sure to touch that directory if you add a new directory to
|
||||
# JDIRS, or else it will not build. XXX
|
||||
#
|
||||
JDIRS = $(JJSD)
|
||||
|
||||
JAR_JSD = jsd10.jar
|
||||
JAR_JSD_CLASSES = $(JJSD)
|
||||
|
||||
#
|
||||
# jars to build at install time
|
||||
#
|
||||
JARS = $(JAR_JSD)
|
||||
|
||||
include $(DEPTH)/config/rules.mk
|
||||
|
||||
JAVA_SOURCEPATH = $(DEPTH)/js/jsd/classes
|
||||
|
||||
doc::
|
||||
$(JAVADOC) -d $(DIST)/doc netscape.jsdebug
|
||||
|
||||
natives_list:: FORCE
|
||||
rm -rf $@
|
||||
find . -name "*.class" -print | sed 's@\./\(.*\)\.class$$@\1@' | \
|
||||
sed 's@/@.@g' | xargs $(JVH) -natives | sort > $@
|
||||
|
||||
check_natives:: natives_list
|
||||
rm -f found_natives
|
||||
nm -B ../$(OBJDIR)/*.o \
|
||||
| egrep "Java.*_stub" | awk '{ print $$3; }' | sort > found_natives
|
||||
diff found_natives natives_list
|
||||
|
||||
FORCE:
|
||||
64
mozilla/js/jsd/classes/Makefile.in
Normal file
64
mozilla/js/jsd/classes/Makefile.in
Normal file
@@ -0,0 +1,64 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
VPATH = @srcdir@
|
||||
srcdir = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = java
|
||||
|
||||
JJSD = netscape/jsdebug
|
||||
|
||||
#
|
||||
# JDIRS is dependant on JAVA_DESTPATH in config/rules.m[a]k.
|
||||
# Be sure to touch that directory if you add a new directory to
|
||||
# JDIRS, or else it will not build. XXX
|
||||
#
|
||||
JDIRS = $(JJSD)
|
||||
|
||||
JAR_JSD = jsd10.jar
|
||||
JAR_JSD_CLASSES = $(JJSD)
|
||||
|
||||
#
|
||||
# jars to build at install time
|
||||
#
|
||||
JARS = $(JAR_JSD)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
JAVA_SOURCEPATH = $(DEPTH)/js/jsd/classes
|
||||
|
||||
doc::
|
||||
$(JAVADOC) -d $(DIST)/doc netscape.jsdebug
|
||||
|
||||
natives_list:: FORCE
|
||||
rm -rf $@
|
||||
find . -name "*.class" -print | sed 's@\./\(.*\)\.class$$@\1@' | \
|
||||
sed 's@/@.@g' | xargs $(JVH) -natives | sort > $@
|
||||
|
||||
check_natives:: natives_list
|
||||
rm -f found_natives
|
||||
nm -B ../$(OBJDIR)/*.o \
|
||||
| egrep "Java.*_stub" | awk '{ print $$3; }' | sort > found_natives
|
||||
diff found_natives natives_list
|
||||
|
||||
FORCE:
|
||||
64
mozilla/js/jsd/classes/makefile.win
Normal file
64
mozilla/js/jsd/classes/makefile.win
Normal file
@@ -0,0 +1,64 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
IGNORE_MANIFEST=1
|
||||
#
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Makefile to build the JavaScriptDebug tree
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
|
||||
DEPTH = ..\..\..
|
||||
JAVA_SOURCEPATH=$(DEPTH)\js\jsd\classes
|
||||
|
||||
#//------------------------------------------------------------------------
|
||||
#//
|
||||
#// Define the files necessary to build the target (ie. OBJS)
|
||||
#//
|
||||
#//------------------------------------------------------------------------
|
||||
include <$(DEPTH)\config\config.mak>
|
||||
|
||||
all::
|
||||
|
||||
MODULE=java
|
||||
JJSD=netscape/jsdebug
|
||||
JDIRS=$(JJSD)
|
||||
JAR_JSD=jsd10.jar
|
||||
JAR_JSD_CLASSES=$(JJSD)
|
||||
JARS=$(JAR_JSD)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
!if "$(MOZ_BITS)" == "32"
|
||||
$(JAR_JSD):
|
||||
cd $(JAVA_DESTPATH)
|
||||
@echo +++ building/updating $@
|
||||
$(ZIP_PROG) -$(COMP_LEVEL)qu $@ META-INF\build
|
||||
-for %i in ($(JAR_JSD_CLASSES:/=\)) do @$(ZIP_PROG) -$(COMP_LEVEL)qu $@ %i\*.class
|
||||
cd $(MAKEDIR)
|
||||
!endif
|
||||
|
||||
jars: $(JARS)
|
||||
|
||||
install:: jars
|
||||
|
||||
|
||||
javadoc:
|
||||
-mkdir $(XPDIST)\javadoc 2> NUL
|
||||
echo $(JAVADOC) -sourcepath . -d $(XPDIST)\javadoc $(JDIRS:/=.)
|
||||
$(JAVADOC) -sourcepath . -d $(XPDIST)\javadoc $(JDIRS:/=.)
|
||||
41
mozilla/js/jsd/classes/netscape/jsdebug/DebugBreakHook.java
Normal file
41
mozilla/js/jsd/classes/netscape/jsdebug/DebugBreakHook.java
Normal file
@@ -0,0 +1,41 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
package netscape.jsdebug;
|
||||
|
||||
/**
|
||||
* DebugBreakHook must be subclassed to respond when a debug break is
|
||||
* requested
|
||||
*
|
||||
* @author John Bandhauer
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
public class DebugBreakHook extends Hook {
|
||||
|
||||
/**
|
||||
* Override this method to respond just before a thread
|
||||
* reaches a particular instruction.
|
||||
* <p>
|
||||
* @param debug ThreadState representing the current state
|
||||
* @param pc the location of the instruction about to be executed
|
||||
*/
|
||||
public void aboutToExecute(ThreadStateBase debug, PC pc) {
|
||||
// defaults to no action
|
||||
}
|
||||
}
|
||||
374
mozilla/js/jsd/classes/netscape/jsdebug/DebugController.java
Normal file
374
mozilla/js/jsd/classes/netscape/jsdebug/DebugController.java
Normal file
@@ -0,0 +1,374 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
package netscape.jsdebug;
|
||||
|
||||
import netscape.util.Hashtable;
|
||||
import netscape.security.PrivilegeManager;
|
||||
import netscape.security.ForbiddenTargetException;
|
||||
|
||||
/**
|
||||
* This is the master control panel for observing events in the VM.
|
||||
* Each method setXHook() must be passed an object that extends
|
||||
* the class XHook. When an event of the specified type
|
||||
* occurs, a well-known method on XHook will be called (see the
|
||||
* various XHook classes for details). The method call takes place
|
||||
* on the same thread that triggered the event in the first place,
|
||||
* so that any monitors held by the thread which triggered the hook
|
||||
* will still be owned in the hook method.
|
||||
* <p>
|
||||
* This class is meant to be a singleton and has a private constructor.
|
||||
* Call the static <code>getDebugController()</code> to get this object.
|
||||
* <p>
|
||||
* Note that all functions use netscape.security.PrivilegeManager to verify
|
||||
* that the caller has the "Debugger" privilege. The exception
|
||||
* netscape.security.ForbiddenTargetException will be throw if this is
|
||||
* not enabled.
|
||||
*
|
||||
* @author John Bandhauer
|
||||
* @author Nick Thompson
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
* @see netscape.security.PrivilegeManager
|
||||
* @see netscape.security.ForbiddenTargetException
|
||||
*/
|
||||
public final class DebugController {
|
||||
|
||||
private static final int majorVersion = 1;
|
||||
private static final int minorVersion = 0;
|
||||
|
||||
private static DebugController controller;
|
||||
private ScriptHook scriptHook;
|
||||
private Hashtable instructionHookTable;
|
||||
private InterruptHook interruptHook;
|
||||
private DebugBreakHook debugBreakHook;
|
||||
private JSErrorReporter errorReporter;
|
||||
|
||||
/**
|
||||
* Get the DebugController object for the current VM.
|
||||
* <p>
|
||||
* @return the singleton DebugController
|
||||
*/
|
||||
public static synchronized DebugController getDebugController()
|
||||
throws ForbiddenTargetException
|
||||
{
|
||||
try {
|
||||
PrivilegeManager.checkPrivilegeEnabled("Debugger");
|
||||
if (controller == null)
|
||||
controller = new DebugController();
|
||||
return controller;
|
||||
} catch (ForbiddenTargetException e) {
|
||||
System.out.println("failed in check Priv in DebugController.getDebugController()");
|
||||
e.printStackTrace(System.out);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
private DebugController()
|
||||
{
|
||||
scriptTable = new Hashtable();
|
||||
_setController(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Request notification of Script loading events.
|
||||
* <p>
|
||||
* Whenever a Script is loaded into or unloaded from the VM
|
||||
* the appropriate method of the ScriptHook argument will be called.
|
||||
* Callers are responsible for chaining hooks if chaining is required.
|
||||
*
|
||||
* @param h new script hook
|
||||
* @return the previous hook object (null if none)
|
||||
*/
|
||||
public synchronized ScriptHook setScriptHook(ScriptHook h)
|
||||
throws ForbiddenTargetException
|
||||
{
|
||||
PrivilegeManager.checkPrivilegeEnabled("Debugger");
|
||||
ScriptHook oldHook = scriptHook;
|
||||
scriptHook = h;
|
||||
return oldHook;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current observer of Script events.
|
||||
* <p>
|
||||
* @return the current script hook (null if none)
|
||||
*/
|
||||
public ScriptHook getScriptHook()
|
||||
throws ForbiddenTargetException
|
||||
{
|
||||
PrivilegeManager.checkPrivilegeEnabled("Debugger");
|
||||
return scriptHook;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a hook at the given program counter value.
|
||||
* <p>
|
||||
* When a thread reaches that instruction, a ThreadState
|
||||
* object will be created and the appropriate method
|
||||
* of the hook object will be called. Callers are responsible
|
||||
* for chaining hooks if chaining is required.
|
||||
*
|
||||
* @param pc pc at which hook should be set
|
||||
* @param h new hook for this pc
|
||||
* @return the previous hook object (null if none)
|
||||
*/
|
||||
public synchronized InstructionHook setInstructionHook(
|
||||
PC pc,
|
||||
InstructionHook h)
|
||||
throws ForbiddenTargetException
|
||||
{
|
||||
PrivilegeManager.checkPrivilegeEnabled("Debugger");
|
||||
InstructionHook oldHook;
|
||||
if (instructionHookTable == null) {
|
||||
instructionHookTable = new Hashtable();
|
||||
}
|
||||
oldHook = (InstructionHook) instructionHookTable.get(pc);
|
||||
instructionHookTable.put(pc, h);
|
||||
setInstructionHook0(pc);
|
||||
return oldHook;
|
||||
}
|
||||
|
||||
private native void setInstructionHook0(PC pc);
|
||||
|
||||
/**
|
||||
* Get the hook at the given program counter value.
|
||||
* <p>
|
||||
* @param pc pc for which hook should be found
|
||||
* @return the hook (null if none)
|
||||
*/
|
||||
public InstructionHook getInstructionHook(PC pc)
|
||||
throws ForbiddenTargetException
|
||||
{
|
||||
PrivilegeManager.checkPrivilegeEnabled("Debugger");
|
||||
return getInstructionHook0(pc);
|
||||
}
|
||||
|
||||
// called by native function
|
||||
private InstructionHook getInstructionHook0(PC pc)
|
||||
{
|
||||
if (instructionHookTable == null)
|
||||
return null;
|
||||
else
|
||||
return (InstructionHook) instructionHookTable.get(pc);
|
||||
}
|
||||
|
||||
/**************************************************************/
|
||||
|
||||
/**
|
||||
* Set the hook at to be called when interrupts occur.
|
||||
* <p>
|
||||
* The next instruction which starts to execute after
|
||||
* <code>sendInterrupt()</code> has been called will
|
||||
* trigger a call to this hook. A ThreadState
|
||||
* object will be created and the appropriate method
|
||||
* of the hook object will be called. Callers are responsible
|
||||
* for chaining hooks if chaining is required.
|
||||
*
|
||||
* @param h new hook
|
||||
* @return the previous hook object (null if none)
|
||||
* @see netscape.jsdebug.DebugController#sendInterrupt
|
||||
*/
|
||||
public synchronized InterruptHook setInterruptHook( InterruptHook h )
|
||||
throws ForbiddenTargetException
|
||||
{
|
||||
PrivilegeManager.checkPrivilegeEnabled("Debugger");
|
||||
InterruptHook oldHook = interruptHook;
|
||||
interruptHook = h;
|
||||
return oldHook;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current hook to be called on interrupt
|
||||
* <p>
|
||||
* @return the hook (null if none)
|
||||
*/
|
||||
public InterruptHook getInterruptHook()
|
||||
throws ForbiddenTargetException
|
||||
{
|
||||
PrivilegeManager.checkPrivilegeEnabled("Debugger");
|
||||
return interruptHook;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cause the interrupt hook to be called when the next
|
||||
* JavaScript instruction starts to execute.
|
||||
* <p>
|
||||
* The interrupt is self clearing
|
||||
* @see netscape.jsdebug.DebugController#setInterruptHook
|
||||
*/
|
||||
public void sendInterrupt()
|
||||
throws ForbiddenTargetException
|
||||
{
|
||||
PrivilegeManager.checkPrivilegeEnabled("Debugger");
|
||||
sendInterrupt0();
|
||||
}
|
||||
|
||||
private native void sendInterrupt0();
|
||||
|
||||
|
||||
/**************************************************************/
|
||||
|
||||
/**
|
||||
* Set the hook at to be called when a <i>debug break</i> is requested
|
||||
* <p>
|
||||
* Set the hook to be called when <i>JSErrorReporter.DEBUG</i> is returned
|
||||
* by the <i>error reporter</i> hook. When that happens a ThreadState
|
||||
* object will be created and the appropriate method
|
||||
* of the hook object will be called. Callers are responsible
|
||||
* for chaining hooks if chaining is required.
|
||||
*
|
||||
* @param h new hook
|
||||
* @return the previous hook object (null if none)
|
||||
* @see netscape.jsdebug.DebugController#setErrorReporter
|
||||
* @see netscape.jsdebug.JSErrorReporter
|
||||
*/
|
||||
public synchronized DebugBreakHook setDebugBreakHook( DebugBreakHook h )
|
||||
throws ForbiddenTargetException
|
||||
{
|
||||
PrivilegeManager.checkPrivilegeEnabled("Debugger");
|
||||
DebugBreakHook oldHook = debugBreakHook;
|
||||
debugBreakHook = h;
|
||||
return oldHook;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current hook to be called on debug break
|
||||
* <p>
|
||||
* @return the hook (null if none)
|
||||
*/
|
||||
public DebugBreakHook getDebugBreakHook()
|
||||
throws ForbiddenTargetException
|
||||
{
|
||||
PrivilegeManager.checkPrivilegeEnabled("Debugger");
|
||||
return debugBreakHook;
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************/
|
||||
/**
|
||||
* Get the 'handle' which cooresponds to the native code representing the
|
||||
* instance of the underlying JavaScript Debugger context.
|
||||
* <p>
|
||||
* This would not normally be useful in java. Some of the other classes
|
||||
* in this package need this. It remains public mostly for historical
|
||||
* reasons. It serves as a check to see that the native classes have been
|
||||
* loaded and the built-in native JavaScript Debugger support has been
|
||||
* initialized. This DebugController is not valid (or useful) when it is
|
||||
* in a state where this native context equals 0.
|
||||
*
|
||||
* @return the native context (0 if none)
|
||||
*/
|
||||
public int getNativeContext()
|
||||
throws ForbiddenTargetException
|
||||
{
|
||||
PrivilegeManager.checkPrivilegeEnabled("Debugger");
|
||||
// System.out.println( "nativecontext = " + _nativeContext + "\n" );
|
||||
return _nativeContext;
|
||||
}
|
||||
|
||||
private native void _setController( boolean set );
|
||||
private Hashtable scriptTable;
|
||||
private int _nativeContext;
|
||||
|
||||
/**
|
||||
* Execute a string as a JavaScript script within a stack frame
|
||||
* <p>
|
||||
* This method can be used to execute arbitrary sets of statements on a
|
||||
* stopped thread. It is useful for inspecting and modifying data.
|
||||
* <p>
|
||||
* This method can only be called while the JavaScript thread is stopped
|
||||
* - i.e. as part of the code responding to a hook. Thgis method
|
||||
* <b>must</b> be called on the same thread as was executing when the
|
||||
* hook was called.
|
||||
* <p>
|
||||
* If an error occurs while execuing this code, then the error
|
||||
* reporter hook will be called if present.
|
||||
*
|
||||
* @param frame the frame context in which to evaluate this script
|
||||
* @param text the script text
|
||||
* @param filename where to tell the JavaScript engine this code came
|
||||
* from (it is usually best to make this the same as the filename of
|
||||
* code represented by the frame)
|
||||
* @param lineno the line number to pass to JS ( >=1 )
|
||||
* @return The result of the script execution converted to a string.
|
||||
* (null if the result was null or void)
|
||||
*/
|
||||
public String executeScriptInStackFrame( JSStackFrameInfo frame,
|
||||
String text,
|
||||
String filename,
|
||||
int lineno )
|
||||
throws ForbiddenTargetException
|
||||
{
|
||||
PrivilegeManager.checkPrivilegeEnabled("Debugger");
|
||||
return executeScriptInStackFrame0( frame, text, filename, lineno );
|
||||
}
|
||||
|
||||
private native String executeScriptInStackFrame0( JSStackFrameInfo frame,
|
||||
String text,
|
||||
String filename,
|
||||
int lineno );
|
||||
|
||||
|
||||
/**
|
||||
* Set the hook at to be called when a JavaScript error occurs
|
||||
* <p>
|
||||
* @param er new error reporter hook
|
||||
* @return the previous hook object (null if none)
|
||||
* @see netscape.jsdebug.JSErrorReporter
|
||||
*/
|
||||
public JSErrorReporter setErrorReporter(JSErrorReporter er)
|
||||
throws ForbiddenTargetException
|
||||
{
|
||||
PrivilegeManager.checkPrivilegeEnabled("Debugger");
|
||||
JSErrorReporter old = errorReporter;
|
||||
errorReporter = er;
|
||||
return old;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the hook at to be called when a JavaScript error occurs
|
||||
* <p>
|
||||
* @return the hook object (null if none)
|
||||
* @see netscape.jsdebug.JSErrorReporter
|
||||
*/
|
||||
public JSErrorReporter getErrorReporter()
|
||||
throws ForbiddenTargetException
|
||||
{
|
||||
PrivilegeManager.checkPrivilegeEnabled("Debugger");
|
||||
return errorReporter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the major version number of this module
|
||||
* <p>
|
||||
* @return the version number
|
||||
*/
|
||||
public static int getMajorVersion() {return majorVersion;}
|
||||
/**
|
||||
* Get the minor version number of this module
|
||||
* <p>
|
||||
* @return the version number
|
||||
*/
|
||||
public static int getMinorVersion() {return minorVersion;}
|
||||
|
||||
private static native int getNativeMajorVersion();
|
||||
private static native int getNativeMinorVersion();
|
||||
}
|
||||
32
mozilla/js/jsd/classes/netscape/jsdebug/Hook.java
Normal file
32
mozilla/js/jsd/classes/netscape/jsdebug/Hook.java
Normal file
@@ -0,0 +1,32 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
package netscape.jsdebug;
|
||||
|
||||
|
||||
/**
|
||||
* An instance of this class is returned for each hook set by
|
||||
* the debugger as a handle for removing the hook later.
|
||||
*
|
||||
* @author John Bandhauer
|
||||
* @author Nick Thompson
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
public abstract class Hook {
|
||||
}
|
||||
55
mozilla/js/jsd/classes/netscape/jsdebug/InstructionHook.java
Normal file
55
mozilla/js/jsd/classes/netscape/jsdebug/InstructionHook.java
Normal file
@@ -0,0 +1,55 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
package netscape.jsdebug;
|
||||
|
||||
/**
|
||||
* InstructionHook must be subclassed to respond to hooks
|
||||
* at a particular program instruction.
|
||||
*
|
||||
* @author John Bandhauer
|
||||
* @author Nick Thompson
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
public class InstructionHook extends Hook {
|
||||
private PC pc;
|
||||
|
||||
/**
|
||||
* Create an InstructionHook at the given PC value.
|
||||
*/
|
||||
public InstructionHook(PC pc) {
|
||||
this.pc = pc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the instruction that the hook is set at.
|
||||
*/
|
||||
public PC getPC() {
|
||||
return pc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Override this method to respond just before a thread
|
||||
* reaches a particular instruction.
|
||||
*/
|
||||
/* jband - 03/31/97 - I made this public to allow chaining */
|
||||
public void aboutToExecute(ThreadStateBase debug) {
|
||||
// defaults to no action
|
||||
}
|
||||
}
|
||||
39
mozilla/js/jsd/classes/netscape/jsdebug/InterruptHook.java
Normal file
39
mozilla/js/jsd/classes/netscape/jsdebug/InterruptHook.java
Normal file
@@ -0,0 +1,39 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
package netscape.jsdebug;
|
||||
|
||||
/**
|
||||
* InterruptHook must be subclassed to respond when interrupts occur
|
||||
*
|
||||
* @author John Bandhauer
|
||||
* @author Nick Thompson
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
public class InterruptHook extends Hook {
|
||||
|
||||
/**
|
||||
* Override this method to respond when interrupts occur
|
||||
* @param debug the state of this thread
|
||||
* @param pc the pc of the instruction about to execute
|
||||
*/
|
||||
public void aboutToExecute(ThreadStateBase debug, PC pc) {
|
||||
// defaults to no action
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
package netscape.jsdebug;
|
||||
|
||||
/**
|
||||
* Exception to indicate bad thread state etc...
|
||||
*
|
||||
* @author John Bandhauer
|
||||
* @author Nick Thompson
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
public class InvalidInfoException extends Exception {
|
||||
/**
|
||||
* Constructs a InvalidInfoException without a detail message.
|
||||
* A detail message is a String that describes this particular exception.
|
||||
*/
|
||||
public InvalidInfoException() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a InvalidInfoException with a detail message.
|
||||
* A detail message is a String that describes this particular exception.
|
||||
* @param s the detail message
|
||||
*/
|
||||
public InvalidInfoException(String s) {
|
||||
super(s);
|
||||
}
|
||||
}
|
||||
70
mozilla/js/jsd/classes/netscape/jsdebug/JSErrorReporter.java
Normal file
70
mozilla/js/jsd/classes/netscape/jsdebug/JSErrorReporter.java
Normal file
@@ -0,0 +1,70 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
package netscape.jsdebug;
|
||||
|
||||
/**
|
||||
* This is a special kind of hook to respond to JavaScript errors
|
||||
*
|
||||
* @author John Bandhauer
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
public interface JSErrorReporter
|
||||
{
|
||||
/* keep these in sync with the numbers in jsdebug.h */
|
||||
|
||||
/**
|
||||
* returned by <code>reportError()</code> to indicate that the error
|
||||
* should be passed along to the error reporter that would have been
|
||||
* called had the debugger not been running
|
||||
*/
|
||||
public static final int PASS_ALONG = 0;
|
||||
/**
|
||||
* returned by <code>reportError()</code> to indicate that the
|
||||
* normal error reporter should not be called and that the JavaScript
|
||||
* engine should do whatever it would normally do after calling the
|
||||
* error reporter.
|
||||
*/
|
||||
public static final int RETURN = 1;
|
||||
/**
|
||||
* returned by <code>reportError()</code> to indicate that the
|
||||
* 'debug break' hook should be called to allow the debugger to
|
||||
* investigate the state of the process when the error occured
|
||||
*/
|
||||
public static final int DEBUG = 2;
|
||||
|
||||
/**
|
||||
* This hook is called when a JavaScript error (compile or runtime) occurs
|
||||
* <p>
|
||||
* One of the codes above should be returned to tell the engine how to
|
||||
* proceed.
|
||||
* @param msg error message passed through from the JavaScript engine
|
||||
* @param filename filename (or url) of the code with the error
|
||||
* @param lineno line number where error was detected
|
||||
* @param linebuf a copy of the line where the error was detected
|
||||
* @param tokenOffset the offset into <i>linebuf</i> where the error
|
||||
* was detected
|
||||
* @returns one of the codes above
|
||||
*/
|
||||
public int reportError( String msg,
|
||||
String filename,
|
||||
int lineno,
|
||||
String linebuf,
|
||||
int tokenOffset );
|
||||
}
|
||||
76
mozilla/js/jsd/classes/netscape/jsdebug/JSPC.java
Normal file
76
mozilla/js/jsd/classes/netscape/jsdebug/JSPC.java
Normal file
@@ -0,0 +1,76 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
package netscape.jsdebug;
|
||||
|
||||
/**
|
||||
* This subclass of PC provides JavaScript-specific information.
|
||||
*
|
||||
* @author John Bandhauer
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
public final class JSPC extends PC {
|
||||
private Script script;
|
||||
private int pc;
|
||||
|
||||
public JSPC(Script script, int pc) {
|
||||
this.script = script;
|
||||
this.pc = pc;
|
||||
}
|
||||
|
||||
public Script getScript() {
|
||||
return script;
|
||||
}
|
||||
|
||||
public int getPC() {
|
||||
return pc;
|
||||
}
|
||||
|
||||
public boolean isValid()
|
||||
{
|
||||
return script.isValid();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the SourceLocation associated with this PC value.
|
||||
* returns null if the source location is unavailable.
|
||||
*/
|
||||
public native SourceLocation getSourceLocation();
|
||||
|
||||
/**
|
||||
* Ask whether two program counter values are equal.
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (!(obj instanceof JSPC))
|
||||
return false;
|
||||
JSPC jspc = (JSPC) obj;
|
||||
return (jspc.script == script && jspc.pc == pc);
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return script.hashCode() + pc;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "<PC "+script+"+"+pc+">";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
package netscape.jsdebug;
|
||||
|
||||
/**
|
||||
* JAvaScript specific SourceLocation
|
||||
*
|
||||
* @author John Bandhauer
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
public class JSSourceLocation extends SourceLocation
|
||||
{
|
||||
public JSSourceLocation( JSPC pc, int line )
|
||||
{
|
||||
_pc = pc;
|
||||
_line = line;
|
||||
_url = pc.getScript().getURL();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the first line number associated with this SourceLocation.
|
||||
* This is the lowest common denominator information that will be
|
||||
* available: some implementations may choose to include more
|
||||
* specific location information in a subclass of SourceLocation.
|
||||
*/
|
||||
public int getLine() {return _line;}
|
||||
|
||||
public String getURL() {return _url;}
|
||||
|
||||
/**
|
||||
* Get the first PC associated with a given SourceLocation.
|
||||
* This is the place to set a breakpoint at that location.
|
||||
* returns null if there is no code corresponding to that source
|
||||
* location.
|
||||
*/
|
||||
public PC getPC() {return _pc;}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return "<SourceLocation "+_url+"#"+_line+">";
|
||||
}
|
||||
|
||||
private JSPC _pc;
|
||||
private int _line;
|
||||
private String _url;
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
package netscape.jsdebug;
|
||||
|
||||
import netscape.util.Vector;
|
||||
import netscape.security.PrivilegeManager;
|
||||
import netscape.security.ForbiddenTargetException;
|
||||
|
||||
/**
|
||||
* This class provides access to SourceText items.
|
||||
* <p>
|
||||
* This class is meant to be a singleton and has a private constructor.
|
||||
* Call the static <code>getSourceTextProvider()</code> to get this object.
|
||||
* <p>
|
||||
* Note that all functions use netscape.security.PrivilegeManager to verify
|
||||
* that the caller has the "Debugger" privilege. The exception
|
||||
* netscape.security.ForbiddenTargetException will be throw if this is
|
||||
* not enabled.
|
||||
*
|
||||
* @author John Bandhauer
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
* @see netscape.security.PrivilegeManager
|
||||
* @see netscape.security.ForbiddenTargetException
|
||||
*/
|
||||
public final class JSSourceTextProvider extends SourceTextProvider
|
||||
{
|
||||
private JSSourceTextProvider( long nativeContext )
|
||||
{
|
||||
_sourceTextVector = new Vector();
|
||||
_nativeContext = nativeContext;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the SourceTextProvider object for the current VM.
|
||||
* <p>
|
||||
* @return the singleton SourceTextProvider
|
||||
*/
|
||||
public static synchronized SourceTextProvider getSourceTextProvider()
|
||||
throws ForbiddenTargetException
|
||||
{
|
||||
PrivilegeManager.checkPrivilegeEnabled("Debugger");
|
||||
if( null == _sourceTextProvider )
|
||||
{
|
||||
long nativeContext = DebugController.getDebugController().getNativeContext();
|
||||
if( 0 != nativeContext )
|
||||
_sourceTextProvider = new JSSourceTextProvider(nativeContext);
|
||||
}
|
||||
return _sourceTextProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the SourceText item for the given URL
|
||||
*/
|
||||
public SourceTextItem findSourceTextItem( String url )
|
||||
throws ForbiddenTargetException
|
||||
{
|
||||
PrivilegeManager.checkPrivilegeEnabled("Debugger");
|
||||
return findSourceTextItem0(url);
|
||||
}
|
||||
|
||||
// also called from native code...
|
||||
private SourceTextItem findSourceTextItem0( String url )
|
||||
{
|
||||
synchronized( _sourceTextVector )
|
||||
{
|
||||
for (int i = 0; i < _sourceTextVector.size(); i++)
|
||||
{
|
||||
SourceTextItem src = (SourceTextItem) _sourceTextVector.elementAt(i);
|
||||
|
||||
if( src.getURL().equals(url) )
|
||||
return src;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the vector of SourceTextItems.
|
||||
* <p>
|
||||
* This is NOT a copy. nor is it necessarily current
|
||||
*/
|
||||
public Vector getSourceTextVector()
|
||||
throws ForbiddenTargetException
|
||||
{
|
||||
PrivilegeManager.checkPrivilegeEnabled("Debugger");
|
||||
return _sourceTextVector;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the SourceText item for the given URL
|
||||
* <p>
|
||||
* <B>This is not guaranteed to be implemented</B>
|
||||
*/
|
||||
public synchronized SourceTextItem loadSourceTextItem( String url )
|
||||
throws ForbiddenTargetException
|
||||
{
|
||||
PrivilegeManager.checkPrivilegeEnabled("Debugger");
|
||||
return loadSourceTextItem0( url );
|
||||
}
|
||||
|
||||
private native SourceTextItem loadSourceTextItem0( String url );
|
||||
|
||||
/**
|
||||
* Refresh the vector to reflect any changes made in the
|
||||
* underlying native system
|
||||
*/
|
||||
public synchronized native void refreshSourceTextVector();
|
||||
|
||||
private static SourceTextProvider _sourceTextProvider = null;
|
||||
private Vector _sourceTextVector;
|
||||
private long _nativeContext;
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
package netscape.jsdebug;
|
||||
|
||||
/**
|
||||
* This interface provides access to the execution stack of a thread.
|
||||
* It has several subclasses to distinguish between different kinds of
|
||||
* stack frames: these currently include activations of Java methods
|
||||
* or JavaScript functions.
|
||||
* It is possible that synchronize blocks and try blocks deserve their own
|
||||
* stack frames - to allow for later extensions a debugger should skip over
|
||||
* stack frames it doesn't understand.
|
||||
* Note that this appears very Java-specific. However, multiple threads and
|
||||
* exceptions are relevant to JavaScript as well because of its
|
||||
* interoperation with Java.
|
||||
*
|
||||
* @author John Bandhauer
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
public final class JSStackFrameInfo extends StackFrameInfo
|
||||
{
|
||||
public JSStackFrameInfo(JSThreadState threadState) {
|
||||
super(threadState);
|
||||
}
|
||||
|
||||
protected native StackFrameInfo getCaller0()
|
||||
throws InvalidInfoException;
|
||||
|
||||
public native PC getPC()
|
||||
throws InvalidInfoException;
|
||||
|
||||
private int _nativePtr; // used internally
|
||||
}
|
||||
|
||||
80
mozilla/js/jsd/classes/netscape/jsdebug/JSThreadState.java
Normal file
80
mozilla/js/jsd/classes/netscape/jsdebug/JSThreadState.java
Normal file
@@ -0,0 +1,80 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
package netscape.jsdebug;
|
||||
|
||||
/**
|
||||
* This is the JavaScript specific implementation of the thread state
|
||||
*
|
||||
* @author John Bandhauer
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
public final class JSThreadState extends ThreadStateBase
|
||||
{
|
||||
/**
|
||||
* <B><font color="red">Not Implemented.</font></B>
|
||||
* Always throws <code>InternalError("unimplemented")</code>
|
||||
*/
|
||||
public static ThreadStateBase getThreadState(Thread t)
|
||||
throws InvalidInfoException
|
||||
{
|
||||
throw new InternalError("unimplemented");
|
||||
}
|
||||
|
||||
/**
|
||||
* get the count of frames
|
||||
*/
|
||||
public native int countStackFrames()
|
||||
throws InvalidInfoException;
|
||||
|
||||
/**
|
||||
* get the 'top' frame
|
||||
*/
|
||||
public native StackFrameInfo getCurrentFrame()
|
||||
throws InvalidInfoException;
|
||||
|
||||
/**
|
||||
* <B><font color="red">Not Implemented.</font></B>
|
||||
* Always throws <code>InternalError("unimplemented")</code>
|
||||
*/
|
||||
public Thread getThread()
|
||||
{
|
||||
throw new InternalError("unimplemented");
|
||||
}
|
||||
|
||||
/**
|
||||
* <B><font color="red">Not Implemented.</font></B>
|
||||
* Always throws <code>InternalError("unimplemented")</code>
|
||||
*/
|
||||
public void leaveSuspended()
|
||||
{
|
||||
throw new InternalError("unimplemented");
|
||||
}
|
||||
|
||||
/**
|
||||
* <B><font color="red">Not Implemented.</font></B>
|
||||
* Always throws <code>InternalError("unimplemented")</code>
|
||||
*/
|
||||
protected void resume0()
|
||||
{
|
||||
throw new InternalError("unimplemented");
|
||||
}
|
||||
|
||||
protected int nativeThreadState; /* used internally */
|
||||
}
|
||||
42
mozilla/js/jsd/classes/netscape/jsdebug/PC.java
Normal file
42
mozilla/js/jsd/classes/netscape/jsdebug/PC.java
Normal file
@@ -0,0 +1,42 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
package netscape.jsdebug;
|
||||
|
||||
/**
|
||||
* The PC class is an opaque representation of a program counter. It
|
||||
* may have different implementations for interpreted Java methods,
|
||||
* methods compiled by the JIT, JavaScript methods, etc.
|
||||
*
|
||||
* @author John Bandhauer
|
||||
* @author Nick Thompson
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
public abstract class PC {
|
||||
/**
|
||||
* Get the SourceLocation associated with this PC value.
|
||||
* returns null if the source location is unavailable.
|
||||
*/
|
||||
public abstract SourceLocation getSourceLocation();
|
||||
|
||||
/**
|
||||
* Ask whether two program counter values are equal.
|
||||
*/
|
||||
public abstract boolean equals(Object obj);
|
||||
}
|
||||
82
mozilla/js/jsd/classes/netscape/jsdebug/Script.java
Normal file
82
mozilla/js/jsd/classes/netscape/jsdebug/Script.java
Normal file
@@ -0,0 +1,82 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
package netscape.jsdebug;
|
||||
|
||||
/**
|
||||
* This instances of this class represent the JavaScript string object. This
|
||||
* class is intended to only be constructed by the underlying native code.
|
||||
* The DebugController will construct an instance of this class when scripts
|
||||
* are created and that instance will always be used to reference the underlying
|
||||
* script throughout the lifetime of that script.
|
||||
*
|
||||
* @author John Bandhauer
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
public final class Script
|
||||
{
|
||||
public String getURL() {return _url; }
|
||||
public String getFunction() {return _function; }
|
||||
public int getBaseLineNumber() {return _baseLineNumber;}
|
||||
public int getLineExtent() {return _lineExtent; }
|
||||
public boolean isValid() {return 0 != _nativePtr;}
|
||||
|
||||
/**
|
||||
* Get the PC of the first executable code on or after the given
|
||||
* line in this script. returns null if none
|
||||
*/
|
||||
public native JSPC getClosestPC(int line);
|
||||
|
||||
public String toString()
|
||||
{
|
||||
int end = _baseLineNumber+_lineExtent-1;
|
||||
if( null == _function )
|
||||
return "<Script "+_url+"["+_baseLineNumber+","+end+"]>";
|
||||
else
|
||||
return "<Script "+_url+"#"+_function+"()["+_baseLineNumber+","+end+"]>";
|
||||
}
|
||||
|
||||
public int hashCode()
|
||||
{
|
||||
return _nativePtr;
|
||||
}
|
||||
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if( obj == this )
|
||||
return true;
|
||||
|
||||
// In our system the native code is the only code that generates
|
||||
// these objects. They are never duplicated
|
||||
return false;
|
||||
/*
|
||||
if( !(obj instanceof Script) )
|
||||
return false;
|
||||
return 0 != _nativePtr && _nativePtr == ((Script)obj)._nativePtr;
|
||||
*/
|
||||
}
|
||||
|
||||
private synchronized void _setInvalid() {_nativePtr = 0;}
|
||||
|
||||
private String _url;
|
||||
private String _function;
|
||||
private int _baseLineNumber;
|
||||
private int _lineExtent;
|
||||
private int _nativePtr; // used internally
|
||||
}
|
||||
57
mozilla/js/jsd/classes/netscape/jsdebug/ScriptHook.java
Normal file
57
mozilla/js/jsd/classes/netscape/jsdebug/ScriptHook.java
Normal file
@@ -0,0 +1,57 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
package netscape.jsdebug;
|
||||
|
||||
/**
|
||||
* ScriptHook must be subclassed to respond to loading and
|
||||
* unloading of scripts
|
||||
*
|
||||
* @author John Bandhauer
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
public class ScriptHook extends Hook
|
||||
{
|
||||
/**
|
||||
* Create a ScriptHook for current the current VM.
|
||||
*/
|
||||
public ScriptHook() {}
|
||||
|
||||
/**
|
||||
* Override this method to respond when a new script is
|
||||
* loaded into the VM.
|
||||
*
|
||||
* @param script a script object created by the controller to
|
||||
* represent this script. This exact same object will be used
|
||||
* in all further references to the script.
|
||||
*/
|
||||
public void justLoadedScript(Script script) {
|
||||
// defaults to no action
|
||||
}
|
||||
|
||||
/**
|
||||
* Override this method to respond when a class is
|
||||
* about to be unloaded from the VM.
|
||||
*
|
||||
* @param script which will be unloaded
|
||||
*/
|
||||
public void aboutToUnloadScript(Script script) {
|
||||
// defaults to no action
|
||||
}
|
||||
}
|
||||
53
mozilla/js/jsd/classes/netscape/jsdebug/SourceLocation.java
Normal file
53
mozilla/js/jsd/classes/netscape/jsdebug/SourceLocation.java
Normal file
@@ -0,0 +1,53 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
package netscape.jsdebug;
|
||||
|
||||
/**
|
||||
* An implementation of the SourceLocation interface is used to represent
|
||||
* a location in a source file. Java classfiles only make source locations
|
||||
* available at the line-by-line granularity, but other languages may
|
||||
* include finer-grain information. At this time only line number
|
||||
* information is included.
|
||||
*
|
||||
* @author John Bandhauer
|
||||
* @author Nick Thompson
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
/* XXX must source locations be contiguous? */
|
||||
public abstract class SourceLocation {
|
||||
/**
|
||||
* Gets the first line number associated with this SourceLocation.
|
||||
* This is the lowest common denominator information that will be
|
||||
* available: some implementations may choose to include more
|
||||
* specific location information in a subclass of SourceLocation.
|
||||
*
|
||||
* @returns source line number cooresponding to this location
|
||||
*/
|
||||
public abstract int getLine();
|
||||
|
||||
/**
|
||||
* Get the first PC associated with a given SourceLocation.
|
||||
* This is the place to set a breakpoint at that location.
|
||||
*
|
||||
* @returns pc object or null if there is no code corresponding
|
||||
* to this source location.
|
||||
*/
|
||||
public abstract PC getPC();
|
||||
}
|
||||
107
mozilla/js/jsd/classes/netscape/jsdebug/SourceTextItem.java
Normal file
107
mozilla/js/jsd/classes/netscape/jsdebug/SourceTextItem.java
Normal file
@@ -0,0 +1,107 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
package netscape.jsdebug;
|
||||
|
||||
/**
|
||||
* This class is used to represent a file or url which contains
|
||||
* JavaScript source text. The actual JavaScript source may be intermixed
|
||||
* with other text (as in an html file) or raw. The debugger uses this
|
||||
* interface to access the source. The file of the actual source need
|
||||
* not physially exist anywhere; i.e. the underlying engine might synthesize
|
||||
* it as needed.
|
||||
* <p>
|
||||
* The <i>url</i> of this class is immutable -- it represents a key in
|
||||
* collections of these objects
|
||||
*
|
||||
* @author John Bandhauer
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
public class SourceTextItem
|
||||
{
|
||||
/* these coorespond to jsdebug.h values - change in both places if anywhere */
|
||||
|
||||
/**
|
||||
* This object is initialized, but contains no text
|
||||
*/
|
||||
public static final int INITED = 0;
|
||||
/**
|
||||
* This object contains the full text
|
||||
*/
|
||||
public static final int FULL = 1;
|
||||
/**
|
||||
* This object contains the partial text (valid , but more may come later)
|
||||
*/
|
||||
public static final int PARTIAL = 2;
|
||||
/**
|
||||
* This object may contain partial text, but loading was aborted (by user?)
|
||||
*/
|
||||
public static final int ABORTED = 3;
|
||||
/**
|
||||
* This object may contain partial text, but loading failed (or the
|
||||
* underlying debugger support was unable to capture it; e.g.
|
||||
* not enough memory...)
|
||||
*/
|
||||
public static final int FAILED = 4;
|
||||
/**
|
||||
* This object contains no text because the debugger has signaled that
|
||||
* the text is no longer needed
|
||||
*/
|
||||
public static final int CLEARED = 5;
|
||||
|
||||
/**
|
||||
* Constuct for url (which is immutable during the lifetime of the object)
|
||||
* <p>
|
||||
* Presumably, text will be added later
|
||||
* @param url url or filename by which this object will be known
|
||||
*/
|
||||
public SourceTextItem( String url )
|
||||
{
|
||||
this( url, (String)null, INITED );
|
||||
}
|
||||
|
||||
/**
|
||||
* Constuct for url with text and status
|
||||
* <p>
|
||||
* @param url url or filename by which this object will be known
|
||||
* @param text source text this object should start with
|
||||
* @param status status this object should start with
|
||||
*/
|
||||
public SourceTextItem( String url, String text, int status )
|
||||
{
|
||||
_url = url;
|
||||
_text = text;
|
||||
_status = status;
|
||||
_dirty = true;
|
||||
}
|
||||
|
||||
public String getURL() {return _url; }
|
||||
public String getText() {return _text; }
|
||||
public int getStatus() {return _status;}
|
||||
public boolean getDirty() {return _dirty; }
|
||||
|
||||
public void setText(String text) {_text = text;}
|
||||
public void setStatus(int status) {_status = status;}
|
||||
public void setDirty(boolean b) {_dirty = b; }
|
||||
|
||||
private String _url;
|
||||
private String _text;
|
||||
private int _status;
|
||||
private boolean _dirty;
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
package netscape.jsdebug;
|
||||
|
||||
import netscape.util.Vector;
|
||||
import netscape.security.ForbiddenTargetException;
|
||||
|
||||
/**
|
||||
* Abstract class to represent entity capable of providing access to source text
|
||||
*
|
||||
* @author John Bandhauer
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
public abstract class SourceTextProvider
|
||||
{
|
||||
public static SourceTextProvider getSourceTextProvider() throws Exception
|
||||
{
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Return the vector of SourceTextItems.
|
||||
* <p>
|
||||
* This is not liekly to be a copy. nor is it necessarily current
|
||||
*/
|
||||
public abstract Vector getSourceTextVector() throws ForbiddenTargetException;
|
||||
/**
|
||||
* Refresh the vector by whatever means to reflect any changes made in the
|
||||
* underlying native system
|
||||
*/
|
||||
public abstract void refreshSourceTextVector();
|
||||
/**
|
||||
* Get the SourceText item for the given URL
|
||||
*/
|
||||
public abstract SourceTextItem findSourceTextItem( String url ) throws ForbiddenTargetException;
|
||||
/**
|
||||
* Load the SourceText item for the given URL
|
||||
* <p>
|
||||
* <B>This is not guaranteed to be implemented</B>
|
||||
*/
|
||||
public abstract SourceTextItem loadSourceTextItem( String url ) throws ForbiddenTargetException;
|
||||
}
|
||||
94
mozilla/js/jsd/classes/netscape/jsdebug/StackFrameInfo.java
Normal file
94
mozilla/js/jsd/classes/netscape/jsdebug/StackFrameInfo.java
Normal file
@@ -0,0 +1,94 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
package netscape.jsdebug;
|
||||
|
||||
/**
|
||||
* This interface provides access to the execution stack of a thread.
|
||||
* It has several subclasses to distinguish between different kinds of
|
||||
* stack frames: these currently include activations of Java methods
|
||||
* or JavaScript functions.
|
||||
* It is possible that synchronize blocks and try blocks deserve their own
|
||||
* stack frames - to allow for later extensions a debugger should skip over
|
||||
* stack frames it doesn't understand.
|
||||
* Note that this appears very Java-specific. However, multiple threads and
|
||||
* exceptions are relevant to JavaScript as well because of its
|
||||
* interoperation with Java.
|
||||
*
|
||||
* @author John Bandhauer
|
||||
* @author Nick Thompson
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
public abstract class StackFrameInfo {
|
||||
ThreadStateBase threadState;
|
||||
StackFrameInfo caller;
|
||||
|
||||
protected StackFrameInfo(ThreadStateBase threadState) {
|
||||
this.threadState = threadState;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if this stack frame is still valid. Stack frames
|
||||
* may become invalid when the thread is resumed (this is more
|
||||
* conservative than invalidating the frame only when it actually
|
||||
* returns).
|
||||
*/
|
||||
public boolean isValid() {
|
||||
return threadState.isValid();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the stack frame where this one was built, or null for the
|
||||
* start of the stack.
|
||||
*/
|
||||
public synchronized StackFrameInfo getCaller()
|
||||
throws InvalidInfoException {
|
||||
if (caller == null)
|
||||
caller = getCaller0();
|
||||
if (!isValid())
|
||||
throw new InvalidInfoException("invalid StackFrameInfo");
|
||||
return caller;
|
||||
}
|
||||
|
||||
protected abstract StackFrameInfo getCaller0()
|
||||
throws InvalidInfoException;
|
||||
|
||||
/**
|
||||
* Get the thread that this stack frame is a part of.
|
||||
*/
|
||||
public Thread getThread() {
|
||||
return threadState.getThread();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the 'enclosing' thread state
|
||||
*/
|
||||
public ThreadStateBase getThreadState() {
|
||||
return threadState;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the current program counter value. Note that the
|
||||
* class JavaPC supports the getMethod() operation.
|
||||
*/
|
||||
public abstract PC getPC()
|
||||
throws InvalidInfoException;
|
||||
}
|
||||
|
||||
241
mozilla/js/jsd/classes/netscape/jsdebug/ThreadStateBase.java
Normal file
241
mozilla/js/jsd/classes/netscape/jsdebug/ThreadStateBase.java
Normal file
@@ -0,0 +1,241 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
package netscape.jsdebug;
|
||||
|
||||
/*
|
||||
* jband - 03/19/97
|
||||
*
|
||||
* This is an 'abstracted version of netscape.debug.ThreadState
|
||||
*
|
||||
* The methods that were 'native' there are 'abstract' here.
|
||||
* Changed 'private' data to 'protected' (though native access is immune)
|
||||
* Changed 'private' resume0() to 'protected'
|
||||
* Removed ThreadHook referneces
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* When a hook is hit, the debugger records the state of the
|
||||
* thread before the hook in a ThreadState object. This object
|
||||
* is then passed to any hook methods that are called, and can
|
||||
* be used to change the state of the thread when it resumes from the
|
||||
* hook.
|
||||
*
|
||||
* @author John Bandhauer
|
||||
* @author Nick Thompson
|
||||
* @version 1.0
|
||||
* @since 1.0
|
||||
*/
|
||||
public abstract class ThreadStateBase {
|
||||
protected Thread thread;
|
||||
protected boolean valid;
|
||||
protected boolean runningHook;
|
||||
protected boolean resumeWhenDone;
|
||||
protected int status;
|
||||
protected int continueState;
|
||||
protected StackFrameInfo[] stack; /* jband - 03/19/97 - had no access modifier */
|
||||
protected Object returnValue;
|
||||
protected Throwable currentException;
|
||||
protected int currentFramePtr; /* used internally */
|
||||
protected ThreadStateBase previous;
|
||||
|
||||
/**
|
||||
* <B><font color="red">Not Implemented.</font></B>
|
||||
* Always throws <code>InternalError("unimplemented")</code>
|
||||
*/
|
||||
public static ThreadStateBase getThreadState(Thread t)
|
||||
throws InvalidInfoException
|
||||
{
|
||||
throw new InternalError("unimplemented");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Thread that this ThreadState came from.
|
||||
*/
|
||||
public Thread getThread() {
|
||||
return thread;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the Thread hasn't been resumed since this ThreadState
|
||||
* was made.
|
||||
*/
|
||||
public boolean isValid() {
|
||||
return valid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the thread is currently running a hook
|
||||
* for this ThreadState
|
||||
*/
|
||||
public boolean isRunningHook() {
|
||||
return runningHook;
|
||||
}
|
||||
|
||||
/**
|
||||
* partial list of thread states from sun.debug.ThreadInfo.
|
||||
* XXX some of these don't apply.
|
||||
*/
|
||||
public final static int THR_STATUS_UNKNOWN = 0x01;
|
||||
public final static int THR_STATUS_ZOMBIE = 0x02;
|
||||
public final static int THR_STATUS_RUNNING = 0x03;
|
||||
public final static int THR_STATUS_SLEEPING = 0x04;
|
||||
public final static int THR_STATUS_MONWAIT = 0x05;
|
||||
public final static int THR_STATUS_CONDWAIT = 0x06;
|
||||
public final static int THR_STATUS_SUSPENDED = 0x07;
|
||||
public final static int THR_STATUS_BREAK = 0x08;
|
||||
|
||||
/**
|
||||
* Get the state of the thread at the time it entered debug mode.
|
||||
* This can't be modified directly.
|
||||
*/
|
||||
public int getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the count of the stackframes
|
||||
*/
|
||||
public abstract int countStackFrames()
|
||||
throws InvalidInfoException;
|
||||
/**
|
||||
* Get the 'top' stackframe; i.e. the one with the current instruction
|
||||
*/
|
||||
public abstract StackFrameInfo getCurrentFrame()
|
||||
throws InvalidInfoException;
|
||||
|
||||
/**
|
||||
* Get the thread's stack as an array. stack[stack.length-1] is the
|
||||
* current frame, and stack[0] is the beginning of the stack.
|
||||
*/
|
||||
public synchronized StackFrameInfo[] getStack()
|
||||
throws InvalidInfoException {
|
||||
// XXX check valid?
|
||||
if (stack == null) {
|
||||
stack = new StackFrameInfo[countStackFrames()];
|
||||
}
|
||||
|
||||
if (stack.length == 0)
|
||||
return stack;
|
||||
|
||||
StackFrameInfo frame = getCurrentFrame();
|
||||
stack[stack.length - 1] = frame;
|
||||
for (int i = stack.length - 2; i >= 0; i--) {
|
||||
frame = frame.getCaller();
|
||||
stack[i] = frame;
|
||||
}
|
||||
|
||||
// should really be read-only for safety
|
||||
return stack;
|
||||
}
|
||||
|
||||
/**
|
||||
* Leave the thread in a suspended state when the hook method(s)
|
||||
* finish. This can be undone by calling resume(). This is the
|
||||
* default only if the break was the result of
|
||||
* DebugController.sendInterrupt().
|
||||
*/
|
||||
public void leaveSuspended() {
|
||||
resumeWhenDone = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resume the thread. This is the default unless the break was the result
|
||||
* of DebugController.sendInterrupt(). This method may be called from a
|
||||
* hook method, in which case the thread will resume when the
|
||||
* method returns.
|
||||
* Alternatively, if there is no active hook method and
|
||||
* the thread is suspended around in the DebugFrame, this resumes it
|
||||
* immediately.
|
||||
*/
|
||||
public synchronized void resume() {
|
||||
if (runningHook)
|
||||
resumeWhenDone = true;
|
||||
else
|
||||
resume0();
|
||||
}
|
||||
|
||||
protected abstract void resume0();
|
||||
|
||||
/**
|
||||
* if the continueState is DEAD, the thread cannot
|
||||
* be restarted.
|
||||
*/
|
||||
public final static int DEBUG_STATE_DEAD = 0x01;
|
||||
|
||||
/**
|
||||
* if the continueState is RUN, the thread will
|
||||
* proceed to the next program counter value when it resumes.
|
||||
*/
|
||||
public final static int DEBUG_STATE_RUN = 0x02;
|
||||
|
||||
/**
|
||||
* if the continueState is RETURN, the thread will
|
||||
* return from the current method with the value in getReturnValue()
|
||||
* when it resumes.
|
||||
*/
|
||||
public final static int DEBUG_STATE_RETURN = 0x03;
|
||||
|
||||
/**
|
||||
* if the continueState is THROW, the thread will
|
||||
* throw an exception (accessible with getException()) when it
|
||||
* resumes.
|
||||
*/
|
||||
public final static int DEBUG_STATE_THROW = 0x04;
|
||||
|
||||
/**
|
||||
* This gets the current continue state of the debug frame, which
|
||||
* will be one of the DEBUG_STATE_* values above.
|
||||
*/
|
||||
public int getContinueState() {
|
||||
return continueState;
|
||||
}
|
||||
|
||||
public int setContinueState(int state) {
|
||||
int old = continueState;
|
||||
continueState = state;
|
||||
return old;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the thread was stopped while in the process of returning
|
||||
* a value, this call returns an object representing that value.
|
||||
* non-Object values are wrapped as in the java.lang.reflect api.
|
||||
* This is only relevant if the continue state is RETURN, and the
|
||||
* method throws an IllegalStateException otherwise.
|
||||
*/
|
||||
public Object getReturnValue() throws IllegalStateException {
|
||||
if (continueState != DEBUG_STATE_RETURN)
|
||||
throw new IllegalStateException("no value being returned");
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the thread was stopped while in the process of throwing an
|
||||
* exception, this call returns that exception.
|
||||
* This is only relevant if the continue state is THROW, and it
|
||||
* throws an IllegalStateException otherwise.
|
||||
*/
|
||||
public Throwable getException() throws IllegalStateException {
|
||||
if (continueState != DEBUG_STATE_THROW)
|
||||
throw new IllegalStateException("no exception throw in progress");
|
||||
return currentException;
|
||||
}
|
||||
}
|
||||
|
||||
190
mozilla/js/jsd/corba/idl/ifaces.idl
Normal file
190
mozilla/js/jsd/corba/idl/ifaces.idl
Normal file
@@ -0,0 +1,190 @@
|
||||
struct Thing {
|
||||
string s;
|
||||
long i;
|
||||
};
|
||||
interface StringReciever {
|
||||
void recieveString(
|
||||
in string arg0
|
||||
);
|
||||
void bounce(
|
||||
in long arg0
|
||||
);
|
||||
};
|
||||
interface TestInterface {
|
||||
string getFirstAppInList();
|
||||
void getAppNames(
|
||||
in ::StringReciever arg0
|
||||
);
|
||||
typedef sequence<::Thing> sequence_of_Thing;
|
||||
::TestInterface::sequence_of_Thing getThings();
|
||||
void callBounce(
|
||||
in ::StringReciever arg0,
|
||||
in long arg1
|
||||
);
|
||||
};
|
||||
interface ISourceTextProvider {
|
||||
typedef sequence<string> sequence_of_string;
|
||||
::ISourceTextProvider::sequence_of_string getAllPages();
|
||||
void refreshAllPages();
|
||||
boolean hasPage(
|
||||
in string arg0
|
||||
);
|
||||
boolean loadPage(
|
||||
in string arg0
|
||||
);
|
||||
void refreshPage(
|
||||
in string arg0
|
||||
);
|
||||
string getPageText(
|
||||
in string arg0
|
||||
);
|
||||
long getPageStatus(
|
||||
in string arg0
|
||||
);
|
||||
long getPageAlterCount(
|
||||
in string arg0
|
||||
);
|
||||
};
|
||||
struct IScriptSection {
|
||||
long base;
|
||||
long extent;
|
||||
};
|
||||
typedef sequence<::IScriptSection> sequence_of_IScriptSection;
|
||||
struct IScript {
|
||||
string url;
|
||||
string funname;
|
||||
long base;
|
||||
long extent;
|
||||
long jsdscript;
|
||||
::sequence_of_IScriptSection sections;
|
||||
};
|
||||
struct IJSPC {
|
||||
::IScript script;
|
||||
long offset;
|
||||
};
|
||||
struct IJSSourceLocation {
|
||||
long line;
|
||||
::IJSPC pc;
|
||||
};
|
||||
interface IJSErrorReporter {
|
||||
long reportError(
|
||||
in string arg0,
|
||||
in string arg1,
|
||||
in long arg2,
|
||||
in string arg3,
|
||||
in long arg4
|
||||
);
|
||||
};
|
||||
interface IScriptHook {
|
||||
void justLoadedScript(
|
||||
in ::IScript arg0
|
||||
);
|
||||
void aboutToUnloadScript(
|
||||
in ::IScript arg0
|
||||
);
|
||||
};
|
||||
struct IJSStackFrameInfo {
|
||||
::IJSPC pc;
|
||||
long jsdframe;
|
||||
};
|
||||
typedef sequence<::IJSStackFrameInfo> sequence_of_IJSStackFrameInfo;
|
||||
struct IJSThreadState {
|
||||
::sequence_of_IJSStackFrameInfo stack;
|
||||
long continueState;
|
||||
string returnValue;
|
||||
long status;
|
||||
long jsdthreadstate;
|
||||
long id;
|
||||
};
|
||||
interface IJSExecutionHook {
|
||||
void aboutToExecute(
|
||||
in ::IJSThreadState arg0,
|
||||
in ::IJSPC arg1
|
||||
);
|
||||
};
|
||||
struct IExecResult {
|
||||
string result;
|
||||
boolean errorOccured;
|
||||
string errorMessage;
|
||||
string errorFilename;
|
||||
long errorLineNumber;
|
||||
string errorLineBuffer;
|
||||
long errorTokenOffset;
|
||||
};
|
||||
interface IDebugController {
|
||||
long getMajorVersion();
|
||||
long getMinorVersion();
|
||||
::IJSErrorReporter setErrorReporter(
|
||||
in ::IJSErrorReporter arg0
|
||||
);
|
||||
::IJSErrorReporter getErrorReporter();
|
||||
::IScriptHook setScriptHook(
|
||||
in ::IScriptHook arg0
|
||||
);
|
||||
::IScriptHook getScriptHook();
|
||||
::IJSPC getClosestPC(
|
||||
in ::IScript arg0,
|
||||
in long arg1
|
||||
);
|
||||
::IJSSourceLocation getSourceLocation(
|
||||
in ::IJSPC arg0
|
||||
);
|
||||
::IJSExecutionHook setInterruptHook(
|
||||
in ::IJSExecutionHook arg0
|
||||
);
|
||||
::IJSExecutionHook getInterruptHook();
|
||||
::IJSExecutionHook setDebugBreakHook(
|
||||
in ::IJSExecutionHook arg0
|
||||
);
|
||||
::IJSExecutionHook getDebugBreakHook();
|
||||
::IJSExecutionHook setInstructionHook(
|
||||
in ::IJSExecutionHook arg0,
|
||||
in ::IJSPC arg1
|
||||
);
|
||||
::IJSExecutionHook getInstructionHook(
|
||||
in ::IJSPC arg0
|
||||
);
|
||||
void setThreadContinueState(
|
||||
in long arg0,
|
||||
in long arg1
|
||||
);
|
||||
void setThreadReturnValue(
|
||||
in long arg0,
|
||||
in string arg1
|
||||
);
|
||||
void sendInterrupt();
|
||||
void sendInterruptStepInto(
|
||||
in long arg0
|
||||
);
|
||||
void sendInterruptStepOver(
|
||||
in long arg0
|
||||
);
|
||||
void sendInterruptStepOut(
|
||||
in long arg0
|
||||
);
|
||||
void reinstateStepper(
|
||||
in long arg0
|
||||
);
|
||||
::IExecResult executeScriptInStackFrame(
|
||||
in long arg0,
|
||||
in ::IJSStackFrameInfo arg1,
|
||||
in string arg2,
|
||||
in string arg3,
|
||||
in long arg4
|
||||
);
|
||||
boolean isRunningHook(
|
||||
in long arg0
|
||||
);
|
||||
boolean isWaitingForResume(
|
||||
in long arg0
|
||||
);
|
||||
void leaveThreadSuspended(
|
||||
in long arg0
|
||||
);
|
||||
void resumeThread(
|
||||
in long arg0
|
||||
);
|
||||
void iterateScripts(
|
||||
in ::IScriptHook arg0
|
||||
);
|
||||
};
|
||||
2554
mozilla/js/jsd/corba/ifaces_c.cpp
Normal file
2554
mozilla/js/jsd/corba/ifaces_c.cpp
Normal file
File diff suppressed because it is too large
Load Diff
1920
mozilla/js/jsd/corba/ifaces_c.hh
Normal file
1920
mozilla/js/jsd/corba/ifaces_c.hh
Normal file
File diff suppressed because it is too large
Load Diff
1041
mozilla/js/jsd/corba/ifaces_s.cpp
Normal file
1041
mozilla/js/jsd/corba/ifaces_s.cpp
Normal file
File diff suppressed because it is too large
Load Diff
777
mozilla/js/jsd/corba/ifaces_s.hh
Normal file
777
mozilla/js/jsd/corba/ifaces_s.hh
Normal file
@@ -0,0 +1,777 @@
|
||||
#ifndef _ifaces_s_hh
|
||||
#define _ifaces_s_hh
|
||||
|
||||
#include "ifaces_c.hh"
|
||||
|
||||
/************************************************************************/
|
||||
/* */
|
||||
/* This file is automatically generated by ORBeline IDL compiler */
|
||||
/* Do not modify this file. */
|
||||
/* */
|
||||
/* ORBeline (c) is copyrighted by PostModern Computing, Inc. */
|
||||
/* */
|
||||
/* The generated code conforms to OMG's IDL C++ mapping as */
|
||||
/* specified in OMG Document Number: 94-9-14. */
|
||||
/* */
|
||||
/************************************************************************/
|
||||
|
||||
class _sk_StringReciever : public StringReciever
|
||||
{
|
||||
protected:
|
||||
_sk_StringReciever(const char *object_name = (const char *)NULL);
|
||||
_sk_StringReciever(const char *service_name, const CORBA::ReferenceData& data);
|
||||
virtual ~_sk_StringReciever() {}
|
||||
public:
|
||||
static const CORBA::TypeInfo _skel_info;
|
||||
|
||||
// The following operations need to be implemented by the server.
|
||||
virtual void recieveString(const char * arg0) = 0;
|
||||
virtual void bounce(CORBA::Long arg0) = 0;
|
||||
|
||||
// Skeleton Operations implemented automatically
|
||||
|
||||
static void _recieveString(void *obj,
|
||||
CORBA::MarshalStream &strm,
|
||||
CORBA::Principal_ptr principal,
|
||||
const char *oper,
|
||||
void *priv_data);
|
||||
|
||||
static void _bounce(void *obj,
|
||||
CORBA::MarshalStream &strm,
|
||||
CORBA::Principal_ptr principal,
|
||||
const char *oper,
|
||||
void *priv_data);
|
||||
|
||||
};
|
||||
template <class T>
|
||||
class _tie_StringReciever : public StringReciever
|
||||
{
|
||||
public:
|
||||
_tie_StringReciever(T& t, const char *obj_name=(char*)NULL) :
|
||||
StringReciever(obj_name),
|
||||
_ref(t) {
|
||||
_object_name(obj_name);
|
||||
}
|
||||
_tie_StringReciever(T& t, const char *service_name,
|
||||
const CORBA::ReferenceData& id)
|
||||
:_ref(t) {
|
||||
_service(service_name, id);
|
||||
}
|
||||
~_tie_StringReciever() {}
|
||||
void recieveString(const char * arg0) {
|
||||
_ref.recieveString(
|
||||
arg0);
|
||||
}
|
||||
void bounce(CORBA::Long arg0) {
|
||||
_ref.bounce(
|
||||
arg0);
|
||||
}
|
||||
|
||||
private:
|
||||
T& _ref;
|
||||
};
|
||||
class _sk_TestInterface : public TestInterface
|
||||
{
|
||||
protected:
|
||||
_sk_TestInterface(const char *object_name = (const char *)NULL);
|
||||
_sk_TestInterface(const char *service_name, const CORBA::ReferenceData& data);
|
||||
virtual ~_sk_TestInterface() {}
|
||||
public:
|
||||
static const CORBA::TypeInfo _skel_info;
|
||||
|
||||
// The following operations need to be implemented by the server.
|
||||
virtual char * getFirstAppInList() = 0;
|
||||
virtual void getAppNames(StringReciever_ptr arg0) = 0;
|
||||
virtual TestInterface::sequence_of_Thing * getThings() = 0;
|
||||
virtual void callBounce(StringReciever_ptr arg0,
|
||||
CORBA::Long arg1) = 0;
|
||||
|
||||
// Skeleton Operations implemented automatically
|
||||
|
||||
static void _getFirstAppInList(void *obj,
|
||||
CORBA::MarshalStream &strm,
|
||||
CORBA::Principal_ptr principal,
|
||||
const char *oper,
|
||||
void *priv_data);
|
||||
|
||||
static void _getAppNames(void *obj,
|
||||
CORBA::MarshalStream &strm,
|
||||
CORBA::Principal_ptr principal,
|
||||
const char *oper,
|
||||
void *priv_data);
|
||||
|
||||
static void _getThings(void *obj,
|
||||
CORBA::MarshalStream &strm,
|
||||
CORBA::Principal_ptr principal,
|
||||
const char *oper,
|
||||
void *priv_data);
|
||||
|
||||
static void _callBounce(void *obj,
|
||||
CORBA::MarshalStream &strm,
|
||||
CORBA::Principal_ptr principal,
|
||||
const char *oper,
|
||||
void *priv_data);
|
||||
|
||||
};
|
||||
template <class T>
|
||||
class _tie_TestInterface : public TestInterface
|
||||
{
|
||||
public:
|
||||
_tie_TestInterface(T& t, const char *obj_name=(char*)NULL) :
|
||||
TestInterface(obj_name),
|
||||
_ref(t) {
|
||||
_object_name(obj_name);
|
||||
}
|
||||
_tie_TestInterface(T& t, const char *service_name,
|
||||
const CORBA::ReferenceData& id)
|
||||
:_ref(t) {
|
||||
_service(service_name, id);
|
||||
}
|
||||
~_tie_TestInterface() {}
|
||||
char * getFirstAppInList() {
|
||||
return _ref.getFirstAppInList();
|
||||
}
|
||||
void getAppNames(StringReciever_ptr arg0) {
|
||||
_ref.getAppNames(
|
||||
arg0);
|
||||
}
|
||||
TestInterface::sequence_of_Thing * getThings() {
|
||||
return _ref.getThings();
|
||||
}
|
||||
void callBounce(StringReciever_ptr arg0,
|
||||
CORBA::Long arg1) {
|
||||
_ref.callBounce(
|
||||
arg0,
|
||||
arg1);
|
||||
}
|
||||
|
||||
private:
|
||||
T& _ref;
|
||||
};
|
||||
class _sk_ISourceTextProvider : public ISourceTextProvider
|
||||
{
|
||||
protected:
|
||||
_sk_ISourceTextProvider(const char *object_name = (const char *)NULL);
|
||||
_sk_ISourceTextProvider(const char *service_name, const CORBA::ReferenceData& data);
|
||||
virtual ~_sk_ISourceTextProvider() {}
|
||||
public:
|
||||
static const CORBA::TypeInfo _skel_info;
|
||||
|
||||
// The following operations need to be implemented by the server.
|
||||
virtual ISourceTextProvider::sequence_of_string * getAllPages() = 0;
|
||||
virtual void refreshAllPages() = 0;
|
||||
virtual CORBA::Boolean hasPage(const char * arg0) = 0;
|
||||
virtual CORBA::Boolean loadPage(const char * arg0) = 0;
|
||||
virtual void refreshPage(const char * arg0) = 0;
|
||||
virtual char * getPageText(const char * arg0) = 0;
|
||||
virtual CORBA::Long getPageStatus(const char * arg0) = 0;
|
||||
virtual CORBA::Long getPageAlterCount(const char * arg0) = 0;
|
||||
|
||||
// Skeleton Operations implemented automatically
|
||||
|
||||
static void _getAllPages(void *obj,
|
||||
CORBA::MarshalStream &strm,
|
||||
CORBA::Principal_ptr principal,
|
||||
const char *oper,
|
||||
void *priv_data);
|
||||
|
||||
static void _refreshAllPages(void *obj,
|
||||
CORBA::MarshalStream &strm,
|
||||
CORBA::Principal_ptr principal,
|
||||
const char *oper,
|
||||
void *priv_data);
|
||||
|
||||
static void _hasPage(void *obj,
|
||||
CORBA::MarshalStream &strm,
|
||||
CORBA::Principal_ptr principal,
|
||||
const char *oper,
|
||||
void *priv_data);
|
||||
|
||||
static void _loadPage(void *obj,
|
||||
CORBA::MarshalStream &strm,
|
||||
CORBA::Principal_ptr principal,
|
||||
const char *oper,
|
||||
void *priv_data);
|
||||
|
||||
static void _refreshPage(void *obj,
|
||||
CORBA::MarshalStream &strm,
|
||||
CORBA::Principal_ptr principal,
|
||||
const char *oper,
|
||||
void *priv_data);
|
||||
|
||||
static void _getPageText(void *obj,
|
||||
CORBA::MarshalStream &strm,
|
||||
CORBA::Principal_ptr principal,
|
||||
const char *oper,
|
||||
void *priv_data);
|
||||
|
||||
static void _getPageStatus(void *obj,
|
||||
CORBA::MarshalStream &strm,
|
||||
CORBA::Principal_ptr principal,
|
||||
const char *oper,
|
||||
void *priv_data);
|
||||
|
||||
static void _getPageAlterCount(void *obj,
|
||||
CORBA::MarshalStream &strm,
|
||||
CORBA::Principal_ptr principal,
|
||||
const char *oper,
|
||||
void *priv_data);
|
||||
|
||||
};
|
||||
template <class T>
|
||||
class _tie_ISourceTextProvider : public ISourceTextProvider
|
||||
{
|
||||
public:
|
||||
_tie_ISourceTextProvider(T& t, const char *obj_name=(char*)NULL) :
|
||||
ISourceTextProvider(obj_name),
|
||||
_ref(t) {
|
||||
_object_name(obj_name);
|
||||
}
|
||||
_tie_ISourceTextProvider(T& t, const char *service_name,
|
||||
const CORBA::ReferenceData& id)
|
||||
:_ref(t) {
|
||||
_service(service_name, id);
|
||||
}
|
||||
~_tie_ISourceTextProvider() {}
|
||||
ISourceTextProvider::sequence_of_string * getAllPages() {
|
||||
return _ref.getAllPages();
|
||||
}
|
||||
void refreshAllPages() {
|
||||
_ref.refreshAllPages();
|
||||
}
|
||||
CORBA::Boolean hasPage(const char * arg0) {
|
||||
return _ref.hasPage(
|
||||
arg0);
|
||||
}
|
||||
CORBA::Boolean loadPage(const char * arg0) {
|
||||
return _ref.loadPage(
|
||||
arg0);
|
||||
}
|
||||
void refreshPage(const char * arg0) {
|
||||
_ref.refreshPage(
|
||||
arg0);
|
||||
}
|
||||
char * getPageText(const char * arg0) {
|
||||
return _ref.getPageText(
|
||||
arg0);
|
||||
}
|
||||
CORBA::Long getPageStatus(const char * arg0) {
|
||||
return _ref.getPageStatus(
|
||||
arg0);
|
||||
}
|
||||
CORBA::Long getPageAlterCount(const char * arg0) {
|
||||
return _ref.getPageAlterCount(
|
||||
arg0);
|
||||
}
|
||||
|
||||
private:
|
||||
T& _ref;
|
||||
};
|
||||
class _sk_IJSErrorReporter : public IJSErrorReporter
|
||||
{
|
||||
protected:
|
||||
_sk_IJSErrorReporter(const char *object_name = (const char *)NULL);
|
||||
_sk_IJSErrorReporter(const char *service_name, const CORBA::ReferenceData& data);
|
||||
virtual ~_sk_IJSErrorReporter() {}
|
||||
public:
|
||||
static const CORBA::TypeInfo _skel_info;
|
||||
|
||||
// The following operations need to be implemented by the server.
|
||||
virtual CORBA::Long reportError(const char * arg0,
|
||||
const char * arg1,
|
||||
CORBA::Long arg2,
|
||||
const char * arg3,
|
||||
CORBA::Long arg4) = 0;
|
||||
|
||||
// Skeleton Operations implemented automatically
|
||||
|
||||
static void _reportError(void *obj,
|
||||
CORBA::MarshalStream &strm,
|
||||
CORBA::Principal_ptr principal,
|
||||
const char *oper,
|
||||
void *priv_data);
|
||||
|
||||
};
|
||||
template <class T>
|
||||
class _tie_IJSErrorReporter : public IJSErrorReporter
|
||||
{
|
||||
public:
|
||||
_tie_IJSErrorReporter(T& t, const char *obj_name=(char*)NULL) :
|
||||
IJSErrorReporter(obj_name),
|
||||
_ref(t) {
|
||||
_object_name(obj_name);
|
||||
}
|
||||
_tie_IJSErrorReporter(T& t, const char *service_name,
|
||||
const CORBA::ReferenceData& id)
|
||||
:_ref(t) {
|
||||
_service(service_name, id);
|
||||
}
|
||||
~_tie_IJSErrorReporter() {}
|
||||
CORBA::Long reportError(const char * arg0,
|
||||
const char * arg1,
|
||||
CORBA::Long arg2,
|
||||
const char * arg3,
|
||||
CORBA::Long arg4) {
|
||||
return _ref.reportError(
|
||||
arg0,
|
||||
arg1,
|
||||
arg2,
|
||||
arg3,
|
||||
arg4);
|
||||
}
|
||||
|
||||
private:
|
||||
T& _ref;
|
||||
};
|
||||
class _sk_IScriptHook : public IScriptHook
|
||||
{
|
||||
protected:
|
||||
_sk_IScriptHook(const char *object_name = (const char *)NULL);
|
||||
_sk_IScriptHook(const char *service_name, const CORBA::ReferenceData& data);
|
||||
virtual ~_sk_IScriptHook() {}
|
||||
public:
|
||||
static const CORBA::TypeInfo _skel_info;
|
||||
|
||||
// The following operations need to be implemented by the server.
|
||||
virtual void justLoadedScript(const IScript& arg0) = 0;
|
||||
virtual void aboutToUnloadScript(const IScript& arg0) = 0;
|
||||
|
||||
// Skeleton Operations implemented automatically
|
||||
|
||||
static void _justLoadedScript(void *obj,
|
||||
CORBA::MarshalStream &strm,
|
||||
CORBA::Principal_ptr principal,
|
||||
const char *oper,
|
||||
void *priv_data);
|
||||
|
||||
static void _aboutToUnloadScript(void *obj,
|
||||
CORBA::MarshalStream &strm,
|
||||
CORBA::Principal_ptr principal,
|
||||
const char *oper,
|
||||
void *priv_data);
|
||||
|
||||
};
|
||||
template <class T>
|
||||
class _tie_IScriptHook : public IScriptHook
|
||||
{
|
||||
public:
|
||||
_tie_IScriptHook(T& t, const char *obj_name=(char*)NULL) :
|
||||
IScriptHook(obj_name),
|
||||
_ref(t) {
|
||||
_object_name(obj_name);
|
||||
}
|
||||
_tie_IScriptHook(T& t, const char *service_name,
|
||||
const CORBA::ReferenceData& id)
|
||||
:_ref(t) {
|
||||
_service(service_name, id);
|
||||
}
|
||||
~_tie_IScriptHook() {}
|
||||
void justLoadedScript(const IScript& arg0) {
|
||||
_ref.justLoadedScript(
|
||||
arg0);
|
||||
}
|
||||
void aboutToUnloadScript(const IScript& arg0) {
|
||||
_ref.aboutToUnloadScript(
|
||||
arg0);
|
||||
}
|
||||
|
||||
private:
|
||||
T& _ref;
|
||||
};
|
||||
class _sk_IJSExecutionHook : public IJSExecutionHook
|
||||
{
|
||||
protected:
|
||||
_sk_IJSExecutionHook(const char *object_name = (const char *)NULL);
|
||||
_sk_IJSExecutionHook(const char *service_name, const CORBA::ReferenceData& data);
|
||||
virtual ~_sk_IJSExecutionHook() {}
|
||||
public:
|
||||
static const CORBA::TypeInfo _skel_info;
|
||||
|
||||
// The following operations need to be implemented by the server.
|
||||
virtual void aboutToExecute(const IJSThreadState& arg0,
|
||||
const IJSPC& arg1) = 0;
|
||||
|
||||
// Skeleton Operations implemented automatically
|
||||
|
||||
static void _aboutToExecute(void *obj,
|
||||
CORBA::MarshalStream &strm,
|
||||
CORBA::Principal_ptr principal,
|
||||
const char *oper,
|
||||
void *priv_data);
|
||||
|
||||
};
|
||||
template <class T>
|
||||
class _tie_IJSExecutionHook : public IJSExecutionHook
|
||||
{
|
||||
public:
|
||||
_tie_IJSExecutionHook(T& t, const char *obj_name=(char*)NULL) :
|
||||
IJSExecutionHook(obj_name),
|
||||
_ref(t) {
|
||||
_object_name(obj_name);
|
||||
}
|
||||
_tie_IJSExecutionHook(T& t, const char *service_name,
|
||||
const CORBA::ReferenceData& id)
|
||||
:_ref(t) {
|
||||
_service(service_name, id);
|
||||
}
|
||||
~_tie_IJSExecutionHook() {}
|
||||
void aboutToExecute(const IJSThreadState& arg0,
|
||||
const IJSPC& arg1) {
|
||||
_ref.aboutToExecute(
|
||||
arg0,
|
||||
arg1);
|
||||
}
|
||||
|
||||
private:
|
||||
T& _ref;
|
||||
};
|
||||
class _sk_IDebugController : public IDebugController
|
||||
{
|
||||
protected:
|
||||
_sk_IDebugController(const char *object_name = (const char *)NULL);
|
||||
_sk_IDebugController(const char *service_name, const CORBA::ReferenceData& data);
|
||||
virtual ~_sk_IDebugController() {}
|
||||
public:
|
||||
static const CORBA::TypeInfo _skel_info;
|
||||
|
||||
// The following operations need to be implemented by the server.
|
||||
virtual CORBA::Long getMajorVersion() = 0;
|
||||
virtual CORBA::Long getMinorVersion() = 0;
|
||||
virtual IJSErrorReporter_ptr setErrorReporter(IJSErrorReporter_ptr arg0) = 0;
|
||||
virtual IJSErrorReporter_ptr getErrorReporter() = 0;
|
||||
virtual IScriptHook_ptr setScriptHook(IScriptHook_ptr arg0) = 0;
|
||||
virtual IScriptHook_ptr getScriptHook() = 0;
|
||||
virtual IJSPC * getClosestPC(const IScript& arg0,
|
||||
CORBA::Long arg1) = 0;
|
||||
virtual IJSSourceLocation * getSourceLocation(const IJSPC& arg0) = 0;
|
||||
virtual IJSExecutionHook_ptr setInterruptHook(IJSExecutionHook_ptr arg0) = 0;
|
||||
virtual IJSExecutionHook_ptr getInterruptHook() = 0;
|
||||
virtual IJSExecutionHook_ptr setDebugBreakHook(IJSExecutionHook_ptr arg0) = 0;
|
||||
virtual IJSExecutionHook_ptr getDebugBreakHook() = 0;
|
||||
virtual IJSExecutionHook_ptr setInstructionHook(IJSExecutionHook_ptr arg0,
|
||||
const IJSPC& arg1) = 0;
|
||||
virtual IJSExecutionHook_ptr getInstructionHook(const IJSPC& arg0) = 0;
|
||||
virtual void setThreadContinueState(CORBA::Long arg0,
|
||||
CORBA::Long arg1) = 0;
|
||||
virtual void setThreadReturnValue(CORBA::Long arg0,
|
||||
const char * arg1) = 0;
|
||||
virtual void sendInterrupt() = 0;
|
||||
virtual void sendInterruptStepInto(CORBA::Long arg0) = 0;
|
||||
virtual void sendInterruptStepOver(CORBA::Long arg0) = 0;
|
||||
virtual void sendInterruptStepOut(CORBA::Long arg0) = 0;
|
||||
virtual void reinstateStepper(CORBA::Long arg0) = 0;
|
||||
virtual IExecResult * executeScriptInStackFrame(CORBA::Long arg0,
|
||||
const IJSStackFrameInfo& arg1,
|
||||
const char * arg2,
|
||||
const char * arg3,
|
||||
CORBA::Long arg4) = 0;
|
||||
virtual CORBA::Boolean isRunningHook(CORBA::Long arg0) = 0;
|
||||
virtual CORBA::Boolean isWaitingForResume(CORBA::Long arg0) = 0;
|
||||
virtual void leaveThreadSuspended(CORBA::Long arg0) = 0;
|
||||
virtual void resumeThread(CORBA::Long arg0) = 0;
|
||||
virtual void iterateScripts(IScriptHook_ptr arg0) = 0;
|
||||
|
||||
// Skeleton Operations implemented automatically
|
||||
|
||||
static void _getMajorVersion(void *obj,
|
||||
CORBA::MarshalStream &strm,
|
||||
CORBA::Principal_ptr principal,
|
||||
const char *oper,
|
||||
void *priv_data);
|
||||
|
||||
static void _getMinorVersion(void *obj,
|
||||
CORBA::MarshalStream &strm,
|
||||
CORBA::Principal_ptr principal,
|
||||
const char *oper,
|
||||
void *priv_data);
|
||||
|
||||
static void _setErrorReporter(void *obj,
|
||||
CORBA::MarshalStream &strm,
|
||||
CORBA::Principal_ptr principal,
|
||||
const char *oper,
|
||||
void *priv_data);
|
||||
|
||||
static void _getErrorReporter(void *obj,
|
||||
CORBA::MarshalStream &strm,
|
||||
CORBA::Principal_ptr principal,
|
||||
const char *oper,
|
||||
void *priv_data);
|
||||
|
||||
static void _setScriptHook(void *obj,
|
||||
CORBA::MarshalStream &strm,
|
||||
CORBA::Principal_ptr principal,
|
||||
const char *oper,
|
||||
void *priv_data);
|
||||
|
||||
static void _getScriptHook(void *obj,
|
||||
CORBA::MarshalStream &strm,
|
||||
CORBA::Principal_ptr principal,
|
||||
const char *oper,
|
||||
void *priv_data);
|
||||
|
||||
static void _getClosestPC(void *obj,
|
||||
CORBA::MarshalStream &strm,
|
||||
CORBA::Principal_ptr principal,
|
||||
const char *oper,
|
||||
void *priv_data);
|
||||
|
||||
static void _getSourceLocation(void *obj,
|
||||
CORBA::MarshalStream &strm,
|
||||
CORBA::Principal_ptr principal,
|
||||
const char *oper,
|
||||
void *priv_data);
|
||||
|
||||
static void _setInterruptHook(void *obj,
|
||||
CORBA::MarshalStream &strm,
|
||||
CORBA::Principal_ptr principal,
|
||||
const char *oper,
|
||||
void *priv_data);
|
||||
|
||||
static void _getInterruptHook(void *obj,
|
||||
CORBA::MarshalStream &strm,
|
||||
CORBA::Principal_ptr principal,
|
||||
const char *oper,
|
||||
void *priv_data);
|
||||
|
||||
static void _setDebugBreakHook(void *obj,
|
||||
CORBA::MarshalStream &strm,
|
||||
CORBA::Principal_ptr principal,
|
||||
const char *oper,
|
||||
void *priv_data);
|
||||
|
||||
static void _getDebugBreakHook(void *obj,
|
||||
CORBA::MarshalStream &strm,
|
||||
CORBA::Principal_ptr principal,
|
||||
const char *oper,
|
||||
void *priv_data);
|
||||
|
||||
static void _setInstructionHook(void *obj,
|
||||
CORBA::MarshalStream &strm,
|
||||
CORBA::Principal_ptr principal,
|
||||
const char *oper,
|
||||
void *priv_data);
|
||||
|
||||
static void _getInstructionHook(void *obj,
|
||||
CORBA::MarshalStream &strm,
|
||||
CORBA::Principal_ptr principal,
|
||||
const char *oper,
|
||||
void *priv_data);
|
||||
|
||||
static void _setThreadContinueState(void *obj,
|
||||
CORBA::MarshalStream &strm,
|
||||
CORBA::Principal_ptr principal,
|
||||
const char *oper,
|
||||
void *priv_data);
|
||||
|
||||
static void _setThreadReturnValue(void *obj,
|
||||
CORBA::MarshalStream &strm,
|
||||
CORBA::Principal_ptr principal,
|
||||
const char *oper,
|
||||
void *priv_data);
|
||||
|
||||
static void _sendInterrupt(void *obj,
|
||||
CORBA::MarshalStream &strm,
|
||||
CORBA::Principal_ptr principal,
|
||||
const char *oper,
|
||||
void *priv_data);
|
||||
|
||||
static void _sendInterruptStepInto(void *obj,
|
||||
CORBA::MarshalStream &strm,
|
||||
CORBA::Principal_ptr principal,
|
||||
const char *oper,
|
||||
void *priv_data);
|
||||
|
||||
static void _sendInterruptStepOver(void *obj,
|
||||
CORBA::MarshalStream &strm,
|
||||
CORBA::Principal_ptr principal,
|
||||
const char *oper,
|
||||
void *priv_data);
|
||||
|
||||
static void _sendInterruptStepOut(void *obj,
|
||||
CORBA::MarshalStream &strm,
|
||||
CORBA::Principal_ptr principal,
|
||||
const char *oper,
|
||||
void *priv_data);
|
||||
|
||||
static void _reinstateStepper(void *obj,
|
||||
CORBA::MarshalStream &strm,
|
||||
CORBA::Principal_ptr principal,
|
||||
const char *oper,
|
||||
void *priv_data);
|
||||
|
||||
static void _executeScriptInStackFrame(void *obj,
|
||||
CORBA::MarshalStream &strm,
|
||||
CORBA::Principal_ptr principal,
|
||||
const char *oper,
|
||||
void *priv_data);
|
||||
|
||||
static void _isRunningHook(void *obj,
|
||||
CORBA::MarshalStream &strm,
|
||||
CORBA::Principal_ptr principal,
|
||||
const char *oper,
|
||||
void *priv_data);
|
||||
|
||||
static void _isWaitingForResume(void *obj,
|
||||
CORBA::MarshalStream &strm,
|
||||
CORBA::Principal_ptr principal,
|
||||
const char *oper,
|
||||
void *priv_data);
|
||||
|
||||
static void _leaveThreadSuspended(void *obj,
|
||||
CORBA::MarshalStream &strm,
|
||||
CORBA::Principal_ptr principal,
|
||||
const char *oper,
|
||||
void *priv_data);
|
||||
|
||||
static void _resumeThread(void *obj,
|
||||
CORBA::MarshalStream &strm,
|
||||
CORBA::Principal_ptr principal,
|
||||
const char *oper,
|
||||
void *priv_data);
|
||||
|
||||
static void _iterateScripts(void *obj,
|
||||
CORBA::MarshalStream &strm,
|
||||
CORBA::Principal_ptr principal,
|
||||
const char *oper,
|
||||
void *priv_data);
|
||||
|
||||
};
|
||||
template <class T>
|
||||
class _tie_IDebugController : public IDebugController
|
||||
{
|
||||
public:
|
||||
_tie_IDebugController(T& t, const char *obj_name=(char*)NULL) :
|
||||
IDebugController(obj_name),
|
||||
_ref(t) {
|
||||
_object_name(obj_name);
|
||||
}
|
||||
_tie_IDebugController(T& t, const char *service_name,
|
||||
const CORBA::ReferenceData& id)
|
||||
:_ref(t) {
|
||||
_service(service_name, id);
|
||||
}
|
||||
~_tie_IDebugController() {}
|
||||
CORBA::Long getMajorVersion() {
|
||||
return _ref.getMajorVersion();
|
||||
}
|
||||
CORBA::Long getMinorVersion() {
|
||||
return _ref.getMinorVersion();
|
||||
}
|
||||
IJSErrorReporter_ptr setErrorReporter(IJSErrorReporter_ptr arg0) {
|
||||
return _ref.setErrorReporter(
|
||||
arg0);
|
||||
}
|
||||
IJSErrorReporter_ptr getErrorReporter() {
|
||||
return _ref.getErrorReporter();
|
||||
}
|
||||
IScriptHook_ptr setScriptHook(IScriptHook_ptr arg0) {
|
||||
return _ref.setScriptHook(
|
||||
arg0);
|
||||
}
|
||||
IScriptHook_ptr getScriptHook() {
|
||||
return _ref.getScriptHook();
|
||||
}
|
||||
IJSPC * getClosestPC(const IScript& arg0,
|
||||
CORBA::Long arg1) {
|
||||
return _ref.getClosestPC(
|
||||
arg0,
|
||||
arg1);
|
||||
}
|
||||
IJSSourceLocation * getSourceLocation(const IJSPC& arg0) {
|
||||
return _ref.getSourceLocation(
|
||||
arg0);
|
||||
}
|
||||
IJSExecutionHook_ptr setInterruptHook(IJSExecutionHook_ptr arg0) {
|
||||
return _ref.setInterruptHook(
|
||||
arg0);
|
||||
}
|
||||
IJSExecutionHook_ptr getInterruptHook() {
|
||||
return _ref.getInterruptHook();
|
||||
}
|
||||
IJSExecutionHook_ptr setDebugBreakHook(IJSExecutionHook_ptr arg0) {
|
||||
return _ref.setDebugBreakHook(
|
||||
arg0);
|
||||
}
|
||||
IJSExecutionHook_ptr getDebugBreakHook() {
|
||||
return _ref.getDebugBreakHook();
|
||||
}
|
||||
IJSExecutionHook_ptr setInstructionHook(IJSExecutionHook_ptr arg0,
|
||||
const IJSPC& arg1) {
|
||||
return _ref.setInstructionHook(
|
||||
arg0,
|
||||
arg1);
|
||||
}
|
||||
IJSExecutionHook_ptr getInstructionHook(const IJSPC& arg0) {
|
||||
return _ref.getInstructionHook(
|
||||
arg0);
|
||||
}
|
||||
void setThreadContinueState(CORBA::Long arg0,
|
||||
CORBA::Long arg1) {
|
||||
_ref.setThreadContinueState(
|
||||
arg0,
|
||||
arg1);
|
||||
}
|
||||
void setThreadReturnValue(CORBA::Long arg0,
|
||||
const char * arg1) {
|
||||
_ref.setThreadReturnValue(
|
||||
arg0,
|
||||
arg1);
|
||||
}
|
||||
void sendInterrupt() {
|
||||
_ref.sendInterrupt();
|
||||
}
|
||||
void sendInterruptStepInto(CORBA::Long arg0) {
|
||||
_ref.sendInterruptStepInto(
|
||||
arg0);
|
||||
}
|
||||
void sendInterruptStepOver(CORBA::Long arg0) {
|
||||
_ref.sendInterruptStepOver(
|
||||
arg0);
|
||||
}
|
||||
void sendInterruptStepOut(CORBA::Long arg0) {
|
||||
_ref.sendInterruptStepOut(
|
||||
arg0);
|
||||
}
|
||||
void reinstateStepper(CORBA::Long arg0) {
|
||||
_ref.reinstateStepper(
|
||||
arg0);
|
||||
}
|
||||
IExecResult * executeScriptInStackFrame(CORBA::Long arg0,
|
||||
const IJSStackFrameInfo& arg1,
|
||||
const char * arg2,
|
||||
const char * arg3,
|
||||
CORBA::Long arg4) {
|
||||
return _ref.executeScriptInStackFrame(
|
||||
arg0,
|
||||
arg1,
|
||||
arg2,
|
||||
arg3,
|
||||
arg4);
|
||||
}
|
||||
CORBA::Boolean isRunningHook(CORBA::Long arg0) {
|
||||
return _ref.isRunningHook(
|
||||
arg0);
|
||||
}
|
||||
CORBA::Boolean isWaitingForResume(CORBA::Long arg0) {
|
||||
return _ref.isWaitingForResume(
|
||||
arg0);
|
||||
}
|
||||
void leaveThreadSuspended(CORBA::Long arg0) {
|
||||
_ref.leaveThreadSuspended(
|
||||
arg0);
|
||||
}
|
||||
void resumeThread(CORBA::Long arg0) {
|
||||
_ref.resumeThread(
|
||||
arg0);
|
||||
}
|
||||
void iterateScripts(IScriptHook_ptr arg0) {
|
||||
_ref.iterateScripts(
|
||||
arg0);
|
||||
}
|
||||
|
||||
private:
|
||||
T& _ref;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
2766
mozilla/js/jsd/corba/jsd_iiop.cpp
Normal file
2766
mozilla/js/jsd/corba/jsd_iiop.cpp
Normal file
File diff suppressed because it is too large
Load Diff
68
mozilla/js/jsd/corba/src/IDebugController.java
Normal file
68
mozilla/js/jsd/corba/src/IDebugController.java
Normal file
@@ -0,0 +1,68 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
public interface IDebugController extends org.omg.CORBA.Object
|
||||
{
|
||||
public int getMajorVersion();
|
||||
public int getMinorVersion();
|
||||
|
||||
public IJSErrorReporter setErrorReporter(IJSErrorReporter er);
|
||||
public IJSErrorReporter getErrorReporter();
|
||||
|
||||
public IScriptHook setScriptHook(IScriptHook h);
|
||||
public IScriptHook getScriptHook();
|
||||
|
||||
public IJSPC getClosestPC(IScript script, int line);
|
||||
|
||||
public IJSSourceLocation getSourceLocation(IJSPC pc);
|
||||
|
||||
public IJSExecutionHook setInterruptHook(IJSExecutionHook hook);
|
||||
public IJSExecutionHook getInterruptHook();
|
||||
|
||||
public IJSExecutionHook setDebugBreakHook(IJSExecutionHook hook);
|
||||
public IJSExecutionHook getDebugBreakHook();
|
||||
|
||||
public IJSExecutionHook setInstructionHook(IJSExecutionHook hook, IJSPC pc);
|
||||
public IJSExecutionHook getInstructionHook(IJSPC pc);
|
||||
|
||||
public void setThreadContinueState(int threadID, int state);
|
||||
public void setThreadReturnValue(int threadID, String value);
|
||||
|
||||
public void sendInterrupt();
|
||||
|
||||
public void sendInterruptStepInto(int threadID);
|
||||
public void sendInterruptStepOver(int threadID);
|
||||
public void sendInterruptStepOut(int threadID);
|
||||
|
||||
public void reinstateStepper(int threadID);
|
||||
|
||||
|
||||
public IExecResult executeScriptInStackFrame(int threadID,
|
||||
IJSStackFrameInfo frame,
|
||||
String text,
|
||||
String filename,
|
||||
int lineno);
|
||||
|
||||
public boolean isRunningHook(int threadID);
|
||||
public boolean isWaitingForResume(int threadID);
|
||||
public void leaveThreadSuspended(int threadID);
|
||||
public void resumeThread(int threadID);
|
||||
|
||||
public void iterateScripts(IScriptHook h);
|
||||
}
|
||||
|
||||
29
mozilla/js/jsd/corba/src/IExecResult.java
Normal file
29
mozilla/js/jsd/corba/src/IExecResult.java
Normal file
@@ -0,0 +1,29 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
public final class IExecResult
|
||||
{
|
||||
public String result;
|
||||
public boolean errorOccured;
|
||||
public String errorMessage;
|
||||
public String errorFilename;
|
||||
public int errorLineNumber;
|
||||
public String errorLineBuffer;
|
||||
public int errorTokenOffset;
|
||||
}
|
||||
|
||||
32
mozilla/js/jsd/corba/src/IJSErrorReporter.java
Normal file
32
mozilla/js/jsd/corba/src/IJSErrorReporter.java
Normal file
@@ -0,0 +1,32 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
public interface IJSErrorReporter extends org.omg.CORBA.Object
|
||||
{
|
||||
/* keep these in sync with the numbers in jsdebug.h */
|
||||
public static final int PASS_ALONG = 0;
|
||||
public static final int RETURN = 1;
|
||||
public static final int DEBUG = 2;
|
||||
|
||||
public int reportError( String msg,
|
||||
String filename,
|
||||
int lineno,
|
||||
String linebuf,
|
||||
int tokenOffset );
|
||||
}
|
||||
|
||||
22
mozilla/js/jsd/corba/src/IJSExecutionHook.java
Normal file
22
mozilla/js/jsd/corba/src/IJSExecutionHook.java
Normal file
@@ -0,0 +1,22 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
public interface IJSExecutionHook extends org.omg.CORBA.Object
|
||||
{
|
||||
public void aboutToExecute(IJSThreadState debug, IJSPC pc);
|
||||
}
|
||||
24
mozilla/js/jsd/corba/src/IJSPC.java
Normal file
24
mozilla/js/jsd/corba/src/IJSPC.java
Normal file
@@ -0,0 +1,24 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
public final class IJSPC
|
||||
{
|
||||
public IScript script;
|
||||
public int offset;
|
||||
}
|
||||
|
||||
23
mozilla/js/jsd/corba/src/IJSSourceLocation.java
Normal file
23
mozilla/js/jsd/corba/src/IJSSourceLocation.java
Normal file
@@ -0,0 +1,23 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
public final class IJSSourceLocation
|
||||
{
|
||||
public int line;
|
||||
public IJSPC pc;
|
||||
}
|
||||
23
mozilla/js/jsd/corba/src/IJSStackFrameInfo.java
Normal file
23
mozilla/js/jsd/corba/src/IJSStackFrameInfo.java
Normal file
@@ -0,0 +1,23 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
public final class IJSStackFrameInfo
|
||||
{
|
||||
public IJSPC pc;
|
||||
public int jsdframe;
|
||||
}
|
||||
65
mozilla/js/jsd/corba/src/IJSThreadState.java
Normal file
65
mozilla/js/jsd/corba/src/IJSThreadState.java
Normal file
@@ -0,0 +1,65 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
public final class IJSThreadState
|
||||
{
|
||||
/**
|
||||
* partial list of thread states from sun.debug.ThreadInfo.
|
||||
* XXX some of these don't apply.
|
||||
*/
|
||||
public final static int THR_STATUS_UNKNOWN = 0x01;
|
||||
public final static int THR_STATUS_ZOMBIE = 0x02;
|
||||
public final static int THR_STATUS_RUNNING = 0x03;
|
||||
public final static int THR_STATUS_SLEEPING = 0x04;
|
||||
public final static int THR_STATUS_MONWAIT = 0x05;
|
||||
public final static int THR_STATUS_CONDWAIT = 0x06;
|
||||
public final static int THR_STATUS_SUSPENDED = 0x07;
|
||||
public final static int THR_STATUS_BREAK = 0x08;
|
||||
|
||||
|
||||
public final static int DEBUG_STATE_DEAD = 0x01;
|
||||
|
||||
/**
|
||||
* if the continueState is RUN, the thread will
|
||||
* proceed to the next program counter value when it resumes.
|
||||
*/
|
||||
public final static int DEBUG_STATE_RUN = 0x02;
|
||||
|
||||
/**
|
||||
* if the continueState is RETURN, the thread will
|
||||
* return from the current method with the value in getReturnValue()
|
||||
* when it resumes.
|
||||
*/
|
||||
public final static int DEBUG_STATE_RETURN = 0x03;
|
||||
|
||||
/**
|
||||
* if the continueState is THROW, the thread will
|
||||
* throw an exception (accessible with getException()) when it
|
||||
* resumes.
|
||||
*/
|
||||
public final static int DEBUG_STATE_THROW = 0x04;
|
||||
|
||||
|
||||
public IJSStackFrameInfo[] stack;
|
||||
public int continueState;
|
||||
public String returnValue;
|
||||
public int status;
|
||||
public int jsdthreadstate;
|
||||
public int id; // used for referencing this object
|
||||
}
|
||||
|
||||
28
mozilla/js/jsd/corba/src/IScript.java
Normal file
28
mozilla/js/jsd/corba/src/IScript.java
Normal file
@@ -0,0 +1,28 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
public final class IScript
|
||||
{
|
||||
public String url;
|
||||
public String funname;
|
||||
public int base;
|
||||
public int extent;
|
||||
public int jsdscript;
|
||||
public IScriptSection[] sections;
|
||||
}
|
||||
|
||||
24
mozilla/js/jsd/corba/src/IScriptHook.java
Normal file
24
mozilla/js/jsd/corba/src/IScriptHook.java
Normal file
@@ -0,0 +1,24 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
public interface IScriptHook extends org.omg.CORBA.Object
|
||||
{
|
||||
public void justLoadedScript(IScript script);
|
||||
public void aboutToUnloadScript(IScript script);
|
||||
}
|
||||
|
||||
23
mozilla/js/jsd/corba/src/IScriptSection.java
Normal file
23
mozilla/js/jsd/corba/src/IScriptSection.java
Normal file
@@ -0,0 +1,23 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
public final class IScriptSection
|
||||
{
|
||||
public int base;
|
||||
public int extent;
|
||||
}
|
||||
37
mozilla/js/jsd/corba/src/ISourceTextProvider.java
Normal file
37
mozilla/js/jsd/corba/src/ISourceTextProvider.java
Normal file
@@ -0,0 +1,37 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
public interface ISourceTextProvider extends org.omg.CORBA.Object
|
||||
{
|
||||
/* these coorespond to jsdebug.h values - change in both places if anywhere */
|
||||
public static final int INITED = 0;
|
||||
public static final int FULL = 1;
|
||||
public static final int PARTIAL = 2;
|
||||
public static final int ABORTED = 3;
|
||||
public static final int FAILED = 4;
|
||||
public static final int CLEARED = 5;
|
||||
|
||||
public String[] getAllPages();
|
||||
public void refreshAllPages();
|
||||
public boolean hasPage(String url);
|
||||
public boolean loadPage(String url);
|
||||
public void refreshPage(String url);
|
||||
public String getPageText(String url);
|
||||
public int getPageStatus(String url);
|
||||
public int getPageAlterCount(String url);
|
||||
}
|
||||
25
mozilla/js/jsd/corba/src/README
Normal file
25
mozilla/js/jsd/corba/src/README
Normal file
@@ -0,0 +1,25 @@
|
||||
/* jband - 09/09/97 - readme for the dreaded js/jsd/corba system */
|
||||
|
||||
This stuff in js/jsd/corba/src is used to generate corba source in IDL, Java,
|
||||
and C++. The raw source is all Java. The 'makefile' is mk.bat which is currently
|
||||
expected to run only on jband's NT box. All of the important output of this
|
||||
process should be checked in to cvs. mk.bat is only needed to regenerate new
|
||||
sources as the interfaces change. Those new sources should then be committed to
|
||||
cvs.
|
||||
|
||||
The main scheme here is to use the Java code in js/jsd/corba/src as idl.
|
||||
mk.bat uses java2idl, orbeline, and idl2java to generate IDL and stubs and
|
||||
skeletons in C++ and Java. There are a few hacks to deal with limitations of
|
||||
these tools.
|
||||
|
||||
The C++ output is copied to js/jsd/corba.
|
||||
The Java output is copied to
|
||||
js/jsdj/classes/com/netscape/jsdebugging/remote/corba.
|
||||
|
||||
Note that the files:
|
||||
|
||||
StringReciever.java
|
||||
TestInterface.java
|
||||
Thing.java
|
||||
|
||||
are used only in test programs and are not part of the product
|
||||
24
mozilla/js/jsd/corba/src/StringReciever.java
Normal file
24
mozilla/js/jsd/corba/src/StringReciever.java
Normal file
@@ -0,0 +1,24 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
public interface StringReciever extends org.omg.CORBA.Object
|
||||
{
|
||||
public void recieveString(String s);
|
||||
public void bounce(int count);
|
||||
}
|
||||
|
||||
26
mozilla/js/jsd/corba/src/TestInterface.java
Normal file
26
mozilla/js/jsd/corba/src/TestInterface.java
Normal file
@@ -0,0 +1,26 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
public interface TestInterface extends org.omg.CORBA.Object
|
||||
{
|
||||
public String getFirstAppInList();
|
||||
public void getAppNames( StringReciever sr );
|
||||
public Thing[] getThings();
|
||||
public void callBounce( StringReciever sr, int count );
|
||||
}
|
||||
|
||||
24
mozilla/js/jsd/corba/src/Thing.java
Normal file
24
mozilla/js/jsd/corba/src/Thing.java
Normal file
@@ -0,0 +1,24 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
public final class Thing
|
||||
{
|
||||
public String s;
|
||||
public int i;
|
||||
}
|
||||
|
||||
BIN
mozilla/js/jsd/corba/src/WAIT.COM
Executable file
BIN
mozilla/js/jsd/corba/src/WAIT.COM
Executable file
Binary file not shown.
31
mozilla/js/jsd/corba/src/bogus0.java
Normal file
31
mozilla/js/jsd/corba/src/bogus0.java
Normal file
@@ -0,0 +1,31 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
//
|
||||
// This class only exist to force a forward declaration in the outputed
|
||||
// idl file.
|
||||
//
|
||||
// It should be handed to java2idl after IScriptSection.class but before
|
||||
// IScript.class
|
||||
//
|
||||
|
||||
public final class bogus0
|
||||
{
|
||||
public IScriptSection[] bogus;
|
||||
}
|
||||
|
||||
31
mozilla/js/jsd/corba/src/bogus1.java
Normal file
31
mozilla/js/jsd/corba/src/bogus1.java
Normal file
@@ -0,0 +1,31 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
//
|
||||
// This class only exist to force a forward declaration in the outputed
|
||||
// idl file.
|
||||
//
|
||||
// It should be handed to java2idl after IJSStackFrameInfo.class but before
|
||||
// IJSThreadState.class
|
||||
//
|
||||
|
||||
public final class bogus1
|
||||
{
|
||||
public IJSStackFrameInfo[] bogus;
|
||||
}
|
||||
|
||||
43
mozilla/js/jsd/corba/src/cutlines.awk
Normal file
43
mozilla/js/jsd/corba/src/cutlines.awk
Normal file
@@ -0,0 +1,43 @@
|
||||
# -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
#
|
||||
# see usage...
|
||||
#
|
||||
|
||||
BEGIN {
|
||||
skiplines_left = 0
|
||||
if( 0 == lines || 0 == pat )
|
||||
{
|
||||
# show usage...
|
||||
print "\n"
|
||||
print "strips some lines when first line contains pattern\n"
|
||||
print "\tusage -v pat=\"pattern\" -v lines=3"
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
if( skiplines_left )
|
||||
skiplines_left--;
|
||||
else
|
||||
{
|
||||
if( match($0, pat) != 0 )
|
||||
skiplines_left = lines-1;
|
||||
else
|
||||
print $0;
|
||||
}
|
||||
}
|
||||
143
mozilla/js/jsd/corba/src/mk.bat
Executable file
143
mozilla/js/jsd/corba/src/mk.bat
Executable file
@@ -0,0 +1,143 @@
|
||||
@echo off
|
||||
REM
|
||||
REM This needs to be run from the src dir. It generates sibling dirs and their
|
||||
REM contents.
|
||||
REM
|
||||
|
||||
set base_package=com.netscape.jsdebugging.remote.corba
|
||||
set base_packslash=com\netscape\jsdebugging\remote\corba
|
||||
set jsdj_classes_dir=..\..\..\jsdj\classes
|
||||
set DELAY=6
|
||||
|
||||
rem -------------------------------------------------------------------------
|
||||
rem -- show settings
|
||||
echo.
|
||||
echo commandline: %0 %1 %2 %3 %4 %5 %6 %7 %8 %9
|
||||
echo.
|
||||
echo ES3_ROOT = %ES3_ROOT%
|
||||
echo base_package = %base_package% // set in this file
|
||||
echo jsdj_classes_dir = %jsdj_classes_dir% // set in this file
|
||||
echo.
|
||||
rem -------------------------------------------------------------------------
|
||||
|
||||
rem -- check for environment settings
|
||||
if "%ES3_ROOT%" == "" goto usage
|
||||
|
||||
set jc=sj.exe
|
||||
set cp=.;%ES3_ROOT%\wai\java\nisb.zip;%ES3_ROOT%\wai\java\WAI.zip;%ES3_ROOT%\plugins\Java\classes\serv3_0.zip
|
||||
set old_classpath=%CLASSPATH%
|
||||
set CLASSPATH=%CLASSPATH%;%ES3_ROOT%\wai\java\nisb.zip;%ES3_ROOT%\wai\java\WAI.zip
|
||||
echo.
|
||||
echo creating output dirs
|
||||
if not exist ..\class\NUL mkdir ..\class
|
||||
if not exist ..\idl\NUL mkdir ..\idl
|
||||
if not exist ..\java\NUL mkdir ..\java
|
||||
if not exist ..\cpp\NUL mkdir ..\cpp
|
||||
|
||||
echo.
|
||||
echo compiling raw Java interfaces
|
||||
%jc% -classpath %cp% *.java -d ..\class
|
||||
|
||||
|
||||
..\src\wait %DELAY%
|
||||
cd ..\class
|
||||
echo.
|
||||
echo.
|
||||
echo generating idl
|
||||
echo.
|
||||
REM
|
||||
REM THESE ARE HAND ORDERED TO DEAL WITH DEPENDENCIES
|
||||
REM
|
||||
%ES3_ROOT%\wai\bin\java2idl Thing.class StringReciever.class TestInterface.class ISourceTextProvider.class IScriptSection.class bogus0.class IScript.class IJSPC.class IJSSourceLocation.class IJSErrorReporter.class IScriptHook.class IJSStackFrameInfo.class bogus1.class IJSThreadState.class IJSExecutionHook.class IExecResult.class IDebugController.class > ..\idl\ifaces.idl
|
||||
|
||||
|
||||
..\src\wait %DELAY%
|
||||
cd ..\idl
|
||||
echo.
|
||||
echo.
|
||||
echo stripping lines from idl which were added to correctly order declarations
|
||||
echo.
|
||||
copy ifaces.idl ifaces_original.idl
|
||||
REM
|
||||
REM since we currenly have 2 of these, we can avoid the copy
|
||||
REM
|
||||
gawk -v pat="struct bogus0" -v lines=3 -f ..\src\cutlines.awk < ifaces.idl > temp.idl
|
||||
gawk -v pat="struct bogus1" -v lines=3 -f ..\src\cutlines.awk < temp.idl > ifaces.idl
|
||||
REM copy temp.idl ifaces.idl
|
||||
|
||||
REM ..\src\wait %DELAY%
|
||||
cd ..\cpp
|
||||
echo.
|
||||
echo.
|
||||
echo generating cpp
|
||||
echo.
|
||||
%ES3_ROOT%\wai\bin\orbeline ..\idl\ifaces.idl
|
||||
|
||||
|
||||
..\src\wait %DELAY%
|
||||
cd ..\java
|
||||
echo.
|
||||
echo.
|
||||
echo generating java
|
||||
echo.
|
||||
%ES3_ROOT%\wai\bin\idl2java ..\idl\ifaces.idl -package %base_package% -no_examples -no_tie -no_comments
|
||||
|
||||
|
||||
..\src\wait %DELAY%
|
||||
cd ..\src
|
||||
echo.
|
||||
echo. copying generated files
|
||||
echo.
|
||||
REM
|
||||
REM preserve generated java, but put ours in the outdir
|
||||
REM
|
||||
xcopy /Q ..\java\%base_packslash%\*.java ..\java\%base_packslash%\_unused\*.jav
|
||||
REM
|
||||
REM *****CUSTOMIZE HERE AS NEW INTERFACES WITH static ints ARE ADDED*****
|
||||
REM
|
||||
copy ..\src\package_header.h+..\src\ISourceTextProvider.java ..\java\%base_packslash%\ISourceTextProvider.java
|
||||
copy ..\src\package_header.h+..\src\IJSErrorReporter.java ..\java\%base_packslash%\IJSErrorReporter.java
|
||||
copy ..\src\package_header.h+..\src\IJSThreadState.java ..\java\%base_packslash%\IJSThreadState.java
|
||||
copy ..\src\package_header.h+..\src\IDebugController.java ..\java\%base_packslash%\IDebugController.java
|
||||
REM
|
||||
REM
|
||||
xcopy /Q ..\cpp\ifaces_c.hh ..\
|
||||
xcopy /Q ..\cpp\ifaces_s.hh ..\
|
||||
xcopy /Q ..\cpp\ifaces_c.cc ..\ifaces_c.cpp
|
||||
xcopy /Q ..\cpp\ifaces_s.cc ..\ifaces_s.cpp
|
||||
|
||||
if "%jsdj_classes_dir%" == "" goto done
|
||||
if not exist %jsdj_classes_dir%\NUL goto done
|
||||
xcopy /Q /S ..\java\*.java %jsdj_classes_dir%
|
||||
|
||||
goto done
|
||||
|
||||
:usage
|
||||
echo.
|
||||
echo usage:
|
||||
echo mk
|
||||
echo.
|
||||
echo See "readme.txt" for details...
|
||||
echo.
|
||||
echo Rules:
|
||||
echo.
|
||||
echo These must be defined in environment:
|
||||
echo ES3_ROOT // location of Enterprise Server (e.g. e:\Netscape\SuiteSpot)
|
||||
echo.
|
||||
|
||||
:done
|
||||
..\src\wait %DELAY%
|
||||
cd ..\src
|
||||
|
||||
set base_package=
|
||||
set base_packslash=
|
||||
set jsdj_classes_dir=
|
||||
set cp=
|
||||
set jc=
|
||||
set DELAY=
|
||||
set CLASSPATH=%old_classpath%
|
||||
set old_classpath=
|
||||
echo.
|
||||
echo.
|
||||
echo done
|
||||
echo.
|
||||
3
mozilla/js/jsd/corba/src/package_header.h
Normal file
3
mozilla/js/jsd/corba/src/package_header.h
Normal file
@@ -0,0 +1,3 @@
|
||||
|
||||
package com.netscape.jsdebugging.remote.corba;
|
||||
|
||||
35
mozilla/js/jsd/java/jni_stubs.c
Normal file
35
mozilla/js/jsd/java/jni_stubs.c
Normal file
@@ -0,0 +1,35 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This supplies non-functional stubs for a couple of JNI functions we need
|
||||
* in order to link LiveConnect
|
||||
*/
|
||||
|
||||
#include "jni.h"
|
||||
|
||||
jint JNICALL JNI_GetDefaultJavaVMInitArgs(void * ignored)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
jint JNICALL JNI_CreateJavaVM(JavaVM ** vm, JNIEnv ** env, void * ignored)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
33
mozilla/js/jsd/java/jniheadr.mak
Normal file
33
mozilla/js/jsd/java/jniheadr.mak
Normal file
@@ -0,0 +1,33 @@
|
||||
|
||||
JSDJNI = .
|
||||
#CLASS_DIR_BASE = $(JSDJNI)\..\..\..\jsdj\dist\classes
|
||||
# until jsdj moves to mozilla...
|
||||
CLASS_DIR_BASE = $(JSDJNI)\..\..\..\..\..\ns\js\jsdj\dist\classes
|
||||
GEN = $(JSDJNI)\_jni
|
||||
HEADER_FILE = $(GEN)\jsdjnih.h
|
||||
|
||||
PACKAGE_SLASH = netscape\jsdebug
|
||||
PACKAGE_DOT = netscape.jsdebug
|
||||
|
||||
STD_CLASSPATH = -classpath $(CLASS_DIR_BASE);$(CLASSPATH)
|
||||
|
||||
CLASSES_WITH_NATIVES = \
|
||||
$(PACKAGE_DOT).DebugController \
|
||||
$(PACKAGE_DOT).JSPC \
|
||||
$(PACKAGE_DOT).JSSourceTextProvider \
|
||||
$(PACKAGE_DOT).JSStackFrameInfo \
|
||||
$(PACKAGE_DOT).JSThreadState \
|
||||
$(PACKAGE_DOT).Script \
|
||||
$(PACKAGE_DOT).SourceTextProvider \
|
||||
$(PACKAGE_DOT).ThreadStateBase \
|
||||
$(PACKAGE_DOT).Value
|
||||
|
||||
all: $(GEN)
|
||||
@echo generating JNI headers
|
||||
@javah -jni -o "$(HEADER_FILE)" $(STD_CLASSPATH) $(CLASSES_WITH_NATIVES)
|
||||
|
||||
$(GEN) :
|
||||
@mkdir $(GEN)
|
||||
|
||||
clean:
|
||||
@if exist $(HEADER_FILE) @del $(HEADER_FILE) > NUL
|
||||
134
mozilla/js/jsd/java/jre/jre.c
Normal file
134
mozilla/js/jsd/java/jre/jre.c
Normal file
@@ -0,0 +1,134 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Sun Microsystems, Inc.
|
||||
* Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*
|
||||
* Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved.
|
||||
*
|
||||
* Sun grants you ("Licensee") a non-exclusive, royalty free, license to use,
|
||||
* modify and redistribute this software in source and binary code form,
|
||||
* provided that i) this copyright notice and license appear on all copies of
|
||||
* the software; and ii) Licensee does not utilize the software in a manner
|
||||
* which is disparaging to Sun.
|
||||
*
|
||||
* This software is provided "AS IS," without a warranty of any kind. ALL
|
||||
* EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
|
||||
* IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
|
||||
* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE
|
||||
* LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
|
||||
* OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS
|
||||
* LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,
|
||||
* INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
|
||||
* CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF
|
||||
* OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGES.
|
||||
*
|
||||
* This software is not designed or intended for use in on-line control of
|
||||
* aircraft, air traffic, aircraft navigation or aircraft communications; or in
|
||||
* the design, construction, operation or maintenance of any nuclear
|
||||
* facility. Licensee represents and warrants that it will not use or
|
||||
* redistribute the Software for such purposes.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portable JRE support functions - pared this down to minimal set I need
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <jni.h>
|
||||
#include "jre.h"
|
||||
|
||||
/*
|
||||
* Exits the runtime with the specified error message.
|
||||
*/
|
||||
void
|
||||
JRE_FatalError(JNIEnv *env, const char *msg)
|
||||
{
|
||||
if ((*env)->ExceptionOccurred(env)) {
|
||||
(*env)->ExceptionDescribe(env);
|
||||
}
|
||||
(*env)->FatalError(env, msg);
|
||||
}
|
||||
|
||||
/*
|
||||
* Parses a runtime version string. Returns 0 if the successful, otherwise
|
||||
* returns -1 if the format of the version string was invalid.
|
||||
*/
|
||||
jint
|
||||
JRE_ParseVersion(const char *ver, char **majorp, char **minorp, char **microp)
|
||||
{
|
||||
int n1 = 0, n2 = 0, n3 = 0;
|
||||
|
||||
sscanf(ver, "%*[0-9]%n.%*[0-9]%n.%*[0-9a-zA-Z]%n", &n1, &n2, &n3);
|
||||
if (n1 == 0 || n2 == 0) {
|
||||
return -1;
|
||||
}
|
||||
if (n3 != 0) {
|
||||
if (n3 != (int)strlen(ver)) {
|
||||
return -1;
|
||||
}
|
||||
} else if (n2 != (int)strlen(ver)) {
|
||||
return -1;
|
||||
}
|
||||
*majorp = JRE_Malloc(n1 + 1);
|
||||
strncpy(*majorp, ver, n1);
|
||||
(*majorp)[n1] = 0;
|
||||
*minorp = JRE_Malloc(n2 - n1);
|
||||
strncpy(*minorp, ver + n1 + 1, n2 - n1 - 1);
|
||||
(*minorp)[n2 - n1 - 1] = 0;
|
||||
if (n3 != 0) {
|
||||
*microp = JRE_Malloc(n3 - n2);
|
||||
strncpy(*microp, ver + n2 + 1, n3 - n2 - 1);
|
||||
(*microp)[n3 - n2 - 1] = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Creates a version number string from the specified major, minor, and
|
||||
* micro version numbers.
|
||||
*/
|
||||
char *
|
||||
JRE_MakeVersion(const char *major, const char *minor, const char *micro)
|
||||
{
|
||||
char *ver = 0;
|
||||
|
||||
if (major != 0 && minor != 0) {
|
||||
int len = strlen(major) + strlen(minor);
|
||||
if (micro != 0) {
|
||||
ver = JRE_Malloc(len + strlen(micro) + 3);
|
||||
sprintf(ver, "%s.%s.%s", major, minor, micro);
|
||||
} else {
|
||||
ver = JRE_Malloc(len + 2);
|
||||
sprintf(ver, "%s.%s", major, minor);
|
||||
}
|
||||
}
|
||||
return ver;
|
||||
}
|
||||
|
||||
/*
|
||||
* Allocate memory or die.
|
||||
*/
|
||||
void *
|
||||
JRE_Malloc(size_t size)
|
||||
{
|
||||
void *p = malloc(size);
|
||||
if (p == 0) {
|
||||
perror("malloc");
|
||||
exit(1);
|
||||
}
|
||||
return p;
|
||||
}
|
||||
85
mozilla/js/jsd/java/jre/jre.h
Normal file
85
mozilla/js/jsd/java/jre/jre.h
Normal file
@@ -0,0 +1,85 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Sun Microsystems, Inc.
|
||||
* Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*
|
||||
* Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved.
|
||||
*
|
||||
* Sun grants you ("Licensee") a non-exclusive, royalty free, license to use,
|
||||
* modify and redistribute this software in source and binary code form,
|
||||
* provided that i) this copyright notice and license appear on all copies of
|
||||
* the software; and ii) Licensee does not utilize the software in a manner
|
||||
* which is disparaging to Sun.
|
||||
*
|
||||
* This software is provided "AS IS," without a warranty of any kind. ALL
|
||||
* EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
|
||||
* IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
|
||||
* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE
|
||||
* LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
|
||||
* OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS
|
||||
* LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,
|
||||
* INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
|
||||
* CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF
|
||||
* OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGES.
|
||||
*
|
||||
* This software is not designed or intended for use in on-line control of
|
||||
* aircraft, air traffic, aircraft navigation or aircraft communications; or in
|
||||
* the design, construction, operation or maintenance of any nuclear
|
||||
* facility. Licensee represents and warrants that it will not use or
|
||||
* redistribute the Software for such purposes.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Portable JRE support functions - pared this down to minimal set I need
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <jni.h>
|
||||
|
||||
#include "jre_md.h"
|
||||
|
||||
/*
|
||||
* Java runtime settings.
|
||||
*/
|
||||
typedef struct JRESettings {
|
||||
char *javaHome; /* Java home directory */
|
||||
char *runtimeLib; /* Runtime shared library or DLL */
|
||||
char *classPath; /* Default class path */
|
||||
char *compiler; /* Just-in-time (JIT) compiler */
|
||||
char *majorVersion; /* Major version of runtime */
|
||||
char *minorVersion; /* Minor version of runtime */
|
||||
char *microVersion; /* Micro version of runtime */
|
||||
} JRESettings;
|
||||
|
||||
/*
|
||||
* JRE functions.
|
||||
*/
|
||||
void *JRE_LoadLibrary(const char *path);
|
||||
void JRE_UnloadLibrary(void *handle);
|
||||
jint JRE_GetDefaultJavaVMInitArgs(void *handle, void *vmargsp);
|
||||
jint JRE_CreateJavaVM(void *handle, JavaVM **vmp, JNIEnv **envp,
|
||||
void *vmargsp);
|
||||
jint JRE_GetCurrentSettings(JRESettings *set);
|
||||
jint JRE_GetSettings(JRESettings *set, const char *ver);
|
||||
jint JRE_GetDefaultSettings(JRESettings *set);
|
||||
jint JRE_ParseVersion(const char *version,
|
||||
char **majorp, char **minorp, char **microp);
|
||||
char *JRE_MakeVersion(const char *major, const char *minor, const char *micro);
|
||||
void *JRE_Malloc(size_t size);
|
||||
void JRE_FatalError(JNIEnv *env, const char *msg);
|
||||
char *JRE_GetDefaultRuntimeLib(const char *dir);
|
||||
char *JRE_GetDefaultClassPath(const char *dir);
|
||||
290
mozilla/js/jsd/java/jre/win32/jre_md.c
Normal file
290
mozilla/js/jsd/java/jre/win32/jre_md.c
Normal file
@@ -0,0 +1,290 @@
|
||||
/*
|
||||
* @(#)jre_md.c 1.6 97/05/15 David Connelly
|
||||
*
|
||||
* Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved.
|
||||
*
|
||||
* Sun grants you ("Licensee") a non-exclusive, royalty free, license to use,
|
||||
* modify and redistribute this software in source and binary code form,
|
||||
* provided that i) this copyright notice and license appear on all copies of
|
||||
* the software; and ii) Licensee does not utilize the software in a manner
|
||||
* which is disparaging to Sun.
|
||||
*
|
||||
* This software is provided "AS IS," without a warranty of any kind. ALL
|
||||
* EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
|
||||
* IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
|
||||
* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE
|
||||
* LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
|
||||
* OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS
|
||||
* LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,
|
||||
* INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
|
||||
* CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF
|
||||
* OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGES.
|
||||
*
|
||||
* This software is not designed or intended for use in on-line control of
|
||||
* aircraft, air traffic, aircraft navigation or aircraft communications; or in
|
||||
* the design, construction, operation or maintenance of any nuclear
|
||||
* facility. Licensee represents and warrants that it will not use or
|
||||
* redistribute the Software for such purposes.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Win32 specific JRE support functions
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
#include <stdlib.h>
|
||||
#include <jni.h>
|
||||
#include "jre.h"
|
||||
|
||||
#define JRE_KEY "Software\\JavaSoft\\Java Runtime Environment"
|
||||
#define JDK_KEY "Software\\JavaSoft\\Java Development Kit"
|
||||
|
||||
#define RUNTIME_LIB "javai.dll"
|
||||
|
||||
/* From jre_main.c */
|
||||
extern jboolean debug;
|
||||
|
||||
/* Forward Declarations */
|
||||
jint LoadSettings(JRESettings *set, HKEY key);
|
||||
jint GetSettings(JRESettings *set, const char *version, const char *keyname);
|
||||
char *GetStringValue(HKEY key, const char *name);
|
||||
|
||||
/*
|
||||
* Retrieve settings from registry for current runtime version. Returns
|
||||
* 0 if successful otherwise returns -1 if no installed runtime was found
|
||||
* or the registry data was invalid.
|
||||
*/
|
||||
jint
|
||||
JRE_GetCurrentSettings(JRESettings *set)
|
||||
{
|
||||
jint r = -1;
|
||||
HKEY key;
|
||||
|
||||
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, JRE_KEY, 0, KEY_READ, &key) == 0) {
|
||||
char *ver = GetStringValue(key, "CurrentVersion");
|
||||
if (ver != 0) {
|
||||
r = JRE_GetSettings(set, ver);
|
||||
}
|
||||
free(ver);
|
||||
RegCloseKey(key);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
/*
|
||||
* Retrieves settings from registry for specified runtime version.
|
||||
* Searches for either installed JRE and JDK runtimes. Returns 0 if
|
||||
* successful otherwise returns -1 if requested version of runtime
|
||||
* could not be found.
|
||||
*/
|
||||
jint
|
||||
JRE_GetSettings(JRESettings *set, const char *version)
|
||||
{
|
||||
if (GetSettings(set, version, JRE_KEY) != 0) {
|
||||
return GetSettings(set, version, JDK_KEY);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
jint
|
||||
GetSettings(JRESettings *set, const char *version, const char *keyname)
|
||||
{
|
||||
HKEY key;
|
||||
int r = -1;
|
||||
|
||||
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, keyname, 0, KEY_READ, &key) == 0) {
|
||||
char *major, *minor, *micro = 0;
|
||||
if (JRE_ParseVersion(version, &major, &minor, µ) == 0) {
|
||||
HKEY subkey;
|
||||
char *ver = JRE_MakeVersion(major, minor, 0);
|
||||
set->majorVersion = major;
|
||||
set->minorVersion = minor;
|
||||
if (RegOpenKeyEx(key, ver, 0, KEY_READ, &subkey) == 0) {
|
||||
if ((r = LoadSettings(set, subkey)) == 0) {
|
||||
if (micro != 0) {
|
||||
if (set->microVersion == 0 ||
|
||||
strcmp(micro, set->microVersion) != 0) {
|
||||
r = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
RegCloseKey(subkey);
|
||||
}
|
||||
free(ver);
|
||||
}
|
||||
RegCloseKey(key);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
/*
|
||||
* Load runtime settings from specified registry key. Returns 0 if
|
||||
* successful otherwise -1 if the registry data was invalid.
|
||||
*/
|
||||
static jint
|
||||
LoadSettings(JRESettings *set, HKEY key)
|
||||
{
|
||||
/* Full path name of JRE home directory (required) */
|
||||
set->javaHome = GetStringValue(key, "JavaHome");
|
||||
if (set->javaHome == 0) {
|
||||
return -1;
|
||||
}
|
||||
/* Full path name of JRE runtime DLL */
|
||||
set->runtimeLib = GetStringValue(key, "RuntimeLib");
|
||||
if (set->runtimeLib == 0) {
|
||||
set->runtimeLib = JRE_GetDefaultRuntimeLib(set->javaHome);
|
||||
}
|
||||
/* Class path setting to override default */
|
||||
set->classPath = GetStringValue(key, "ClassPath");
|
||||
if (set->classPath == 0) {
|
||||
set->classPath = JRE_GetDefaultClassPath(set->javaHome);
|
||||
}
|
||||
/* Optional JIT compiler library name */
|
||||
set->compiler = GetStringValue(key, "Compiler");
|
||||
/* Release micro-version */
|
||||
set->microVersion = GetStringValue(key, "MicroVersion");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns string data for the specified registry value name, or
|
||||
* NULL if not found.
|
||||
*/
|
||||
static char *
|
||||
GetStringValue(HKEY key, const char *name)
|
||||
{
|
||||
DWORD type, size;
|
||||
char *value = 0;
|
||||
|
||||
if (RegQueryValueEx(key, name, 0, &type, 0, &size) == 0 &&
|
||||
type == REG_SZ ) {
|
||||
value = JRE_Malloc(size);
|
||||
if (RegQueryValueEx(key, name, 0, 0, value, &size) != 0) {
|
||||
free(value);
|
||||
value = 0;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns default runtime settings based on location of this program.
|
||||
* Makes best attempt at determining location of runtime. Returns 0
|
||||
* if successful or -1 if a runtime could not be found.
|
||||
*/
|
||||
jint
|
||||
JRE_GetDefaultSettings(JRESettings *set)
|
||||
{
|
||||
char buf[MAX_PATH], *bp;
|
||||
int n;
|
||||
|
||||
// Try to obtain default value for Java home directory based on
|
||||
// location of this executable.
|
||||
|
||||
if ((n = GetModuleFileName(0, buf, MAX_PATH)) == 0) {
|
||||
return -1;
|
||||
}
|
||||
bp = buf + n;
|
||||
while (*--bp != '\\') ;
|
||||
bp -= 4;
|
||||
if (bp < buf || strnicmp(bp, "\\bin", 4) != 0) {
|
||||
return -1;
|
||||
}
|
||||
*bp = '\0';
|
||||
set->javaHome = strdup(buf);
|
||||
|
||||
// Get default runtime library
|
||||
set->runtimeLib = JRE_GetDefaultRuntimeLib(set->javaHome);
|
||||
|
||||
// Get default class path
|
||||
set->classPath = JRE_GetDefaultClassPath(set->javaHome);
|
||||
|
||||
// Reset other fields since these are unknown
|
||||
set->compiler = 0;
|
||||
set->majorVersion = 0;
|
||||
set->minorVersion = 0;
|
||||
set->microVersion = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return default runtime library for specified Java home directory.
|
||||
*/
|
||||
char *
|
||||
JRE_GetDefaultRuntimeLib(const char *dir)
|
||||
{
|
||||
char *cp = JRE_Malloc(strlen(dir) + sizeof(RUNTIME_LIB) + 8);
|
||||
sprintf(cp, "%s\\bin\\" RUNTIME_LIB, dir);
|
||||
return cp;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return default class path for specified Java home directory.
|
||||
*/
|
||||
char *
|
||||
JRE_GetDefaultClassPath(const char *dir)
|
||||
{
|
||||
char *cp = JRE_Malloc(strlen(dir) * 4 + 64);
|
||||
sprintf(cp, "%s\\lib\\rt.jar;%s\\lib\\i18n.jar;%s\\lib\\classes.zip;"
|
||||
"%s\\classes", dir, dir, dir, dir);
|
||||
return cp;
|
||||
}
|
||||
|
||||
/*
|
||||
* Loads the runtime library corresponding to 'libname' and returns
|
||||
* an opaque handle to the library.
|
||||
*/
|
||||
void *
|
||||
JRE_LoadLibrary(const char *path)
|
||||
{
|
||||
return (void *)LoadLibrary(path);
|
||||
}
|
||||
|
||||
/*
|
||||
* Unloads the runtime library associated with handle.
|
||||
*/
|
||||
void
|
||||
JRE_UnloadLibrary(void *handle)
|
||||
{
|
||||
FreeLibrary(handle);
|
||||
}
|
||||
|
||||
/*
|
||||
* Loads default VM args for the specified runtime library handle.
|
||||
*/
|
||||
jint
|
||||
JRE_GetDefaultJavaVMInitArgs(void *handle, void *vmargs)
|
||||
{
|
||||
FARPROC proc = GetProcAddress(handle, "JNI_GetDefaultJavaVMInitArgs");
|
||||
return proc != 0 ? ((*proc)(vmargs), 0) : -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Creates a Java VM for the specified runtime library handle.
|
||||
*/
|
||||
jint
|
||||
JRE_CreateJavaVM(void *handle, JavaVM **vmp, JNIEnv **envp, void *vmargs)
|
||||
{
|
||||
FARPROC proc = GetProcAddress(handle, "JNI_CreateJavaVM");
|
||||
return proc != 0 ? (*proc)(vmp, envp, vmargs) : -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Entry point for JREW (Windows-only) version of the runtime loader.
|
||||
* This entry point is called when the '-subsystem:windows' linker
|
||||
* option is used, and will cause the resulting executable to run
|
||||
* detached from the console.
|
||||
*/
|
||||
|
||||
/**
|
||||
* int WINAPI
|
||||
* WinMain(HINSTANCE inst, HINSTANCE prevInst, LPSTR cmdLine, int cmdShow)
|
||||
* {
|
||||
* __declspec(dllimport) char **__initenv;
|
||||
*
|
||||
* __initenv = _environ;
|
||||
* exit(main(__argc, __argv));
|
||||
* }
|
||||
*/
|
||||
36
mozilla/js/jsd/java/jre/win32/jre_md.h
Normal file
36
mozilla/js/jsd/java/jre/win32/jre_md.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* @(#)jre_md.h 1.1 97/05/19 David Connelly
|
||||
*
|
||||
* Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved.
|
||||
*
|
||||
* Sun grants you ("Licensee") a non-exclusive, royalty free, license to use,
|
||||
* modify and redistribute this software in source and binary code form,
|
||||
* provided that i) this copyright notice and license appear on all copies of
|
||||
* the software; and ii) Licensee does not utilize the software in a manner
|
||||
* which is disparaging to Sun.
|
||||
*
|
||||
* This software is provided "AS IS," without a warranty of any kind. ALL
|
||||
* EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
|
||||
* IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
|
||||
* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE
|
||||
* LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
|
||||
* OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS
|
||||
* LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,
|
||||
* INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
|
||||
* CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF
|
||||
* OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGES.
|
||||
*
|
||||
* This software is not designed or intended for use in on-line control of
|
||||
* aircraft, air traffic, aircraft navigation or aircraft communications; or in
|
||||
* the design, construction, operation or maintenance of any nuclear
|
||||
* facility. Licensee represents and warrants that it will not use or
|
||||
* redistribute the Software for such purposes.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Win32 specific JRE support definitions
|
||||
*/
|
||||
|
||||
#define FILE_SEPARATOR '\\'
|
||||
#define PATH_SEPARATOR ';'
|
||||
2694
mozilla/js/jsd/java/jsd_jntv.c
Normal file
2694
mozilla/js/jsd/java/jsd_jntv.c
Normal file
File diff suppressed because it is too large
Load Diff
349
mozilla/js/jsd/java/jsd_jvm.c
Normal file
349
mozilla/js/jsd/java/jsd_jvm.c
Normal file
@@ -0,0 +1,349 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Sun Microsystems, Inc.
|
||||
* Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*
|
||||
* Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved.
|
||||
*
|
||||
* Sun grants you ("Licensee") a non-exclusive, royalty free, license to use,
|
||||
* modify and redistribute this software in source and binary code form,
|
||||
* provided that i) this copyright notice and license appear on all copies of
|
||||
* the software; and ii) Licensee does not utilize the software in a manner
|
||||
* which is disparaging to Sun.
|
||||
*
|
||||
* This software is provided "AS IS," without a warranty of any kind. ALL
|
||||
* EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY
|
||||
* IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
|
||||
* NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE
|
||||
* LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
|
||||
* OR DISTRIBUTING THE SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS
|
||||
* LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT,
|
||||
* INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
|
||||
* CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF
|
||||
* OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGES.
|
||||
*
|
||||
* This software is not designed or intended for use in on-line control of
|
||||
* aircraft, air traffic, aircraft navigation or aircraft communications; or in
|
||||
* the design, construction, operation or maintenance of any nuclear
|
||||
* facility. Licensee represents and warrants that it will not use or
|
||||
* redistribute the Software for such purposes.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Code to start a Java VM (*some* code from the JRE)
|
||||
*/
|
||||
|
||||
#include "jsdj.h"
|
||||
|
||||
/***************************************************************************/
|
||||
#ifdef JSD_STANDALONE_JAVA_VM
|
||||
#include "jre.h"
|
||||
|
||||
static char* more_classpath[] =
|
||||
{
|
||||
{"..\\..\\jsdj\\dist\\classes"},
|
||||
{"..\\..\\jsdj\\dist\\classes\\ifc11.jar"},
|
||||
|
||||
/*
|
||||
* {"..\\..\\..\\jsdj\\dist\\classes"},
|
||||
* {"..\\..\\..\\jsdj\\dist\\classes\\ifc12.jar"},
|
||||
*/
|
||||
|
||||
/*
|
||||
* {"..\\..\\samples\\jslogger"},
|
||||
* {"classes"},
|
||||
* {"ifc12.jar"},
|
||||
* {"jsd10.jar"},
|
||||
* {"jsdeb15.jar"}
|
||||
*/
|
||||
};
|
||||
#define MORE_CLASSPATH_COUNT (sizeof(more_classpath)/sizeof(more_classpath[0]))
|
||||
|
||||
/*
|
||||
* static char main_class[] = "callnative";
|
||||
* static char main_class[] = "simpleIFC";
|
||||
* static char* params[] = {"16 Dec 1997"};
|
||||
* #define PARAM_COUNT (sizeof(params)/sizeof(params[0]))
|
||||
*/
|
||||
|
||||
/*
|
||||
* static char main_class[] = "netscape/jslogger/JSLogger";
|
||||
* static char main_class[] = "LaunchJSDebugger";
|
||||
*/
|
||||
static char main_class[] = "com/netscape/jsdebugging/ifcui/launcher/local/LaunchJSDebugger";
|
||||
static char* params[] = {NULL};
|
||||
#define PARAM_COUNT 0
|
||||
|
||||
/* Globals */
|
||||
static char **props; /* User-defined properties */
|
||||
static int numProps, maxProps; /* Current, max number of properties */
|
||||
|
||||
static void *handle;
|
||||
static JavaVM *jvm;
|
||||
static JNIEnv *env;
|
||||
|
||||
/* Check for null value and return */
|
||||
#define NULL_CHECK(e) if ((e) == 0) return 0
|
||||
|
||||
/*
|
||||
* Adds a user-defined system property definition.
|
||||
*/
|
||||
void AddProperty(char *def)
|
||||
{
|
||||
if (numProps >= maxProps) {
|
||||
if (props == 0) {
|
||||
maxProps = 4;
|
||||
props = JRE_Malloc(maxProps * sizeof(char **));
|
||||
} else {
|
||||
char **tmp;
|
||||
maxProps *= 2;
|
||||
tmp = JRE_Malloc(maxProps * sizeof(char **));
|
||||
memcpy(tmp, props, numProps * sizeof(char **));
|
||||
free(props);
|
||||
props = tmp;
|
||||
}
|
||||
}
|
||||
props[numProps++] = def;
|
||||
}
|
||||
|
||||
/*
|
||||
* Deletes a property definition by name.
|
||||
*/
|
||||
void DeleteProperty(const char *name)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < numProps; ) {
|
||||
char *def = props[i];
|
||||
char *c = strchr(def, '=');
|
||||
int n;
|
||||
if (c != 0) {
|
||||
n = c - def;
|
||||
} else {
|
||||
n = strlen(def);
|
||||
}
|
||||
if (strncmp(name, def, n) == 0) {
|
||||
if (i < --numProps) {
|
||||
memmove(&props[i], &props[i+1], (numProps-i) * sizeof(char **));
|
||||
}
|
||||
} else {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Creates an array of Java string objects from the specified array of C
|
||||
* strings. Returns 0 if the array could not be created.
|
||||
*/
|
||||
jarray NewStringArray(JNIEnv *env, char **cpp, int count)
|
||||
{
|
||||
jclass cls;
|
||||
jarray ary;
|
||||
int i;
|
||||
|
||||
NULL_CHECK(cls = (*env)->FindClass(env, "java/lang/String"));
|
||||
NULL_CHECK(ary = (*env)->NewObjectArray(env, count, cls, 0));
|
||||
for (i = 0; i < count; i++) {
|
||||
jstring str = (*env)->NewStringUTF(env, *cpp++);
|
||||
NULL_CHECK(str);
|
||||
(*env)->SetObjectArrayElement(env, ary, i, str);
|
||||
(*env)->DeleteLocalRef(env, str);
|
||||
}
|
||||
return ary;
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
static JNIEnv*
|
||||
_CreateJavaVM(void)
|
||||
{
|
||||
JNIEnv* env = NULL;
|
||||
JDK1_1InitArgs vmargs;
|
||||
JRESettings set;
|
||||
|
||||
printf("Starting Java...\n");
|
||||
|
||||
if(JRE_GetCurrentSettings(&set) != 0)
|
||||
{
|
||||
if(JRE_GetDefaultSettings(&set) != 0)
|
||||
{
|
||||
fprintf(stderr, "Could not locate Java runtime\n");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/* Load runtime library */
|
||||
handle = JRE_LoadLibrary(set.runtimeLib);
|
||||
if (handle == 0) {
|
||||
fprintf(stderr, "Could not load runtime library: %s\n",
|
||||
set.runtimeLib);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Add pre-defined system properties */
|
||||
if (set.javaHome != 0) {
|
||||
char *def = JRE_Malloc(strlen(set.javaHome) + 16);
|
||||
sprintf(def, "java.home=%s", set.javaHome);
|
||||
AddProperty(def);
|
||||
}
|
||||
|
||||
if (set.compiler != 0) {
|
||||
char *def = JRE_Malloc(strlen(set.compiler) + 16);
|
||||
sprintf(def, "java.compiler=%s", set.compiler);
|
||||
AddProperty(def);
|
||||
}
|
||||
|
||||
/*
|
||||
* The following is used to specify that we require at least
|
||||
* JNI version 1.1. Currently, this field is not checked but
|
||||
* will be starting with JDK/JRE 1.2. The value returned after
|
||||
* calling JNI_GetDefaultJavaVMInitArgs() is the actual JNI version
|
||||
* supported, and is always higher that the requested version.
|
||||
*/
|
||||
vmargs.version = 0x00010001;
|
||||
|
||||
if (JRE_GetDefaultJavaVMInitArgs(handle, &vmargs) != 0) {
|
||||
fprintf(stderr, "Could not initialize Java VM\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Tack on our classpath */
|
||||
if(MORE_CLASSPATH_COUNT)
|
||||
{
|
||||
int i;
|
||||
int size = strlen(set.classPath) + 1;
|
||||
char sep[2];
|
||||
|
||||
sep[0] = PATH_SEPARATOR;
|
||||
sep[1] = 0;
|
||||
|
||||
for(i = 0; i < MORE_CLASSPATH_COUNT; i++)
|
||||
size += strlen(more_classpath[i]) + 1;
|
||||
|
||||
vmargs.classpath = malloc(size);
|
||||
if(vmargs.classpath == 0)
|
||||
{
|
||||
fprintf(stderr, "malloc error\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
strcpy(vmargs.classpath, set.classPath);
|
||||
for(i = 0; i < MORE_CLASSPATH_COUNT; i++)
|
||||
{
|
||||
strcat(vmargs.classpath, sep);
|
||||
strcat(vmargs.classpath, more_classpath[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
vmargs.classpath = set.classPath;
|
||||
}
|
||||
|
||||
/*
|
||||
* fprintf(stderr, "classpath: %s\n", vmargs.classpath);
|
||||
*/
|
||||
|
||||
/* Set user-defined system properties for Java VM */
|
||||
if (props != 0) {
|
||||
if (numProps == maxProps) {
|
||||
char **tmp = JRE_Malloc((numProps + 1) * sizeof(char **));
|
||||
memcpy(tmp, props, numProps * sizeof(char **));
|
||||
free(props);
|
||||
props = tmp;
|
||||
}
|
||||
props[numProps] = 0;
|
||||
vmargs.properties = props;
|
||||
}
|
||||
|
||||
|
||||
/* verbose? */
|
||||
/*
|
||||
* vmargs.verbose = JNI_TRUE;
|
||||
*/
|
||||
|
||||
/* Load and initialize Java VM */
|
||||
if (JRE_CreateJavaVM(handle, &jvm, &env, &vmargs) != 0) {
|
||||
fprintf(stderr, "Could not create Java VM\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Free properties */
|
||||
if (props != 0) {
|
||||
free(props);
|
||||
}
|
||||
return env;
|
||||
}
|
||||
|
||||
static JSBool
|
||||
_StartDebuggerFE(JNIEnv* env)
|
||||
{
|
||||
jclass clazz;
|
||||
jmethodID mid;
|
||||
jarray args;
|
||||
|
||||
/* Find class */
|
||||
clazz = (*env)->FindClass(env, main_class);
|
||||
if (clazz == 0) {
|
||||
fprintf(stderr, "Class not found: %s\n", main_class);
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
/* Find main method of class */
|
||||
mid = (*env)->GetStaticMethodID(env, clazz, "main",
|
||||
"([Ljava/lang/String;)V");
|
||||
if (mid == 0) {
|
||||
fprintf(stderr, "In class %s: public static void main(String args[])"
|
||||
" is not defined\n");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
/* Invoke main method */
|
||||
args = NewStringArray(env, params, PARAM_COUNT);
|
||||
|
||||
if (args == 0) {
|
||||
JRE_FatalError(env, "Couldn't build argument list for main\n");
|
||||
}
|
||||
(*env)->CallStaticVoidMethod(env, clazz, mid, args);
|
||||
if ((*env)->ExceptionOccurred(env)) {
|
||||
(*env)->ExceptionDescribe(env);
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JNIEnv*
|
||||
jsdj_CreateJavaVMAndStartDebugger(JSDJContext* jsdjc)
|
||||
{
|
||||
JNIEnv* env = NULL;
|
||||
|
||||
env = _CreateJavaVM();
|
||||
if( ! env )
|
||||
return NULL;
|
||||
|
||||
jsdj_SetJNIEnvForCurrentThread(jsdjc, env);
|
||||
if( ! jsdj_RegisterNatives(jsdjc) )
|
||||
return NULL;
|
||||
if( ! _StartDebuggerFE(env) )
|
||||
return NULL;
|
||||
|
||||
return env;
|
||||
}
|
||||
|
||||
|
||||
#endif /* JSD_STANDALONE_JAVA_VM */
|
||||
/***************************************************************************/
|
||||
|
||||
147
mozilla/js/jsd/java/jsdj.h
Normal file
147
mozilla/js/jsd/java/jsdj.h
Normal file
@@ -0,0 +1,147 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Header for JavaScript Debugger JNI support (internal functions)
|
||||
*/
|
||||
|
||||
#ifndef jsdj_h___
|
||||
#define jsdj_h___
|
||||
|
||||
/* Get jstypes.h included first. After that we can use PR macros for doing
|
||||
* this extern "C" stuff!
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
#include "jstypes.h"
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
JS_BEGIN_EXTERN_C
|
||||
#include "jsutil.h" /* Added by JSIFY */
|
||||
#include "jshash.h" /* Added by JSIFY */
|
||||
#include "jsdjava.h"
|
||||
#include "jsobj.h"
|
||||
#include "jsfun.h"
|
||||
#include "jsdbgapi.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
JS_END_EXTERN_C
|
||||
|
||||
JS_BEGIN_EXTERN_C
|
||||
|
||||
/***************************************************************************/
|
||||
/* defines copied from Java sources.
|
||||
** NOTE: javah used to put these in the h files, but with JNI does not seem
|
||||
** to do this anymore. Be careful with synchronization of these
|
||||
**
|
||||
*/
|
||||
|
||||
/* From: ThreadStateBase.java */
|
||||
|
||||
#define THR_STATUS_UNKNOWN 0x01
|
||||
#define THR_STATUS_ZOMBIE 0x02
|
||||
#define THR_STATUS_RUNNING 0x03
|
||||
#define THR_STATUS_SLEEPING 0x04
|
||||
#define THR_STATUS_MONWAIT 0x05
|
||||
#define THR_STATUS_CONDWAIT 0x06
|
||||
#define THR_STATUS_SUSPENDED 0x07
|
||||
#define THR_STATUS_BREAK 0x08
|
||||
|
||||
#define DEBUG_STATE_DEAD 0x01
|
||||
#define DEBUG_STATE_RUN 0x02
|
||||
#define DEBUG_STATE_RETURN 0x03
|
||||
#define DEBUG_STATE_THROW 0x04
|
||||
|
||||
/***************************************************************************/
|
||||
/* Our structures */
|
||||
|
||||
typedef struct JSDJContext
|
||||
{
|
||||
JSDContext* jsdc;
|
||||
JSHashTable* envTable;
|
||||
jobject controller;
|
||||
JSDJ_UserCallbacks callbacks;
|
||||
void* user;
|
||||
JSBool ownJSDC;
|
||||
} JSDJContext;
|
||||
|
||||
/***************************************************************************/
|
||||
/* Code validation support */
|
||||
|
||||
#ifdef DEBUG
|
||||
extern void JSDJ_ASSERT_VALID_CONTEXT(JSDJContext* jsdjc);
|
||||
#else
|
||||
#define JSDJ_ASSERT_VALID_CONTEXT(x) ((void)0)
|
||||
#endif
|
||||
|
||||
/***************************************************************************/
|
||||
/* higher level functions */
|
||||
|
||||
extern JSDJContext*
|
||||
jsdj_SimpleInitForSingleContextMode(JSDContext* jsdc,
|
||||
JSDJ_GetJNIEnvProc getEnvProc, void* user);
|
||||
extern JSBool
|
||||
jsdj_SetSingleContextMode();
|
||||
|
||||
extern JSDJContext*
|
||||
jsdj_CreateContext();
|
||||
|
||||
extern void
|
||||
jsdj_DestroyContext(JSDJContext* jsdjc);
|
||||
|
||||
extern void
|
||||
jsdj_SetUserCallbacks(JSDJContext* jsdjc, JSDJ_UserCallbacks* callbacks,
|
||||
void* user);
|
||||
extern void
|
||||
jsdj_SetJNIEnvForCurrentThread(JSDJContext* jsdjc, JNIEnv* env);
|
||||
|
||||
extern JNIEnv*
|
||||
jsdj_GetJNIEnvForCurrentThread(JSDJContext* jsdjc);
|
||||
|
||||
extern void
|
||||
jsdj_SetJSDContext(JSDJContext* jsdjc, JSDContext* jsdc);
|
||||
|
||||
extern JSDContext*
|
||||
jsdj_GetJSDContext(JSDJContext* jsdjc);
|
||||
|
||||
extern JSBool
|
||||
jsdj_RegisterNatives(JSDJContext* jsdjc);
|
||||
|
||||
/***************************************************************************/
|
||||
#ifdef JSD_STANDALONE_JAVA_VM
|
||||
|
||||
extern JNIEnv*
|
||||
jsdj_CreateJavaVMAndStartDebugger(JSDJContext* jsdjc);
|
||||
|
||||
/**
|
||||
* extern JNIEnv*
|
||||
* jsdj_CreateJavaVM(JSDContext* jsdc);
|
||||
*/
|
||||
|
||||
#endif /* JSD_STANDALONE_JAVA_VM */
|
||||
/***************************************************************************/
|
||||
|
||||
JS_END_EXTERN_C
|
||||
|
||||
#endif /* jsdj_h___ */
|
||||
|
||||
110
mozilla/js/jsd/java/jsdjava.c
Normal file
110
mozilla/js/jsd/java/jsdjava.c
Normal file
@@ -0,0 +1,110 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Public functions to reflect JSD into Java
|
||||
*/
|
||||
|
||||
#include "jsdj.h"
|
||||
|
||||
JSDJ_PUBLIC_API(JSDJContext*)
|
||||
JSDJ_SimpleInitForSingleContextMode(JSDContext* jsdc,
|
||||
JSDJ_GetJNIEnvProc getEnvProc, void* user)
|
||||
{
|
||||
return jsdj_SimpleInitForSingleContextMode(jsdc, getEnvProc, user);
|
||||
}
|
||||
|
||||
JSDJ_PUBLIC_API(JSBool)
|
||||
JSDJ_SetSingleContextMode()
|
||||
{
|
||||
return jsdj_SetSingleContextMode();
|
||||
}
|
||||
|
||||
JSDJ_PUBLIC_API(JSDJContext*)
|
||||
JSDJ_CreateContext()
|
||||
{
|
||||
return jsdj_CreateContext();
|
||||
}
|
||||
|
||||
JSDJ_PUBLIC_API(void)
|
||||
JSDJ_DestroyContext(JSDJContext* jsdjc)
|
||||
{
|
||||
JSDJ_ASSERT_VALID_CONTEXT(jsdjc);
|
||||
jsdj_DestroyContext(jsdjc);
|
||||
}
|
||||
|
||||
JSDJ_PUBLIC_API(void)
|
||||
JSDJ_SetUserCallbacks(JSDJContext* jsdjc, JSDJ_UserCallbacks* callbacks,
|
||||
void* user)
|
||||
{
|
||||
JSDJ_ASSERT_VALID_CONTEXT(jsdjc);
|
||||
JS_ASSERT(!callbacks ||
|
||||
(callbacks->size > 0 &&
|
||||
callbacks->size <= sizeof(JSDJ_UserCallbacks)));
|
||||
jsdj_SetUserCallbacks(jsdjc, callbacks, user);
|
||||
}
|
||||
|
||||
JSDJ_PUBLIC_API(void)
|
||||
JSDJ_SetJNIEnvForCurrentThread(JSDJContext* jsdjc, JNIEnv* env)
|
||||
{
|
||||
JSDJ_ASSERT_VALID_CONTEXT(jsdjc);
|
||||
JS_ASSERT(env);
|
||||
jsdj_SetJNIEnvForCurrentThread(jsdjc, env);
|
||||
}
|
||||
|
||||
JSDJ_PUBLIC_API(JNIEnv*)
|
||||
JSDJ_GetJNIEnvForCurrentThread(JSDJContext* jsdjc)
|
||||
{
|
||||
JSDJ_ASSERT_VALID_CONTEXT(jsdjc);
|
||||
return jsdj_GetJNIEnvForCurrentThread(jsdjc);
|
||||
}
|
||||
|
||||
JSDJ_PUBLIC_API(void)
|
||||
JSDJ_SetJSDContext(JSDJContext* jsdjc, JSDContext* jsdc)
|
||||
{
|
||||
JSDJ_ASSERT_VALID_CONTEXT(jsdjc);
|
||||
JS_ASSERT(jsdc);
|
||||
jsdj_SetJSDContext(jsdjc, jsdc);
|
||||
}
|
||||
|
||||
JSDJ_PUBLIC_API(JSDContext*)
|
||||
JSDJ_GetJSDContext(JSDJContext* jsdjc)
|
||||
{
|
||||
JSDJ_ASSERT_VALID_CONTEXT(jsdjc);
|
||||
return jsdj_GetJSDContext(jsdjc);
|
||||
}
|
||||
|
||||
JSDJ_PUBLIC_API(JSBool)
|
||||
JSDJ_RegisterNatives(JSDJContext* jsdjc)
|
||||
{
|
||||
JSDJ_ASSERT_VALID_CONTEXT(jsdjc);
|
||||
return jsdj_RegisterNatives(jsdjc);
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
#ifdef JSD_STANDALONE_JAVA_VM
|
||||
|
||||
JSDJ_PUBLIC_API(JNIEnv*)
|
||||
JSDJ_CreateJavaVMAndStartDebugger(JSDJContext* jsdjc)
|
||||
{
|
||||
JSDJ_ASSERT_VALID_CONTEXT(jsdjc);
|
||||
return jsdj_CreateJavaVMAndStartDebugger(jsdjc);
|
||||
}
|
||||
|
||||
#endif /* JSD_STANDALONE_JAVA_VM */
|
||||
/***************************************************************************/
|
||||
133
mozilla/js/jsd/java/jsdjava.h
Normal file
133
mozilla/js/jsd/java/jsdjava.h
Normal file
@@ -0,0 +1,133 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Header for JavaScript Debugger JNI interfaces
|
||||
*/
|
||||
|
||||
#ifndef jsdjava_h___
|
||||
#define jsdjava_h___
|
||||
|
||||
/* Get jstypes.h included first. After that we can use PR macros for doing
|
||||
* this extern "C" stuff!
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
#include "jstypes.h"
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
JS_BEGIN_EXTERN_C
|
||||
#include "jsdebug.h"
|
||||
#include "jni.h"
|
||||
JS_END_EXTERN_C
|
||||
|
||||
|
||||
JS_BEGIN_EXTERN_C
|
||||
|
||||
/*
|
||||
* The linkage of JSDJ API functions differs depending on whether the file is
|
||||
* used within the JSDJ library or not. Any source file within the JSDJ
|
||||
* libraray should define EXPORT_JSDJ_API whereas any client of the library
|
||||
* should not.
|
||||
*/
|
||||
#ifdef EXPORT_JSDJ_API
|
||||
#define JSDJ_PUBLIC_API(t) JS_EXPORT_API(t)
|
||||
#define JSDJ_PUBLIC_DATA(t) JS_EXPORT_DATA(t)
|
||||
#else
|
||||
#define JSDJ_PUBLIC_API(t) JS_IMPORT_API(t)
|
||||
#define JSDJ_PUBLIC_DATA(t) JS_IMPORT_DATA(t)
|
||||
#endif
|
||||
|
||||
#define JSDJ_FRIEND_API(t) JSDJ_PUBLIC_API(t)
|
||||
#define JSDJ_FRIEND_DATA(t) JSDJ_PUBLIC_DATA(t)
|
||||
|
||||
/***************************************************************************/
|
||||
/* Opaque typedefs for handles */
|
||||
|
||||
typedef struct JSDJContext JSDJContext;
|
||||
|
||||
/***************************************************************************/
|
||||
/* High Level functions */
|
||||
|
||||
#define JSDJ_START_SUCCESS 1
|
||||
#define JSDJ_START_FAILURE 2
|
||||
#define JSDJ_STOP 3
|
||||
|
||||
typedef void
|
||||
(*JSDJ_StartStopProc)(JSDJContext* jsdjc, int event, void *user);
|
||||
|
||||
typedef JNIEnv*
|
||||
(*JSDJ_GetJNIEnvProc)(JSDJContext* jsdjc, void* user);
|
||||
|
||||
/* This struct could have more fields in future versions */
|
||||
typedef struct
|
||||
{
|
||||
uintN size; /* size of this struct (init before use)*/
|
||||
JSDJ_StartStopProc startStop;
|
||||
JSDJ_GetJNIEnvProc getJNIEnv;
|
||||
} JSDJ_UserCallbacks;
|
||||
|
||||
extern JSDJ_PUBLIC_API(JSDJContext*)
|
||||
JSDJ_SimpleInitForSingleContextMode(JSDContext* jsdc,
|
||||
JSDJ_GetJNIEnvProc getEnvProc, void* user);
|
||||
|
||||
extern JSDJ_PUBLIC_API(JSBool)
|
||||
JSDJ_SetSingleContextMode();
|
||||
|
||||
extern JSDJ_PUBLIC_API(JSDJContext*)
|
||||
JSDJ_CreateContext();
|
||||
|
||||
extern JSDJ_PUBLIC_API(void)
|
||||
JSDJ_DestroyContext(JSDJContext* jsdjc);
|
||||
|
||||
extern JSDJ_PUBLIC_API(void)
|
||||
JSDJ_SetUserCallbacks(JSDJContext* jsdjc, JSDJ_UserCallbacks* callbacks,
|
||||
void* user);
|
||||
|
||||
extern JSDJ_PUBLIC_API(void)
|
||||
JSDJ_SetJNIEnvForCurrentThread(JSDJContext* jsdjc, JNIEnv* env);
|
||||
|
||||
extern JSDJ_PUBLIC_API(JNIEnv*)
|
||||
JSDJ_GetJNIEnvForCurrentThread(JSDJContext* jsdjc);
|
||||
|
||||
extern JSDJ_PUBLIC_API(void)
|
||||
JSDJ_SetJSDContext(JSDJContext* jsdjc, JSDContext* jsdc);
|
||||
|
||||
extern JSDJ_PUBLIC_API(JSDContext*)
|
||||
JSDJ_GetJSDContext(JSDJContext* jsdjc);
|
||||
|
||||
extern JSDJ_PUBLIC_API(JSBool)
|
||||
JSDJ_RegisterNatives(JSDJContext* jsdjc);
|
||||
|
||||
/***************************************************************************/
|
||||
#ifdef JSD_STANDALONE_JAVA_VM
|
||||
|
||||
extern JSDJ_PUBLIC_API(JNIEnv*)
|
||||
JSDJ_CreateJavaVMAndStartDebugger(JSDJContext* jsdjc);
|
||||
|
||||
#endif /* JSD_STANDALONE_JAVA_VM */
|
||||
/***************************************************************************/
|
||||
|
||||
JS_END_EXTERN_C
|
||||
|
||||
#endif /* jsdjava_h___ */
|
||||
|
||||
78
mozilla/js/jsd/java/jsdjava.mak
Normal file
78
mozilla/js/jsd/java/jsdjava.mak
Normal file
@@ -0,0 +1,78 @@
|
||||
|
||||
PROJ = jsdjava
|
||||
JSDJAVA = .
|
||||
JSD = $(JSDJAVA)\..
|
||||
JS = $(JSD)\..\src
|
||||
JSPROJ = js32
|
||||
JSDPROJ = jsd
|
||||
|
||||
!IF "$(BUILD_OPT)" != ""
|
||||
OBJ = Release
|
||||
CC_FLAGS = /DNDEBUG
|
||||
!ELSE
|
||||
OBJ = Debug
|
||||
CC_FLAGS = /DDEBUG
|
||||
LINK_FLAGS = /DEBUG
|
||||
!ENDIF
|
||||
|
||||
QUIET=@
|
||||
|
||||
CFLAGS = /nologo /MDd /W3 /Gm /GX /Zi /Od\
|
||||
/I $(JS)\
|
||||
/I $(JSD)\
|
||||
/I $(JSDJAVA)\
|
||||
/DDEBUG /DWIN32 /DXP_PC /D_WINDOWS /D_WIN32\
|
||||
/DJSD_THREADSAFE\
|
||||
/DEXPORT_JSDJ_API\
|
||||
/DJSDEBUGGER\
|
||||
!IF "$(JSD_STANDALONE_JAVA_VM)" != ""
|
||||
/I $(JSDJAVA)\jre\
|
||||
/I $(JSDJAVA)\jre\win32\
|
||||
/DJSD_STANDALONE_JAVA_VM\
|
||||
!ENDIF
|
||||
$(CC_FLAGS)\
|
||||
/c /Fp$(OBJ)\$(PROJ).pch /Fd$(OBJ)\$(PROJ).pdb /YX -Fo$@ $<
|
||||
|
||||
LFLAGS = /nologo /subsystem:console /DLL /incremental:no /machine:I386 \
|
||||
$(LINK_FLAGS) /pdb:$(OBJ)\$(PROJ).pdb -out:$(OBJ)\$(PROJ).dll
|
||||
|
||||
LLIBS = kernel32.lib advapi32.lib \
|
||||
$(JS)\$(OBJ)\$(JSPROJ).lib $(JSD)\$(OBJ)\$(JSDPROJ).lib
|
||||
|
||||
CPP=cl.exe
|
||||
LINK32=link.exe
|
||||
|
||||
all: $(OBJ) $(OBJ)\$(PROJ).dll
|
||||
|
||||
|
||||
$(OBJ)\$(PROJ).dll: \
|
||||
!IF "$(JSD_STANDALONE_JAVA_VM)" != ""
|
||||
$(OBJ)\jsd_jvm.obj \
|
||||
$(OBJ)\jre.obj \
|
||||
$(OBJ)\jre_md.obj \
|
||||
!ENDIF
|
||||
$(OBJ)\jsdjava.obj \
|
||||
$(OBJ)\jsd_jntv.obj
|
||||
$(QUIET)$(LINK32) $(LFLAGS) $** $(LLIBS)
|
||||
|
||||
{$(JSDJAVA)}.c{$(OBJ)}.obj :
|
||||
$(QUIET)$(CPP) $(CFLAGS)
|
||||
|
||||
{$(JSDJAVA)\jre}.c{$(OBJ)}.obj :
|
||||
$(QUIET)$(CPP) $(CFLAGS)
|
||||
|
||||
{$(JSDJAVA)\jre\win32}.c{$(OBJ)}.obj :
|
||||
$(QUIET)$(CPP) $(CFLAGS)
|
||||
|
||||
$(OBJ) :
|
||||
$(QUIET)mkdir $(OBJ)
|
||||
|
||||
clean:
|
||||
@echo deleting old output
|
||||
$(QUIET)del $(OBJ)\*.pch >NUL
|
||||
$(QUIET)del $(OBJ)\*.obj >NUL
|
||||
$(QUIET)del $(OBJ)\*.exp >NUL
|
||||
$(QUIET)del $(OBJ)\*.lib >NUL
|
||||
$(QUIET)del $(OBJ)\*.idb >NUL
|
||||
$(QUIET)del $(OBJ)\*.pdb >NUL
|
||||
$(QUIET)del $(OBJ)\*.dll >NUL
|
||||
147
mozilla/js/jsd/javawrap/javawrap.mak
Normal file
147
mozilla/js/jsd/javawrap/javawrap.mak
Normal file
@@ -0,0 +1,147 @@
|
||||
|
||||
PROJ = nativejsengine
|
||||
PACKAGE_DOT = com.netscape.nativejsengine
|
||||
|
||||
NJSE = .
|
||||
TESTS = $(NJSE)\tests
|
||||
GEN = $(NJSE)\_jni
|
||||
JSD = $(NJSE)\..
|
||||
JS = $(JSD)\..\src
|
||||
JSDJAVA = $(JSD)\java
|
||||
|
||||
JSPROJ = js32
|
||||
JSDPROJ = jsd
|
||||
JSDJAVAPROJ = jsdjava
|
||||
|
||||
EXPORT_BIN_BASE_DIR = $(NJSE)\..\..\jsdj\dist\bin
|
||||
EXPORT_CLASSES_BASE_DIR = $(NJSE)\..\..\jsdj\dist\classes
|
||||
|
||||
!IF "$(BUILD_OPT)" != ""
|
||||
OBJ = Release
|
||||
CC_FLAGS = /DNDEBUG
|
||||
!ELSE
|
||||
OBJ = Debug
|
||||
CC_FLAGS = /DDEBUG
|
||||
LINK_FLAGS = /DEBUG
|
||||
!ENDIF
|
||||
|
||||
QUIET=@
|
||||
|
||||
EXPORT_BIN_DIR = $(EXPORT_BIN_BASE_DIR)\$(OBJ)
|
||||
|
||||
STD_CLASSPATH = -classpath $(EXPORT_CLASSES_BASE_DIR);$(CLASSPATH)
|
||||
|
||||
CFLAGS = /nologo /MDd /W3 /Gm /GX /Zi /Od\
|
||||
/DWIN32 /DXP_PC /D_WINDOWS /D_WIN32\
|
||||
/I $(JS)\
|
||||
/I $(JSD)\
|
||||
/I $(JSDJAVA)\
|
||||
/DJSDEBUGGER\
|
||||
/DJSD_THREADSAFE\
|
||||
$(CC_FLAGS)\
|
||||
/c /Fp$(OBJ)\$(PROJ).pch /Fd$(OBJ)\$(PROJ).pdb /YX -Fo$@ $<
|
||||
|
||||
LFLAGS = /nologo /subsystem:console /incremental:no /DLL /machine:I386 \
|
||||
$(LINK_FLAGS) /pdb:$(OBJ)\$(PROJ).pdb -out:$(OBJ)\$(PROJ).dll
|
||||
|
||||
LLIBS = kernel32.lib advapi32.lib \
|
||||
$(JS)\$(OBJ)\$(JSPROJ).lib \
|
||||
$(JSD)\$(OBJ)\$(JSDPROJ).lib \
|
||||
$(JSDJAVA)\$(OBJ)\$(JSDJAVAPROJ).lib
|
||||
|
||||
CPP=cl.exe
|
||||
LINK32=link.exe
|
||||
|
||||
CLASSES_WITH_NATIVES = \
|
||||
$(PACKAGE_DOT).JSRuntime\
|
||||
$(PACKAGE_DOT).JSContext
|
||||
|
||||
|
||||
all: $(GEN) $(OBJ) dlls mkjniheaders $(OBJ)\$(PROJ).dll export_binaries
|
||||
|
||||
$(OBJ)\$(PROJ).dll: \
|
||||
$(OBJ)\nativejsengine.obj
|
||||
$(QUIET)$(LINK32) $(LFLAGS) $** $(LLIBS)
|
||||
|
||||
.c{$(OBJ)}.obj:
|
||||
$(QUIET)$(CPP) $(CFLAGS)
|
||||
|
||||
$(GEN) :
|
||||
@mkdir $(GEN)
|
||||
|
||||
$(OBJ) :
|
||||
@mkdir $(OBJ)
|
||||
|
||||
dlls :
|
||||
$(QUIET)cd ..\..\src
|
||||
!IF "$(BUILD_OPT)" != ""
|
||||
$(QUIET)nmake -f js.mak CFG="js - Win32 Release"
|
||||
!ELSE
|
||||
$(QUIET)nmake -f js.mak CFG="js - Win32 Debug"
|
||||
!ENDIF
|
||||
$(QUIET)cd ..\jsd\javawrap
|
||||
$(QUIET)cd ..
|
||||
$(QUIET)nmake -f jsd.mak JSD_THREADSAFE=1 $(OPT)
|
||||
$(QUIET)cd javawrap
|
||||
$(QUIET)cd ..\java
|
||||
$(QUIET)nmake -f jsdjava.mak $(OPT)
|
||||
$(QUIET)cd ..\javawrap
|
||||
|
||||
|
||||
export_binaries : mk_export_dirs
|
||||
@echo exporting binaries
|
||||
$(QUIET)copy $(JS)\$(OBJ)\$(JSPROJ).dll $(EXPORT_BIN_DIR) >NUL
|
||||
$(QUIET)copy $(JS)\$(OBJ)\$(JSPROJ).pdb $(EXPORT_BIN_DIR) >NUL
|
||||
$(QUIET)copy $(JSD)\$(OBJ)\$(JSDPROJ).dll $(EXPORT_BIN_DIR) >NUL
|
||||
$(QUIET)copy $(JSD)\$(OBJ)\$(JSDPROJ).pdb $(EXPORT_BIN_DIR) >NUL
|
||||
$(QUIET)copy $(JSDJAVA)\$(OBJ)\$(JSDJAVAPROJ).dll $(EXPORT_BIN_DIR) >NUL
|
||||
$(QUIET)copy $(JSDJAVA)\$(OBJ)\$(JSDJAVAPROJ).pdb $(EXPORT_BIN_DIR) >NUL
|
||||
$(QUIET)copy $(OBJ)\$(PROJ).pdb $(EXPORT_BIN_DIR) >NUL
|
||||
$(QUIET)copy $(OBJ)\$(PROJ).dll $(EXPORT_BIN_DIR) >NUL
|
||||
|
||||
mkjniheaders :
|
||||
@echo generating JNI header
|
||||
$(QUIET)javah -jni -d "$(GEN)" $(STD_CLASSPATH) $(CLASSES_WITH_NATIVES)
|
||||
@touch *.c >NUL
|
||||
|
||||
mk_export_dirs:
|
||||
@if not exist $(JS)\..\jsdj\dist\NUL @mkdir $(JS)\..\jsdj\dist
|
||||
@if not exist $(JS)\..\jsdj\dist\bin\NUL @mkdir $(JS)\..\jsdj\dist\bin
|
||||
@if not exist $(EXPORT_BIN_DIR)\NUL @mkdir $(EXPORT_BIN_DIR)
|
||||
|
||||
#mktest :
|
||||
# @echo compiling Java test file
|
||||
# @sj $(JAVAFLAGS) $(TEST_CLASSPATH) $(TESTS)\Main.java
|
||||
# @echo copying js and jsd dlls
|
||||
# @copy $(JS)\$(OBJ)\$(JSPROJ).dll $(OBJ) >NUL
|
||||
# @copy $(JS)\$(OBJ)\$(JSPROJ).pdb $(OBJ) >NUL
|
||||
# @copy $(JSD)\$(OBJ)\$(JSDPROJ).dll $(OBJ) >NUL
|
||||
# @copy $(JSD)\$(OBJ)\$(JSDPROJ).pdb $(OBJ) >NUL
|
||||
# @copy $(TESTS)\*.js $(OBJ) >NUL
|
||||
|
||||
clean:
|
||||
@echo deleting old output
|
||||
$(QUIET)del $(OBJ)\*.pch >NUL
|
||||
$(QUIET)del $(OBJ)\*.obj >NUL
|
||||
$(QUIET)del $(OBJ)\*.exp >NUL
|
||||
$(QUIET)del $(OBJ)\*.lib >NUL
|
||||
$(QUIET)del $(OBJ)\*.idb >NUL
|
||||
$(QUIET)del $(OBJ)\*.pdb >NUL
|
||||
$(QUIET)del $(OBJ)\*.dll >NUL
|
||||
$(QUIET)del $(GEN)\*.h >NUL
|
||||
|
||||
|
||||
deep_clean: clean
|
||||
$(QUIET)cd ..\..\src
|
||||
!IF "$(BUILD_OPT)" != ""
|
||||
$(QUIET)nmake -f js.mak CFG="js - Win32 Release" clean
|
||||
!ELSE
|
||||
$(QUIET)nmake -f js.mak CFG="js - Win32 Debug" clean
|
||||
!ENDIF
|
||||
$(QUIET)cd ..\jsd\javawrap
|
||||
$(QUIET)cd ..
|
||||
$(QUIET)nmake -f jsd.mak clean
|
||||
$(QUIET)cd javawrap
|
||||
$(QUIET)cd ..\java
|
||||
$(QUIET)nmake -f jsdjava.mak clean
|
||||
$(QUIET)cd ..\javawrap
|
||||
1
mozilla/js/jsd/javawrap/mk.bat
Executable file
1
mozilla/js/jsd/javawrap/mk.bat
Executable file
@@ -0,0 +1 @@
|
||||
nmake -f javawrap.mak %1 %2 %3 %4 %5
|
||||
616
mozilla/js/jsd/javawrap/nativejsengine.c
Normal file
616
mozilla/js/jsd/javawrap/nativejsengine.c
Normal file
@@ -0,0 +1,616 @@
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "_jni/com_netscape_nativejsengine_JSRuntime.h"
|
||||
#include "_jni/com_netscape_nativejsengine_JSContext.h"
|
||||
|
||||
#include "jsapi.h"
|
||||
#include "jstypes.h"
|
||||
#include "jsutil.h" /* Added by JSIFY */
|
||||
|
||||
#ifdef JSDEBUGGER
|
||||
#include "jsdebug.h"
|
||||
#include "jsdjava.h"
|
||||
#endif
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
#define ASSERT_RETURN_VOID(x) \
|
||||
JS_BEGIN_MACRO \
|
||||
if(!(x)) \
|
||||
{ \
|
||||
JS_ASSERT(0); \
|
||||
return; \
|
||||
} \
|
||||
JS_END_MACRO
|
||||
|
||||
#define ASSERT_RETURN_VALUE(x,v)\
|
||||
JS_BEGIN_MACRO \
|
||||
if(!(x)) \
|
||||
{ \
|
||||
JS_ASSERT(0); \
|
||||
return v; \
|
||||
} \
|
||||
JS_END_MACRO
|
||||
|
||||
#define CHECK_RETURN_VOID(x) \
|
||||
JS_BEGIN_MACRO \
|
||||
if(!(x)) \
|
||||
{ \
|
||||
return; \
|
||||
} \
|
||||
JS_END_MACRO
|
||||
|
||||
#define CHECK_RETURN_VALUE(x,v) \
|
||||
JS_BEGIN_MACRO \
|
||||
if(!(x)) \
|
||||
{ \
|
||||
return v; \
|
||||
} \
|
||||
JS_END_MACRO
|
||||
|
||||
#define ASSERT_GOTO(x,w) \
|
||||
JS_BEGIN_MACRO \
|
||||
if(!(x)) \
|
||||
{ \
|
||||
JS_ASSERT(0); \
|
||||
goto w; \
|
||||
} \
|
||||
JS_END_MACRO
|
||||
|
||||
#define CHECK_GOTO(x,w) \
|
||||
JS_BEGIN_MACRO \
|
||||
if(!(x)) \
|
||||
{ \
|
||||
goto w; \
|
||||
} \
|
||||
JS_END_MACRO
|
||||
|
||||
#ifdef DEBUG
|
||||
#define ASSERT_CLEAR_EXCEPTION(e) \
|
||||
JS_BEGIN_MACRO \
|
||||
if((*e)->ExceptionOccurred(e)) \
|
||||
{ \
|
||||
(*e)->ExceptionDescribe(e); \
|
||||
JS_ASSERT(0); \
|
||||
} \
|
||||
(*e)->ExceptionClear(e); \
|
||||
JS_END_MACRO
|
||||
#else /* ! DEBUG */
|
||||
#define ASSERT_CLEAR_EXCEPTION(e) (*e)->ExceptionClear(e)
|
||||
#endif /* DEBUG */
|
||||
|
||||
#define CHECK_CLEAR_EXCEPTION(e) (*e)->ExceptionClear(e)
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
typedef struct ContextInfo {
|
||||
JNIEnv* env;
|
||||
jobject contextObject;
|
||||
} ContextInfo;
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
#ifdef JSDEBUGGER
|
||||
static void
|
||||
_jamSourceIntoJSD(JSContext *cx, const char* src, int len, const char* filename)
|
||||
{
|
||||
jclass clazz_self;
|
||||
jclass clazz;
|
||||
JSDJContext* jsdjc;
|
||||
jobject rtObject;
|
||||
jobject contextObject;
|
||||
jmethodID mid;
|
||||
jfieldID fid;
|
||||
ContextInfo* info;
|
||||
JNIEnv* env;
|
||||
|
||||
info = (ContextInfo*) JS_GetContextPrivate(cx);
|
||||
ASSERT_RETURN_VOID(info);
|
||||
|
||||
env = info->env;
|
||||
ASSERT_RETURN_VOID(env);
|
||||
|
||||
contextObject = info->contextObject;
|
||||
ASSERT_RETURN_VOID(contextObject);
|
||||
|
||||
clazz_self = (*env)->GetObjectClass(env, contextObject);
|
||||
ASSERT_RETURN_VOID(clazz_self);
|
||||
|
||||
fid = (*env)->GetFieldID(env, clazz_self, "_runtime",
|
||||
"Lcom/netscape/nativejsengine/JSRuntime;");
|
||||
ASSERT_RETURN_VOID(fid);
|
||||
|
||||
rtObject = (*env)->GetObjectField(env, contextObject, fid);
|
||||
ASSERT_RETURN_VOID(rtObject);
|
||||
|
||||
clazz = (*env)->GetObjectClass(env, rtObject);
|
||||
ASSERT_RETURN_VOID(clazz);
|
||||
|
||||
mid = (*env)->GetMethodID(env, clazz, "getNativeDebugSupport", "()J");
|
||||
ASSERT_RETURN_VOID(mid);
|
||||
|
||||
jsdjc = (JSDJContext*) (*env)->CallObjectMethod(env, rtObject, mid);
|
||||
if(jsdjc)
|
||||
{
|
||||
JSDContext* jsdc;
|
||||
|
||||
jsdc = JSDJ_GetJSDContext(jsdjc);
|
||||
ASSERT_RETURN_VOID(jsdc);
|
||||
|
||||
JSD_AddFullSourceText(jsdc, src, len, filename);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static JSBool
|
||||
_loadSingleFile(JSContext *cx, JSObject *obj, const char* filename)
|
||||
{
|
||||
char* buf;
|
||||
FILE* file;
|
||||
int file_len;
|
||||
jsval result;
|
||||
|
||||
errno = 0;
|
||||
file = fopen(filename, "rb");
|
||||
if (!file) {
|
||||
JS_ReportError(cx, "can't open %s: %s", filename, strerror(errno));
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
fseek(file, 0, SEEK_END);
|
||||
file_len = ftell(file);
|
||||
fseek(file, 0, SEEK_SET);
|
||||
|
||||
if(! file_len) {
|
||||
fclose(file);
|
||||
JS_ReportError(cx, "%s is empty", filename);
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
buf = (char*) malloc(file_len);
|
||||
if(! buf) {
|
||||
fclose(file);
|
||||
JS_ReportError(cx, "memory alloc error while trying to read %s", filename);
|
||||
return JS_FALSE;
|
||||
}
|
||||
fread(buf, 1, file_len, file);
|
||||
fclose(file);
|
||||
|
||||
#ifdef JSDEBUGGER
|
||||
_jamSourceIntoJSD(cx, buf, file_len, filename);
|
||||
#endif
|
||||
|
||||
JS_EvaluateScript(cx, obj, buf, file_len, filename, 1, &result);
|
||||
|
||||
free(buf);
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
static void _sendPrintStringToJava(JNIEnv* env, jobject contextObject,
|
||||
jmethodID mid, const char* str)
|
||||
{
|
||||
if(! str)
|
||||
return;
|
||||
(*env)->CallObjectMethod(env, contextObject, mid,
|
||||
(*env)->NewStringUTF(env, str));
|
||||
}
|
||||
|
||||
static JSBool
|
||||
Print(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
uintN i, n;
|
||||
JSString *str;
|
||||
|
||||
ContextInfo* info;
|
||||
jmethodID mid;
|
||||
jclass clazz;
|
||||
JNIEnv* env;
|
||||
|
||||
info = (ContextInfo*) JS_GetContextPrivate(cx);
|
||||
ASSERT_RETURN_VALUE(info, JS_FALSE);
|
||||
|
||||
env = info->env;
|
||||
ASSERT_RETURN_VALUE(env, JS_FALSE);
|
||||
|
||||
clazz = (*env)->GetObjectClass(env, info->contextObject);
|
||||
ASSERT_RETURN_VALUE(clazz, JS_FALSE);
|
||||
|
||||
mid = (*env)->GetMethodID(env, clazz, "_print", "(Ljava/lang/String;)V");
|
||||
ASSERT_RETURN_VALUE(mid, JS_FALSE);
|
||||
|
||||
for (i = n = 0; i < argc; i++) {
|
||||
str = JS_ValueToString(cx, argv[i]);
|
||||
if (!str)
|
||||
return JS_FALSE;
|
||||
|
||||
if(i)
|
||||
_sendPrintStringToJava(env, info->contextObject, mid, "");
|
||||
_sendPrintStringToJava(env, info->contextObject, mid, JS_GetStringBytes(str));
|
||||
n++;
|
||||
}
|
||||
if (n)
|
||||
_sendPrintStringToJava(env, info->contextObject, mid, "\n");
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
static JSBool
|
||||
Version(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
if (argc > 0 && JSVAL_IS_INT(argv[0]))
|
||||
*rval = INT_TO_JSVAL(JS_SetVersion(cx, JSVAL_TO_INT(argv[0])));
|
||||
else
|
||||
*rval = INT_TO_JSVAL(JS_GetVersion(cx));
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
static JSBool
|
||||
Load(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
uintN i;
|
||||
JSString *str;
|
||||
const char *filename;
|
||||
|
||||
for (i = 0; i < argc; i++) {
|
||||
str = JS_ValueToString(cx, argv[i]);
|
||||
if (!str)
|
||||
return JS_FALSE;
|
||||
argv[i] = STRING_TO_JSVAL(str);
|
||||
filename = JS_GetStringBytes(str);
|
||||
|
||||
if(! _loadSingleFile(cx, obj, filename))
|
||||
return JS_FALSE;
|
||||
}
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
static JSFunctionSpec shell_functions[] = {
|
||||
{"version", Version, 0},
|
||||
{"load", Load, 1},
|
||||
{"print", Print, 0},
|
||||
{0}
|
||||
};
|
||||
|
||||
static void
|
||||
my_ErrorReporter(JSContext *cx, const char *message, JSErrorReport *report)
|
||||
{
|
||||
ContextInfo* info;
|
||||
jmethodID mid;
|
||||
jclass clazz;
|
||||
JNIEnv* env;
|
||||
|
||||
jobject msg = NULL;
|
||||
jobject filename = NULL;
|
||||
jobject lineBuf = NULL;
|
||||
int lineno = 0;
|
||||
int offset = 0;
|
||||
|
||||
info = (ContextInfo*) JS_GetContextPrivate(cx);
|
||||
ASSERT_RETURN_VOID(info);
|
||||
|
||||
env = info->env;
|
||||
ASSERT_RETURN_VOID(env);
|
||||
|
||||
clazz = (*env)->GetObjectClass(env, info->contextObject);
|
||||
ASSERT_RETURN_VOID(clazz);
|
||||
|
||||
mid = (*env)->GetMethodID(env, clazz, "_reportError",
|
||||
"(Ljava/lang/String;Ljava/lang/String;ILjava/lang/String;I)V");
|
||||
ASSERT_RETURN_VOID(mid);
|
||||
|
||||
|
||||
if(message)
|
||||
msg = (*env)->NewStringUTF(env, message);
|
||||
|
||||
if(report)
|
||||
{
|
||||
lineno = report->lineno;
|
||||
if(report->filename)
|
||||
filename = (*env)->NewStringUTF(env, report->filename);
|
||||
|
||||
if(report->linebuf)
|
||||
{
|
||||
lineBuf = (*env)->NewStringUTF(env, report->linebuf);
|
||||
if(report->tokenptr)
|
||||
offset = report->tokenptr - report->linebuf;
|
||||
}
|
||||
}
|
||||
|
||||
(*env)->CallObjectMethod(env, info->contextObject, mid,
|
||||
msg, filename, lineno, lineBuf, offset);
|
||||
|
||||
}
|
||||
|
||||
static JSClass global_class = {
|
||||
"global", 0,
|
||||
JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
|
||||
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub
|
||||
};
|
||||
|
||||
/*
|
||||
* Class: com_netscape_nativejsengine_JSRuntime
|
||||
* Method: _init
|
||||
* Signature: (Z)Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_com_netscape_nativejsengine_JSRuntime__1init
|
||||
(JNIEnv * env, jobject self, jboolean enableDebugging)
|
||||
{
|
||||
JSRuntime *rt;
|
||||
jclass clazz;
|
||||
jfieldID fid;
|
||||
|
||||
rt = JS_NewRuntime(8L * 1024L * 1024L);
|
||||
ASSERT_RETURN_VALUE(rt, JNI_FALSE);
|
||||
|
||||
clazz = (*env)->GetObjectClass(env, self);
|
||||
ASSERT_RETURN_VALUE(clazz, JNI_FALSE);
|
||||
|
||||
fid = (*env)->GetFieldID(env, clazz, "_nativeRuntime", "J");
|
||||
ASSERT_RETURN_VALUE(fid, JNI_FALSE);
|
||||
(*env)->SetLongField(env, self, fid, (long) rt);
|
||||
|
||||
|
||||
#ifdef JSDEBUGGER
|
||||
if(enableDebugging)
|
||||
{
|
||||
JSDJContext* jsdjc;
|
||||
JSDContext* jsdc;
|
||||
|
||||
jsdc = JSD_DebuggerOnForUser(rt, NULL, NULL);
|
||||
ASSERT_RETURN_VALUE(jsdc, JNI_FALSE);
|
||||
|
||||
jsdjc = JSDJ_CreateContext();
|
||||
ASSERT_RETURN_VALUE(jsdjc, JNI_FALSE);
|
||||
|
||||
JSDJ_SetJSDContext(jsdjc, jsdc);
|
||||
JSDJ_SetJNIEnvForCurrentThread(jsdjc, env);
|
||||
|
||||
fid = (*env)->GetFieldID(env, clazz, "_nativeDebugSupport", "J");
|
||||
ASSERT_RETURN_VALUE(fid, JNI_FALSE);
|
||||
(*env)->SetLongField(env, self, fid, (long) jsdjc);
|
||||
}
|
||||
#else
|
||||
if(enableDebugging)
|
||||
printf("ERROR - Context created with enableDebugging flag, but no debugging support compiled in!");
|
||||
#endif
|
||||
|
||||
return JNI_TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: com_netscape_nativejsengine_JSRuntime
|
||||
* Method: _exit
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_com_netscape_nativejsengine_JSRuntime__1exit
|
||||
(JNIEnv * env, jobject self)
|
||||
{
|
||||
jfieldID fid;
|
||||
jclass clazz;
|
||||
JSRuntime *rt;
|
||||
JSContext *iterp = NULL;
|
||||
|
||||
clazz = (*env)->GetObjectClass(env, self);
|
||||
ASSERT_RETURN_VOID(clazz);
|
||||
|
||||
fid = (*env)->GetFieldID(env, clazz, "_nativeRuntime", "J");
|
||||
ASSERT_RETURN_VOID(fid);
|
||||
rt = (JSRuntime *) (*env)->GetLongField(env, self, fid);
|
||||
ASSERT_RETURN_VOID(rt);
|
||||
|
||||
|
||||
/*
|
||||
* Can't kill runtime if it holds any contexts
|
||||
*
|
||||
* However, JSD may make it's own context(s), so don't ASSERT
|
||||
*/
|
||||
CHECK_RETURN_VOID(!JS_ContextIterator(rt, &iterp));
|
||||
|
||||
printf("runtime = %d\n", (int)rt);
|
||||
|
||||
JS_DestroyRuntime(rt);
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
/*
|
||||
* Class: com_netscape_nativejsengine_JSContext
|
||||
* Method: _init
|
||||
* Signature: ()Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_com_netscape_nativejsengine_JSContext__1init
|
||||
(JNIEnv *env, jobject self)
|
||||
{
|
||||
JSContext *cx;
|
||||
JSObject *glob;
|
||||
jfieldID fid;
|
||||
jmethodID mid;
|
||||
JSRuntime *rt;
|
||||
jobject rtObject;
|
||||
jclass clazz;
|
||||
jclass clazz_self;
|
||||
JSBool ok;
|
||||
ContextInfo* info;
|
||||
|
||||
#ifdef JSDEBUGGER
|
||||
JSDJContext* jsdjc;
|
||||
#endif
|
||||
|
||||
clazz_self = (*env)->GetObjectClass(env, self);
|
||||
ASSERT_RETURN_VALUE(clazz_self, JNI_FALSE);
|
||||
|
||||
fid = (*env)->GetFieldID(env, clazz_self, "_runtime",
|
||||
"Lcom/netscape/nativejsengine/JSRuntime;");
|
||||
ASSERT_RETURN_VALUE(fid, JNI_FALSE);
|
||||
|
||||
rtObject = (*env)->GetObjectField(env, self, fid);
|
||||
ASSERT_RETURN_VALUE(rtObject, JNI_FALSE);
|
||||
|
||||
clazz = (*env)->GetObjectClass(env, rtObject);
|
||||
ASSERT_RETURN_VALUE(clazz, JNI_FALSE);
|
||||
|
||||
mid = (*env)->GetMethodID(env, clazz, "getNativeRuntime", "()J");
|
||||
ASSERT_RETURN_VALUE(mid, JNI_FALSE);
|
||||
|
||||
rt = (JSRuntime *) (*env)->CallObjectMethod(env, rtObject, mid);
|
||||
ASSERT_RETURN_VALUE(rt, JNI_FALSE);
|
||||
|
||||
cx = JS_NewContext(rt, 8192);
|
||||
ASSERT_RETURN_VALUE(cx, JNI_FALSE);
|
||||
|
||||
JS_SetErrorReporter(cx, my_ErrorReporter);
|
||||
|
||||
glob = JS_NewObject(cx, &global_class, NULL, NULL);
|
||||
ASSERT_RETURN_VALUE(glob, JNI_FALSE);
|
||||
|
||||
ok = JS_InitStandardClasses(cx, glob);
|
||||
ASSERT_RETURN_VALUE(ok, JNI_FALSE);
|
||||
|
||||
ok = JS_DefineFunctions(cx, glob, shell_functions);
|
||||
ASSERT_RETURN_VALUE(ok, JNI_FALSE);
|
||||
|
||||
fid = (*env)->GetFieldID(env, clazz_self, "_nativeContext", "J");
|
||||
ASSERT_RETURN_VALUE(fid, JNI_FALSE);
|
||||
(*env)->SetLongField(env, self, fid, (long) cx);
|
||||
|
||||
|
||||
info = (ContextInfo*) malloc(sizeof(ContextInfo));
|
||||
ASSERT_RETURN_VALUE(info, JNI_FALSE);
|
||||
|
||||
info->env = env;
|
||||
info->contextObject = self;
|
||||
|
||||
JS_SetContextPrivate(cx, info);
|
||||
|
||||
#ifdef JSDEBUGGER
|
||||
mid = (*env)->GetMethodID(env, clazz, "getNativeDebugSupport", "()J");
|
||||
ASSERT_RETURN_VALUE(mid, JNI_FALSE);
|
||||
|
||||
jsdjc = (JSDJContext*) (*env)->CallObjectMethod(env, rtObject, mid);
|
||||
if(jsdjc)
|
||||
{
|
||||
JSDContext* jsdc = JSDJ_GetJSDContext(jsdjc);
|
||||
ASSERT_RETURN_VALUE(jsdc, JNI_FALSE);
|
||||
|
||||
JSDJ_SetJNIEnvForCurrentThread(jsdjc, env);
|
||||
JSD_JSContextInUse(jsdc, cx);
|
||||
}
|
||||
#endif
|
||||
|
||||
return JNI_TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: com_netscape_nativejsengine_JSContext
|
||||
* Method: _exit
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_com_netscape_nativejsengine_JSContext__1exit
|
||||
(JNIEnv *env, jobject self)
|
||||
{
|
||||
jfieldID fid;
|
||||
jclass clazz;
|
||||
JSContext *cx;
|
||||
ContextInfo* info;
|
||||
|
||||
clazz = (*env)->GetObjectClass(env, self);
|
||||
ASSERT_RETURN_VOID(clazz);
|
||||
|
||||
fid = (*env)->GetFieldID(env, clazz, "_nativeContext", "J");
|
||||
ASSERT_RETURN_VOID(fid);
|
||||
|
||||
cx = (JSContext *) (*env)->GetLongField(env, self, fid);
|
||||
ASSERT_RETURN_VOID(cx);
|
||||
|
||||
info = (ContextInfo*) JS_GetContextPrivate(cx);
|
||||
ASSERT_RETURN_VOID(info);
|
||||
free(info);
|
||||
|
||||
printf("context = %d\n", (int)cx);
|
||||
|
||||
JS_DestroyContext(cx);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: com_netscape_nativejsengine_JSContext
|
||||
* Method: _eval
|
||||
* Signature: (Ljava/lang/String;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_com_netscape_nativejsengine_JSContext__1eval
|
||||
(JNIEnv * env, jobject self, jstring str, jstring filename, jint lineno)
|
||||
{
|
||||
jfieldID fid;
|
||||
jclass clazz_self;
|
||||
JSContext *cx;
|
||||
JSObject *glob;
|
||||
jsval rval;
|
||||
int len;
|
||||
const char* Cstr;
|
||||
const char* Cfilename;
|
||||
jboolean isCopy;
|
||||
|
||||
clazz_self = (*env)->GetObjectClass(env, self);
|
||||
ASSERT_RETURN_VOID(clazz_self);
|
||||
|
||||
fid = (*env)->GetFieldID(env, clazz_self, "_nativeContext", "J");
|
||||
ASSERT_RETURN_VOID(fid);
|
||||
|
||||
cx = (JSContext *) (*env)->GetLongField(env, self, fid);
|
||||
ASSERT_RETURN_VOID(cx);
|
||||
|
||||
glob = JS_GetGlobalObject(cx);
|
||||
ASSERT_RETURN_VOID(glob);
|
||||
|
||||
len = (*env)->GetStringUTFLength(env, str);
|
||||
Cstr = (*env)->GetStringUTFChars(env, str, &isCopy);
|
||||
Cfilename = (*env)->GetStringUTFChars(env, filename, &isCopy);
|
||||
|
||||
#ifdef JSDEBUGGER
|
||||
/*
|
||||
* XXX this just overwrites any previous source for this url!
|
||||
*/
|
||||
_jamSourceIntoJSD(cx, Cstr, len, Cfilename);
|
||||
#endif
|
||||
|
||||
JS_EvaluateScript(cx, glob, Cstr, len, Cfilename, lineno, &rval);
|
||||
|
||||
(*env)->ReleaseStringUTFChars(env, str, Cstr);
|
||||
(*env)->ReleaseStringUTFChars(env, filename, Cfilename);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: com_netscape_nativejsengine_JSContext
|
||||
* Method: _load
|
||||
* Signature: (Ljava/lang/String;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_com_netscape_nativejsengine_JSContext__1load
|
||||
(JNIEnv *env, jobject self, jstring filename)
|
||||
{
|
||||
jfieldID fid;
|
||||
jclass clazz;
|
||||
JSContext *cx;
|
||||
const char* Cfilename;
|
||||
jboolean isCopy;
|
||||
JSObject *glob;
|
||||
|
||||
clazz = (*env)->GetObjectClass(env, self);
|
||||
ASSERT_RETURN_VOID(clazz);
|
||||
|
||||
fid = (*env)->GetFieldID(env, clazz, "_nativeContext", "J");
|
||||
ASSERT_RETURN_VOID(fid);
|
||||
|
||||
cx = (JSContext *) (*env)->GetLongField(env, self, fid);
|
||||
ASSERT_RETURN_VOID(cx);
|
||||
|
||||
glob = JS_GetGlobalObject(cx);
|
||||
ASSERT_RETURN_VOID(glob);
|
||||
|
||||
Cfilename = (*env)->GetStringUTFChars(env, filename, &isCopy);
|
||||
|
||||
_loadSingleFile(cx, glob, Cfilename);
|
||||
|
||||
(*env)->ReleaseStringUTFChars(env, filename, Cfilename);
|
||||
}
|
||||
954
mozilla/js/jsd/jsd.h
Normal file
954
mozilla/js/jsd/jsd.h
Normal file
@@ -0,0 +1,954 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Header for JavaScript Debugging support - Internal ONLY declarations
|
||||
*/
|
||||
|
||||
#ifndef jsd_h___
|
||||
#define jsd_h___
|
||||
|
||||
/*
|
||||
* NOTE: This is a *private* header file and should only be included by
|
||||
* the sources in js/jsd. Defining EXPORT_JSD_API in an outside module
|
||||
* using jsd would be bad.
|
||||
*/
|
||||
#define EXPORT_JSD_API 1 /* if used, must be set before include of jsdebug.h */
|
||||
|
||||
/*
|
||||
* These can be controled by the makefile, but this allows a place to set
|
||||
* the values always used in the mozilla client, but perhaps done differnetly
|
||||
* in other embeddings.
|
||||
*/
|
||||
#ifdef MOZILLA_CLIENT
|
||||
#define JSD_THREADSAFE 1
|
||||
#define JSD_HAS_DANGEROUS_THREAD 1
|
||||
#define JSD_USE_NSPR_LOCKS 1
|
||||
#endif /* MOZILLA_CLIENT */
|
||||
|
||||
|
||||
/* Get jstypes.h included first. After that we can use PR macros for doing
|
||||
* this extern "C" stuff!
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
#include "jstypes.h"
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
JS_BEGIN_EXTERN_C
|
||||
#include "jsprf.h"
|
||||
#include "jsutil.h" /* Added by JSIFY */
|
||||
#include "jshash.h" /* Added by JSIFY */
|
||||
#include "jsclist.h"
|
||||
#include "jsdebug.h"
|
||||
#include "jsapi.h"
|
||||
#include "jsobj.h"
|
||||
#include "jsfun.h"
|
||||
#include "jsdbgapi.h"
|
||||
#include "jsd_lock.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef LIVEWIRE
|
||||
#include <base/pblock.h>
|
||||
#include <base/session.h>
|
||||
#include <frame/log.h>
|
||||
#include <frame/req.h>
|
||||
#endif /* LIVEWIRE */
|
||||
JS_END_EXTERN_C
|
||||
|
||||
JS_BEGIN_EXTERN_C
|
||||
|
||||
#define JSD_MAJOR_VERSION 1
|
||||
#define JSD_MINOR_VERSION 1
|
||||
|
||||
/***************************************************************************/
|
||||
/* handy macros */
|
||||
#undef CHECK_BIT_FLAG
|
||||
#define CHECK_BIT_FLAG(f,b) ((f)&(b))
|
||||
#undef SET_BIT_FLAG
|
||||
#define SET_BIT_FLAG(f,b) ((f)|=(b))
|
||||
#undef CLEAR_BIT_FLAG
|
||||
#define CLEAR_BIT_FLAG(f,b) ((f)&=(~(b)))
|
||||
|
||||
|
||||
/***************************************************************************/
|
||||
/* These are not exposed in jsdebug.h - typedef here for consistency */
|
||||
|
||||
typedef struct JSDExecHook JSDExecHook;
|
||||
typedef struct JSDAtom JSDAtom;
|
||||
|
||||
/***************************************************************************/
|
||||
/* Our structures */
|
||||
|
||||
/*
|
||||
* XXX What I'm calling a JSDContext is really more of a JSDTaskState.
|
||||
*/
|
||||
|
||||
struct JSDContext
|
||||
{
|
||||
JSCList links; /* we are part of a JSCList */
|
||||
JSBool inited;
|
||||
JSD_ScriptHookProc scriptHook;
|
||||
void* scriptHookData;
|
||||
JSD_ExecutionHookProc interruptHook;
|
||||
void* interruptHookData;
|
||||
JSRuntime* jsrt;
|
||||
JSD_ErrorReporter errorReporter;
|
||||
void* errorReporterData;
|
||||
JSCList threadsStates;
|
||||
JSD_ExecutionHookProc debugBreakHook;
|
||||
void* debugBreakHookData;
|
||||
JSD_ExecutionHookProc debuggerHook;
|
||||
void* debuggerHookData;
|
||||
JSD_ExecutionHookProc throwHook;
|
||||
void* throwHookData;
|
||||
JSContext* dumbContext;
|
||||
JSObject* glob;
|
||||
JSD_UserCallbacks userCallbacks;
|
||||
void* user;
|
||||
JSCList scripts;
|
||||
JSCList sources;
|
||||
JSCList removedSources;
|
||||
uintN sourceAlterCount;
|
||||
JSHashTable* atoms;
|
||||
JSCList objectsList;
|
||||
JSHashTable* objectsTable;
|
||||
#ifdef JSD_THREADSAFE
|
||||
void* scriptsLock;
|
||||
void* sourceTextLock;
|
||||
void* objectsLock;
|
||||
void* atomsLock;
|
||||
void* threadStatesLock;
|
||||
#endif /* JSD_THREADSAFE */
|
||||
#ifdef JSD_HAS_DANGEROUS_THREAD
|
||||
void* dangerousThread;
|
||||
#endif /* JSD_HAS_DANGEROUS_THREAD */
|
||||
|
||||
};
|
||||
|
||||
struct JSDScript
|
||||
{
|
||||
JSCList links; /* we are part of a JSCList */
|
||||
JSDContext* jsdc; /* JSDContext for this jsdscript */
|
||||
JSScript* script; /* script we are wrapping */
|
||||
JSFunction* function; /* back pointer to owning function (can be NULL) */
|
||||
uintN lineBase; /* we cache this */
|
||||
uintN lineExtent; /* we cache this */
|
||||
JSCList hooks; /* JSCList of JSDExecHooks for this script */
|
||||
char* url;
|
||||
#ifdef LIVEWIRE
|
||||
LWDBGApp* app;
|
||||
LWDBGScript* lwscript;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct JSDSourceText
|
||||
{
|
||||
JSCList links; /* we are part of a JSCList */
|
||||
char* url;
|
||||
char* text;
|
||||
uintN textLength;
|
||||
uintN textSpace;
|
||||
JSBool dirty;
|
||||
JSDSourceStatus status;
|
||||
uintN alterCount;
|
||||
JSBool doingEval;
|
||||
};
|
||||
|
||||
struct JSDExecHook
|
||||
{
|
||||
JSCList links; /* we are part of a JSCList */
|
||||
JSDScript* jsdscript;
|
||||
jsuword pc;
|
||||
JSD_ExecutionHookProc hook;
|
||||
void* callerdata;
|
||||
};
|
||||
|
||||
struct JSDThreadState
|
||||
{
|
||||
JSCList links; /* we are part of a JSCList */
|
||||
JSContext* context;
|
||||
void* thread;
|
||||
JSCList stack;
|
||||
uintN stackDepth;
|
||||
};
|
||||
|
||||
struct JSDStackFrameInfo
|
||||
{
|
||||
JSCList links; /* we are part of a JSCList */
|
||||
JSDThreadState* jsdthreadstate;
|
||||
JSDScript* jsdscript;
|
||||
jsuword pc;
|
||||
JSStackFrame* fp;
|
||||
};
|
||||
|
||||
#define GOT_PROTO ((short) (1 << 0))
|
||||
#define GOT_PROPS ((short) (1 << 1))
|
||||
#define GOT_PARENT ((short) (1 << 2))
|
||||
#define GOT_CTOR ((short) (1 << 3))
|
||||
|
||||
struct JSDValue
|
||||
{
|
||||
jsval val;
|
||||
intN nref;
|
||||
JSCList props;
|
||||
JSString* string;
|
||||
const char* funName;
|
||||
const char* className;
|
||||
JSDValue* proto;
|
||||
JSDValue* parent;
|
||||
JSDValue* ctor;
|
||||
uintN flags;
|
||||
};
|
||||
|
||||
struct JSDProperty
|
||||
{
|
||||
JSCList links; /* we are part of a JSCList */
|
||||
intN nref;
|
||||
JSDValue* val;
|
||||
JSDValue* name;
|
||||
JSDValue* alias;
|
||||
uintN slot;
|
||||
uintN flags;
|
||||
};
|
||||
|
||||
struct JSDAtom
|
||||
{
|
||||
char* str; /* must be first element in stuct for compare */
|
||||
intN refcount;
|
||||
};
|
||||
|
||||
struct JSDObject
|
||||
{
|
||||
JSCList links; /* we are part of a JSCList */
|
||||
JSObject* obj;
|
||||
JSDAtom* newURL;
|
||||
uintN newLineno;
|
||||
JSDAtom* ctorURL;
|
||||
uintN ctorLineno;
|
||||
JSDAtom* ctorName;
|
||||
};
|
||||
|
||||
/***************************************************************************/
|
||||
/* Code validation support */
|
||||
|
||||
#ifdef DEBUG
|
||||
extern void JSD_ASSERT_VALID_CONTEXT(JSDContext* jsdc);
|
||||
extern void JSD_ASSERT_VALID_SCRIPT(JSDScript* jsdscript);
|
||||
extern void JSD_ASSERT_VALID_SOURCE_TEXT(JSDSourceText* jsdsrc);
|
||||
extern void JSD_ASSERT_VALID_THREAD_STATE(JSDThreadState* jsdthreadstate);
|
||||
extern void JSD_ASSERT_VALID_STACK_FRAME(JSDStackFrameInfo* jsdframe);
|
||||
extern void JSD_ASSERT_VALID_EXEC_HOOK(JSDExecHook* jsdhook);
|
||||
extern void JSD_ASSERT_VALID_VALUE(JSDValue* jsdval);
|
||||
extern void JSD_ASSERT_VALID_PROPERTY(JSDProperty* jsdprop);
|
||||
extern void JSD_ASSERT_VALID_OBJECT(JSDObject* jsdobj);
|
||||
#else
|
||||
#define JSD_ASSERT_VALID_CONTEXT(x) ((void)0)
|
||||
#define JSD_ASSERT_VALID_SCRIPT(x) ((void)0)
|
||||
#define JSD_ASSERT_VALID_SOURCE_TEXT(x) ((void)0)
|
||||
#define JSD_ASSERT_VALID_THREAD_STATE(x)((void)0)
|
||||
#define JSD_ASSERT_VALID_STACK_FRAME(x) ((void)0)
|
||||
#define JSD_ASSERT_VALID_EXEC_HOOK(x) ((void)0)
|
||||
#define JSD_ASSERT_VALID_VALUE(x) ((void)0)
|
||||
#define JSD_ASSERT_VALID_PROPERTY(x) ((void)0)
|
||||
#define JSD_ASSERT_VALID_OBJECT(x) ((void)0)
|
||||
#endif
|
||||
|
||||
/***************************************************************************/
|
||||
/* higher level functions */
|
||||
|
||||
extern JSDContext*
|
||||
jsd_DebuggerOnForUser(JSRuntime* jsrt,
|
||||
JSD_UserCallbacks* callbacks,
|
||||
void* user);
|
||||
extern JSDContext*
|
||||
jsd_DebuggerOn(void);
|
||||
|
||||
extern void
|
||||
jsd_DebuggerOff(JSDContext* jsdc);
|
||||
|
||||
extern void
|
||||
jsd_SetUserCallbacks(JSRuntime* jsrt, JSD_UserCallbacks* callbacks, void* user);
|
||||
|
||||
extern JSDContext*
|
||||
jsd_JSDContextForJSContext(JSContext* context);
|
||||
|
||||
extern JSBool
|
||||
jsd_SetErrorReporter(JSDContext* jsdc,
|
||||
JSD_ErrorReporter reporter,
|
||||
void* callerdata);
|
||||
|
||||
extern JSBool
|
||||
jsd_GetErrorReporter(JSDContext* jsdc,
|
||||
JSD_ErrorReporter* reporter,
|
||||
void** callerdata);
|
||||
|
||||
JS_STATIC_DLL_CALLBACK(JSBool)
|
||||
jsd_DebugErrorHook(JSContext *cx, const char *message,
|
||||
JSErrorReport *report, void *closure);
|
||||
|
||||
/***************************************************************************/
|
||||
/* Script functions */
|
||||
|
||||
extern void
|
||||
jsd_DestroyAllJSDScripts(JSDContext* jsdc);
|
||||
|
||||
extern JSDScript*
|
||||
jsd_FindJSDScript(JSDContext* jsdc,
|
||||
JSScript *script);
|
||||
|
||||
extern JSDScript*
|
||||
jsd_IterateScripts(JSDContext* jsdc, JSDScript **iterp);
|
||||
|
||||
extern JSBool
|
||||
jsd_IsActiveScript(JSDContext* jsdc, JSDScript *jsdscript);
|
||||
|
||||
extern const char*
|
||||
jsd_GetScriptFilename(JSDContext* jsdc, JSDScript *jsdscript);
|
||||
|
||||
extern const char*
|
||||
jsd_GetScriptFunctionName(JSDContext* jsdc, JSDScript *jsdscript);
|
||||
|
||||
extern uintN
|
||||
jsd_GetScriptBaseLineNumber(JSDContext* jsdc, JSDScript *jsdscript);
|
||||
|
||||
extern uintN
|
||||
jsd_GetScriptLineExtent(JSDContext* jsdc, JSDScript *jsdscript);
|
||||
|
||||
extern JSBool
|
||||
jsd_SetScriptHook(JSDContext* jsdc, JSD_ScriptHookProc hook, void* callerdata);
|
||||
|
||||
extern JSBool
|
||||
jsd_GetScriptHook(JSDContext* jsdc, JSD_ScriptHookProc* hook, void** callerdata);
|
||||
|
||||
extern jsuword
|
||||
jsd_GetClosestPC(JSDContext* jsdc, JSDScript* jsdscript, uintN line);
|
||||
|
||||
extern uintN
|
||||
jsd_GetClosestLine(JSDContext* jsdc, JSDScript* jsdscript, jsuword pc);
|
||||
|
||||
extern void JS_DLL_CALLBACK
|
||||
jsd_NewScriptHookProc(
|
||||
JSContext *cx,
|
||||
const char *filename, /* URL this script loads from */
|
||||
uintN lineno, /* line where this script starts */
|
||||
JSScript *script,
|
||||
JSFunction *fun,
|
||||
void* callerdata);
|
||||
|
||||
extern void JS_DLL_CALLBACK
|
||||
jsd_DestroyScriptHookProc(
|
||||
JSContext *cx,
|
||||
JSScript *script,
|
||||
void* callerdata);
|
||||
|
||||
/* Script execution hook functions */
|
||||
|
||||
extern JSBool
|
||||
jsd_SetExecutionHook(JSDContext* jsdc,
|
||||
JSDScript* jsdscript,
|
||||
jsuword pc,
|
||||
JSD_ExecutionHookProc hook,
|
||||
void* callerdata);
|
||||
|
||||
extern JSBool
|
||||
jsd_ClearExecutionHook(JSDContext* jsdc,
|
||||
JSDScript* jsdscript,
|
||||
jsuword pc);
|
||||
|
||||
extern JSBool
|
||||
jsd_ClearAllExecutionHooksForScript(JSDContext* jsdc, JSDScript* jsdscript);
|
||||
|
||||
extern JSBool
|
||||
jsd_ClearAllExecutionHooks(JSDContext* jsdc);
|
||||
|
||||
extern void
|
||||
jsd_ScriptCreated(JSDContext* jsdc,
|
||||
JSContext *cx,
|
||||
const char *filename, /* URL this script loads from */
|
||||
uintN lineno, /* line where this script starts */
|
||||
JSScript *script,
|
||||
JSFunction *fun);
|
||||
|
||||
extern void
|
||||
jsd_ScriptDestroyed(JSDContext* jsdc,
|
||||
JSContext *cx,
|
||||
JSScript *script);
|
||||
|
||||
/***************************************************************************/
|
||||
/* Source Text functions */
|
||||
|
||||
extern JSDSourceText*
|
||||
jsd_IterateSources(JSDContext* jsdc, JSDSourceText **iterp);
|
||||
|
||||
extern JSDSourceText*
|
||||
jsd_FindSourceForURL(JSDContext* jsdc, const char* url);
|
||||
|
||||
extern const char*
|
||||
jsd_GetSourceURL(JSDContext* jsdc, JSDSourceText* jsdsrc);
|
||||
|
||||
extern JSBool
|
||||
jsd_GetSourceText(JSDContext* jsdc, JSDSourceText* jsdsrc,
|
||||
const char** ppBuf, intN* pLen);
|
||||
|
||||
extern void
|
||||
jsd_ClearSourceText(JSDContext* jsdc, JSDSourceText* jsdsrc);
|
||||
|
||||
extern JSDSourceStatus
|
||||
jsd_GetSourceStatus(JSDContext* jsdc, JSDSourceText* jsdsrc);
|
||||
|
||||
extern JSBool
|
||||
jsd_IsSourceDirty(JSDContext* jsdc, JSDSourceText* jsdsrc);
|
||||
|
||||
extern void
|
||||
jsd_SetSourceDirty(JSDContext* jsdc, JSDSourceText* jsdsrc, JSBool dirty);
|
||||
|
||||
extern uintN
|
||||
jsd_GetSourceAlterCount(JSDContext* jsdc, JSDSourceText* jsdsrc);
|
||||
|
||||
extern uintN
|
||||
jsd_IncrementSourceAlterCount(JSDContext* jsdc, JSDSourceText* jsdsrc);
|
||||
|
||||
extern JSDSourceText*
|
||||
jsd_NewSourceText(JSDContext* jsdc, const char* url);
|
||||
|
||||
extern JSDSourceText*
|
||||
jsd_AppendSourceText(JSDContext* jsdc,
|
||||
JSDSourceText* jsdsrc,
|
||||
const char* text, /* *not* zero terminated */
|
||||
size_t length,
|
||||
JSDSourceStatus status);
|
||||
|
||||
extern JSDSourceText*
|
||||
jsd_AppendUCSourceText(JSDContext* jsdc,
|
||||
JSDSourceText* jsdsrc,
|
||||
const jschar* text, /* *not* zero terminated */
|
||||
size_t length,
|
||||
JSDSourceStatus status);
|
||||
|
||||
/* convienence function for adding complete source of url in one call */
|
||||
extern JSBool
|
||||
jsd_AddFullSourceText(JSDContext* jsdc,
|
||||
const char* text, /* *not* zero terminated */
|
||||
size_t length,
|
||||
const char* url);
|
||||
|
||||
extern void
|
||||
jsd_DestroyAllSources(JSDContext* jsdc);
|
||||
|
||||
extern const char*
|
||||
jsd_BuildNormalizedURL(const char* url_string);
|
||||
|
||||
extern void
|
||||
jsd_StartingEvalUsingFilename(JSDContext* jsdc, const char* url);
|
||||
|
||||
extern void
|
||||
jsd_FinishedEvalUsingFilename(JSDContext* jsdc, const char* url);
|
||||
|
||||
/***************************************************************************/
|
||||
/* Interrupt Hook functions */
|
||||
|
||||
extern JSBool
|
||||
jsd_SetInterruptHook(JSDContext* jsdc,
|
||||
JSD_ExecutionHookProc hook,
|
||||
void* callerdata);
|
||||
|
||||
extern JSBool
|
||||
jsd_ClearInterruptHook(JSDContext* jsdc);
|
||||
|
||||
extern JSBool
|
||||
jsd_SetDebugBreakHook(JSDContext* jsdc,
|
||||
JSD_ExecutionHookProc hook,
|
||||
void* callerdata);
|
||||
|
||||
extern JSBool
|
||||
jsd_ClearDebugBreakHook(JSDContext* jsdc);
|
||||
|
||||
extern JSBool
|
||||
jsd_SetDebuggerHook(JSDContext* jsdc,
|
||||
JSD_ExecutionHookProc hook,
|
||||
void* callerdata);
|
||||
|
||||
extern JSBool
|
||||
jsd_ClearDebuggerHook(JSDContext* jsdc);
|
||||
|
||||
extern JSTrapStatus
|
||||
jsd_CallExecutionHook(JSDContext* jsdc,
|
||||
JSContext *cx,
|
||||
JSDHookType type,
|
||||
JSD_ExecutionHookProc hook,
|
||||
void* hookData,
|
||||
jsval* rval);
|
||||
|
||||
extern JSBool
|
||||
jsd_SetThrowHook(JSDContext* jsdc,
|
||||
JSD_ExecutionHookProc hook,
|
||||
void* callerdata);
|
||||
extern JSBool
|
||||
jsd_ClearThrowHook(JSDContext* jsdc);
|
||||
|
||||
extern JSTrapStatus JS_DLL_CALLBACK
|
||||
jsd_DebuggerHandler(JSContext *cx, JSScript *script, jsbytecode *pc,
|
||||
jsval *rval, void *closure);
|
||||
|
||||
extern JSTrapStatus JS_DLL_CALLBACK
|
||||
jsd_ThrowHandler(JSContext *cx, JSScript *script, jsbytecode *pc,
|
||||
jsval *rval, void *closure);
|
||||
|
||||
/***************************************************************************/
|
||||
/* Stack Frame functions */
|
||||
|
||||
extern uintN
|
||||
jsd_GetCountOfStackFrames(JSDContext* jsdc, JSDThreadState* jsdthreadstate);
|
||||
|
||||
extern JSDStackFrameInfo*
|
||||
jsd_GetStackFrame(JSDContext* jsdc, JSDThreadState* jsdthreadstate);
|
||||
|
||||
extern JSDStackFrameInfo*
|
||||
jsd_GetCallingStackFrame(JSDContext* jsdc,
|
||||
JSDThreadState* jsdthreadstate,
|
||||
JSDStackFrameInfo* jsdframe);
|
||||
|
||||
extern JSDScript*
|
||||
jsd_GetScriptForStackFrame(JSDContext* jsdc,
|
||||
JSDThreadState* jsdthreadstate,
|
||||
JSDStackFrameInfo* jsdframe);
|
||||
|
||||
extern jsuword
|
||||
jsd_GetPCForStackFrame(JSDContext* jsdc,
|
||||
JSDThreadState* jsdthreadstate,
|
||||
JSDStackFrameInfo* jsdframe);
|
||||
|
||||
extern JSDValue*
|
||||
jsd_GetCallObjectForStackFrame(JSDContext* jsdc,
|
||||
JSDThreadState* jsdthreadstate,
|
||||
JSDStackFrameInfo* jsdframe);
|
||||
|
||||
extern JSDValue*
|
||||
jsd_GetScopeChainForStackFrame(JSDContext* jsdc,
|
||||
JSDThreadState* jsdthreadstate,
|
||||
JSDStackFrameInfo* jsdframe);
|
||||
|
||||
extern JSDValue*
|
||||
jsd_GetThisForStackFrame(JSDContext* jsdc,
|
||||
JSDThreadState* jsdthreadstate,
|
||||
JSDStackFrameInfo* jsdframe);
|
||||
|
||||
extern JSDThreadState*
|
||||
jsd_NewThreadState(JSDContext* jsdc, JSContext *cx);
|
||||
|
||||
extern void
|
||||
jsd_DestroyThreadState(JSDContext* jsdc, JSDThreadState* jsdthreadstate);
|
||||
|
||||
extern JSBool
|
||||
jsd_EvaluateScriptInStackFrame(JSDContext* jsdc,
|
||||
JSDThreadState* jsdthreadstate,
|
||||
JSDStackFrameInfo* jsdframe,
|
||||
const char *bytes, uintN length,
|
||||
const char *filename, uintN lineno, jsval *rval);
|
||||
|
||||
extern JSString*
|
||||
jsd_ValToStringInStackFrame(JSDContext* jsdc,
|
||||
JSDThreadState* jsdthreadstate,
|
||||
JSDStackFrameInfo* jsdframe,
|
||||
jsval val);
|
||||
|
||||
extern JSBool
|
||||
jsd_IsValidThreadState(JSDContext* jsdc,
|
||||
JSDThreadState* jsdthreadstate);
|
||||
|
||||
extern JSBool
|
||||
jsd_IsValidFrameInThreadState(JSDContext* jsdc,
|
||||
JSDThreadState* jsdthreadstate,
|
||||
JSDStackFrameInfo* jsdframe);
|
||||
|
||||
extern JSDValue*
|
||||
jsd_GetException(JSDContext* jsdc, JSDThreadState* jsdthreadstate);
|
||||
|
||||
extern JSBool
|
||||
jsd_SetException(JSDContext* jsdc, JSDThreadState* jsdthreadstate,
|
||||
JSDValue* jsdval);
|
||||
|
||||
/***************************************************************************/
|
||||
/* Locking support */
|
||||
|
||||
/* protos are in js_lock.h for:
|
||||
* jsd_CreateLock
|
||||
* jsd_Lock
|
||||
* jsd_Unlock
|
||||
* jsd_IsLocked
|
||||
* jsd_CurrentThread
|
||||
*/
|
||||
|
||||
#ifdef JSD_THREADSAFE
|
||||
|
||||
/* the system-wide lock */
|
||||
extern void* _jsd_global_lock;
|
||||
#define JSD_LOCK() \
|
||||
JS_BEGIN_MACRO \
|
||||
if(!_jsd_global_lock) \
|
||||
_jsd_global_lock = jsd_CreateLock(); \
|
||||
JS_ASSERT(_jsd_global_lock); \
|
||||
jsd_Lock(_jsd_global_lock); \
|
||||
JS_END_MACRO
|
||||
|
||||
#define JSD_UNLOCK() \
|
||||
JS_BEGIN_MACRO \
|
||||
JS_ASSERT(_jsd_global_lock); \
|
||||
jsd_Unlock(_jsd_global_lock); \
|
||||
JS_END_MACRO
|
||||
|
||||
/* locks for the subsystems of a given context */
|
||||
#define JSD_INIT_LOCKS(jsdc) \
|
||||
( (NULL != (jsdc->scriptsLock = jsd_CreateLock())) && \
|
||||
(NULL != (jsdc->sourceTextLock = jsd_CreateLock())) && \
|
||||
(NULL != (jsdc->atomsLock = jsd_CreateLock())) && \
|
||||
(NULL != (jsdc->objectsLock = jsd_CreateLock())) && \
|
||||
(NULL != (jsdc->threadStatesLock = jsd_CreateLock())) )
|
||||
|
||||
#define JSD_LOCK_SCRIPTS(jsdc) jsd_Lock(jsdc->scriptsLock)
|
||||
#define JSD_UNLOCK_SCRIPTS(jsdc) jsd_Unlock(jsdc->scriptsLock)
|
||||
|
||||
#define JSD_LOCK_SOURCE_TEXT(jsdc) jsd_Lock(jsdc->sourceTextLock)
|
||||
#define JSD_UNLOCK_SOURCE_TEXT(jsdc) jsd_Unlock(jsdc->sourceTextLock)
|
||||
|
||||
#define JSD_LOCK_ATOMS(jsdc) jsd_Lock(jsdc->atomsLock)
|
||||
#define JSD_UNLOCK_ATOMS(jsdc) jsd_Unlock(jsdc->atomsLock)
|
||||
|
||||
#define JSD_LOCK_OBJECTS(jsdc) jsd_Lock(jsdc->objectsLock)
|
||||
#define JSD_UNLOCK_OBJECTS(jsdc) jsd_Unlock(jsdc->objectsLock)
|
||||
|
||||
#define JSD_LOCK_THREADSTATES(jsdc) jsd_Lock(jsdc->threadStatesLock)
|
||||
#define JSD_UNLOCK_THREADSTATES(jsdc) jsd_Unlock(jsdc->threadStatesLock)
|
||||
|
||||
#else /* !JSD_THREADSAFE */
|
||||
|
||||
#define JSD_LOCK() ((void)0)
|
||||
#define JSD_UNLOCK() ((void)0)
|
||||
|
||||
#define JSD_INIT_LOCKS(jsdc) 1
|
||||
|
||||
#define JSD_LOCK_SCRIPTS(jsdc) ((void)0)
|
||||
#define JSD_UNLOCK_SCRIPTS(jsdc) ((void)0)
|
||||
|
||||
#define JSD_LOCK_SOURCE_TEXT(jsdc) ((void)0)
|
||||
#define JSD_UNLOCK_SOURCE_TEXT(jsdc) ((void)0)
|
||||
|
||||
#define JSD_LOCK_ATOMS(jsdc) ((void)0)
|
||||
#define JSD_UNLOCK_ATOMS(jsdc) ((void)0)
|
||||
|
||||
#define JSD_LOCK_OBJECTS(jsdc) ((void)0)
|
||||
#define JSD_UNLOCK_OBJECTS(jsdc) ((void)0)
|
||||
|
||||
#define JSD_LOCK_THREADSTATES(jsdc) ((void)0)
|
||||
#define JSD_UNLOCK_THREADSTATES(jsdc) ((void)0)
|
||||
|
||||
#endif /* JSD_THREADSAFE */
|
||||
|
||||
/* NOTE: These are intended for ASSERTs. Thus we supply checks for both
|
||||
* LOCKED and UNLOCKED (rather that just LOCKED and !LOCKED) so that in
|
||||
* the DEBUG non-Threadsafe case we can have an ASSERT that always succeeds
|
||||
* without having to special case things in the code.
|
||||
*/
|
||||
#if defined(JSD_THREADSAFE) && defined(DEBUG)
|
||||
#define JSD_SCRIPTS_LOCKED(jsdc) (jsd_IsLocked(jsdc->scriptsLock))
|
||||
#define JSD_SOURCE_TEXT_LOCKED(jsdc) (jsd_IsLocked(jsdc->sourceTextLock))
|
||||
#define JSD_ATOMS_LOCKED(jsdc) (jsd_IsLocked(jsdc->atomsLock))
|
||||
#define JSD_OBJECTS_LOCKED(jsdc) (jsd_IsLocked(jsdc->objectsLock))
|
||||
#define JSD_THREADSTATES_LOCKED(jsdc) (jsd_IsLocked(jsdc->threadStatesLock))
|
||||
#define JSD_SCRIPTS_UNLOCKED(jsdc) (!jsd_IsLocked(jsdc->scriptsLock))
|
||||
#define JSD_SOURCE_TEXT_UNLOCKED(jsdc) (!jsd_IsLocked(jsdc->sourceTextLock))
|
||||
#define JSD_ATOMS_UNLOCKED(jsdc) (!jsd_IsLocked(jsdc->atomsLock))
|
||||
#define JSD_OBJECTS_UNLOCKED(jsdc) (!jsd_IsLocked(jsdc->objectsLock))
|
||||
#define JSD_THREADSTATES_UNLOCKED(jsdc) (!jsd_IsLocked(jsdc->threadStatesLock))
|
||||
#else
|
||||
#define JSD_SCRIPTS_LOCKED(jsdc) 1
|
||||
#define JSD_SOURCE_TEXT_LOCKED(jsdc) 1
|
||||
#define JSD_ATOMS_LOCKED(jsdc) 1
|
||||
#define JSD_OBJECTS_LOCKED(jsdc) 1
|
||||
#define JSD_THREADSTATES_LOCKED(jsdc) 1
|
||||
#define JSD_SCRIPTS_UNLOCKED(jsdc) 1
|
||||
#define JSD_SOURCE_TEXT_UNLOCKED(jsdc) 1
|
||||
#define JSD_ATOMS_UNLOCKED(jsdc) 1
|
||||
#define JSD_OBJECTS_UNLOCKED(jsdc) 1
|
||||
#define JSD_THREADSTATES_UNLOCKED(jsdc) 1
|
||||
#endif /* defined(JSD_THREADSAFE) && defined(DEBUG) */
|
||||
|
||||
/***************************************************************************/
|
||||
/* Threading support */
|
||||
|
||||
#ifdef JSD_THREADSAFE
|
||||
|
||||
#define JSD_CURRENT_THREAD() jsd_CurrentThread()
|
||||
|
||||
#else /* !JSD_THREADSAFE */
|
||||
|
||||
#define JSD_CURRENT_THREAD() ((void*)0)
|
||||
|
||||
#endif /* JSD_THREADSAFE */
|
||||
|
||||
/***************************************************************************/
|
||||
/* Dangerous thread support */
|
||||
|
||||
#ifdef JSD_HAS_DANGEROUS_THREAD
|
||||
|
||||
#define JSD_IS_DANGEROUS_THREAD(jsdc) \
|
||||
(JSD_CURRENT_THREAD() == jsdc->dangerousThread)
|
||||
|
||||
#else /* !JSD_HAS_DANGEROUS_THREAD */
|
||||
|
||||
#define JSD_IS_DANGEROUS_THREAD(jsdc) 0
|
||||
|
||||
#endif /* JSD_HAS_DANGEROUS_THREAD */
|
||||
|
||||
/***************************************************************************/
|
||||
/* Value and Property Functions */
|
||||
|
||||
extern JSDValue*
|
||||
jsd_NewValue(JSDContext* jsdc, jsval val);
|
||||
|
||||
extern void
|
||||
jsd_DropValue(JSDContext* jsdc, JSDValue* jsdval);
|
||||
|
||||
extern jsval
|
||||
jsd_GetValueWrappedJSVal(JSDContext* jsdc, JSDValue* jsdval);
|
||||
|
||||
extern void
|
||||
jsd_RefreshValue(JSDContext* jsdc, JSDValue* jsdval);
|
||||
|
||||
/**************************************************/
|
||||
|
||||
extern JSBool
|
||||
jsd_IsValueObject(JSDContext* jsdc, JSDValue* jsdval);
|
||||
|
||||
extern JSBool
|
||||
jsd_IsValueNumber(JSDContext* jsdc, JSDValue* jsdval);
|
||||
|
||||
extern JSBool
|
||||
jsd_IsValueInt(JSDContext* jsdc, JSDValue* jsdval);
|
||||
|
||||
extern JSBool
|
||||
jsd_IsValueDouble(JSDContext* jsdc, JSDValue* jsdval);
|
||||
|
||||
extern JSBool
|
||||
jsd_IsValueString(JSDContext* jsdc, JSDValue* jsdval);
|
||||
|
||||
extern JSBool
|
||||
jsd_IsValueBoolean(JSDContext* jsdc, JSDValue* jsdval);
|
||||
|
||||
extern JSBool
|
||||
jsd_IsValueNull(JSDContext* jsdc, JSDValue* jsdval);
|
||||
|
||||
extern JSBool
|
||||
jsd_IsValueVoid(JSDContext* jsdc, JSDValue* jsdval);
|
||||
|
||||
extern JSBool
|
||||
jsd_IsValuePrimitive(JSDContext* jsdc, JSDValue* jsdval);
|
||||
|
||||
extern JSBool
|
||||
jsd_IsValueFunction(JSDContext* jsdc, JSDValue* jsdval);
|
||||
|
||||
extern JSBool
|
||||
jsd_IsValueNative(JSDContext* jsdc, JSDValue* jsdval);
|
||||
|
||||
/**************************************************/
|
||||
|
||||
extern JSBool
|
||||
jsd_GetValueBoolean(JSDContext* jsdc, JSDValue* jsdval);
|
||||
|
||||
extern int32
|
||||
jsd_GetValueInt(JSDContext* jsdc, JSDValue* jsdval);
|
||||
|
||||
extern jsdouble*
|
||||
jsd_GetValueDouble(JSDContext* jsdc, JSDValue* jsdval);
|
||||
|
||||
extern JSString*
|
||||
jsd_GetValueString(JSDContext* jsdc, JSDValue* jsdval);
|
||||
|
||||
extern const char*
|
||||
jsd_GetValueFunctionName(JSDContext* jsdc, JSDValue* jsdval);
|
||||
|
||||
/**************************************************/
|
||||
|
||||
extern uintN
|
||||
jsd_GetCountOfProperties(JSDContext* jsdc, JSDValue* jsdval);
|
||||
|
||||
extern JSDProperty*
|
||||
jsd_IterateProperties(JSDContext* jsdc, JSDValue* jsdval, JSDProperty **iterp);
|
||||
|
||||
extern JSDProperty*
|
||||
jsd_GetValueProperty(JSDContext* jsdc, JSDValue* jsdval, JSString* name);
|
||||
|
||||
extern JSDValue*
|
||||
jsd_GetValuePrototype(JSDContext* jsdc, JSDValue* jsdval);
|
||||
|
||||
extern JSDValue*
|
||||
jsd_GetValueParent(JSDContext* jsdc, JSDValue* jsdval);
|
||||
|
||||
extern JSDValue*
|
||||
jsd_GetValueConstructor(JSDContext* jsdc, JSDValue* jsdval);
|
||||
|
||||
extern const char*
|
||||
jsd_GetValueClassName(JSDContext* jsdc, JSDValue* jsdval);
|
||||
|
||||
/**************************************************/
|
||||
|
||||
extern void
|
||||
jsd_DropProperty(JSDContext* jsdc, JSDProperty* jsdprop);
|
||||
|
||||
extern JSDValue*
|
||||
jsd_GetPropertyName(JSDContext* jsdc, JSDProperty* jsdprop);
|
||||
|
||||
extern JSDValue*
|
||||
jsd_GetPropertyValue(JSDContext* jsdc, JSDProperty* jsdprop);
|
||||
|
||||
extern JSDValue*
|
||||
jsd_GetPropertyAlias(JSDContext* jsdc, JSDProperty* jsdprop);
|
||||
|
||||
extern JSDPropertyFlags
|
||||
jsd_GetPropertyFlags(JSDContext* jsdc, JSDProperty* jsdprop);
|
||||
|
||||
extern uintN
|
||||
jsd_GetPropertyVarArgSlot(JSDContext* jsdc, JSDProperty* jsdprop);
|
||||
|
||||
/**************************************************/
|
||||
/* Stepping Functions */
|
||||
|
||||
extern void * JS_DLL_CALLBACK
|
||||
jsd_InterpreterHook(JSContext *cx, JSStackFrame *fp, JSBool before,
|
||||
JSBool *ok, void *closure);
|
||||
|
||||
/**************************************************/
|
||||
/* Object Functions */
|
||||
|
||||
extern JSBool
|
||||
jsd_InitObjectManager(JSDContext* jsdc);
|
||||
|
||||
extern void
|
||||
jsd_DestroyObjectManager(JSDContext* jsdc);
|
||||
|
||||
extern void JS_DLL_CALLBACK
|
||||
jsd_ObjectHook(JSContext *cx, JSObject *obj, JSBool isNew, void *closure);
|
||||
|
||||
extern void
|
||||
jsd_Constructing(JSDContext* jsdc, JSContext *cx, JSObject *obj,
|
||||
JSStackFrame *fp);
|
||||
|
||||
extern JSDObject*
|
||||
jsd_IterateObjects(JSDContext* jsdc, JSDObject** iterp);
|
||||
|
||||
extern JSObject*
|
||||
jsd_GetWrappedObject(JSDContext* jsdc, JSDObject* jsdobj);
|
||||
|
||||
extern const char*
|
||||
jsd_GetObjectNewURL(JSDContext* jsdc, JSDObject* jsdobj);
|
||||
|
||||
extern uintN
|
||||
jsd_GetObjectNewLineNumber(JSDContext* jsdc, JSDObject* jsdobj);
|
||||
|
||||
extern const char*
|
||||
jsd_GetObjectConstructorURL(JSDContext* jsdc, JSDObject* jsdobj);
|
||||
|
||||
extern uintN
|
||||
jsd_GetObjectConstructorLineNumber(JSDContext* jsdc, JSDObject* jsdobj);
|
||||
|
||||
extern const char*
|
||||
jsd_GetObjectConstructorName(JSDContext* jsdc, JSDObject* jsdobj);
|
||||
|
||||
extern JSDObject*
|
||||
jsd_GetJSDObjectForJSObject(JSDContext* jsdc, JSObject* jsobj);
|
||||
|
||||
extern JSDObject*
|
||||
jsd_GetObjectForValue(JSDContext* jsdc, JSDValue* jsdval);
|
||||
|
||||
/*
|
||||
* returns new refcounted JSDValue
|
||||
*/
|
||||
extern JSDValue*
|
||||
jsd_GetValueForObject(JSDContext* jsdc, JSDObject* jsdobj);
|
||||
|
||||
/**************************************************/
|
||||
/* Atom Functions */
|
||||
|
||||
extern JSBool
|
||||
jsd_CreateAtomTable(JSDContext* jsdc);
|
||||
|
||||
extern void
|
||||
jsd_DestroyAtomTable(JSDContext* jsdc);
|
||||
|
||||
extern JSDAtom*
|
||||
jsd_AddAtom(JSDContext* jsdc, const char* str);
|
||||
|
||||
extern JSDAtom*
|
||||
jsd_CloneAtom(JSDContext* jsdc, JSDAtom* atom);
|
||||
|
||||
extern void
|
||||
jsd_DropAtom(JSDContext* jsdc, JSDAtom* atom);
|
||||
|
||||
#define JSD_ATOM_TO_STRING(a) ((const char*)((a)->str))
|
||||
|
||||
/***************************************************************************/
|
||||
/* Livewire specific API */
|
||||
#ifdef LIVEWIRE
|
||||
|
||||
extern LWDBGScript*
|
||||
jsdlw_GetLWScript(JSDContext* jsdc, JSDScript* jsdscript);
|
||||
|
||||
extern char*
|
||||
jsdlw_BuildAppRelativeFilename(LWDBGApp* app, const char* filename);
|
||||
|
||||
extern JSDSourceText*
|
||||
jsdlw_PreLoadSource(JSDContext* jsdc, LWDBGApp* app,
|
||||
const char* filename, JSBool clear);
|
||||
|
||||
extern JSDSourceText*
|
||||
jsdlw_ForceLoadSource(JSDContext* jsdc, JSDSourceText* jsdsrc);
|
||||
|
||||
extern JSBool
|
||||
jsdlw_UserCodeAtPC(JSDContext* jsdc, JSDScript* jsdscript, jsuword pc);
|
||||
|
||||
extern JSBool
|
||||
jsdlw_RawToProcessedLineNumber(JSDContext* jsdc, JSDScript* jsdscript,
|
||||
uintN lineIn, uintN* lineOut);
|
||||
|
||||
extern JSBool
|
||||
jsdlw_ProcessedToRawLineNumber(JSDContext* jsdc, JSDScript* jsdscript,
|
||||
uintN lineIn, uintN* lineOut);
|
||||
|
||||
|
||||
#if 0
|
||||
/* our hook proc for LiveWire app start/stop */
|
||||
extern void JS_DLL_CALLBACK
|
||||
jsdlw_AppHookProc(LWDBGApp* app,
|
||||
JSBool created,
|
||||
void *callerdata);
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
/***************************************************************************/
|
||||
|
||||
JS_END_EXTERN_C
|
||||
|
||||
#endif /* jsd_h___ */
|
||||
70
mozilla/js/jsd/jsd.mak
Normal file
70
mozilla/js/jsd/jsd.mak
Normal file
@@ -0,0 +1,70 @@
|
||||
|
||||
PROJ = jsd
|
||||
JSD = .
|
||||
JS = $(JSD)\..\src
|
||||
JSPROJ = js32
|
||||
|
||||
!IF "$(BUILD_OPT)" != ""
|
||||
OBJ = Release
|
||||
CC_FLAGS = /DNDEBUG
|
||||
!ELSE
|
||||
OBJ = Debug
|
||||
CC_FLAGS = /DDEBUG
|
||||
LINK_FLAGS = /DEBUG
|
||||
!ENDIF
|
||||
|
||||
QUIET=@
|
||||
|
||||
CFLAGS = /nologo /MDd /W3 /Gm /GX /Zi /Od\
|
||||
/I $(JS)\
|
||||
/I $(JSD)\
|
||||
/DDEBUG /DWIN32 /D_CONSOLE /DXP_PC /D_WINDOWS /D_WIN32\
|
||||
/DJSDEBUGGER\
|
||||
!IF "$(JSD_THREADSAFE)" != ""
|
||||
/DJSD_THREADSAFE\
|
||||
!ENDIF
|
||||
/DEXPORT_JSD_API\
|
||||
$(CC_FLAGS)\
|
||||
/c /Fp$(OBJ)\$(PROJ).pch /Fd$(OBJ)\$(PROJ).pdb /YX -Fo$@ $<
|
||||
|
||||
LFLAGS = /nologo /subsystem:console /DLL /incremental:no /machine:I386 \
|
||||
$(LINK_FLAGS) /pdb:$(OBJ)\$(PROJ).pdb -out:$(OBJ)\$(PROJ).dll
|
||||
|
||||
LLIBS = kernel32.lib advapi32.lib $(JS)\$(OBJ)\$(JSPROJ).lib
|
||||
# unused... user32.lib gdi32.lib winspool.lib comdlg32.lib shell32.lib
|
||||
|
||||
CPP=cl.exe
|
||||
LINK32=link.exe
|
||||
|
||||
all: $(OBJ) $(OBJ)\$(PROJ).dll
|
||||
|
||||
|
||||
$(OBJ)\$(PROJ).dll: \
|
||||
$(OBJ)\jsdebug.obj \
|
||||
$(OBJ)\jsd_atom.obj \
|
||||
$(OBJ)\jsd_high.obj \
|
||||
$(OBJ)\jsd_hook.obj \
|
||||
$(OBJ)\jsd_obj.obj \
|
||||
$(OBJ)\jsd_scpt.obj \
|
||||
$(OBJ)\jsd_stak.obj \
|
||||
$(OBJ)\jsd_step.obj \
|
||||
$(OBJ)\jsd_text.obj \
|
||||
$(OBJ)\jsd_lock.obj \
|
||||
$(OBJ)\jsd_val.obj
|
||||
$(QUIET)$(LINK32) $(LFLAGS) $** $(LLIBS)
|
||||
|
||||
{$(JSD)}.c{$(OBJ)}.obj :
|
||||
$(QUIET)$(CPP) $(CFLAGS)
|
||||
|
||||
$(OBJ) :
|
||||
$(QUIET)mkdir $(OBJ)
|
||||
|
||||
clean:
|
||||
@echo deleting old output
|
||||
$(QUIET)del $(OBJ)\*.pch >NUL
|
||||
$(QUIET)del $(OBJ)\*.obj >NUL
|
||||
$(QUIET)del $(OBJ)\*.exp >NUL
|
||||
$(QUIET)del $(OBJ)\*.lib >NUL
|
||||
$(QUIET)del $(OBJ)\*.idb >NUL
|
||||
$(QUIET)del $(OBJ)\*.pdb >NUL
|
||||
$(QUIET)del $(OBJ)\*.dll >NUL
|
||||
89
mozilla/js/jsd/jsd1640.def
Normal file
89
mozilla/js/jsd/jsd1640.def
Normal file
@@ -0,0 +1,89 @@
|
||||
; -*- Mode: Fundamental; tab-width: 4; indent-tabs-mode: nil -*-
|
||||
;
|
||||
; The contents of this file are subject to the Netscape Public License
|
||||
; Version 1.0 (the "NPL"); you may not use this file except in
|
||||
; compliance with the NPL. You may obtain a copy of the NPL at
|
||||
; http://www.mozilla.org/NPL/
|
||||
;
|
||||
; Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
; WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
; for the specific language governing rights and limitations under the
|
||||
; NPL.
|
||||
;
|
||||
; The Initial Developer of this code under the NPL is Netscape
|
||||
; Communications Corporation. Portions created by Netscape are
|
||||
; Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
; Reserved.
|
||||
|
||||
|
||||
LIBRARY JSD1640.DLL
|
||||
EXETYPE WINDOWS
|
||||
PROTMODE
|
||||
|
||||
DESCRIPTION 'Netscape 16-bit JavaScript Debugger Library'
|
||||
|
||||
CODE LOADONCALL MOVEABLE DISCARDABLE
|
||||
DATA PRELOAD MOVEABLE SINGLE
|
||||
|
||||
HEAPSIZE 8192
|
||||
|
||||
EXPORTS
|
||||
WEP @1 RESIDENTNAME NONAME
|
||||
_JSD_AppendSourceText
|
||||
_JSD_ClearAllExecutionHooks
|
||||
_JSD_ClearAllExecutionHooksForScript
|
||||
_JSD_ClearDebugBreakHook
|
||||
_JSD_ClearExecutionHook
|
||||
_JSD_ClearInterruptHook
|
||||
_JSD_ClearSourceText
|
||||
_JSD_DebuggerOff
|
||||
_JSD_DebuggerOn
|
||||
_JSD_EvaluateScriptInStackFrame
|
||||
_JSD_FindSourceForURL
|
||||
_JSD_GetCallingStackFrame
|
||||
_JSD_GetClosestLine
|
||||
_JSD_GetClosestPC
|
||||
_JSD_GetCountOfStackFrames
|
||||
_JSD_GetDefaultJSContext
|
||||
_JSD_GetMajorVersion
|
||||
_JSD_GetMinorVersion
|
||||
_JSD_GetPCForStackFrame
|
||||
_JSD_GetScriptBaseLineNumber
|
||||
_JSD_GetScriptFilename
|
||||
_JSD_GetScriptForStackFrame
|
||||
_JSD_GetScriptFunctionName
|
||||
_JSD_GetScriptHook
|
||||
_JSD_GetScriptLineExtent
|
||||
_JSD_GetSourceAlterCount
|
||||
_JSD_GetSourceStatus
|
||||
_JSD_GetSourceText
|
||||
_JSD_GetSourceURL
|
||||
_JSD_GetStackFrame
|
||||
_JSD_IncrementSourceAlterCount
|
||||
_JSD_IsSourceDirty
|
||||
_JSD_IterateScripts
|
||||
_JSD_IterateSources
|
||||
_JSD_LockScriptSubsystem
|
||||
_JSD_LockSourceTextSubsystem
|
||||
_JSD_NewSourceText
|
||||
_JSD_SetDebugBreakHook
|
||||
_JSD_SetErrorReporter
|
||||
_JSD_SetExecutionHook
|
||||
_JSD_SetInterruptHook
|
||||
_JSD_SetScriptHook
|
||||
_JSD_SetSourceDirty
|
||||
_JSD_SetUserCallbacks
|
||||
_JSD_UnlockScriptSubsystem
|
||||
_JSD_UnlockSourceTextSubsystem
|
||||
_Java_netscape_jsdebug_DebugController__0005fsetController_stub
|
||||
_Java_netscape_jsdebug_DebugController_executeScriptInStackFrame_stub
|
||||
_Java_netscape_jsdebug_DebugController_sendInterrupt_stub
|
||||
_Java_netscape_jsdebug_DebugController_setInstructionHook0_stub
|
||||
_Java_netscape_jsdebug_JSPC_getSourceLocation_stub
|
||||
_Java_netscape_jsdebug_JSSourceTextProvider_loadSourceTextItem_stub
|
||||
_Java_netscape_jsdebug_JSSourceTextProvider_refreshSourceTextVector_stub
|
||||
_Java_netscape_jsdebug_JSStackFrameInfo_getCaller0_stub
|
||||
_Java_netscape_jsdebug_JSStackFrameInfo_getPC_stub
|
||||
_Java_netscape_jsdebug_JSThreadState_countStackFrames_stub
|
||||
_Java_netscape_jsdebug_JSThreadState_getCurrentFrame_stub
|
||||
_Java_netscape_jsdebug_Script_getClosestPC_stub
|
||||
80
mozilla/js/jsd/jsd1640.rc
Normal file
80
mozilla/js/jsd/jsd1640.rc
Normal file
@@ -0,0 +1,80 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Version stamp for this .DLL
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include <ver.h>
|
||||
|
||||
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
|
||||
FILEVERSION 4 // major, minor, release (alpha 1), build #
|
||||
|
||||
PRODUCTVERSION 4
|
||||
|
||||
FILEFLAGSMASK 0
|
||||
|
||||
FILEFLAGS 0 // final version
|
||||
|
||||
FILEOS VOS_DOS_WINDOWS16
|
||||
|
||||
FILETYPE VFT_DLL
|
||||
|
||||
FILESUBTYPE 0 // not used
|
||||
|
||||
BEGIN
|
||||
|
||||
BLOCK "StringFileInfo"
|
||||
|
||||
BEGIN
|
||||
|
||||
BLOCK "040904E4" // Lang=US English, CharSet=Windows Multilingual
|
||||
|
||||
BEGIN
|
||||
|
||||
VALUE "CompanyName", "Netscape Communications Corporation\0"
|
||||
|
||||
VALUE "FileDescription", "Netscape 16-bit JavaScript Debugger Module\0"
|
||||
|
||||
VALUE "FileVersion", "4.0\0"
|
||||
|
||||
VALUE "InternalName", "JSD1640\0"
|
||||
|
||||
VALUE "LegalCopyright", "Copyright Netscape Communications. 1994-96\0"
|
||||
|
||||
VALUE "LegalTrademarks", "Netscape, Mozilla\0"
|
||||
|
||||
VALUE "OriginalFilename","JSD1640.DLL\0"
|
||||
|
||||
VALUE "ProductName", "NETSCAPE\0"
|
||||
|
||||
VALUE "ProductVersion", "4.0\0"
|
||||
|
||||
END
|
||||
|
||||
END
|
||||
|
||||
END
|
||||
|
||||
99
mozilla/js/jsd/jsd3240.rc
Normal file
99
mozilla/js/jsd/jsd3240.rc
Normal file
@@ -0,0 +1,99 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
//Microsoft Developer Studio generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "winver.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Version
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 4,0,0,0
|
||||
PRODUCTVERSION 4,0,0,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
#else
|
||||
FILEFLAGS 0x0L
|
||||
#endif
|
||||
FILEOS 0x10004L
|
||||
FILETYPE 0x2L
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904e4"
|
||||
BEGIN
|
||||
VALUE "CompanyName", "Netscape Communications Corporation\0"
|
||||
VALUE "FileDescription", "Netscape 32-bit JavaScript Debugger Module\0"
|
||||
VALUE "FileVersion", "4.0\0"
|
||||
VALUE "InternalName", "JSD3240\0"
|
||||
VALUE "LegalCopyright", "Copyright Netscape Communications. 1994-96\0"
|
||||
VALUE "LegalTrademarks", "Netscape, Mozilla\0"
|
||||
VALUE "OriginalFilename", "jsd3240.dll\0"
|
||||
VALUE "ProductName", "NETSCAPE\0"
|
||||
VALUE "ProductVersion", "4.0\0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1252
|
||||
END
|
||||
END
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"#include ""winver.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
159
mozilla/js/jsd/jsd_atom.c
Normal file
159
mozilla/js/jsd/jsd_atom.c
Normal file
@@ -0,0 +1,159 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* JavaScript Debugging support - Atom support
|
||||
*/
|
||||
|
||||
#include "jsd.h"
|
||||
|
||||
/* #define TEST_ATOMS 1 */
|
||||
|
||||
#ifdef TEST_ATOMS
|
||||
static void
|
||||
_testAtoms(JSDContext*jsdc)
|
||||
{
|
||||
JSDAtom* atom0 = jsd_AddAtom(jsdc, "foo");
|
||||
JSDAtom* atom1 = jsd_AddAtom(jsdc, "foo");
|
||||
JSDAtom* atom2 = jsd_AddAtom(jsdc, "bar");
|
||||
JSDAtom* atom3 = jsd_CloneAtom(jsdc, atom1);
|
||||
JSDAtom* atom4 = jsd_CloneAtom(jsdc, atom2);
|
||||
|
||||
const char* c0 = JSD_ATOM_TO_STRING(atom0);
|
||||
const char* c1 = JSD_ATOM_TO_STRING(atom1);
|
||||
const char* c2 = JSD_ATOM_TO_STRING(atom2);
|
||||
const char* c3 = JSD_ATOM_TO_STRING(atom3);
|
||||
const char* c4 = JSD_ATOM_TO_STRING(atom4);
|
||||
|
||||
jsd_DropAtom(jsdc, atom0);
|
||||
jsd_DropAtom(jsdc, atom1);
|
||||
jsd_DropAtom(jsdc, atom2);
|
||||
jsd_DropAtom(jsdc, atom3);
|
||||
jsd_DropAtom(jsdc, atom4);
|
||||
}
|
||||
#endif
|
||||
|
||||
JS_STATIC_DLL_CALLBACK(intN)
|
||||
_atom_smasher(JSHashEntry *he, intN i, void *arg)
|
||||
{
|
||||
JS_ASSERT(he);
|
||||
JS_ASSERT(he->value);
|
||||
JS_ASSERT(((JSDAtom*)(he->value))->str);
|
||||
|
||||
free(((JSDAtom*)(he->value))->str);
|
||||
free(he->value);
|
||||
he->value = NULL;
|
||||
he->key = NULL;
|
||||
return HT_ENUMERATE_NEXT;
|
||||
}
|
||||
|
||||
JS_STATIC_DLL_CALLBACK(intN)
|
||||
_compareAtomKeys(const void *v1, const void *v2)
|
||||
{
|
||||
return 0 == strcmp((const char*)v1, (const char*)v2);
|
||||
}
|
||||
|
||||
JS_STATIC_DLL_CALLBACK(intN)
|
||||
_compareAtoms(const void *v1, const void *v2)
|
||||
{
|
||||
return 0 == strcmp(((JSDAtom*)v1)->str, ((JSDAtom*)v2)->str);
|
||||
}
|
||||
|
||||
|
||||
JSBool
|
||||
jsd_CreateAtomTable(JSDContext* jsdc)
|
||||
{
|
||||
jsdc->atoms = JS_NewHashTable(256, JS_HashString,
|
||||
_compareAtomKeys, _compareAtoms,
|
||||
NULL, NULL);
|
||||
#ifdef TEST_ATOMS
|
||||
_testAtoms(jsdc);
|
||||
#endif
|
||||
return (JSBool) jsdc->atoms;
|
||||
}
|
||||
|
||||
void
|
||||
jsd_DestroyAtomTable(JSDContext* jsdc)
|
||||
{
|
||||
if( jsdc->atoms )
|
||||
{
|
||||
JS_HashTableEnumerateEntries(jsdc->atoms, _atom_smasher, NULL);
|
||||
JS_HashTableDestroy(jsdc->atoms);
|
||||
jsdc->atoms = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
JSDAtom*
|
||||
jsd_AddAtom(JSDContext* jsdc, const char* str)
|
||||
{
|
||||
JSDAtom* atom;
|
||||
|
||||
if(!str)
|
||||
{
|
||||
JS_ASSERT(0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
JSD_LOCK_ATOMS(jsdc);
|
||||
|
||||
atom = (JSDAtom*) JS_HashTableLookup(jsdc->atoms, str);
|
||||
|
||||
if( atom )
|
||||
atom->refcount++;
|
||||
else
|
||||
{
|
||||
atom = (JSDAtom*) malloc(sizeof(JSDAtom));
|
||||
if( atom )
|
||||
{
|
||||
atom->str = strdup(str);
|
||||
atom->refcount = 1;
|
||||
if(!JS_HashTableAdd(jsdc->atoms, atom->str, atom))
|
||||
{
|
||||
free(atom->str);
|
||||
free(atom);
|
||||
atom = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
JSD_UNLOCK_ATOMS(jsdc);
|
||||
return atom;
|
||||
}
|
||||
|
||||
JSDAtom*
|
||||
jsd_CloneAtom(JSDContext* jsdc, JSDAtom* atom)
|
||||
{
|
||||
JSD_LOCK_ATOMS(jsdc);
|
||||
atom->refcount++;
|
||||
JSD_UNLOCK_ATOMS(jsdc);
|
||||
return atom;
|
||||
}
|
||||
|
||||
void
|
||||
jsd_DropAtom(JSDContext* jsdc, JSDAtom* atom)
|
||||
{
|
||||
JSD_LOCK_ATOMS(jsdc);
|
||||
if(! --atom->refcount)
|
||||
{
|
||||
JS_HashTableRemove(jsdc->atoms, atom->str);
|
||||
free(atom->str);
|
||||
free(atom);
|
||||
}
|
||||
JSD_UNLOCK_ATOMS(jsdc);
|
||||
}
|
||||
|
||||
348
mozilla/js/jsd/jsd_high.c
Normal file
348
mozilla/js/jsd/jsd_high.c
Normal file
@@ -0,0 +1,348 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* JavaScript Debugging support - 'High Level' functions
|
||||
*/
|
||||
|
||||
#include "jsd.h"
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
/* XXX not 'static' because of old Mac CodeWarrior bug */
|
||||
JSCList _jsd_context_list = JS_INIT_STATIC_CLIST(&_jsd_context_list);
|
||||
|
||||
/* these are used to connect JSD_SetUserCallbacks() with JSD_DebuggerOn() */
|
||||
static JSD_UserCallbacks _callbacks;
|
||||
static void* _user = NULL;
|
||||
static JSRuntime* _jsrt = NULL;
|
||||
|
||||
#ifdef JSD_HAS_DANGEROUS_THREAD
|
||||
static void* _dangerousThread = NULL;
|
||||
#endif
|
||||
|
||||
#ifdef JSD_THREADSAFE
|
||||
void* _jsd_global_lock = NULL;
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
void JSD_ASSERT_VALID_CONTEXT(JSDContext* jsdc)
|
||||
{
|
||||
JS_ASSERT(jsdc->inited);
|
||||
JS_ASSERT(jsdc->jsrt);
|
||||
JS_ASSERT(jsdc->dumbContext);
|
||||
JS_ASSERT(jsdc->glob);
|
||||
}
|
||||
#endif
|
||||
|
||||
static JSClass global_class = {
|
||||
"JSDGlobal", 0,
|
||||
JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
|
||||
JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub
|
||||
};
|
||||
|
||||
static JSBool
|
||||
_validateUserCallbacks(JSD_UserCallbacks* callbacks)
|
||||
{
|
||||
return !callbacks ||
|
||||
(callbacks->size && callbacks->size <= sizeof(JSD_UserCallbacks));
|
||||
}
|
||||
|
||||
static JSDContext*
|
||||
_newJSDContext(JSRuntime* jsrt,
|
||||
JSD_UserCallbacks* callbacks,
|
||||
void* user)
|
||||
{
|
||||
JSDContext* jsdc = NULL;
|
||||
|
||||
if( ! jsrt )
|
||||
return NULL;
|
||||
|
||||
if( ! _validateUserCallbacks(callbacks) )
|
||||
return NULL;
|
||||
|
||||
jsdc = (JSDContext*) calloc(1, sizeof(JSDContext));
|
||||
if( ! jsdc )
|
||||
goto label_newJSDContext_failure;
|
||||
|
||||
if( ! JSD_INIT_LOCKS(jsdc) )
|
||||
goto label_newJSDContext_failure;
|
||||
|
||||
JS_INIT_CLIST(&jsdc->links);
|
||||
|
||||
jsdc->jsrt = jsrt;
|
||||
|
||||
if( callbacks )
|
||||
memcpy(&jsdc->userCallbacks, callbacks, callbacks->size);
|
||||
|
||||
jsdc->user = user;
|
||||
|
||||
#ifdef JSD_HAS_DANGEROUS_THREAD
|
||||
jsdc->dangerousThread = _dangerousThread;
|
||||
#endif
|
||||
|
||||
JS_INIT_CLIST(&jsdc->threadsStates);
|
||||
JS_INIT_CLIST(&jsdc->scripts);
|
||||
JS_INIT_CLIST(&jsdc->sources);
|
||||
JS_INIT_CLIST(&jsdc->removedSources);
|
||||
|
||||
jsdc->sourceAlterCount = 1;
|
||||
|
||||
if( ! jsd_CreateAtomTable(jsdc) )
|
||||
goto label_newJSDContext_failure;
|
||||
|
||||
if( ! jsd_InitObjectManager(jsdc) )
|
||||
goto label_newJSDContext_failure;
|
||||
|
||||
jsdc->dumbContext = JS_NewContext(jsdc->jsrt, 256);
|
||||
if( ! jsdc->dumbContext )
|
||||
goto label_newJSDContext_failure;
|
||||
|
||||
jsdc->glob = JS_NewObject(jsdc->dumbContext, &global_class, NULL, NULL);
|
||||
if( ! jsdc->glob )
|
||||
goto label_newJSDContext_failure;
|
||||
|
||||
if( ! JS_InitStandardClasses(jsdc->dumbContext, jsdc->glob) )
|
||||
goto label_newJSDContext_failure;
|
||||
|
||||
jsdc->inited = JS_TRUE;
|
||||
|
||||
JSD_LOCK();
|
||||
JS_INSERT_LINK(&jsdc->links, &_jsd_context_list);
|
||||
JSD_UNLOCK();
|
||||
|
||||
return jsdc;
|
||||
|
||||
label_newJSDContext_failure:
|
||||
jsd_DestroyObjectManager(jsdc);
|
||||
jsd_DestroyAtomTable(jsdc);
|
||||
if( jsdc )
|
||||
free(jsdc);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
_destroyJSDContext(JSDContext* jsdc)
|
||||
{
|
||||
JSD_ASSERT_VALID_CONTEXT(jsdc);
|
||||
|
||||
JSD_LOCK();
|
||||
JS_REMOVE_LINK(&jsdc->links);
|
||||
JSD_UNLOCK();
|
||||
|
||||
jsd_DestroyObjectManager(jsdc);
|
||||
jsd_DestroyAtomTable(jsdc);
|
||||
|
||||
jsdc->inited = JS_FALSE;
|
||||
|
||||
/*
|
||||
* We should free jsdc here, but we let it leak in case there are any
|
||||
* asynchronous hooks calling into the system using it as a handle
|
||||
*
|
||||
* XXX we also leak the locks
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
JSDContext*
|
||||
jsd_DebuggerOnForUser(JSRuntime* jsrt,
|
||||
JSD_UserCallbacks* callbacks,
|
||||
void* user)
|
||||
{
|
||||
JSDContext* jsdc;
|
||||
JSContext* iter = NULL;
|
||||
|
||||
jsdc = _newJSDContext(jsrt, callbacks, user);
|
||||
if( ! jsdc )
|
||||
return NULL;
|
||||
|
||||
/* set hooks here */
|
||||
JS_SetNewScriptHookProc(jsdc->jsrt, jsd_NewScriptHookProc, jsdc);
|
||||
JS_SetDestroyScriptHookProc(jsdc->jsrt, jsd_DestroyScriptHookProc, jsdc);
|
||||
JS_SetDebuggerHandler(jsdc->jsrt, jsd_DebuggerHandler, jsdc);
|
||||
JS_SetExecuteHook(jsdc->jsrt, jsd_InterpreterHook, jsdc);
|
||||
JS_SetCallHook(jsdc->jsrt, jsd_InterpreterHook, jsdc);
|
||||
JS_SetObjectHook(jsdc->jsrt, jsd_ObjectHook, jsdc);
|
||||
JS_SetThrowHook(jsdc->jsrt, jsd_ThrowHandler, jsdc);
|
||||
JS_SetDebugErrorHook(jsdc->jsrt, jsd_DebugErrorHook, jsdc);
|
||||
#ifdef LIVEWIRE
|
||||
LWDBG_SetNewScriptHookProc(jsd_NewScriptHookProc, jsdc);
|
||||
#endif
|
||||
if( jsdc->userCallbacks.setContext )
|
||||
jsdc->userCallbacks.setContext(jsdc, jsdc->user);
|
||||
return jsdc;
|
||||
}
|
||||
|
||||
JSDContext*
|
||||
jsd_DebuggerOn(void)
|
||||
{
|
||||
JS_ASSERT(_jsrt);
|
||||
JS_ASSERT(_validateUserCallbacks(&_callbacks));
|
||||
return jsd_DebuggerOnForUser(_jsrt, &_callbacks, _user);
|
||||
}
|
||||
|
||||
void
|
||||
jsd_DebuggerOff(JSDContext* jsdc)
|
||||
{
|
||||
/* clear hooks here */
|
||||
JS_SetNewScriptHookProc(jsdc->jsrt, NULL, NULL);
|
||||
JS_SetDestroyScriptHookProc(jsdc->jsrt, NULL, NULL);
|
||||
JS_SetDebuggerHandler(jsdc->jsrt, NULL, NULL);
|
||||
JS_SetExecuteHook(jsdc->jsrt, NULL, NULL);
|
||||
JS_SetCallHook(jsdc->jsrt, NULL, NULL);
|
||||
JS_SetObjectHook(jsdc->jsrt, NULL, NULL);
|
||||
JS_SetThrowHook(jsdc->jsrt, NULL, NULL);
|
||||
JS_SetDebugErrorHook(jsdc->jsrt, NULL, NULL);
|
||||
#ifdef LIVEWIRE
|
||||
LWDBG_SetNewScriptHookProc(NULL,NULL);
|
||||
#endif
|
||||
|
||||
/* clean up */
|
||||
jsd_DestroyAllJSDScripts(jsdc);
|
||||
jsd_DestroyAllSources(jsdc);
|
||||
|
||||
_destroyJSDContext(jsdc);
|
||||
|
||||
if( jsdc->userCallbacks.setContext )
|
||||
jsdc->userCallbacks.setContext(NULL, jsdc->user);
|
||||
}
|
||||
|
||||
void
|
||||
jsd_SetUserCallbacks(JSRuntime* jsrt, JSD_UserCallbacks* callbacks, void* user)
|
||||
{
|
||||
_jsrt = jsrt;
|
||||
_user = user;
|
||||
|
||||
#ifdef JSD_HAS_DANGEROUS_THREAD
|
||||
_dangerousThread = JSD_CURRENT_THREAD();
|
||||
#endif
|
||||
|
||||
if( callbacks )
|
||||
memcpy(&_callbacks, callbacks, sizeof(JSD_UserCallbacks));
|
||||
else
|
||||
memset(&_callbacks, 0 , sizeof(JSD_UserCallbacks));
|
||||
}
|
||||
|
||||
JSDContext*
|
||||
jsd_JSDContextForJSContext(JSContext* context)
|
||||
{
|
||||
JSDContext* iter;
|
||||
JSDContext* jsdc = NULL;
|
||||
JSRuntime* runtime = JS_GetRuntime(context);
|
||||
|
||||
JSD_LOCK();
|
||||
for( iter = (JSDContext*)_jsd_context_list.next;
|
||||
iter != (JSDContext*)&_jsd_context_list;
|
||||
iter = (JSDContext*)iter->links.next )
|
||||
{
|
||||
if( runtime == iter->jsrt )
|
||||
{
|
||||
jsdc = iter;
|
||||
break;
|
||||
}
|
||||
}
|
||||
JSD_UNLOCK();
|
||||
return jsdc;
|
||||
}
|
||||
|
||||
JS_STATIC_DLL_CALLBACK(JSBool)
|
||||
jsd_DebugErrorHook(JSContext *cx, const char *message,
|
||||
JSErrorReport *report, void *closure)
|
||||
{
|
||||
JSDContext* jsdc = (JSDContext*) closure;
|
||||
JSD_ErrorReporter errorReporter;
|
||||
void* errorReporterData;
|
||||
|
||||
if( ! jsdc )
|
||||
{
|
||||
JS_ASSERT(0);
|
||||
return JS_TRUE;
|
||||
}
|
||||
if( JSD_IS_DANGEROUS_THREAD(jsdc) )
|
||||
return JS_TRUE;
|
||||
|
||||
/* local in case hook gets cleared on another thread */
|
||||
JSD_LOCK();
|
||||
errorReporter = jsdc->errorReporter;
|
||||
errorReporterData = jsdc->errorReporterData;
|
||||
JSD_UNLOCK();
|
||||
|
||||
if(!errorReporter)
|
||||
return JS_TRUE;
|
||||
|
||||
switch(errorReporter(jsdc, cx, message, report, errorReporterData))
|
||||
{
|
||||
case JSD_ERROR_REPORTER_PASS_ALONG:
|
||||
return JS_TRUE;
|
||||
case JSD_ERROR_REPORTER_RETURN:
|
||||
return JS_FALSE;
|
||||
case JSD_ERROR_REPORTER_DEBUG:
|
||||
{
|
||||
jsval rval;
|
||||
JSD_ExecutionHookProc hook;
|
||||
void* hookData;
|
||||
|
||||
/* local in case hook gets cleared on another thread */
|
||||
JSD_LOCK();
|
||||
hook = jsdc->debugBreakHook;
|
||||
hookData = jsdc->debugBreakHookData;
|
||||
JSD_UNLOCK();
|
||||
|
||||
jsd_CallExecutionHook(jsdc, cx, JSD_HOOK_DEBUG_REQUESTED,
|
||||
hook, hookData, &rval);
|
||||
/* XXX Should make this dependent on ExecutionHook retval */
|
||||
return JS_TRUE;
|
||||
}
|
||||
case JSD_ERROR_REPORTER_CLEAR_RETURN:
|
||||
if(report && JSREPORT_IS_EXCEPTION(report->flags))
|
||||
JS_ClearPendingException(cx);
|
||||
return JS_FALSE;
|
||||
default:
|
||||
JS_ASSERT(0);
|
||||
break;
|
||||
}
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JSBool
|
||||
jsd_SetErrorReporter(JSDContext* jsdc,
|
||||
JSD_ErrorReporter reporter,
|
||||
void* callerdata)
|
||||
{
|
||||
JSD_LOCK();
|
||||
jsdc->errorReporter = reporter;
|
||||
jsdc->errorReporterData = callerdata;
|
||||
JSD_UNLOCK();
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JSBool
|
||||
jsd_GetErrorReporter(JSDContext* jsdc,
|
||||
JSD_ErrorReporter* reporter,
|
||||
void** callerdata)
|
||||
{
|
||||
JSD_LOCK();
|
||||
if( reporter )
|
||||
*reporter = jsdc->errorReporter;
|
||||
if( callerdata )
|
||||
*callerdata = jsdc->errorReporterData;
|
||||
JSD_UNLOCK();
|
||||
return JS_TRUE;
|
||||
}
|
||||
260
mozilla/js/jsd/jsd_hook.c
Normal file
260
mozilla/js/jsd/jsd_hook.c
Normal file
@@ -0,0 +1,260 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* JavaScript Debugging support - Hook support
|
||||
*/
|
||||
|
||||
#include "jsd.h"
|
||||
|
||||
JSTrapStatus JS_DLL_CALLBACK
|
||||
jsd_InterruptHandler(JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval,
|
||||
void *closure)
|
||||
{
|
||||
JSDScript* jsdscript;
|
||||
JSDContext* jsdc = (JSDContext*) closure;
|
||||
JSD_ExecutionHookProc hook;
|
||||
void* hookData;
|
||||
|
||||
if( ! jsdc || ! jsdc->inited )
|
||||
return JSTRAP_CONTINUE;
|
||||
|
||||
if( JSD_IS_DANGEROUS_THREAD(jsdc) )
|
||||
return JSTRAP_CONTINUE;
|
||||
|
||||
JSD_LOCK_SCRIPTS(jsdc);
|
||||
jsdscript = jsd_FindJSDScript(jsdc, script);
|
||||
JSD_UNLOCK_SCRIPTS(jsdc);
|
||||
if( ! jsdscript )
|
||||
return JSTRAP_CONTINUE;
|
||||
|
||||
#ifdef LIVEWIRE
|
||||
if( ! jsdlw_UserCodeAtPC(jsdc, jsdscript, (jsuword)pc) )
|
||||
return JSTRAP_CONTINUE;
|
||||
#endif
|
||||
|
||||
/* local in case jsdc->interruptHook gets cleared on another thread */
|
||||
JSD_LOCK();
|
||||
hook = jsdc->interruptHook;
|
||||
hookData = jsdc->interruptHookData;
|
||||
JSD_UNLOCK();
|
||||
|
||||
return jsd_CallExecutionHook(jsdc, cx, JSD_HOOK_INTERRUPTED,
|
||||
hook, hookData, rval);
|
||||
}
|
||||
|
||||
JSTrapStatus JS_DLL_CALLBACK
|
||||
jsd_DebuggerHandler(JSContext *cx, JSScript *script, jsbytecode *pc,
|
||||
jsval *rval, void *closure)
|
||||
{
|
||||
JSDScript* jsdscript;
|
||||
JSDContext* jsdc = (JSDContext*) closure;
|
||||
JSD_ExecutionHookProc hook;
|
||||
void* hookData;
|
||||
|
||||
if( ! jsdc || ! jsdc->inited )
|
||||
return JSTRAP_CONTINUE;
|
||||
|
||||
if( JSD_IS_DANGEROUS_THREAD(jsdc) )
|
||||
return JSTRAP_CONTINUE;
|
||||
|
||||
JSD_LOCK_SCRIPTS(jsdc);
|
||||
jsdscript = jsd_FindJSDScript(jsdc, script);
|
||||
JSD_UNLOCK_SCRIPTS(jsdc);
|
||||
if( ! jsdscript )
|
||||
return JSTRAP_CONTINUE;
|
||||
|
||||
/* local in case jsdc->debuggerHook gets cleared on another thread */
|
||||
JSD_LOCK();
|
||||
hook = jsdc->debuggerHook;
|
||||
hookData = jsdc->debuggerHookData;
|
||||
JSD_UNLOCK();
|
||||
|
||||
return jsd_CallExecutionHook(jsdc, cx, JSD_HOOK_DEBUGGER_KEYWORD,
|
||||
hook, hookData, rval);
|
||||
}
|
||||
|
||||
|
||||
JSTrapStatus JS_DLL_CALLBACK
|
||||
jsd_ThrowHandler(JSContext *cx, JSScript *script, jsbytecode *pc,
|
||||
jsval *rval, void *closure)
|
||||
{
|
||||
JSDScript* jsdscript;
|
||||
JSDContext* jsdc = (JSDContext*) closure;
|
||||
JSD_ExecutionHookProc hook;
|
||||
void* hookData;
|
||||
|
||||
JS_GetPendingException(cx, rval);
|
||||
|
||||
if( ! jsdc || ! jsdc->inited )
|
||||
return JSD_HOOK_RETURN_CONTINUE_THROW;
|
||||
|
||||
if( JSD_IS_DANGEROUS_THREAD(jsdc) )
|
||||
return JSD_HOOK_RETURN_CONTINUE_THROW;
|
||||
|
||||
JSD_LOCK_SCRIPTS(jsdc);
|
||||
jsdscript = jsd_FindJSDScript(jsdc, script);
|
||||
JSD_UNLOCK_SCRIPTS(jsdc);
|
||||
if( ! jsdscript )
|
||||
return JSD_HOOK_RETURN_CONTINUE_THROW;
|
||||
|
||||
/* local in case jsdc->throwHook gets cleared on another thread */
|
||||
JSD_LOCK();
|
||||
hook = jsdc->throwHook;
|
||||
hookData = jsdc->throwHookData;
|
||||
JSD_UNLOCK();
|
||||
|
||||
return jsd_CallExecutionHook(jsdc, cx, JSD_HOOK_THROW,
|
||||
hook, hookData, rval);
|
||||
}
|
||||
|
||||
JSTrapStatus
|
||||
jsd_CallExecutionHook(JSDContext* jsdc,
|
||||
JSContext *cx,
|
||||
JSDHookType type,
|
||||
JSD_ExecutionHookProc hook,
|
||||
void* hookData,
|
||||
jsval* rval)
|
||||
{
|
||||
JSDHookResult hookanswer = JSD_HOOK_THROW == type ?
|
||||
JSD_HOOK_RETURN_CONTINUE_THROW :
|
||||
JSD_HOOK_RETURN_CONTINUE;
|
||||
JSDThreadState* jsdthreadstate;
|
||||
|
||||
if(hook && NULL != (jsdthreadstate = jsd_NewThreadState(jsdc,cx)))
|
||||
{
|
||||
hookanswer = hook(jsdc, jsdthreadstate, type, hookData, rval);
|
||||
jsd_DestroyThreadState(jsdc, jsdthreadstate);
|
||||
}
|
||||
|
||||
switch(hookanswer)
|
||||
{
|
||||
case JSD_HOOK_RETURN_ABORT:
|
||||
case JSD_HOOK_RETURN_HOOK_ERROR:
|
||||
return JSTRAP_ERROR;
|
||||
case JSD_HOOK_RETURN_RET_WITH_VAL:
|
||||
return JSTRAP_RETURN;
|
||||
case JSD_HOOK_RETURN_THROW_WITH_VAL:
|
||||
return JSTRAP_THROW;
|
||||
case JSD_HOOK_RETURN_CONTINUE:
|
||||
break;
|
||||
case JSD_HOOK_RETURN_CONTINUE_THROW:
|
||||
/* only makes sense for jsd_ThrowHandler (which init'd rval) */
|
||||
JS_ASSERT(JSD_HOOK_THROW == type);
|
||||
return JSTRAP_THROW;
|
||||
default:
|
||||
JS_ASSERT(0);
|
||||
break;
|
||||
}
|
||||
return JSTRAP_CONTINUE;
|
||||
}
|
||||
|
||||
JSBool
|
||||
jsd_SetInterruptHook(JSDContext* jsdc,
|
||||
JSD_ExecutionHookProc hook,
|
||||
void* callerdata)
|
||||
{
|
||||
JSD_LOCK();
|
||||
jsdc->interruptHookData = callerdata;
|
||||
jsdc->interruptHook = hook;
|
||||
JS_SetInterrupt(jsdc->jsrt, jsd_InterruptHandler, (void*) jsdc);
|
||||
JSD_UNLOCK();
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JSBool
|
||||
jsd_ClearInterruptHook(JSDContext* jsdc)
|
||||
{
|
||||
JSD_LOCK();
|
||||
JS_ClearInterrupt(jsdc->jsrt, NULL, NULL );
|
||||
jsdc->interruptHook = NULL;
|
||||
JSD_UNLOCK();
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JSBool
|
||||
jsd_SetDebugBreakHook(JSDContext* jsdc,
|
||||
JSD_ExecutionHookProc hook,
|
||||
void* callerdata)
|
||||
{
|
||||
JSD_LOCK();
|
||||
jsdc->debugBreakHookData = callerdata;
|
||||
jsdc->debugBreakHook = hook;
|
||||
JSD_UNLOCK();
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JSBool
|
||||
jsd_ClearDebugBreakHook(JSDContext* jsdc)
|
||||
{
|
||||
JSD_LOCK();
|
||||
jsdc->debugBreakHook = NULL;
|
||||
JSD_UNLOCK();
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JSBool
|
||||
jsd_SetDebuggerHook(JSDContext* jsdc,
|
||||
JSD_ExecutionHookProc hook,
|
||||
void* callerdata)
|
||||
{
|
||||
JSD_LOCK();
|
||||
jsdc->debuggerHookData = callerdata;
|
||||
jsdc->debuggerHook = hook;
|
||||
JSD_UNLOCK();
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JSBool
|
||||
jsd_ClearDebuggerHook(JSDContext* jsdc)
|
||||
{
|
||||
JSD_LOCK();
|
||||
jsdc->debuggerHook = NULL;
|
||||
JSD_UNLOCK();
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JSBool
|
||||
jsd_SetThrowHook(JSDContext* jsdc,
|
||||
JSD_ExecutionHookProc hook,
|
||||
void* callerdata)
|
||||
{
|
||||
JSD_LOCK();
|
||||
jsdc->throwHookData = callerdata;
|
||||
jsdc->throwHook = hook;
|
||||
JSD_UNLOCK();
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JSBool
|
||||
jsd_ClearThrowHook(JSDContext* jsdc)
|
||||
{
|
||||
JSD_LOCK();
|
||||
jsdc->throwHook = NULL;
|
||||
JSD_UNLOCK();
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
801
mozilla/js/jsd/jsd_java.c
Normal file
801
mozilla/js/jsd/jsd_java.c
Normal file
@@ -0,0 +1,801 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/* this is all going away... replaced by code in js/jsd/java */
|
||||
|
||||
#if 0
|
||||
|
||||
#include "native.h"
|
||||
#include "jsdebug.h"
|
||||
|
||||
#ifndef XP_MAC
|
||||
#include "_gen/netscape_jsdebug_DebugController.h"
|
||||
#include "_gen/netscape_jsdebug_Script.h"
|
||||
#include "_gen/netscape_jsdebug_JSThreadState.h"
|
||||
#include "_gen/netscape_jsdebug_JSStackFrameInfo.h"
|
||||
#include "_gen/netscape_jsdebug_JSPC.h"
|
||||
#include "_gen/netscape_jsdebug_JSSourceTextProvider.h"
|
||||
#include "_gen/netscape_jsdebug_JSErrorReporter.h"
|
||||
#else
|
||||
#include "n_jsdebug_DebugController.h"
|
||||
#include "netscape_jsdebug_Script.h"
|
||||
#include "n_jsdebug_JSThreadState.h"
|
||||
#include "n_jsdebug_JSStackFrameInfo.h"
|
||||
#include "netscape_jsdebug_JSPC.h"
|
||||
#include "n_j_JSSourceTextProvider.h"
|
||||
#include "n_jsdebug_JSErrorReporter.h"
|
||||
#endif
|
||||
|
||||
static JSDContext* context = 0;
|
||||
static struct Hnetscape_jsdebug_DebugController* controller = 0;
|
||||
|
||||
/***************************************************************************/
|
||||
/* helpers */
|
||||
|
||||
static JHandle*
|
||||
_constructInteger(ExecEnv *ee, long i)
|
||||
{
|
||||
return (JHandle*)
|
||||
execute_java_constructor(ee, "java/lang/Integer", 0, "(I)", i);
|
||||
}
|
||||
|
||||
static JHandle*
|
||||
_putHash(ExecEnv *ee, JHandle* tbl, JHandle* key, JHandle* ob)
|
||||
{
|
||||
return (JHandle*)
|
||||
execute_java_dynamic_method(
|
||||
ee, tbl, "put",
|
||||
"(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;",
|
||||
key, ob );
|
||||
}
|
||||
|
||||
static JHandle*
|
||||
_getHash(ExecEnv *ee, JHandle* tbl, JHandle* key)
|
||||
{
|
||||
return (JHandle*)
|
||||
execute_java_dynamic_method(
|
||||
ee, tbl, "get",
|
||||
"(Ljava/lang/Object;)Ljava/lang/Object;",
|
||||
key );
|
||||
}
|
||||
|
||||
static JHandle*
|
||||
_removeHash(ExecEnv *ee, JHandle* tbl, JHandle* key)
|
||||
{
|
||||
return (JHandle*)
|
||||
execute_java_dynamic_method(
|
||||
ee, tbl, "remove",
|
||||
"(Ljava/lang/Object;)Ljava/lang/Object;",
|
||||
key );
|
||||
}
|
||||
|
||||
struct Hnetscape_jsdebug_JSStackFrameInfo*
|
||||
_constructJSStackFrameInfo( ExecEnv* ee, JSDStackFrameInfo* jsdframe,
|
||||
struct Hnetscape_jsdebug_JSThreadState* threadState )
|
||||
{
|
||||
struct Hnetscape_jsdebug_JSStackFrameInfo* frame;
|
||||
|
||||
frame = (struct Hnetscape_jsdebug_JSStackFrameInfo*)
|
||||
execute_java_constructor( ee, "netscape/jsdebug/JSStackFrameInfo", 0,
|
||||
"(Lnetscape/jsdebug/JSThreadState;)",
|
||||
threadState );
|
||||
if( ! frame )
|
||||
return NULL;
|
||||
|
||||
/* XXX fill in additional fields */
|
||||
unhand(frame)->_nativePtr = (long) jsdframe;
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
struct Hnetscape_jsdebug_JSPC*
|
||||
_constructJSPC( ExecEnv* ee, struct Hnetscape_jsdebug_Script* script, long pc )
|
||||
{
|
||||
struct Hnetscape_jsdebug_JSPC * pcOb;
|
||||
|
||||
pcOb = (struct Hnetscape_jsdebug_JSPC *)
|
||||
execute_java_constructor( ee, "netscape/jsdebug/JSPC", 0,
|
||||
"(Lnetscape/jsdebug/Script;I)",
|
||||
script, pc );
|
||||
if( ! pcOb )
|
||||
return NULL;
|
||||
|
||||
/* XXX fill in additional fields */
|
||||
|
||||
return pcOb;
|
||||
}
|
||||
|
||||
static Hnetscape_jsdebug_Script*
|
||||
_scriptObFromJSDScriptPtr( ExecEnv* ee, JSDScript* jsdscript )
|
||||
{
|
||||
JHandle* tbl = (JHandle*) unhand(controller)->scriptTable;
|
||||
JHandle* key = _constructInteger(ee,(long)jsdscript);
|
||||
return (Hnetscape_jsdebug_Script*) _getHash( ee, tbl, key );
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
void PR_CALLBACK
|
||||
_scriptHook( JSDContext* jsdc,
|
||||
JSDScript* jsdscript,
|
||||
JSBool creating,
|
||||
void* callerdata )
|
||||
{
|
||||
Hnetscape_jsdebug_Script* script;
|
||||
ExecEnv* ee = EE();
|
||||
|
||||
if( ! context || ! controller || ! ee )
|
||||
return;
|
||||
|
||||
if( creating )
|
||||
{
|
||||
char* url = (char*)JSD_GetScriptFilename (jsdc, jsdscript);
|
||||
char* function = (char*)JSD_GetScriptFunctionName (jsdc, jsdscript);
|
||||
int base = JSD_GetScriptBaseLineNumber (jsdc, jsdscript);
|
||||
int extent = JSD_GetScriptLineExtent (jsdc, jsdscript);
|
||||
|
||||
if( ! url )
|
||||
{
|
||||
return;
|
||||
/* url = ""; */
|
||||
}
|
||||
|
||||
/* create Java Object for Script */
|
||||
script = (Hnetscape_jsdebug_Script*)
|
||||
execute_java_constructor(ee, "netscape/jsdebug/Script", 0, "()");
|
||||
|
||||
if( ! script )
|
||||
return;
|
||||
|
||||
/* set the members */
|
||||
unhand(script)->_url = makeJavaString(url,strlen(url));
|
||||
unhand(script)->_function = function ? makeJavaString(function,strlen(function)) : 0;
|
||||
unhand(script)->_baseLineNumber = base;
|
||||
unhand(script)->_lineExtent = extent;
|
||||
unhand(script)->_nativePtr = (long)jsdscript;
|
||||
|
||||
/* add it to the hash table */
|
||||
_putHash( ee, (JHandle*) unhand(controller)->scriptTable,
|
||||
_constructInteger(ee, (long)jsdscript), (JHandle*)script );
|
||||
|
||||
/* call the hook */
|
||||
if( unhand(controller)->scriptHook )
|
||||
{
|
||||
execute_java_dynamic_method( ee,(JHandle*)unhand(controller)->scriptHook,
|
||||
"justLoadedScript",
|
||||
"(Lnetscape/jsdebug/Script;)V",
|
||||
script );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
JHandle* tbl = (JHandle*) unhand(controller)->scriptTable;
|
||||
JHandle* key = _constructInteger(ee,(long)jsdscript);
|
||||
|
||||
/* find Java Object for Script */
|
||||
script = (Hnetscape_jsdebug_Script*) _getHash( ee, tbl, key );
|
||||
|
||||
if( ! script )
|
||||
return;
|
||||
|
||||
/* remove it from the hash table */
|
||||
_removeHash( ee, tbl, key );
|
||||
|
||||
/* call the hook */
|
||||
if( unhand(controller)->scriptHook )
|
||||
{
|
||||
execute_java_dynamic_method( ee,(JHandle*)unhand(controller)->scriptHook,
|
||||
"aboutToUnloadScript",
|
||||
"(Lnetscape/jsdebug/Script;)V",
|
||||
script );
|
||||
}
|
||||
/* set the Script as invalid */
|
||||
execute_java_dynamic_method( ee,(JHandle*)script,
|
||||
"_setInvalid",
|
||||
"()V" );
|
||||
}
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
PRUintn PR_CALLBACK
|
||||
_executionHook( JSDContext* jsdc,
|
||||
JSDThreadState* jsdstate,
|
||||
PRUintn type,
|
||||
void* callerdata )
|
||||
{
|
||||
Hnetscape_jsdebug_JSThreadState* threadState;
|
||||
Hnetscape_jsdebug_Script* script;
|
||||
JHandle* pcOb;
|
||||
JSDStackFrameInfo* jsdframe;
|
||||
JSDScript* jsdscript;
|
||||
int pc;
|
||||
JHandle* tblScript;
|
||||
JHandle* keyScript;
|
||||
ExecEnv* ee = EE();
|
||||
|
||||
if( ! context || ! controller || ! ee )
|
||||
return JSD_HOOK_RETURN_HOOK_ERROR;
|
||||
|
||||
/* get the JSDStackFrameInfo */
|
||||
jsdframe = JSD_GetStackFrame(jsdc, jsdstate);
|
||||
if( ! jsdframe )
|
||||
return JSD_HOOK_RETURN_HOOK_ERROR;
|
||||
|
||||
/* get the JSDScript */
|
||||
jsdscript = JSD_GetScriptForStackFrame(jsdc, jsdstate, jsdframe);
|
||||
if( ! jsdscript )
|
||||
return JSD_HOOK_RETURN_HOOK_ERROR;
|
||||
|
||||
/* find Java Object for Script */
|
||||
tblScript = (JHandle*) unhand(controller)->scriptTable;
|
||||
keyScript = _constructInteger(ee, (long)jsdscript);
|
||||
script = (Hnetscape_jsdebug_Script*) _getHash( ee, tblScript, keyScript );
|
||||
if( ! script )
|
||||
return JSD_HOOK_RETURN_HOOK_ERROR;
|
||||
|
||||
/* generate a JSPC */
|
||||
pc = JSD_GetPCForStackFrame(jsdc, jsdstate, jsdframe);
|
||||
|
||||
pcOb = (JHandle*)
|
||||
_constructJSPC(ee, script, pc);
|
||||
if( ! pcOb )
|
||||
return JSD_HOOK_RETURN_HOOK_ERROR;
|
||||
|
||||
/* build a JSThreadState */
|
||||
threadState = (struct Hnetscape_jsdebug_JSThreadState*)
|
||||
execute_java_constructor( ee, "netscape/jsdebug/JSThreadState",0,"()");
|
||||
if( ! threadState )
|
||||
return JSD_HOOK_RETURN_HOOK_ERROR;
|
||||
|
||||
/* populate the ThreadState */
|
||||
/* XXX FILL IN THE REST... */
|
||||
unhand(threadState)->valid = 1; /* correct value for true? */
|
||||
unhand(threadState)->currentFramePtr = (long) jsdframe;
|
||||
unhand(threadState)->nativeThreadState = (long) jsdstate;
|
||||
unhand(threadState)->continueState = netscape_jsdebug_JSThreadState_DEBUG_STATE_RUN;
|
||||
|
||||
/* XXX FILL IN THE REST... */
|
||||
|
||||
|
||||
/* find and call the appropriate Hook */
|
||||
if( JSD_HOOK_INTERRUPTED == type )
|
||||
{
|
||||
JHandle* hook;
|
||||
|
||||
/* clear the JSD level hook (must reset on next sendInterrupt0()*/
|
||||
JSD_ClearInterruptHook(context);
|
||||
|
||||
hook = (JHandle*) unhand(controller)->interruptHook;
|
||||
if( ! hook )
|
||||
return JSD_HOOK_RETURN_HOOK_ERROR;
|
||||
|
||||
/* call the hook */
|
||||
execute_java_dynamic_method(
|
||||
ee, hook, "aboutToExecute",
|
||||
"(Lnetscape/jsdebug/ThreadStateBase;Lnetscape/jsdebug/PC;)V",
|
||||
threadState, pcOb );
|
||||
}
|
||||
else if( JSD_HOOK_DEBUG_REQUESTED == type )
|
||||
{
|
||||
JHandle* hook;
|
||||
|
||||
hook = (JHandle*) unhand(controller)->debugBreakHook;
|
||||
if( ! hook )
|
||||
return JSD_HOOK_RETURN_HOOK_ERROR;
|
||||
|
||||
/* call the hook */
|
||||
execute_java_dynamic_method(
|
||||
ee, hook, "aboutToExecute",
|
||||
"(Lnetscape/jsdebug/ThreadStateBase;Lnetscape/jsdebug/PC;)V",
|
||||
threadState, pcOb );
|
||||
}
|
||||
else if( JSD_HOOK_BREAKPOINT == type )
|
||||
{
|
||||
JHandle* hook;
|
||||
|
||||
hook = (JHandle*)
|
||||
execute_java_dynamic_method(
|
||||
ee,(JHandle*)controller,
|
||||
"getInstructionHook0",
|
||||
"(Lnetscape/jsdebug/PC;)Lnetscape/jsdebug/InstructionHook;",
|
||||
pcOb );
|
||||
if( ! hook )
|
||||
return JSD_HOOK_RETURN_HOOK_ERROR;
|
||||
|
||||
/* call the hook */
|
||||
execute_java_dynamic_method(
|
||||
ee, hook, "aboutToExecute",
|
||||
"(Lnetscape/jsdebug/ThreadStateBase;)V",
|
||||
threadState );
|
||||
}
|
||||
|
||||
if( netscape_jsdebug_JSThreadState_DEBUG_STATE_THROW ==
|
||||
unhand(threadState)->continueState )
|
||||
return JSD_HOOK_RETURN_ABORT;
|
||||
|
||||
return JSD_HOOK_RETURN_CONTINUE;
|
||||
}
|
||||
|
||||
PRUintn PR_CALLBACK
|
||||
_errorReporter( JSDContext* jsdc,
|
||||
JSContext* cx,
|
||||
const char* message,
|
||||
JSErrorReport* report,
|
||||
void* callerdata )
|
||||
{
|
||||
JHandle* reporter;
|
||||
JHandle* msg = NULL;
|
||||
JHandle* filename = NULL;
|
||||
int lineno = 0;
|
||||
JHandle* linebuf = NULL;
|
||||
int tokenOffset = 0;
|
||||
ExecEnv* ee = EE();
|
||||
|
||||
if( ! context || ! controller || ! ee )
|
||||
return JSD_ERROR_REPORTER_PASS_ALONG;
|
||||
|
||||
reporter = (JHandle*) unhand(controller)->errorReporter;
|
||||
if( ! reporter )
|
||||
return JSD_ERROR_REPORTER_PASS_ALONG;
|
||||
|
||||
if( message )
|
||||
msg = (JHandle*) makeJavaString((char*)message, strlen(message));
|
||||
if( report && report->filename )
|
||||
filename = (JHandle*) makeJavaString((char*)report->filename, strlen(report->filename));
|
||||
if( report && report->linebuf )
|
||||
linebuf = (JHandle*) makeJavaString((char*)report->linebuf, strlen(report->linebuf));
|
||||
if( report )
|
||||
lineno = report->lineno;
|
||||
if( report && report->linebuf && report->tokenptr )
|
||||
tokenOffset = report->tokenptr - report->linebuf;
|
||||
|
||||
return (int)
|
||||
execute_java_dynamic_method(
|
||||
ee, reporter, "reportError",
|
||||
"(Ljava/lang/String;Ljava/lang/String;ILjava/lang/String;I)I",
|
||||
msg,
|
||||
filename,
|
||||
lineno,
|
||||
linebuf,
|
||||
tokenOffset );
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
/* from "_gen\netscape_jsdebug_DebugController.h" */
|
||||
|
||||
|
||||
/* XXX HACK */
|
||||
JSDContext* _simContext = 0;
|
||||
|
||||
void netscape_jsdebug_DebugController__setController(struct Hnetscape_jsdebug_DebugController * self,/*boolean*/ long on)
|
||||
{
|
||||
if(on)
|
||||
{
|
||||
context = JSD_DebuggerOn();
|
||||
if( ! context )
|
||||
return;
|
||||
|
||||
_simContext = context; /* XXX HACK */
|
||||
|
||||
unhand(self)->_nativeContext = (long) context;
|
||||
controller = self;
|
||||
JSD_SetScriptHook(context, _scriptHook, (void*)1 );
|
||||
JSD_SetErrorReporter(context, _errorReporter, (void*)1 );
|
||||
JSD_SetDebugBreakHook(context, _executionHook, (void*)1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
/* XXX stop somehow... */
|
||||
/* kill context */
|
||||
JSD_SetDebugBreakHook(context, NULL, NULL );
|
||||
JSD_SetErrorReporter(context, NULL, NULL);
|
||||
JSD_SetScriptHook(context, NULL, NULL);
|
||||
context = 0;
|
||||
controller = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void netscape_jsdebug_DebugController_setInstructionHook0(struct Hnetscape_jsdebug_DebugController * self,struct Hnetscape_jsdebug_PC * pcOb)
|
||||
{
|
||||
Hnetscape_jsdebug_Script* script;
|
||||
JSDScript* jsdscript;
|
||||
PRUintn pc;
|
||||
ExecEnv* ee = EE();
|
||||
|
||||
if( ! context || ! controller || ! ee )
|
||||
return;
|
||||
|
||||
script = (Hnetscape_jsdebug_Script*)
|
||||
execute_java_dynamic_method(ee, (JHandle*)pcOb, "getScript","()Lnetscape/jsdebug/Script;");
|
||||
|
||||
if( ! script )
|
||||
return;
|
||||
|
||||
jsdscript = (JSDScript*) unhand(script)->_nativePtr;
|
||||
if( ! jsdscript )
|
||||
return;
|
||||
|
||||
pc = (PRUintn)
|
||||
execute_java_dynamic_method(ee, (JHandle*)pcOb, "getPC","()I");
|
||||
|
||||
JSD_SetExecutionHook(context, jsdscript, pc, _executionHook, 0);
|
||||
}
|
||||
|
||||
void netscape_jsdebug_DebugController_sendInterrupt0(struct Hnetscape_jsdebug_DebugController * self)
|
||||
{
|
||||
if( ! context || ! controller )
|
||||
return;
|
||||
JSD_SetInterruptHook(context, _executionHook, 0);
|
||||
}
|
||||
|
||||
struct Hjava_lang_String *netscape_jsdebug_DebugController_executeScriptInStackFrame0(struct Hnetscape_jsdebug_DebugController *self,struct Hnetscape_jsdebug_JSStackFrameInfo *frame,struct Hjava_lang_String *src,struct Hjava_lang_String *filename,long lineno)
|
||||
{
|
||||
struct Hnetscape_jsdebug_JSThreadState* threadStateOb;
|
||||
JSDThreadState* jsdthreadstate;
|
||||
JSDStackFrameInfo* jsdframe;
|
||||
char* filenameC;
|
||||
char* srcC;
|
||||
JSString* jsstr;
|
||||
jsval rval;
|
||||
JSBool success;
|
||||
int srclen;
|
||||
|
||||
threadStateOb = (struct Hnetscape_jsdebug_JSThreadState*)unhand(frame)->threadState;
|
||||
jsdthreadstate = (JSDThreadState*) unhand(threadStateOb)->nativeThreadState;
|
||||
|
||||
jsdframe = (JSDStackFrameInfo*) unhand(frame)->_nativePtr;
|
||||
|
||||
if( ! context || ! controller || ! jsdframe )
|
||||
return NULL;
|
||||
|
||||
filenameC = allocCString(filename);
|
||||
if( ! filenameC )
|
||||
return NULL;
|
||||
srcC = allocCString(src);
|
||||
if( ! srcC )
|
||||
{
|
||||
free(filenameC);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
srclen = strlen(srcC);
|
||||
|
||||
success = JSD_EvaluateScriptInStackFrame(context, jsdthreadstate, jsdframe,
|
||||
srcC, srclen,
|
||||
filenameC, lineno, &rval);
|
||||
|
||||
/* XXX crashing on Windows under Symantec (though I can't see why!)*/
|
||||
|
||||
free(filenameC);
|
||||
free(srcC);
|
||||
|
||||
|
||||
if( ! success )
|
||||
return NULL;
|
||||
|
||||
if( JSVAL_IS_NULL(rval) || JSVAL_IS_VOID(rval) )
|
||||
return NULL;
|
||||
|
||||
jsstr = JSD_ValToStringInStackFrame(context,jsdthreadstate,jsdframe,rval);
|
||||
if( ! jsstr )
|
||||
return NULL;
|
||||
|
||||
/* XXXbe should use JS_GetStringChars and preserve Unicode. */
|
||||
return makeJavaString((char*)JS_GetStringBytes(jsstr), JS_GetStringLength(jsstr));
|
||||
}
|
||||
|
||||
long netscape_jsdebug_DebugController_getNativeMajorVersion(struct Hnetscape_jsdebug_DebugController* self)
|
||||
{
|
||||
return (long) JSD_GetMajorVersion();
|
||||
}
|
||||
|
||||
long netscape_jsdebug_DebugController_getNativeMinorVersion(struct Hnetscape_jsdebug_DebugController* self)
|
||||
{
|
||||
return (long) JSD_GetMinorVersion();
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
/* from "_gen\netscape_jsdebug_Script.h" */
|
||||
|
||||
struct Hnetscape_jsdebug_JSPC *netscape_jsdebug_Script_getClosestPC(struct Hnetscape_jsdebug_Script * self,long line)
|
||||
{
|
||||
PRUintn pc;
|
||||
JSDScript* jsdscript;
|
||||
|
||||
if( ! context || ! controller )
|
||||
return 0;
|
||||
|
||||
jsdscript = (JSDScript*) unhand(self)->_nativePtr;
|
||||
if( ! jsdscript )
|
||||
return 0;
|
||||
|
||||
pc = JSD_GetClosestPC(context, jsdscript, line);
|
||||
|
||||
if( -1 == pc )
|
||||
return 0;
|
||||
return _constructJSPC( 0, self, pc);
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
/* from "_gen\netscape_jsdebug_JSThreadState.h" */
|
||||
|
||||
long netscape_jsdebug_JSThreadState_countStackFrames(struct Hnetscape_jsdebug_JSThreadState * self)
|
||||
{
|
||||
JSDThreadState* jsdstate;
|
||||
|
||||
if( ! context || ! controller )
|
||||
return 0;
|
||||
|
||||
jsdstate = (JSDThreadState*) unhand(self)->nativeThreadState;
|
||||
|
||||
if( ! jsdstate )
|
||||
return 0;
|
||||
|
||||
return (long) JSD_GetCountOfStackFrames(context, jsdstate);
|
||||
}
|
||||
|
||||
struct Hnetscape_jsdebug_StackFrameInfo *netscape_jsdebug_JSThreadState_getCurrentFrame(struct Hnetscape_jsdebug_JSThreadState * self)
|
||||
{
|
||||
JSDThreadState* jsdstate;
|
||||
JSDStackFrameInfo* jsdframe;
|
||||
|
||||
if( ! context || ! controller )
|
||||
return NULL;
|
||||
|
||||
jsdstate = (JSDThreadState*) unhand(self)->nativeThreadState;
|
||||
|
||||
if( ! jsdstate )
|
||||
return NULL;
|
||||
|
||||
jsdframe = JSD_GetStackFrame(context, jsdstate);
|
||||
if( ! jsdframe )
|
||||
return NULL;
|
||||
|
||||
return (struct Hnetscape_jsdebug_StackFrameInfo*)
|
||||
_constructJSStackFrameInfo( 0, jsdframe, self );
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************/
|
||||
/* from "_gen\netscape_jsdebug_JSStackFrameInfo.h" */
|
||||
|
||||
struct Hnetscape_jsdebug_StackFrameInfo *netscape_jsdebug_JSStackFrameInfo_getCaller0(struct Hnetscape_jsdebug_JSStackFrameInfo * self)
|
||||
{
|
||||
JSDStackFrameInfo* jsdframeCur;
|
||||
JSDStackFrameInfo* jsdframeCaller;
|
||||
struct Hnetscape_jsdebug_JSThreadState* threadState;
|
||||
JSDThreadState* jsdthreadstate;
|
||||
|
||||
if( ! context || ! controller )
|
||||
return NULL;
|
||||
|
||||
jsdframeCur = (JSDStackFrameInfo*) unhand(self)->_nativePtr;
|
||||
if( ! jsdframeCur )
|
||||
return NULL;
|
||||
|
||||
threadState = (struct Hnetscape_jsdebug_JSThreadState*) unhand(self)->threadState;
|
||||
if( ! threadState )
|
||||
return NULL;
|
||||
|
||||
jsdthreadstate = (JSDThreadState*) unhand(threadState)->nativeThreadState;
|
||||
if( ! jsdthreadstate )
|
||||
return NULL;
|
||||
|
||||
jsdframeCaller = JSD_GetCallingStackFrame(context, jsdthreadstate, jsdframeCur);
|
||||
if( ! jsdframeCaller )
|
||||
return NULL;
|
||||
|
||||
return (struct Hnetscape_jsdebug_StackFrameInfo*)
|
||||
_constructJSStackFrameInfo( 0, jsdframeCaller, threadState );
|
||||
}
|
||||
struct Hnetscape_jsdebug_PC *netscape_jsdebug_JSStackFrameInfo_getPC(struct Hnetscape_jsdebug_JSStackFrameInfo * self)
|
||||
{
|
||||
JSDScript* jsdscript;
|
||||
JSDStackFrameInfo* jsdframe;
|
||||
struct Hnetscape_jsdebug_Script* script;
|
||||
struct Hnetscape_jsdebug_JSThreadState* threadState;
|
||||
JSDThreadState* jsdthreadstate;
|
||||
int pc;
|
||||
ExecEnv* ee = EE();
|
||||
|
||||
if( ! context || ! controller || ! ee )
|
||||
return NULL;
|
||||
|
||||
jsdframe = (JSDStackFrameInfo*) unhand(self)->_nativePtr;
|
||||
if( ! jsdframe )
|
||||
return NULL;
|
||||
|
||||
threadState = (struct Hnetscape_jsdebug_JSThreadState*) unhand(self)->threadState;
|
||||
if( ! threadState )
|
||||
return NULL;
|
||||
|
||||
jsdthreadstate = (JSDThreadState*) unhand(threadState)->nativeThreadState;
|
||||
if( ! jsdthreadstate )
|
||||
return NULL;
|
||||
|
||||
jsdscript = JSD_GetScriptForStackFrame(context, jsdthreadstate, jsdframe );
|
||||
if( ! jsdscript )
|
||||
return NULL;
|
||||
|
||||
script = _scriptObFromJSDScriptPtr(ee, jsdscript);
|
||||
if( ! script )
|
||||
return NULL;
|
||||
|
||||
pc = JSD_GetPCForStackFrame(context, jsdthreadstate, jsdframe);
|
||||
if( ! pc )
|
||||
return NULL;
|
||||
|
||||
return (struct Hnetscape_jsdebug_PC*) _constructJSPC(ee, script, pc);
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
/* from "_gen\netscape_jsdebug_JSPC.h" */
|
||||
|
||||
struct Hnetscape_jsdebug_SourceLocation *netscape_jsdebug_JSPC_getSourceLocation(struct Hnetscape_jsdebug_JSPC * self)
|
||||
{
|
||||
JSDScript* jsdscript;
|
||||
struct Hnetscape_jsdebug_Script* script;
|
||||
struct Hnetscape_jsdebug_JSPC* newPCOb;
|
||||
int line;
|
||||
int newpc;
|
||||
int pc;
|
||||
ExecEnv* ee = EE();
|
||||
|
||||
if( ! context || ! controller || ! ee )
|
||||
return NULL;
|
||||
|
||||
script = unhand(self)->script;
|
||||
|
||||
if( ! script )
|
||||
return NULL;
|
||||
|
||||
jsdscript = (JSDScript*) unhand(script)->_nativePtr;
|
||||
if( ! jsdscript )
|
||||
return NULL;
|
||||
pc = unhand(self)->pc;
|
||||
|
||||
line = JSD_GetClosestLine(context, jsdscript, pc);
|
||||
newpc = JSD_GetClosestPC(context, jsdscript, line);
|
||||
|
||||
newPCOb = _constructJSPC(ee, script, newpc );
|
||||
if( ! newPCOb )
|
||||
return NULL;
|
||||
|
||||
return (struct Hnetscape_jsdebug_SourceLocation *)
|
||||
execute_java_constructor( ee, "netscape/jsdebug/JSSourceLocation", 0,
|
||||
"(Lnetscape/jsdebug/JSPC;I)",
|
||||
newPCOb, line );
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
/* from "_gen\netscape_jsdebug_JSSourceTextProvider.h" */
|
||||
|
||||
struct Hnetscape_jsdebug_SourceTextItem *netscape_jsdebug_JSSourceTextProvider_loadSourceTextItem0(struct Hnetscape_jsdebug_JSSourceTextProvider * self,struct Hjava_lang_String * url)
|
||||
{
|
||||
/* this should attempt to load the source for the indicated URL */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void netscape_jsdebug_JSSourceTextProvider_refreshSourceTextVector(struct Hnetscape_jsdebug_JSSourceTextProvider * self)
|
||||
{
|
||||
|
||||
JHandle* vec;
|
||||
JHandle* itemOb;
|
||||
JSDSourceText* iterp = 0;
|
||||
JSDSourceText* item;
|
||||
const char* url;
|
||||
struct Hjava_lang_String* urlOb;
|
||||
ExecEnv* ee = EE();
|
||||
|
||||
if( ! context || ! controller || ! ee )
|
||||
return;
|
||||
|
||||
/* create new vector */
|
||||
vec = (JHandle*) execute_java_constructor(ee, "netscape/util/Vector", 0, "()");
|
||||
if( ! vec )
|
||||
return;
|
||||
|
||||
/* lock the native subsystem */
|
||||
JSD_LockSourceTextSubsystem(context);
|
||||
|
||||
/* iterate through the native items */
|
||||
while( 0 != (item = JSD_IterateSources(context, &iterp)) )
|
||||
{
|
||||
int urlStrLen;
|
||||
int status = JSD_GetSourceStatus(context,item);
|
||||
|
||||
/* try to find Java object */
|
||||
url = JSD_GetSourceURL(context, item);
|
||||
if( ! url || 0 == (urlStrLen = strlen(url)) ) /* ignoring those with no url */
|
||||
continue;
|
||||
|
||||
urlOb = makeJavaString((char*)url,urlStrLen);
|
||||
if( ! urlOb )
|
||||
continue;
|
||||
|
||||
itemOb = (JHandle*)
|
||||
execute_java_dynamic_method( ee, (JHandle*)self, "findSourceTextItem0",
|
||||
"(Ljava/lang/String;)Lnetscape/jsdebug/SourceTextItem;",
|
||||
urlOb );
|
||||
|
||||
if( ! itemOb )
|
||||
{
|
||||
/* if not found then generate new item */
|
||||
struct Hjava_lang_String* textOb;
|
||||
const char* str;
|
||||
int length;
|
||||
|
||||
if( ! JSD_GetSourceText(context, item, &str, &length ) )
|
||||
{
|
||||
str = "";
|
||||
length = 0;
|
||||
}
|
||||
textOb = makeJavaString((char*)str, length);
|
||||
|
||||
itemOb = (JHandle*)
|
||||
execute_java_constructor(ee, "netscape/jsdebug/SourceTextItem",0,
|
||||
"(Ljava/lang/String;Ljava/lang/String;I)",
|
||||
urlOb, textOb, status );
|
||||
}
|
||||
else if( JSD_IsSourceDirty(context, item) &&
|
||||
JSD_SOURCE_CLEARED != status )
|
||||
{
|
||||
/* if found and dirty then update */
|
||||
struct Hjava_lang_String* textOb;
|
||||
const char* str;
|
||||
int length;
|
||||
|
||||
if( ! JSD_GetSourceText(context, item, &str, &length ) )
|
||||
{
|
||||
str = "";
|
||||
length = 0;
|
||||
}
|
||||
textOb = makeJavaString((char*)str, length);
|
||||
execute_java_dynamic_method(ee, itemOb, "setText",
|
||||
"(Ljava/lang/String;)V", textOb);
|
||||
execute_java_dynamic_method(ee, itemOb, "setStatus",
|
||||
"(I)V", status );
|
||||
execute_java_dynamic_method(ee, itemOb, "setDirty", "(Z)V", 1 );
|
||||
}
|
||||
|
||||
/* we have our copy; clear the native cached text */
|
||||
if( JSD_SOURCE_INITED != status &&
|
||||
JSD_SOURCE_PARTIAL != status &&
|
||||
JSD_SOURCE_CLEARED != status )
|
||||
{
|
||||
JSD_ClearSourceText(context, item);
|
||||
}
|
||||
|
||||
/* set the item clean */
|
||||
JSD_SetSourceDirty(context, item, FALSE );
|
||||
|
||||
/* add the item to the vector */
|
||||
if( itemOb )
|
||||
execute_java_dynamic_method(ee, vec, "addElement",
|
||||
"(Ljava/lang/Object;)V", itemOb );
|
||||
}
|
||||
/* unlock the native subsystem */
|
||||
JSD_UnlockSourceTextSubsystem(context);
|
||||
|
||||
/* set main vector to our new vector */
|
||||
|
||||
unhand(self)->_sourceTextVector = (struct Hnetscape_util_Vector*) vec;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
236
mozilla/js/jsd/jsd_lock.c
Normal file
236
mozilla/js/jsd/jsd_lock.c
Normal file
@@ -0,0 +1,236 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* JavaScript Debugging support - Locking and threading support
|
||||
*/
|
||||
|
||||
/*
|
||||
* ifdef JSD_USE_NSPR_LOCKS then you musat build and run against NSPR2.
|
||||
* Otherwise, there are stubs that can be filled in with your own locking
|
||||
* code. Also, note that these stubs include a jsd_CurrentThread()
|
||||
* implementation that only works on Win32 - this is needed for the inprocess
|
||||
* Java-based debugger.
|
||||
*/
|
||||
|
||||
#include "jsd.h"
|
||||
|
||||
#ifdef JSD_THREADSAFE
|
||||
|
||||
#ifdef JSD_USE_NSPR_LOCKS
|
||||
|
||||
#include "prlock.h"
|
||||
#include "prthread.h"
|
||||
|
||||
#ifdef JSD_ATTACH_THREAD_HACK
|
||||
#include "pprthred.h" /* need this as long as JS_AttachThread is needed */
|
||||
#endif
|
||||
|
||||
typedef struct JSDStaticLock
|
||||
{
|
||||
void* owner;
|
||||
PRLock* lock;
|
||||
int count;
|
||||
#ifdef DEBUG
|
||||
uint16 sig;
|
||||
#endif
|
||||
} JSDStaticLock;
|
||||
|
||||
/*
|
||||
* This exists to wrap non-NSPR theads (e.g. Java threads) in NSPR wrappers.
|
||||
* XXX We ignore the memory leak issue.
|
||||
* It is claimed that future versions of NSPR will automatically wrap on
|
||||
* the call to PR_GetCurrentThread.
|
||||
*
|
||||
* XXX We ignore the memory leak issue - i.e. we never call PR_DetachThread.
|
||||
*
|
||||
*/
|
||||
#undef _CURRENT_THREAD
|
||||
#ifdef JSD_ATTACH_THREAD_HACK
|
||||
#define _CURRENT_THREAD(out) \
|
||||
JS_BEGIN_MACRO \
|
||||
out = (void*) PR_GetCurrentThread(); \
|
||||
if(!out) \
|
||||
out = (void*) JS_AttachThread(PR_USER_THREAD,PR_PRIORITY_NORMAL,NULL);\
|
||||
JS_ASSERT(out); \
|
||||
JS_END_MACRO
|
||||
#else
|
||||
#define _CURRENT_THREAD(out) \
|
||||
JS_BEGIN_MACRO \
|
||||
out = (void*) PR_GetCurrentThread(); \
|
||||
JS_ASSERT(out); \
|
||||
JS_END_MACRO
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
#define JSD_LOCK_SIG 0x10CC10CC
|
||||
void ASSERT_VALID_LOCK(JSDStaticLock* lock)
|
||||
{
|
||||
JS_ASSERT(lock);
|
||||
JS_ASSERT(lock->lock);
|
||||
JS_ASSERT(lock->count >= 0);
|
||||
JS_ASSERT((! lock->count && ! lock->owner) || (lock->count && lock->owner));
|
||||
JS_ASSERT(lock->sig == (uint16) JSD_LOCK_SIG);
|
||||
}
|
||||
#else
|
||||
#define ASSERT_VALID_LOCK(x) ((void)0)
|
||||
#endif
|
||||
|
||||
void*
|
||||
jsd_CreateLock()
|
||||
{
|
||||
JSDStaticLock* lock;
|
||||
|
||||
if( ! (lock = calloc(1, sizeof(JSDStaticLock))) ||
|
||||
! (lock->lock = PR_NewLock()) )
|
||||
{
|
||||
if(lock)
|
||||
{
|
||||
free(lock);
|
||||
lock = NULL;
|
||||
}
|
||||
}
|
||||
#ifdef DEBUG
|
||||
if(lock) lock->sig = (uint16) JSD_LOCK_SIG;
|
||||
#endif
|
||||
return lock;
|
||||
}
|
||||
|
||||
void
|
||||
jsd_Lock(JSDStaticLock* lock)
|
||||
{
|
||||
void* me;
|
||||
|
||||
_CURRENT_THREAD(me);
|
||||
|
||||
ASSERT_VALID_LOCK(lock);
|
||||
|
||||
if(lock->owner == me)
|
||||
lock->count++;
|
||||
else
|
||||
{
|
||||
PR_Lock(lock->lock); /* this can block... */
|
||||
JS_ASSERT(lock->owner == 0);
|
||||
lock->count = 1;
|
||||
lock->owner = me;
|
||||
}
|
||||
ASSERT_VALID_LOCK(lock);
|
||||
}
|
||||
|
||||
void
|
||||
jsd_Unlock(JSDStaticLock* lock)
|
||||
{
|
||||
void* me;
|
||||
|
||||
ASSERT_VALID_LOCK(lock);
|
||||
_CURRENT_THREAD(me);
|
||||
|
||||
if(lock->owner != me)
|
||||
{
|
||||
JS_ASSERT(0); /* it's an error to unlock a lock you don't own */
|
||||
return;
|
||||
}
|
||||
if(--lock->count == 0)
|
||||
{
|
||||
lock->owner = NULL;
|
||||
PR_Unlock(lock->lock);
|
||||
}
|
||||
ASSERT_VALID_LOCK(lock);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
JSBool
|
||||
jsd_IsLocked(JSDStaticLock* lock)
|
||||
{
|
||||
void* me;
|
||||
ASSERT_VALID_LOCK(lock);
|
||||
_CURRENT_THREAD(me);
|
||||
return lock->owner == me ? JS_TRUE : JS_FALSE;
|
||||
}
|
||||
#endif /* DEBUG */
|
||||
|
||||
void*
|
||||
jsd_CurrentThread()
|
||||
{
|
||||
void* me;
|
||||
_CURRENT_THREAD(me);
|
||||
return me;
|
||||
}
|
||||
|
||||
|
||||
#else /* ! JSD_USE_NSPR_LOCKS */
|
||||
|
||||
#ifdef WIN32
|
||||
#pragma message("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
|
||||
#pragma message("!! you are compiling the stubbed version of jsd_lock.c !!")
|
||||
#pragma message("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
|
||||
#endif
|
||||
|
||||
/*
|
||||
* NOTE: 'Real' versions of these locks must be reentrant in the sense that
|
||||
* they support nested calls to lock and unlock.
|
||||
*/
|
||||
|
||||
void*
|
||||
jsd_CreateLock()
|
||||
{
|
||||
return (void*)1;
|
||||
}
|
||||
|
||||
void
|
||||
jsd_Lock(void* lock)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
jsd_Unlock(void* lock)
|
||||
{
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
JSBool
|
||||
jsd_IsLocked(void* lock)
|
||||
{
|
||||
return JS_TRUE;
|
||||
}
|
||||
#endif /* DEBUG */
|
||||
|
||||
/*
|
||||
* This Windows only thread id code is here to allow the Java-based
|
||||
* JSDebugger to work with the single threaded js.c shell (even without
|
||||
* real locking and threading support).
|
||||
*/
|
||||
|
||||
#ifdef WIN32
|
||||
/* bogus (but good enough) declaration*/
|
||||
extern void* __stdcall GetCurrentThreadId(void);
|
||||
#endif
|
||||
|
||||
void*
|
||||
jsd_CurrentThread()
|
||||
{
|
||||
#ifdef WIN32
|
||||
return GetCurrentThreadId();
|
||||
#else
|
||||
return (void*)1;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* JSD_USE_NSPR_LOCKS */
|
||||
|
||||
#endif /* JSD_THREADSAFE */
|
||||
53
mozilla/js/jsd/jsd_lock.h
Normal file
53
mozilla/js/jsd/jsd_lock.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Header for JavaScript Debugging support - Locking and threading functions
|
||||
*/
|
||||
|
||||
#ifndef jsd_lock_h___
|
||||
#define jsd_lock_h___
|
||||
|
||||
/*
|
||||
* If you want to support threading and locking, define JSD_THREADSAFE and
|
||||
* implement the functions below.
|
||||
*/
|
||||
|
||||
/*
|
||||
* NOTE: These locks must be reentrant in the sense that they support
|
||||
* nested calls to lock and unlock.
|
||||
*/
|
||||
|
||||
extern void*
|
||||
jsd_CreateLock();
|
||||
|
||||
extern void
|
||||
jsd_Lock(void* lock);
|
||||
|
||||
extern void
|
||||
jsd_Unlock(void* lock);
|
||||
|
||||
#ifdef DEBUG
|
||||
extern JSBool
|
||||
jsd_IsLocked(void* lock);
|
||||
#endif /* DEBUG */
|
||||
|
||||
extern void*
|
||||
jsd_CurrentThread();
|
||||
|
||||
#endif /* jsd_lock_h___ */
|
||||
307
mozilla/js/jsd/jsd_obj.c
Normal file
307
mozilla/js/jsd/jsd_obj.c
Normal file
@@ -0,0 +1,307 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* JavaScript Debugging support - Object support
|
||||
*/
|
||||
|
||||
#include "jsd.h"
|
||||
|
||||
/*
|
||||
* #define JSD_TRACE 1
|
||||
*/
|
||||
|
||||
#ifdef JSD_TRACE
|
||||
#define TRACEOBJ(jsdc, jsdobj, which) _traceObj(jsdc, jsdobj, which)
|
||||
|
||||
static char *
|
||||
_describeObj(JSDContext* jsdc, JSDObject *jsdobj)
|
||||
{
|
||||
return
|
||||
JS_smprintf("%0x new'd in %s at line %d using ctor %s in %s at line %d",
|
||||
(int)jsdobj,
|
||||
JSD_GetObjectNewURL(jsdc, jsdobj),
|
||||
JSD_GetObjectNewLineNumber(jsdc, jsdobj),
|
||||
JSD_GetObjectConstructorName(jsdc, jsdobj),
|
||||
JSD_GetObjectConstructorURL(jsdc, jsdobj),
|
||||
JSD_GetObjectConstructorLineNumber(jsdc, jsdobj));
|
||||
}
|
||||
|
||||
static void
|
||||
_traceObj(JSDContext* jsdc, JSDObject* jsdobj, int which)
|
||||
{
|
||||
char* description;
|
||||
|
||||
if( !jsdobj )
|
||||
return;
|
||||
|
||||
description = _describeObj(jsdc, jsdobj);
|
||||
|
||||
printf("%s : %s\n",
|
||||
which == 0 ? "new " :
|
||||
which == 1 ? "final" :
|
||||
"ctor ",
|
||||
description);
|
||||
if(description)
|
||||
free(description);
|
||||
}
|
||||
#else
|
||||
#define TRACEOBJ(jsdc, jsdobj, which) ((void)0)
|
||||
#endif /* JSD_TRACE */
|
||||
|
||||
#ifdef DEBUG
|
||||
void JSD_ASSERT_VALID_OBJECT(JSDObject* jsdobj)
|
||||
{
|
||||
JS_ASSERT(jsdobj);
|
||||
JS_ASSERT(!JS_CLIST_IS_EMPTY(&jsdobj->links));
|
||||
JS_ASSERT(jsdobj->obj);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static void
|
||||
_destroyJSDObject(JSDContext* jsdc, JSDObject* jsdobj)
|
||||
{
|
||||
JS_ASSERT(JSD_OBJECTS_LOCKED(jsdc));
|
||||
|
||||
JS_REMOVE_LINK(&jsdobj->links);
|
||||
JS_HashTableRemove(jsdc->objectsTable, jsdobj->obj);
|
||||
|
||||
if(jsdobj->newURL)
|
||||
jsd_DropAtom(jsdc, jsdobj->newURL);
|
||||
if(jsdobj->ctorURL)
|
||||
jsd_DropAtom(jsdc, jsdobj->ctorURL);
|
||||
if(jsdobj->ctorName)
|
||||
jsd_DropAtom(jsdc, jsdobj->ctorName);
|
||||
free(jsdobj);
|
||||
}
|
||||
|
||||
static JSDObject*
|
||||
_createJSDObject(JSDContext* jsdc, JSContext *cx, JSObject *obj)
|
||||
{
|
||||
JSDObject* jsdobj;
|
||||
JSStackFrame* fp;
|
||||
JSStackFrame* iter = NULL;
|
||||
const char* newURL;
|
||||
jsbytecode* pc;
|
||||
|
||||
JS_ASSERT(JSD_OBJECTS_LOCKED(jsdc));
|
||||
|
||||
jsdobj = (JSDObject*) calloc(1, sizeof(JSDObject));
|
||||
if( jsdobj )
|
||||
{
|
||||
JS_INIT_CLIST(&jsdobj->links);
|
||||
JS_APPEND_LINK(&jsdobj->links, &jsdc->objectsList);
|
||||
jsdobj->obj = obj;
|
||||
JS_HashTableAdd(jsdc->objectsTable, obj, jsdobj);
|
||||
|
||||
/* walk the stack to find js frame (if any) causing creation */
|
||||
while( NULL != (fp = JS_FrameIterator(cx, &iter)) )
|
||||
{
|
||||
if( !JS_IsNativeFrame(cx, fp) )
|
||||
{
|
||||
JSScript* script = JS_GetFrameScript(cx, fp);
|
||||
if( !script )
|
||||
continue;
|
||||
|
||||
newURL = JS_GetScriptFilename(cx, script);
|
||||
if( newURL )
|
||||
jsdobj->newURL = jsd_AddAtom(jsdc, newURL);
|
||||
|
||||
pc = JS_GetFramePC(cx, fp);
|
||||
if( pc )
|
||||
jsdobj->newLineno = JS_PCToLineNumber(cx, script, pc);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return jsdobj;
|
||||
}
|
||||
|
||||
void JS_DLL_CALLBACK
|
||||
jsd_ObjectHook(JSContext *cx, JSObject *obj, JSBool isNew, void *closure)
|
||||
{
|
||||
JSDObject* jsdobj;
|
||||
JSDContext* jsdc = (JSDContext*) closure;
|
||||
|
||||
if( ! jsdc || ! jsdc->inited )
|
||||
return;
|
||||
|
||||
JSD_LOCK_OBJECTS(jsdc);
|
||||
if(isNew)
|
||||
{
|
||||
jsdobj = _createJSDObject(jsdc, cx, obj);
|
||||
TRACEOBJ(jsdc, jsdobj, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
jsdobj = jsd_GetJSDObjectForJSObject(jsdc, obj);
|
||||
if( jsdobj )
|
||||
{
|
||||
TRACEOBJ(jsdc, jsdobj, 1);
|
||||
_destroyJSDObject(jsdc, jsdobj);
|
||||
}
|
||||
}
|
||||
JSD_UNLOCK_OBJECTS(jsdc);
|
||||
}
|
||||
|
||||
void
|
||||
jsd_Constructing(JSDContext* jsdc, JSContext *cx, JSObject *obj,
|
||||
JSStackFrame *fp)
|
||||
{
|
||||
JSDObject* jsdobj;
|
||||
JSScript* script;
|
||||
JSDScript* jsdscript;
|
||||
const char* ctorURL;
|
||||
const char* ctorName;
|
||||
|
||||
JSD_LOCK_OBJECTS(jsdc);
|
||||
jsdobj = jsd_GetJSDObjectForJSObject(jsdc, obj);
|
||||
if( jsdobj && !jsdobj->ctorURL && !JS_IsNativeFrame(cx, fp) )
|
||||
{
|
||||
script = JS_GetFrameScript(cx, fp);
|
||||
if( script )
|
||||
{
|
||||
ctorURL = JS_GetScriptFilename(cx, script);
|
||||
if( ctorURL )
|
||||
jsdobj->ctorURL = jsd_AddAtom(jsdc, ctorURL);
|
||||
|
||||
JSD_LOCK_SCRIPTS(jsdc);
|
||||
jsdscript = jsd_FindJSDScript(jsdc, script);
|
||||
JSD_UNLOCK_SCRIPTS(jsdc);
|
||||
if( jsdscript )
|
||||
{
|
||||
ctorName = jsd_GetScriptFunctionName(jsdc, jsdscript);
|
||||
if( ctorName )
|
||||
jsdobj->ctorName = jsd_AddAtom(jsdc, ctorName);
|
||||
}
|
||||
jsdobj->ctorLineno = JS_GetScriptBaseLineNumber(cx, script);
|
||||
}
|
||||
}
|
||||
TRACEOBJ(jsdc, jsdobj, 3);
|
||||
JSD_UNLOCK_OBJECTS(jsdc);
|
||||
}
|
||||
|
||||
JS_STATIC_DLL_CALLBACK(JSHashNumber)
|
||||
_hash_root(const void *key)
|
||||
{
|
||||
return ((JSHashNumber) key) >> 2; /* help lame MSVC1.5 on Win16 */
|
||||
}
|
||||
|
||||
JSBool
|
||||
jsd_InitObjectManager(JSDContext* jsdc)
|
||||
{
|
||||
JS_INIT_CLIST(&jsdc->objectsList);
|
||||
jsdc->objectsTable = JS_NewHashTable(256, _hash_root,
|
||||
JS_CompareValues, JS_CompareValues,
|
||||
NULL, NULL);
|
||||
return (JSBool) jsdc->objectsTable;
|
||||
}
|
||||
|
||||
void
|
||||
jsd_DestroyObjectManager(JSDContext* jsdc)
|
||||
{
|
||||
JSD_LOCK_OBJECTS(jsdc);
|
||||
while( !JS_CLIST_IS_EMPTY(&jsdc->objectsList) )
|
||||
_destroyJSDObject(jsdc, (JSDObject*)JS_NEXT_LINK(&jsdc->objectsList));
|
||||
JS_HashTableDestroy(jsdc->objectsTable);
|
||||
JSD_UNLOCK_OBJECTS(jsdc);
|
||||
}
|
||||
|
||||
JSDObject*
|
||||
jsd_IterateObjects(JSDContext* jsdc, JSDObject** iterp)
|
||||
{
|
||||
JSDObject *jsdobj = *iterp;
|
||||
|
||||
JS_ASSERT(JSD_OBJECTS_LOCKED(jsdc));
|
||||
|
||||
if( !jsdobj )
|
||||
jsdobj = (JSDObject *)jsdc->objectsList.next;
|
||||
if( jsdobj == (JSDObject *)&jsdc->objectsList )
|
||||
return NULL;
|
||||
*iterp = (JSDObject*) jsdobj->links.next;
|
||||
return jsdobj;
|
||||
}
|
||||
|
||||
JSObject*
|
||||
jsd_GetWrappedObject(JSDContext* jsdc, JSDObject* jsdobj)
|
||||
{
|
||||
return jsdobj->obj;
|
||||
}
|
||||
|
||||
const char*
|
||||
jsd_GetObjectNewURL(JSDContext* jsdc, JSDObject* jsdobj)
|
||||
{
|
||||
if( jsdobj->newURL )
|
||||
return JSD_ATOM_TO_STRING(jsdobj->newURL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
uintN
|
||||
jsd_GetObjectNewLineNumber(JSDContext* jsdc, JSDObject* jsdobj)
|
||||
{
|
||||
return jsdobj->newLineno;
|
||||
}
|
||||
|
||||
const char*
|
||||
jsd_GetObjectConstructorURL(JSDContext* jsdc, JSDObject* jsdobj)
|
||||
{
|
||||
if( jsdobj->ctorURL )
|
||||
return JSD_ATOM_TO_STRING(jsdobj->ctorURL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
uintN
|
||||
jsd_GetObjectConstructorLineNumber(JSDContext* jsdc, JSDObject* jsdobj)
|
||||
{
|
||||
return jsdobj->ctorLineno;
|
||||
}
|
||||
|
||||
const char*
|
||||
jsd_GetObjectConstructorName(JSDContext* jsdc, JSDObject* jsdobj)
|
||||
{
|
||||
if( jsdobj->ctorName )
|
||||
return JSD_ATOM_TO_STRING(jsdobj->ctorName);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
JSDObject*
|
||||
jsd_GetJSDObjectForJSObject(JSDContext* jsdc, JSObject* jsobj)
|
||||
{
|
||||
JSDObject* jsdobj;
|
||||
|
||||
JSD_LOCK_OBJECTS(jsdc);
|
||||
jsdobj = (JSDObject*) JS_HashTableLookup(jsdc->objectsTable, jsobj);
|
||||
JSD_UNLOCK_OBJECTS(jsdc);
|
||||
return jsdobj;
|
||||
}
|
||||
|
||||
JSDObject*
|
||||
jsd_GetObjectForValue(JSDContext* jsdc, JSDValue* jsdval)
|
||||
{
|
||||
return jsd_GetJSDObjectForJSObject(jsdc, JSVAL_TO_OBJECT(jsdval->val));
|
||||
}
|
||||
|
||||
JSDValue*
|
||||
jsd_GetValueForObject(JSDContext* jsdc, JSDObject* jsdobj)
|
||||
{
|
||||
return jsd_NewValue(jsdc, OBJECT_TO_JSVAL(jsdobj->obj));
|
||||
}
|
||||
|
||||
|
||||
668
mozilla/js/jsd/jsd_scpt.c
Normal file
668
mozilla/js/jsd/jsd_scpt.c
Normal file
@@ -0,0 +1,668 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* JavaScript Debugging support - Script support
|
||||
*/
|
||||
|
||||
#include "jsd.h"
|
||||
|
||||
/* Comment this out to disable (NT specific) dumping as we go */
|
||||
/*
|
||||
** #ifdef DEBUG
|
||||
** #define JSD_DUMP 1
|
||||
** #endif
|
||||
*/
|
||||
|
||||
#define NOT_SET_YET -1
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
#ifdef DEBUG
|
||||
void JSD_ASSERT_VALID_SCRIPT(JSDScript* jsdscript)
|
||||
{
|
||||
JS_ASSERT(jsdscript);
|
||||
JS_ASSERT(jsdscript->script);
|
||||
}
|
||||
void JSD_ASSERT_VALID_EXEC_HOOK(JSDExecHook* jsdhook)
|
||||
{
|
||||
JS_ASSERT(jsdhook);
|
||||
JS_ASSERT(jsdhook->hook);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef LIVEWIRE
|
||||
static JSBool
|
||||
HasFileExtention(const char* name, const char* ext)
|
||||
{
|
||||
int i;
|
||||
int len = strlen(ext);
|
||||
const char* p = strrchr(name,'.');
|
||||
if( !p )
|
||||
return JS_FALSE;
|
||||
p++;
|
||||
for(i = 0; i < len; i++ )
|
||||
{
|
||||
JS_ASSERT(islower(ext[i]));
|
||||
if( 0 == p[i] || tolower(p[i]) != ext[i] )
|
||||
return JS_FALSE;
|
||||
}
|
||||
if( 0 != p[i] )
|
||||
return JS_FALSE;
|
||||
return JS_TRUE;
|
||||
}
|
||||
#endif /* LIVEWIRE */
|
||||
|
||||
static JSDScript*
|
||||
_newJSDScript(JSDContext* jsdc,
|
||||
JSContext *cx,
|
||||
JSScript *script,
|
||||
JSFunction* function)
|
||||
{
|
||||
JSDScript* jsdscript;
|
||||
uintN lineno;
|
||||
const char* raw_filename;
|
||||
|
||||
JS_ASSERT(JSD_SCRIPTS_LOCKED(jsdc));
|
||||
|
||||
/* these are inlined javascript: urls and we can't handle them now */
|
||||
lineno = (uintN) JS_GetScriptBaseLineNumber(cx, script);
|
||||
if( lineno == 0 )
|
||||
return NULL;
|
||||
|
||||
jsdscript = (JSDScript*) calloc(1, sizeof(JSDScript));
|
||||
if( ! jsdscript )
|
||||
return NULL;
|
||||
|
||||
raw_filename = JS_GetScriptFilename(cx,script);
|
||||
|
||||
JS_APPEND_LINK(&jsdscript->links, &jsdc->scripts);
|
||||
jsdscript->jsdc = jsdc;
|
||||
jsdscript->script = script;
|
||||
jsdscript->function = function;
|
||||
jsdscript->lineBase = lineno;
|
||||
jsdscript->lineExtent = (uintN)NOT_SET_YET;
|
||||
#ifndef LIVEWIRE
|
||||
jsdscript->url = (char*) jsd_BuildNormalizedURL(raw_filename);
|
||||
#else
|
||||
jsdscript->app = LWDBG_GetCurrentApp();
|
||||
if( jsdscript->app && raw_filename )
|
||||
{
|
||||
jsdscript->url = jsdlw_BuildAppRelativeFilename(jsdscript->app, raw_filename);
|
||||
if( function )
|
||||
{
|
||||
jsdscript->lwscript =
|
||||
LWDBG_GetScriptOfFunction(jsdscript->app,
|
||||
JS_GetFunctionName(function));
|
||||
|
||||
/* also, make sure this file is added to filelist if is .js file */
|
||||
if( HasFileExtention(raw_filename,"js") ||
|
||||
HasFileExtention(raw_filename,"sjs") )
|
||||
{
|
||||
jsdlw_PreLoadSource(jsdc, jsdscript->app, raw_filename, JS_FALSE);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
jsdscript->lwscript = LWDBG_GetCurrentTopLevelScript();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
JS_INIT_CLIST(&jsdscript->hooks);
|
||||
|
||||
return jsdscript;
|
||||
}
|
||||
|
||||
static void
|
||||
_destroyJSDScript(JSDContext* jsdc,
|
||||
JSDScript* jsdscript)
|
||||
{
|
||||
JS_ASSERT(JSD_SCRIPTS_LOCKED(jsdc));
|
||||
|
||||
/* destroy all hooks */
|
||||
jsd_ClearAllExecutionHooksForScript(jsdc, jsdscript);
|
||||
|
||||
JS_REMOVE_LINK(&jsdscript->links);
|
||||
if(jsdscript->url)
|
||||
free(jsdscript->url);
|
||||
|
||||
if(jsdscript)
|
||||
free(jsdscript);
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
#ifdef JSD_DUMP
|
||||
static void
|
||||
_dumpJSDScript(JSDContext* jsdc, JSDScript* jsdscript, const char* leadingtext)
|
||||
{
|
||||
const char* name;
|
||||
const char* fun;
|
||||
uintN base;
|
||||
uintN extent;
|
||||
char Buf[256];
|
||||
|
||||
name = jsd_GetScriptFilename(jsdc, jsdscript);
|
||||
fun = jsd_GetScriptFunctionName(jsdc, jsdscript);
|
||||
base = jsd_GetScriptBaseLineNumber(jsdc, jsdscript);
|
||||
extent = jsd_GetScriptLineExtent(jsdc, jsdscript);
|
||||
|
||||
sprintf( Buf, "%sscript=%08X, %s, %s, %d-%d\n",
|
||||
leadingtext,
|
||||
(unsigned) jsdscript->script,
|
||||
name ? name : "no URL",
|
||||
fun ? fun : "no fun",
|
||||
base, base + extent - 1 );
|
||||
OutputDebugString( Buf );
|
||||
}
|
||||
|
||||
static void
|
||||
_dumpJSDScriptList( JSDContext* jsdc )
|
||||
{
|
||||
JSDScript* iterp = NULL;
|
||||
JSDScript* jsdscript = NULL;
|
||||
|
||||
OutputDebugString( "*** JSDScriptDump\n" );
|
||||
while( NULL != (jsdscript = jsd_IterateScripts(jsdc, &iterp)) )
|
||||
_dumpJSDScript( jsdc, jsdscript, " script: " );
|
||||
}
|
||||
#endif /* JSD_DUMP */
|
||||
|
||||
/***************************************************************************/
|
||||
void
|
||||
jsd_DestroyAllJSDScripts( JSDContext* jsdc )
|
||||
{
|
||||
JSDScript *jsdscript;
|
||||
JSDScript *next;
|
||||
|
||||
JS_ASSERT(JSD_SCRIPTS_LOCKED(jsdc));
|
||||
|
||||
for( jsdscript = (JSDScript*)jsdc->scripts.next;
|
||||
jsdscript != (JSDScript*)&jsdc->scripts;
|
||||
jsdscript = next )
|
||||
{
|
||||
next = (JSDScript*)jsdscript->links.next;
|
||||
_destroyJSDScript( jsdc, jsdscript );
|
||||
}
|
||||
}
|
||||
|
||||
JSDScript*
|
||||
jsd_FindJSDScript( JSDContext* jsdc,
|
||||
JSScript *script )
|
||||
{
|
||||
JSDScript *jsdscript;
|
||||
|
||||
JS_ASSERT(JSD_SCRIPTS_LOCKED(jsdc));
|
||||
|
||||
for( jsdscript = (JSDScript *)jsdc->scripts.next;
|
||||
jsdscript != (JSDScript *)&jsdc->scripts;
|
||||
jsdscript = (JSDScript *)jsdscript->links.next )
|
||||
{
|
||||
if (jsdscript->script == script)
|
||||
return jsdscript;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
JSDScript*
|
||||
jsd_IterateScripts(JSDContext* jsdc, JSDScript **iterp)
|
||||
{
|
||||
JSDScript *jsdscript = *iterp;
|
||||
|
||||
JS_ASSERT(JSD_SCRIPTS_LOCKED(jsdc));
|
||||
|
||||
if( !jsdscript )
|
||||
jsdscript = (JSDScript *)jsdc->scripts.next;
|
||||
if( jsdscript == (JSDScript *)&jsdc->scripts )
|
||||
return NULL;
|
||||
*iterp = (JSDScript*) jsdscript->links.next;
|
||||
return jsdscript;
|
||||
}
|
||||
|
||||
JSBool
|
||||
jsd_IsActiveScript(JSDContext* jsdc, JSDScript *jsdscript)
|
||||
{
|
||||
JSDScript *current;
|
||||
|
||||
JS_ASSERT(JSD_SCRIPTS_LOCKED(jsdc));
|
||||
|
||||
for( current = (JSDScript *)jsdc->scripts.next;
|
||||
current != (JSDScript *)&jsdc->scripts;
|
||||
current = (JSDScript *)current->links.next )
|
||||
{
|
||||
if(jsdscript == current)
|
||||
return JS_TRUE;
|
||||
}
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
const char*
|
||||
jsd_GetScriptFilename(JSDContext* jsdc, JSDScript *jsdscript)
|
||||
{
|
||||
return jsdscript->url;
|
||||
}
|
||||
|
||||
const char*
|
||||
jsd_GetScriptFunctionName(JSDContext* jsdc, JSDScript *jsdscript)
|
||||
{
|
||||
if( ! jsdscript->function )
|
||||
return NULL;
|
||||
return JS_GetFunctionName(jsdscript->function);
|
||||
}
|
||||
|
||||
uintN
|
||||
jsd_GetScriptBaseLineNumber(JSDContext* jsdc, JSDScript *jsdscript)
|
||||
{
|
||||
return jsdscript->lineBase;
|
||||
}
|
||||
|
||||
uintN
|
||||
jsd_GetScriptLineExtent(JSDContext* jsdc, JSDScript *jsdscript)
|
||||
{
|
||||
if( NOT_SET_YET == jsdscript->lineExtent )
|
||||
jsdscript->lineExtent = JS_GetScriptLineExtent(jsdc->dumbContext, jsdscript->script);
|
||||
return jsdscript->lineExtent;
|
||||
}
|
||||
|
||||
jsuword
|
||||
jsd_GetClosestPC(JSDContext* jsdc, JSDScript* jsdscript, uintN line)
|
||||
{
|
||||
#ifdef LIVEWIRE
|
||||
if( jsdscript && jsdscript->lwscript )
|
||||
{
|
||||
uintN newline;
|
||||
jsdlw_RawToProcessedLineNumber(jsdc, jsdscript, line, &newline);
|
||||
if( line != newline )
|
||||
line = newline;
|
||||
}
|
||||
#endif
|
||||
|
||||
return (jsuword) JS_LineNumberToPC(jsdc->dumbContext,
|
||||
jsdscript->script, line );
|
||||
}
|
||||
|
||||
uintN
|
||||
jsd_GetClosestLine(JSDContext* jsdc, JSDScript* jsdscript, jsuword pc)
|
||||
{
|
||||
uintN first = jsdscript->lineBase;
|
||||
uintN last = first + jsd_GetScriptLineExtent(jsdc, jsdscript) - 1;
|
||||
uintN line = JS_PCToLineNumber(jsdc->dumbContext,
|
||||
jsdscript->script, (jsbytecode*)pc);
|
||||
|
||||
if( line < first )
|
||||
return first;
|
||||
if( line > last )
|
||||
return last;
|
||||
|
||||
#ifdef LIVEWIRE
|
||||
if( jsdscript && jsdscript->lwscript )
|
||||
{
|
||||
uintN newline;
|
||||
jsdlw_ProcessedToRawLineNumber(jsdc, jsdscript, line, &newline);
|
||||
line = newline;
|
||||
}
|
||||
#endif
|
||||
|
||||
return line;
|
||||
}
|
||||
|
||||
JSBool
|
||||
jsd_SetScriptHook(JSDContext* jsdc, JSD_ScriptHookProc hook, void* callerdata)
|
||||
{
|
||||
JSD_LOCK();
|
||||
jsdc->scriptHook = hook;
|
||||
jsdc->scriptHookData = callerdata;
|
||||
JSD_UNLOCK();
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JSBool
|
||||
jsd_GetScriptHook(JSDContext* jsdc, JSD_ScriptHookProc* hook, void** callerdata)
|
||||
{
|
||||
JSD_LOCK();
|
||||
if( hook )
|
||||
*hook = jsdc->scriptHook;
|
||||
if( callerdata )
|
||||
*callerdata = jsdc->scriptHookData;
|
||||
JSD_UNLOCK();
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
void JS_DLL_CALLBACK
|
||||
jsd_NewScriptHookProc(
|
||||
JSContext *cx,
|
||||
const char *filename, /* URL this script loads from */
|
||||
uintN lineno, /* line where this script starts */
|
||||
JSScript *script,
|
||||
JSFunction *fun,
|
||||
void* callerdata )
|
||||
{
|
||||
JSDScript* jsdscript = NULL;
|
||||
JSDContext* jsdc = (JSDContext*) callerdata;
|
||||
JSD_ScriptHookProc hook;
|
||||
void* hookData;
|
||||
|
||||
JSD_ASSERT_VALID_CONTEXT(jsdc);
|
||||
|
||||
if( JSD_IS_DANGEROUS_THREAD(jsdc) )
|
||||
return;
|
||||
|
||||
#ifdef LIVEWIRE
|
||||
if( 1 == lineno )
|
||||
jsdlw_PreLoadSource(jsdc, LWDBG_GetCurrentApp(), filename, JS_TRUE );
|
||||
#endif
|
||||
|
||||
JSD_LOCK_SCRIPTS(jsdc);
|
||||
jsdscript = _newJSDScript(jsdc, cx, script, fun);
|
||||
JSD_UNLOCK_SCRIPTS(jsdc);
|
||||
if( ! jsdscript )
|
||||
return;
|
||||
|
||||
#ifdef JSD_DUMP
|
||||
JSD_LOCK_SCRIPTS(jsdc);
|
||||
_dumpJSDScript(jsdc, jsdscript, "***NEW Script: ");
|
||||
_dumpJSDScriptList( jsdc );
|
||||
JSD_UNLOCK_SCRIPTS(jsdc);
|
||||
#endif /* JSD_DUMP */
|
||||
|
||||
/* local in case jsdc->scriptHook gets cleared on another thread */
|
||||
JSD_LOCK();
|
||||
hook = jsdc->scriptHook;
|
||||
hookData = jsdc->scriptHookData;
|
||||
JSD_UNLOCK();
|
||||
|
||||
if( hook )
|
||||
hook(jsdc, jsdscript, JS_TRUE, hookData);
|
||||
}
|
||||
|
||||
void JS_DLL_CALLBACK
|
||||
jsd_DestroyScriptHookProc(
|
||||
JSContext *cx,
|
||||
JSScript *script,
|
||||
void* callerdata )
|
||||
{
|
||||
JSDScript* jsdscript = NULL;
|
||||
JSDContext* jsdc = (JSDContext*) callerdata;
|
||||
JSD_ScriptHookProc hook;
|
||||
void* hookData;
|
||||
|
||||
JSD_ASSERT_VALID_CONTEXT(jsdc);
|
||||
|
||||
if( JSD_IS_DANGEROUS_THREAD(jsdc) )
|
||||
return;
|
||||
|
||||
JSD_LOCK_SCRIPTS(jsdc);
|
||||
jsdscript = jsd_FindJSDScript(jsdc, script);
|
||||
JSD_UNLOCK_SCRIPTS(jsdc);
|
||||
|
||||
if( ! jsdscript )
|
||||
return;
|
||||
|
||||
#ifdef JSD_DUMP
|
||||
JSD_LOCK_SCRIPTS(jsdc);
|
||||
_dumpJSDScript(jsdc, jsdscript, "***DESTROY Script: ");
|
||||
JSD_UNLOCK_SCRIPTS(jsdc);
|
||||
#endif /* JSD_DUMP */
|
||||
|
||||
/* local in case hook gets cleared on another thread */
|
||||
JSD_LOCK();
|
||||
hook = jsdc->scriptHook;
|
||||
hookData = jsdc->scriptHookData;
|
||||
JSD_UNLOCK();
|
||||
|
||||
if( hook )
|
||||
hook(jsdc, jsdscript, JS_FALSE, hookData);
|
||||
|
||||
JSD_LOCK_SCRIPTS(jsdc);
|
||||
_destroyJSDScript(jsdc, jsdscript);
|
||||
JSD_UNLOCK_SCRIPTS(jsdc);
|
||||
|
||||
#ifdef JSD_DUMP
|
||||
JSD_LOCK_SCRIPTS(jsdc);
|
||||
_dumpJSDScriptList(jsdc);
|
||||
JSD_UNLOCK_SCRIPTS(jsdc);
|
||||
#endif /* JSD_DUMP */
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
static JSDExecHook*
|
||||
_findHook(JSDContext* jsdc, JSDScript* jsdscript, jsuword pc)
|
||||
{
|
||||
JSDExecHook* jsdhook;
|
||||
JSCList* list = &jsdscript->hooks;
|
||||
|
||||
for( jsdhook = (JSDExecHook*)list->next;
|
||||
jsdhook != (JSDExecHook*)list;
|
||||
jsdhook = (JSDExecHook*)jsdhook->links.next )
|
||||
{
|
||||
if (jsdhook->pc == pc)
|
||||
return jsdhook;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static JSBool
|
||||
_isActiveHook(JSDContext* jsdc, JSScript *script, JSDExecHook* jsdhook)
|
||||
{
|
||||
JSDExecHook* current;
|
||||
JSCList* list;
|
||||
JSDScript* jsdscript;
|
||||
|
||||
JSD_LOCK_SCRIPTS(jsdc);
|
||||
jsdscript = jsd_FindJSDScript(jsdc, script);
|
||||
if( ! jsdscript)
|
||||
{
|
||||
JSD_UNLOCK_SCRIPTS(jsdc);
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
list = &jsdscript->hooks;
|
||||
|
||||
for( current = (JSDExecHook*)list->next;
|
||||
current != (JSDExecHook*)list;
|
||||
current = (JSDExecHook*)current->links.next )
|
||||
{
|
||||
if(current == jsdhook)
|
||||
{
|
||||
JSD_UNLOCK_SCRIPTS(jsdc);
|
||||
return JS_TRUE;
|
||||
}
|
||||
}
|
||||
JSD_UNLOCK_SCRIPTS(jsdc);
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
||||
JSTrapStatus JS_DLL_CALLBACK
|
||||
jsd_TrapHandler(JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval,
|
||||
void *closure)
|
||||
{
|
||||
JSDExecHook* jsdhook = (JSDExecHook*) closure;
|
||||
JSD_ExecutionHookProc hook;
|
||||
void* hookData;
|
||||
JSDContext* jsdc;
|
||||
JSDScript* jsdscript;
|
||||
|
||||
JSD_LOCK();
|
||||
|
||||
if( NULL == (jsdc = jsd_JSDContextForJSContext(cx)) ||
|
||||
! _isActiveHook(jsdc, script, jsdhook) )
|
||||
{
|
||||
JSD_UNLOCK();
|
||||
return JSTRAP_CONTINUE;
|
||||
}
|
||||
|
||||
JSD_ASSERT_VALID_EXEC_HOOK(jsdhook);
|
||||
JS_ASSERT(jsdhook->pc == (jsuword)pc);
|
||||
JS_ASSERT(jsdhook->jsdscript->script == script);
|
||||
JS_ASSERT(jsdhook->jsdscript->jsdc == jsdc);
|
||||
|
||||
hook = jsdhook->hook;
|
||||
hookData = jsdhook->callerdata;
|
||||
jsdscript = jsdhook->jsdscript;
|
||||
|
||||
/* do not use jsdhook-> after this point */
|
||||
JSD_UNLOCK();
|
||||
|
||||
if( ! jsdc || ! jsdc->inited )
|
||||
return JSTRAP_CONTINUE;
|
||||
|
||||
if( JSD_IS_DANGEROUS_THREAD(jsdc) )
|
||||
return JSTRAP_CONTINUE;
|
||||
|
||||
#ifdef LIVEWIRE
|
||||
if( ! jsdlw_UserCodeAtPC(jsdc, jsdscript, (jsuword)pc) )
|
||||
return JSTRAP_CONTINUE;
|
||||
#endif
|
||||
|
||||
return jsd_CallExecutionHook(jsdc, cx, JSD_HOOK_BREAKPOINT,
|
||||
hook, hookData, rval);
|
||||
}
|
||||
|
||||
|
||||
|
||||
JSBool
|
||||
jsd_SetExecutionHook(JSDContext* jsdc,
|
||||
JSDScript* jsdscript,
|
||||
jsuword pc,
|
||||
JSD_ExecutionHookProc hook,
|
||||
void* callerdata)
|
||||
{
|
||||
JSDExecHook* jsdhook;
|
||||
|
||||
JSD_LOCK();
|
||||
if( ! hook )
|
||||
{
|
||||
jsd_ClearExecutionHook(jsdc, jsdscript, pc);
|
||||
JSD_UNLOCK();
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
jsdhook = _findHook(jsdc, jsdscript, pc);
|
||||
if( jsdhook )
|
||||
{
|
||||
jsdhook->hook = hook;
|
||||
jsdhook->callerdata = callerdata;
|
||||
return JS_TRUE;
|
||||
}
|
||||
/* else... */
|
||||
|
||||
jsdhook = (JSDExecHook*)calloc(1, sizeof(JSDExecHook));
|
||||
if( ! jsdhook )
|
||||
return JS_FALSE;
|
||||
jsdhook->jsdscript = jsdscript;
|
||||
jsdhook->pc = pc;
|
||||
jsdhook->hook = hook;
|
||||
jsdhook->callerdata = callerdata;
|
||||
|
||||
if( ! JS_SetTrap(jsdc->dumbContext, jsdscript->script,
|
||||
(jsbytecode*)pc, jsd_TrapHandler, (void*) jsdhook) )
|
||||
{
|
||||
free(jsdhook);
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
JS_APPEND_LINK(&jsdhook->links, &jsdscript->hooks);
|
||||
JSD_UNLOCK();
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JSBool
|
||||
jsd_ClearExecutionHook(JSDContext* jsdc,
|
||||
JSDScript* jsdscript,
|
||||
jsuword pc)
|
||||
{
|
||||
JSDExecHook* jsdhook;
|
||||
|
||||
JSD_LOCK();
|
||||
|
||||
jsdhook = _findHook(jsdc, jsdscript, pc);
|
||||
if( ! jsdhook )
|
||||
{
|
||||
JS_ASSERT(0);
|
||||
JSD_UNLOCK();
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
JS_ClearTrap(jsdc->dumbContext, jsdscript->script,
|
||||
(jsbytecode*)pc, NULL, NULL );
|
||||
|
||||
JS_REMOVE_LINK(&jsdhook->links);
|
||||
free(jsdhook);
|
||||
|
||||
JSD_UNLOCK();
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JSBool
|
||||
jsd_ClearAllExecutionHooksForScript(JSDContext* jsdc, JSDScript* jsdscript)
|
||||
{
|
||||
JSDExecHook* jsdhook;
|
||||
JSCList* list = &jsdscript->hooks;
|
||||
|
||||
JSD_LOCK();
|
||||
|
||||
while( (JSDExecHook*)list != (jsdhook = (JSDExecHook*)list->next) )
|
||||
{
|
||||
JS_REMOVE_LINK(&jsdhook->links);
|
||||
free(jsdhook);
|
||||
}
|
||||
|
||||
JS_ClearScriptTraps(jsdc->dumbContext, jsdscript->script);
|
||||
JSD_UNLOCK();
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
JSBool
|
||||
jsd_ClearAllExecutionHooks(JSDContext* jsdc)
|
||||
{
|
||||
JSDScript* jsdscript;
|
||||
JSDScript* iterp = NULL;
|
||||
|
||||
JSD_LOCK();
|
||||
while( NULL != (jsdscript = jsd_IterateScripts(jsdc, &iterp)) )
|
||||
jsd_ClearAllExecutionHooksForScript(jsdc, jsdscript);
|
||||
JSD_UNLOCK();
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
jsd_ScriptCreated(JSDContext* jsdc,
|
||||
JSContext *cx,
|
||||
const char *filename, /* URL this script loads from */
|
||||
uintN lineno, /* line where this script starts */
|
||||
JSScript *script,
|
||||
JSFunction *fun)
|
||||
{
|
||||
jsd_NewScriptHookProc(cx, filename, lineno, script, fun, jsdc);
|
||||
}
|
||||
|
||||
void
|
||||
jsd_ScriptDestroyed(JSDContext* jsdc,
|
||||
JSContext *cx,
|
||||
JSScript *script)
|
||||
{
|
||||
jsd_DestroyScriptHookProc(cx, script, jsdc);
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user