Changes to JScall after moving, to make it into a discrete library.

svn path=/trunk/jscall-sharp/; revision=62249
This commit is contained in:
Michael Hutchinson 2006-07-04 20:40:46 +00:00
Родитель 707e8f02b7
Коммит 3ecf4bac50
21 изменённых файлов: 464 добавлений и 70 удалений

7
AUTHORS Normal file
Просмотреть файл

@ -0,0 +1,7 @@
The following developers have contributed to JSCall:
Michael Hutchinson <m.j.hutchinson@dur.ac.uk>
Initial development, maintainer.
Chris Howie <cdhowie@nerdshack.com>
JSEval method.

20
COPYING Normal file
Просмотреть файл

@ -0,0 +1,20 @@
Copyright (c) 2006 the individuals listed on the ChangeLog entries.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Просмотреть файл

@ -1,17 +0,0 @@
2006-06-24 Michael Hutchinson <m.j.hutchinson@gmail.com>
* jscallglue/jscallglue.cpp: Fix build on Gecko 1.8+ browsers. Not a
long-term solution -- need to re-work Mozilla string conversions to use
the new frozen interfaces, but that will break backwards compatibility.
2006-06-14 Michael Hutchinson <m.j.hutchinson@gmail.com>
* AspNetEdit.JSCall/CommandManager.cs: Null input checking to avoid
segfaults, general cleanup.
2006-06-14 Chris Howie <cdhowie@nerdshack.com>
* jscallglue/jscallglue.cpp,
AspNetEdit.JSCall/CommandManager.cs:
Add a method "JSEval" to execute arbitrary JavaScript in the browser.

28
INSTALL Normal file
Просмотреть файл

@ -0,0 +1,28 @@
Prerequisites
=============
You will need:
Mono 1.1.9
Gtk# 2.4
Gecko# 0.10
GCC 3.3
Gtk+ 2.4 + developer headers
Mozilla 1.6 + developer headers
Building JSCall
===============
Open a terminal in the root aspnetedit directory and run
./autoconf.sh --prefix=PREFIX
This will automatically run the configure script as well, but you may access
additional options by running
./configure --help
The library can the be built with the command
make
Installing JSCall
=================
To install JSCall into the PREFIX directory you specified during
configuration, simply run
make install
The libraries and scripts will be installed into PREFIX/lib/jscall-sharp.

Просмотреть файл

@ -1,29 +1,7 @@
SUBDIRS = jscallglue
SUBDIRS = src
EXTRA_DIST = jscall-sharp.pc.in
ASSEMBLY_NAME = jscall
ASSEMBLY = $(top_builddir)/build/lib/$(ASSEMBLY_NAME).dll
TARGET = $(ASSEMBLY)
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = jscall-sharp.pc
jscalldir=$(pkglibdir)
jscall_SCRIPTS = $(ASSEMBLY)
jscall_DATA = $(ASSEMBLY).mdb
JSCALL_CSFILES = \
$(srcdir)/AssemblyInfo.cs \
$(srcdir)/AspNetEdit.JSCall/CommandManager.cs \
$(srcdir)/AspNetEdit.JSCall/InvalidJSArgumentException.cs
JSCALL_REFERENCES = \
$(GTKSHARP_LIBS) \
$(GECKOSHARP_LIBS)
$(ASSEMBLY): $(JSCALL_CSFILES)
$(MCS) $(MCS_OPTIONS) $(JSCALL_REFERENCES) -debug -target:library -out:$@ $(JSCALL_CSFILES)
$(ASSEMBLY).mdb: $(ASSEMBLY)
all: $(ASSEMBLY)
EXTRA_DIST = $(JSCALL_CSFILES) $(srcdir)/README $(srcdir)/Resources/JSCall.js
CLEANFILES = $(ASSEMBLY) $(ASSEMBLY).mdb
DISTCLEANFILES = config.guess config.sub Makefile.in configure install-sh missing aclocal.m4

1
NEWS Normal file
Просмотреть файл

@ -0,0 +1 @@

74
README
Просмотреть файл

@ -1,25 +1,79 @@
INTRODUCTION
Introduction
============
This is the AspNetEdit.JSGlue layer for calling C# functions from JavaScript in a Gecko# control, and vice versa. It should work with any .NET language but I've referrred to C# for simplicity. I don't expect many people to use this, so the documentation is little more than minimal; please contact me <m.j.hutchinson@gmail.com> if you need help working out how it works.
JSCall is a simple JavaScript bridge for Gecko#. It's an interim solution
until someone writes a proper XPCOM bridge for Mono, and uses unmanaged code
and P/Invoke to invoke Gecko's XPCOM components from managed code. It should
work with any .NET language, but I've referred to C# for simplicity. I don't
expect many people to use this, so the documentation is little more than
minimal; please contact me <m.j.hutchinson@gmail.com> if you need help
working out how it works.
BUILDING
========
Use automake (./autogen.sh --prefix=/usr/local) at the application level.
USAGE
Installation
============
For installation instruction please read the INSTALL file.
Architecture
============
There are currently two communication mechanisms:
Message-passing:
Requires loading JSCall.js in the document. Functions can
be registered on the JS side and then called from the C# side, and vice
versa. Return values are handle asynchonously as callbacks.
CLR -> Gecko calls are made by injecting children into a 'jscall' node in the
DOM, while Gecko -> CLR calls are made via document's window title.
JS evaluation:
Scripts can be passed into the browser from managed code, and executed in the
page context. This can also be used to load JSCall.js and other scripts when
setting up the message-passing scheme in pages that cannot be modified
directly, e.g. internet sites
Usage
=====
On the CLR side of things, create an instance of AspNetEdit.JSGlue.CommandManager by passing the constructor the Gecko# control. This object has the following methods:
On the CLR side of things, create an instance of
AspNetEdit.JSGlue.CommandManager by passing the Gecko# control to its
constructor. This object has the following methods:
RegisterJSHandler(string name, ClrCall handler)
Register a ClrCall delegate as the handler when JS calls the named 'name' function.
Register a ClrCall delegate as the handler when JS calls the named
'name' function.
UnregisterJSHandler(string name)
Unregister the 'name' function.
JSCall(string function, string returnTo, string[] args)
Call the 'function' JS function, with 'returnTo' as the callback for any return value. Arguments as a string array.
Call the 'function' JS function, with 'returnTo' as the callback for
any return value. Arguments as a string array.
JSEval (string script)
Executes the JS that is passed in. Does not require JSGlue.js, so can
be used to load it.
On the JS side, load the JSGlue.js file into your document and call
JSGlueInit(). You then have the following functions available, mirroring the
C# functions but a bit more "javascripty".
On the JS side, load the JSGlue.js file into your document and call JSGlueInit(). You then have the following functions available, mirroring the C# functions but a bit more "javascripty".
JSGluePlaceClrCall(fn, returnTo, args)
Call the 'fn' C# function, with 'returnTo' as the callback for any return value. Arguments as a string array.
JSGlueRegisterClrHandler(n, fn)
Register a the 'fn' function as the handler when C# calls the named 'n' function.
JSGlueUnregisterClrHandler()
Unregister the 'name' function.
Developers
==========
A list of contributors can be found in the AUTHORS file. If you are
interested in contributing to JSCall, please contact Michael Hutchinson
<m.j.hutchinson@gmail.com>. I am prepared to accept any generally useful
Gecko#-interfacing code.
Release Notes
=============
Alpha 0.0.2:
Split from AspNetEdit ASP.NET graphical designer. See
http://svn.myrealbox.com/viewcvs/trunk/aspeditor/src/jscall/ for previous
release information.

83
autogen.sh Executable file
Просмотреть файл

@ -0,0 +1,83 @@
#! /bin/sh
PROJECT=jscall-sharp
FILE=src/AspNetEdit.JSCall/CommandManager.cs
CONFIGURE=configure.ac
: ${AUTOCONF=autoconf}
: ${AUTOHEADER=autoheader}
: ${AUTOMAKE=automake}
: ${LIBTOOLIZE=libtoolize}
: ${ACLOCAL=aclocal}
: ${LIBTOOL=libtool}
srcdir=`dirname $0`
test -z "$srcdir" && srcdir=.
ORIGDIR=`pwd`
cd $srcdir
TEST_TYPE=-f
aclocalinclude="-I . $ACLOCAL_FLAGS"
DIE=0
($AUTOCONF --version) < /dev/null > /dev/null 2>&1 || {
echo
echo "You must have autoconf installed to compile $PROJECT."
echo "Download the appropriate package for your distribution,"
echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
DIE=1
}
($AUTOMAKE --version) < /dev/null > /dev/null 2>&1 || {
echo
echo "You must have automake installed to compile $PROJECT."
echo "Get ftp://sourceware.cygnus.com/pub/automake/automake-1.4.tar.gz"
echo "(or a newer version if it is available)"
DIE=1
}
(grep "^AM_PROG_LIBTOOL" $CONFIGURE >/dev/null) && {
($LIBTOOL --version) < /dev/null > /dev/null 2>&1 || {
echo
echo "**Error**: You must have \`libtool' installed to compile $PROJECT."
echo "Get ftp://ftp.gnu.org/pub/gnu/libtool-1.2d.tar.gz"
echo "(or a newer version if it is available)"
DIE=1
}
}
if test "$DIE" -eq 1; then
exit 1
fi
test $TEST_TYPE $FILE || {
echo "You must run this script in the top-level $PROJECT directory"
exit 1
}
if test -z "$*"; then
echo "I am going to run ./configure with no arguments - if you wish "
echo "to pass any to it, please specify them on the $0 command line."
fi
case $CC in
*xlc | *xlc\ * | *lcc | *lcc\ *) am_opt=--include-deps;;
esac
(grep "^AM_PROG_LIBTOOL" $CONFIGURE >/dev/null) && {
echo "Running $LIBTOOLIZE ..."
$LIBTOOLIZE --force --copy
}
echo "Running $ACLOCAL $aclocalinclude ..."
$ACLOCAL $aclocalinclude
echo "Running $AUTOMAKE -a --gnu $am_opt ..."
$AUTOMAKE -a --add-missing --gnu $am_opt
echo "Running $AUTOCONF ..."
$AUTOCONF
echo Running $srcdir/configure $conf_flags "$@" ...
$srcdir/configure --enable-maintainer-mode $conf_flags "$@" \

110
configure.ac Normal file
Просмотреть файл

@ -0,0 +1,110 @@
AC_INIT(README)
AC_CANONICAL_SYSTEM
AM_INIT_AUTOMAKE(jscall-sharp, 0.0.2.0)
AM_MAINTAINER_MODE
AC_PROG_INSTALL
AC_PROG_CXX
### Dependency version numbers
MONO_REQUIRED_VERSION=1.1.9
GTKSHARP_REQUIRED_VERSION=2.4
GECKOSHARP_REQUIRED_VERSION=0.10
m4_define(gtk_required_version, 2.6.0)
m4_define(mozilla_required_version, 1.6)
m4_define(firefox_required_version, 1.0)
### Check for pkg-config
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
if test "x$PKG_CONFIG" = "xno"; then
AC_MSG_ERROR([You need to install pkg-config])
fi
### Check mono version
PKG_CHECK_MODULES(MONO, mono >= $MONO_REQUIRED_VERSION)
#Check for C# compiler
AC_PATH_PROG(CSC, csc, no)
AC_PATH_PROG(MCS, mcs, no)
AC_PATH_PROG(MONO, mono, no)
### Find a c# compiler
CS="C#"
if test "x$CSC" = "xno" -a "x$MCS" = "xno" ; then
dnl AC_MSG_ERROR([You need to install a C# compiler])
AC_MSG_ERROR([No $CS compiler found])
fi
if test "x$MCS" = "xno" ; then
MCS=$CSC
fi
if test "x$MONO" = "xno"; then
AC_MSG_ERROR([No mono runtime found])
fi
AC_SUBST(MCS)
MCS_OPTIONS="-d:TRACE"
AC_SUBST(MCS_OPTIONS)
### Check c# dependencies
PKG_CHECK_MODULES(GTKSHARP, gtk-sharp-2.0 >= $GTKSHARP_REQUIRED_VERSION)
PKG_CHECK_MODULES(GECKOSHARP, gecko-sharp-2.0 >= $GECKOSHARP_REQUIRED_VERSION)
### Check for C++/Mozilla dependencies (inspired by gnome-python-extras)
AC_ARG_WITH(gtkmozembed, AS_HELP_STRING(
[--with-gtkmozembed=mozilla|firefox],
[package that provides libgtkmozembed]),
[mozpackage=$withval], [mozpackage=any])
if test $mozpackage = any ; then
AC_MSG_CHECKING(for Gecko development files)
if $PKG_CONFIG --exists mozilla-gtkmozembed; then
AC_MSG_RESULT([Mozilla detected])
mozpackage=mozilla
else
if $PKG_CONFIG --exists firefox-gtkmozembed; then
AC_MSG_RESULT([Firefox detected])
mozpackage=firefox
else
AC_MSG_ERROR([Neither Firefox nor Mozilla development packages were detected])
fi
fi
fi
case $mozpackage in
firefox) mozpackage_required_version=firefox_required_version ;;
mozilla) mozpackage_required_version=mozilla_required_version ;;
*) AC_MSG_ERROR([--with-gtkmozembed argument must be either 'mozilla' or 'firefox'])
esac
MOZILLA_HOME="`$PKG_CONFIG --variable=libdir $mozpackage-gtkmozembed`"
AC_SUBST(MOZILLA_HOME)
PKG_CHECK_MODULES(JSGLUEDEPS, [$mozpackage-gtkmozembed >= $mozpackage_required_version,
$mozpackage-xpcom >= $mozpackage_required_version
gtk+-2.0 >= gtk_required_version])
AC_OUTPUT([
Makefile
jscall-sharp.pc
src/Makefile
src/AssemblyInfo.cs
])
echo ""
echo "Configuration summary"
echo ""
echo " * Installation prefix = $prefix"
echo " * C# compiler = $MCS"
echo " * C# compiler options = $MCS_OPTIONS"
echo " * Gecko libraries from: $mozpackage"
echo " * $mozpackage home: $MOZILLA_HOME"
echo ""

10
jscall-sharp.pc.in Normal file
Просмотреть файл

@ -0,0 +1,10 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
Libraries=@libdir@/jscall-sharp/jscall-sharp.dll
Name: jscall-sharp
Description: jscall-sharp - Limited JavaScript bridge for Gecko#
Version: @VERSION@
Libs: -r:@libdir@/jscall-sharp/jscall-sharp.dll

Просмотреть файл

@ -1,16 +0,0 @@
jscallgluedir=$(pkglibdir)
dllfile = $(top_builddir)/build/lib/libjscallglue.dll.so
jscallglue_SCRIPTS = $(dllfile)
CXXFLAGS = -shared -g -fPIC -fno-rtti $(JSGLUEDEPS_CFLAGS)
LDFLAGS = $(JSGLUEDEPS_CFLAGS)
all: $(dllfile)
$(dllfile): jscallglue.cpp
$(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS)
CLEANFILES = $(dllfile)
EXTRA_DIST = README

Просмотреть файл

17
src/ChangeLog Normal file
Просмотреть файл

@ -0,0 +1,17 @@
2006-06-24 Michael Hutchinson <m.j.hutchinson@gmail.com>
* jscallglue/jscallglue.cpp: Fix build on Gecko 1.8+ browsers. Not a
long-term solution -- need to re-work Mozilla string conversions to use
the new frozen interfaces, but that will break backwards compatibility.
2006-06-14 Michael Hutchinson <m.j.hutchinson@gmail.com>
* AspNetEdit.JSCall/CommandManager.cs: Null input checking to avoid
segfaults, general cleanup.
2006-06-14 Chris Howie <cdhowie@nerdshack.com>
* jscallglue/jscallglue.cpp,
AspNetEdit.JSCall/CommandManager.cs:
Add a method "JSEval" to execute arbitrary JavaScript in the browser.

57
src/Makefile.am Normal file
Просмотреть файл

@ -0,0 +1,57 @@
### Names ###
ASSEMBLY_NAME = jscall
ASSEMBLY = $(ASSEMBLY_NAME).dll
GLUELIB = lib$(ASSEMBLY_NAME)glue.dll.so
### Source files and refs ###
ASSEMBLY_CSFILES = \
AssemblyInfo.cs \
AspNetEdit.JSCall/CommandManager.cs \
AspNetEdit.JSCall/InvalidJSArgumentException.cs
ASSEMBLY_REFERENCES = \
$(GTKSHARP_LIBS) \
$(GECKOSHARP_LIBS)
GLUELIB_CPPFILES = \
jscallglue/jscallglue.cpp
CXXFLAGS = -shared -g -fPIC -fno-rtti $(JSGLUEDEPS_CFLAGS)
LDFLAGS = $(JSGLUEDEPS_CFLAGS)
JS_FILES = \
Resources/JSCall.js
DOC_FILES = \
jscallglue/README
### Install locations, files ###
jscalldir=$(pkglibdir)
jscall_SCRIPTS = $(ASSEMBLY) $(GLUELIB) $(JS_FILES)
jscall_DATA = $(ASSEMBLY).mdb
### Build rules ###
all: $(ASSEMBLY)
$(ASSEMBLY): $(ASSEMBLY_CSFILES)
$(MCS) $(MCS_OPTIONS) $(ASSEMBLY_REFERENCES) -debug -target:library -out:$@ $^
$(ASSEMBLY).mdb: $(ASSEMBLY)
$(GLUELIB): $(GLUELIB_CPPFILES)
$(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS)
### Extra dist and clean info ###
EXTRA_DIST = $(ASSEMBLY_CSFILES) $(GLUELIB_CPPFILES) $(JS_FILES) $(DOC_FILES)
CLEANFILES = $(ASSEMBLY) $(ASSEMBLY).mdb $(GLUELIB)

Просмотреть файл

45
src/jscall.mdp Normal file
Просмотреть файл

@ -0,0 +1,45 @@
<Project name="jscall" fileversion="2.0" language="C#" clr-version="Net_1_1" ctype="DotNetProject">
<Configurations active="Debug">
<Configuration name="Debug" ctype="DotNetProjectConfiguration">
<Output directory="../../build/lib" assembly="jscall" />
<Build debugmode="True" target="Library" />
<Execution runwithwarnings="True" consolepause="True" runtime="MsNet" clr-version="Net_1_1" />
<CodeGeneration compiler="Csc" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" mainclass="" generatexmldocumentation="False" ctype="CSharpCompilerParameters" />
</Configuration>
<Configuration name="Release" ctype="DotNetProjectConfiguration">
<Output directory="../../build/lib" assembly="jscall" />
<Build debugmode="False" target="Library" />
<Execution runwithwarnings="True" consolepause="True" runtime="MsNet" clr-version="Net_1_1" />
<CodeGeneration compiler="Csc" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" mainclass="" generatexmldocumentation="False" ctype="CSharpCompilerParameters" />
</Configuration>
</Configurations>
<DeployTargets />
<DeploymentInformation strategy="File">
<excludeFiles>
<ExcludeFile file="./AssemblyInfo.cs.in" />
<ExcludeFile file="./ChangeLog" />
<ExcludeFile file="./Resources/ChangeLog" />
<ExcludeFile file="./jscallglue/ChangeLog" />
<ExcludeFile file="./AspNetEdit.JSCall/ChangeLog" />
<ExcludeFile file="./jscall.dll.mdb" />
<ExcludeFile file="./libjscallglue.dll.so" />
</excludeFiles>
</DeploymentInformation>
<Contents>
<File name="./AssemblyInfo.cs.in" subtype="Code" buildaction="Exclude" />
<File name="./AspNetEdit.JSCall/CommandManager.cs" subtype="Code" buildaction="Compile" />
<File name="./AspNetEdit.JSCall/InvalidJSArgumentException.cs" subtype="Code" buildaction="Compile" />
<File name="./Resources/JSCall.js" subtype="Code" buildaction="Exclude" />
<File name="./jscallglue/README" subtype="Code" buildaction="Exclude" />
<File name="./jscallglue/jscallglue.cpp" subtype="Code" buildaction="Exclude" />
<File name="./ChangeLog" subtype="Code" buildaction="Exclude" />
</Contents>
<References>
<ProjectReference type="Gac" localcopy="True" refto="System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<ProjectReference type="Gac" localcopy="True" refto="gtk-sharp, Version=2.6.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
<ProjectReference type="Gac" localcopy="True" refto="glib-sharp, Version=2.6.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
<ProjectReference type="Gac" localcopy="True" refto="gdk-sharp, Version=2.6.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
<ProjectReference type="Gac" localcopy="True" refto="gecko-sharp, Version=2.0.0.0, Culture=neutral, PublicKeyToken=ccf7d78a55e9f021" />
<ProjectReference type="Gac" localcopy="True" refto="atk-sharp, Version=2.6.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
</References>
</Project>

17
src/jscall.mds Normal file
Просмотреть файл

@ -0,0 +1,17 @@
<Combine name="jscall" fileversion="2.0">
<Configurations active="Debug">
<Configuration name="Debug" ctype="CombineConfiguration">
<Entry build="True" name="jscall" configuration="Debug" />
</Configuration>
<Configuration name="Release" ctype="CombineConfiguration">
<Entry build="True" name="jscall" configuration="Debug" />
</Configuration>
</Configurations>
<DeployTargets />
<StartMode startupentry="jscall" single="True">
<Execute type="None" entry="jscall" />
</StartMode>
<Entries>
<Entry filename="./jscall.mdp" />
</Entries>
</Combine>

Просмотреть файл

Просмотреть файл