Giter VIP home page Giter VIP logo

rust-mozjs's Introduction

rust-mozjs

Rust bindings to SpiderMonkey, now living in servo/mozjs.

rust-mozjs's People

Contributors

bors-servo avatar brson avatar cybai avatar eijebong avatar ejpbruel avatar emilio avatar fitzgen avatar frewsxcv avatar ilyoan avatar jdm avatar kmcallister avatar larsbergstrom avatar manishearth avatar marmistrz avatar mbrubeck avatar metajack avatar meteor-lsw avatar michaelwu avatar mmeyerho avatar mrowqa avatar ms2ger avatar nikomatsakis avatar nox avatar pcwalton avatar redfire75369 avatar sagudev avatar simonsapin avatar taki-jaro avatar vvuk avatar xanewok avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rust-mozjs's Issues

Make Handle objects take lifetimes

Handles are currently dangerous right now since they can outlive the Roots that they're taken from. We should make them take lifetimes to avoid that issue. This api is introduced in #150

How to use rust-mozjs on Windows?

I took a look at the examples/callback.rs and I would like to try using rust-mozjs, but I'm not sure how to. Any plans to create a crate?

I was under the impression that I need to build SpiderMonkey on my PC. On this PC, I'm running Windows 8.1 and I'm not that familiar with make or mozmake. Here is a recap of what I've done so far:

cd c:\rust
git clone https://github.com/mozilla/gecko-dev.git --depth 1

Downloaded MozillaBuild 2.0.0 and extracted to c:\rust\mozilla-build. I have Visual Studio 2015 installed, so I launched the build environment c:\rust\mozilla-build\start-shell-msvc2015-x64.bat. In it, I did:

cd /c/rust/gecko-dev
mkdir build_OPT.OBJ
cd build_OPT.OBJ
../configure --target=x86_64-pc-mingw32 --host=x86_64-pc-mingw32 --enable-nspr-build
mozmake

image

How do I get a list of mozmake targets? How do I get it to build?

Here is `../configure --help' output:

Usage: configure [options] [host]
Options: [defaults in brackets after descriptions]
Configuration:
  --cache-file=FILE       cache test results in FILE
  --help                  print this message
  --no-create             do not create output files
  --quiet, --silent       do not print `checking...' messages
  --version               print the version of autoconf that created configure
Directory and file names:
  --prefix=PREFIX         install architecture-independent files in PREFIX
                          [/usr/local]
  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
                          [same as prefix]
  --bindir=DIR            user executables in DIR [EPREFIX/bin]
  --sbindir=DIR           system admin executables in DIR [EPREFIX/sbin]
  --libexecdir=DIR        program executables in DIR [EPREFIX/libexec]
  --datadir=DIR           read-only architecture-independent data in DIR
                          [PREFIX/share]
  --sysconfdir=DIR        read-only single-machine data in DIR [PREFIX/etc]
  --sharedstatedir=DIR    modifiable architecture-independent data in DIR
                          [PREFIX/com]
  --localstatedir=DIR     modifiable single-machine data in DIR [PREFIX/var]
  --libdir=DIR            object code libraries in DIR [EPREFIX/lib]
  --includedir=DIR        C header files in DIR [PREFIX/include]
  --oldincludedir=DIR     C header files for non-gcc in DIR [/usr/include]
  --infodir=DIR           info documentation in DIR [PREFIX/info]
  --mandir=DIR            man documentation in DIR [PREFIX/man]
  --srcdir=DIR            find the sources in DIR [configure dir or ..]
  --program-prefix=PREFIX prepend PREFIX to installed program names
  --program-suffix=SUFFIX append SUFFIX to installed program names
  --program-transform-name=PROGRAM
                          run sed PROGRAM on installed program names
Host type:
  --build=BUILD           configure for building on BUILD [BUILD=HOST]
  --host=HOST             configure for HOST [guessed]
  --target=TARGET         configure for TARGET [TARGET=HOST]
Features and packages:
  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
  --x-includes=DIR        X include files are in DIR
  --x-libraries=DIR       X library files are in DIR
--enable and --with options recognized:
  --enable-release        Build with more conservative, release engineering-oriented options.
                          This may slow down builds.
  --disable-compile-environment
                          Disable compiler/library checks.
  --with-l10n-base=DIR    path to l10n repositories
  --with-gonk=DIR
               location of gonk dir
  --with-gonk-toolchain-prefix=DIR
                          prefix to gonk toolchain commands
  --with-android-ndk=DIR
                          location where the Android NDK can be found
  --with-android-toolchain=DIR
                          location of the android toolchain
  --with-android-gnu-compiler-version=VER
                          gnu compiler version to use
  --enable-android-libstdcxx
                          use GNU libstdc++ instead of STLPort
  --with-android-version=VER
                          android platform version, default 9
  --with-ios-sdk=TYPE
                          Type of iOS SDK to use (iphonesimulator, iphoneos)
                          and optionally version (like iphoneos8.2)
  --enable-ios-target=VER (default=8.0)
                          Set the minimum iOS version needed at runtime
  --with-compiler-wrapper[=path/to/wrapper]
    Enable compiling with wrappers such as distcc and ccache
  --with-ccache[=path/to/ccache]
                          Enable compiling with ccache
  --enable-rust           Include rust language sources
  --enable-macos-target=VER (default=10.6)
                          Set the minimum MacOS version needed at runtime
  --with-windows-version=WINSDK_TARGETVER
                          Windows SDK version to target. Win8.1 (603) is
                          currently the minimum supported version.
  --with-unify-dist=dir   Location of the dist directory to unify with at packaging time (Mac OS X universal build only)
  --with-macos-sdk=dir    Location of platform SDK to use (Mac OS X only)
  --with-macos-private-frameworks=dir    Location of private frameworks to use (Mac OS X only)
  --with-x                use the X Window System
  --with-arch=[[type|toolchain-default]]
                           Use specific CPU features (-march=type). Resets
                           thumb, fpu, float-abi, etc. defaults when set
  --with-thumb[[=yes|no|toolchain-default]]
                          Use Thumb instruction set (-mthumb)
  --with-thumb-interwork[[=yes|no|toolchain-default]]
                           Use Thumb/ARM instuctions interwork (-mthumb-interwork)
  --with-fpu=[[type|toolchain-default]]
                           Use specific FPU type (-mfpu=type)
  --with-float-abi=[[type|toolchain-default]]
                           Use specific arm float ABI (-mfloat-abi=type)
  --with-soft-float[[=yes|no|toolchain-default]]
                           Use soft float library (-msoft-float)
  --enable-address-sanitizer       Enable Address Sanitizer (default=no)
  --enable-memory-sanitizer       Enable Memory Sanitizer (default=no)
  --enable-thread-sanitizer       Enable Thread Sanitizer (default=no)
  --enable-llvm-hacks       Enable workarounds required for several LLVM instrumentations (default=no)
  --enable-warnings-as-errors
                          Enable treating warnings as errors
  --enable-profiling      Set compile flags necessary for using sampling profilers (e.g. shark, perf)
  --enable-systrace       Set compile flags necessary for using sampling profilers (e.g. shark, perf)
  --enable-valgrind       Enable Valgrind integration hooks (default=no)
  --enable-jprof          Enable jprof profiling tool (needs mozilla/tools/jprof). Implies --enable-profiling.
  --enable-shark          Enable shark remote profiling. Implies --enable-profiling.
  --enable-instruments    Enable instruments remote profiling. Implies --enable-profiling.
  --enable-callgrind      Enable callgrind profiling. Implies --enable-profiling.
  --enable-vtune          Enable vtune profiling. Implies --enable-profiling.
  --enable-debug[=DBG]    Enable building with developer debug info
                           (using compiler flags DBG)
  --with-debug-label=LABELS
                          Define DEBUG_<value> for each comma-separated
                          value given.
  --enable-debug-symbols[=DBG]
                          Enable debugging symbols (using compiler flags DBG)
  --enable-cpp-rtti       Enable C++ RTTI 
  --enable-gold           Enable GNU Gold Linker when it is not already the default
  --disable-icf          Disable Identical Code Folding
  --enable-pie           Enable Position Independent Executables
  --enable-dtrace         build with dtrace support if available (default=no)
  --with-linux-headers=DIR
                          location where the Linux kernel headers can be found
  --with-pthreads         Force use of system pthread library with NSPR 
  --with-libxul-sdk=PFX   Use the libXUL SDK at <PFX>
  --with-nspr-cflags=FLAGS
                          Pass FLAGS to CC when building code that uses NSPR.
                          Use this when there's no accurate nspr-config
                          script available.  This is the case when building
                          SpiderMonkey as part of the Mozilla tree: the
                          top-level configure script computes NSPR flags
                          that accomodate the quirks of that environment.
  --with-nspr-libs=LIBS   Pass LIBS to LD when linking code that uses NSPR.
                          See --with-nspr-cflags for more details.
  --enable-nspr-build     Configure and build NSPR from source tree
  --with-system-nspr      Use an NSPR that is already built and installed.
                          Use the 'nspr-config' script in the current path,
                          or look for the script in the directories given with
                          --with-nspr-exec-prefix or --with-nspr-prefix.
                          (Those flags are only checked if you specify
                          --with-system-nspr.)
  --enable-posix-nspr-emulation
                          Enable emulation of NSPR for POSIX systems
  --with-nspr-prefix=PFX  Prefix where NSPR is installed
  --with-nspr-exec-prefix=PFX
                          Exec prefix where NSPR is installed
  --with-system-libevent[=PFX]
                          Use system libevent [installed at prefix PFX]
  --with-system-nss       Use system installed NSS
  --with-nss-prefix=PFX   Prefix where NSS is installed
  --with-nss-exec-prefix=PFX
                          Exec prefix where NSS is installed
  --with-system-jpeg[=PFX]
                          Use system libjpeg [installed at prefix PFX]
  --with-system-zlib[=PFX]
                          Use system libz [installed at prefix PFX]
  --with-system-bz2[=PFX]
                          Use system libbz2 [installed at prefix PFX]
  --with-system-png[=PFX]
                          Use system libpng [installed at prefix PFX]
  --enable-png-arm-neon-support=TYPE
             Options include:
                 no
                 check (default)
                 nocheck (faster but unsafe)
  --enable-system-hunspell
                          Use system hunspell (located with pkgconfig)
  --enable-system-ffi       Use system libffi (located with pkgconfig)
  --enable-shared-js
                          Create a shared JavaScript library.
  --with-java-bin-path=dir
                          Location of Java binaries (java, javac, jar)
  --with-external-source-dir=dir
                          External directory containing additional build files.
  --enable-application=APP
                          Options include:
                            browser (Firefox)
                            xulrunner
                            tools/update-packaging (AUS-related packaging tools)
  --with-xulrunner-stub-name=appname   Create the xulrunner stub with the given name
  --enable-update-channel=CHANNEL
                          Select application update channel (default=default)
  --with-mozilla-api-keyfile=file   Use the secret key contained in the given keyfile for Mozilla API requests
  --with-google-api-keyfile=file   Use the secret key contained in the given keyfile for Google API requests
 --with-google-oauth-api-keyfile=file  Use the client id and secret key contained in the given keyfile for Google OAuth API requests
  --with-bing-api-keyfile=file   Use the client id and secret key contained in the given keyfile for Bing API requests
  --with-adjust-sdk-keyfile=file   Use the app token contained in the given keyfile for Adjust SDK requests
  --disable-android-include-fonts
                          Disable the inclusion of fonts into the final APK
  --enable-android-resource-constrained
                          Exclude hi-res images and similar from the final APK
  --enable-official-branding
                          Enable Official mozilla.org Branding
                          Do not distribute builds with
                          --enable-official-branding unless you have
                          permission to use trademarks per
                          http://www.mozilla.org/foundation/trademarks/ .
--with-app-name=APPNAME sets MOZ_APP_NAME to APPNAME
--with-app-basename=BASENAME sets MOZ_APP_BASENAME to BASENAME
  --with-android-sdk=DIR
                          location where the Android SDK can be found (base directory, e.g. .../android/platforms/android-6)
  --with-android-min-sdk=[VER]     Impose a minimum Firefox for Android SDK version
  --with-android-max-sdk=[VER]     Impose a maximum Firefox for Android SDK version
  --enable-default-toolkit=TK
                          Select default toolkit
                          Platform specific defaults:
                            Mac OS X - cairo-cocoa
                            Win32 - cairo-windows
                            * - cairo-gtk2
                            * - cairo-gtk3
                            * - cairo-qt
  --without-x              Build without X11
  --with-arm-kuser         Use kuser helpers (Linux/ARM only -- requires kernel 2.6.13 or later)
  --enable-startup-notification
                          Enable startup-notification support (default: disabled) 
  --disable-printing      Disable printing support
  --with-qtdir=$dir       Specify Qt directory 
  --enable-ui-locale=ab-CD
                          Select the user interface locale (default: en-US)
  --with-branding=dir     Use branding from the specified directory.
  --with-distribution-id=ID
                          Set distribution-specific id (default=org.mozilla)
  --disable-gio           Disable GIO support
  --disable-gconf      Disable Gconf support 
  --enable-libproxy         Enable libproxy support 
  --enable-gnomeui        Enable libgnomeui instead of GIO & GTK for icon theme support 
  --disable-dbus          Disable dbus support 
  --enable-android-apz      Switch to C++ pan/zoom code
  --disable-websms-backend
                           Disable WebSMS backend
  --enable-ipdl-tests     Enable expensive IPDL tests
  --disable-dbm           Disable building dbm
  --disable-accessibility Disable accessibility support
  --disable-webrtc        Disable support for WebRTC
  --enable-hardware-aec-ns   Enable support for hardware AEC and noise suppression
  --disable-webspeech        Disable support for HTML Speech API
  --disable-webspeechtestbackend        Disable support for HTML Speech API Test Backend
  --enable-raw           Enable support for RAW media
  --disable-webm          Disable support for WebM media (VP8 video and Vorbis audio)
  --disable-directshow  Disable support for DirectShow
  --disable-wmf  Disable support for Windows Media Foundation
  --disable-ffmpeg         Disable FFmpeg for fragmented H264/AAC decoding
  --disable-fmp4  Disable support for in built Fragmented MP4 parsing
  --enable-eme[=adobe]  Enable support for Encrypted Media Extensions  
  --enable-android-omx  Enable support for Android OMX media backend
  --enable-media-navigator  Enable support for getUserMedia
  --enable-omx-plugin      Enable building OMX plugin (B2G)
  --with-system-libvpx    Use system libvpx (located with pkgconfig)
  --disable-wave          Disable Wave decoder support
  --enable-alsa          Enable Alsa support (default on Linux)
  --disable-pulseaudio          Disable PulseAudio support
  --enable-gstreamer[=0.10]           Enable GStreamer support
  --disable-permissions   Disable permissions (popup and cookie blocking)
  --disable-negotiateauth Disable GSS-API negotiation 
  --disable-pref-extensions
                          Disable pref extensions such as autoconfig
  --disable-system-extension-dirs
                          Disable searching system- and account-global
                          directories for extensions of any kind; use
                          only profile-specific extension directories
  --disable-universalchardet
                          Disable universal encoding detection
  --enable-require-all-d3dc-versions Require all versions of the D3D compiler needed for supported Windows systems.
  --disable-gamepad   Disable gamepad support
  --disable-crashreporter Disable breakpad crash reporting
  --with-crashreporter-enable-percent=NN
                          Enable sending crash reports by default on NN% of users. (default=100)
 --disable-libjpeg-turbo  Disable optimized jpeg decoding routines
  --enable-extensions     Enable extensions
  --enable-tree-freetype  Enable Tree FreeType
  --disable-webapp-runtime  Disable Web App Runtime
  --enable-maintenance-service       Enable building of maintenanceservice
  --enable-bundled-fonts  Enable support for bundled fonts on desktop platforms
  --enable-verify-mar     Enable verifying MAR signatures
  --enable-signmar     Enable building the signmar program
  --disable-updater       Disable building of updater
  --enable-update-packaging
                          Enable tools/update-packaging
  --disable-tests         Do not build test libraries & programs
  --disable-parental-controls
                          Do not build parental controls
  --disable-sandbox        Disable sandboxing support
  --enable-content-sandbox Enable sandboxing support for content-processes
  --disable-content-sandbox Disable sandboxing support for content-processes
  --disable-feeds         Disable feed handling and processing components
  --enable-system-sqlite  Use system sqlite (located with pkgconfig)
  --enable-safe-browsing  Enable safe browsing (anti-phishing) implementation
  --enable-url-classifier Enable url classifier module
  --disable-zipwriter     Disable zipwriter component
  --with-gl-provider=ID
                          Set GL provider backend type
  --enable-faststripe     Use faststripe theme
  --enable-mobile-optimize
                          Enable mobile optimizations
  --disable-optimize      Disable compiler optimization
  --enable-optimize=[OPT] Specify compiler optimization flags [OPT=-O]
  --disable-logging       Disable logging facilities
  --enable-logrefcnt      Enable logging of refcounts (default=debug) 
 --enable-approximate-location    Enable approximate location 
 --enable-gps-debug    Enable gps specific debug messages 
  --enable-dump-painting          Enable paint debugging.
  --enable-dmd            Enable DMD; also enables jemalloc and replace-malloc
  --enable-jemalloc       Replace memory allocator with jemalloc
  --enable-replace-malloc   Enable ability to dynamically replace the malloc implementation
  --with-static-checking=path/to/gcc_dehydra.so
                          Enable static checking of code using GCC-dehydra
  --enable-clang-plugin   Enable building with the mozilla clang plugin 
  --enable-strip          Enable stripping of libs & executables 
  --enable-install-strip  Enable stripping of libs & executables when packaging 
  --disable-elf-hack      Disable elf hacks
  --enable-stdcxx-compat  Enable compatibility with older libstdc++
  --enable-tasktracer       Set compile flags necessary for using TaskTracer
  --enable-reflow-perf    Enable reflow performance tracing
  --disable-startupcache          Disable startup cache 
  --enable-b2g-ril      Set compile flags necessary for testing B2G Radio Interface Layer via network sockets 
  --enable-b2g-bt      Set compile flags necessary for compiling Bluetooth API for B2G 
  --enable-nfc         Set compile flags necessary for compiling NFC API 
  --enable-synth-pico  Set compile flags necessary for compiling Pico Web Speech API 
  --enable-b2g-camera      Set compile flags necessary for compiling camera API for B2G 
  --jitreport-granularity=N
                           Default granularity at which to report JIT code
                           to external tools
                             0 - no info
                             1 - code ranges for whole functions only
                             2 - per-line information
                             3 - per-op information
  --disable-mozril-geoloc         Disable Mozilla's RIL and geolocation
  --enable-xterm-updates  Update XTERM titles with current command.
  --enable-chrome-format=jar|flat|omni
                          Select FORMAT of chrome files during packaging
  --with-default-mozilla-five-home
                          Set the default value for MOZILLA_FIVE_HOME
  --with-user-appdir=DIR  Set user-specific appdir (default=.mozilla)
  --with-doc-input-dirs=DIRS
                          Header/idl dirs to create docs from
  --with-doc-include-dirs=DIRS
                          Include dirs to preprocess doc headers
  --with-doc-output-dir=DIR
                          Dir to generate docs into
  --enable-skia   Enable use of Skia
  --disable-skia-gpu  Disable use of Skia-GPU
  --enable-system-cairo   Use system cairo (located with pkgconfig)
 --enable-system-pixman Use system pixman (located with pkgconfig)
  --disable-xul           Disable XUL
  --disable-profilelocking
                          Disable profile locking
  --enable-necko-protocols[={http,ftp,default,all,none}]
                          Enable/disable specific protocol handlers
  --disable-necko-wifi    Disable necko wifi scanner
  --disable-cookies       Disable cookie support
  --disable-ctypes        Disable js-ctypes
  --with-macbundlename-prefix=prefix
                          Prefix for MOZ_MACBUNDLE_NAME
  --with-system-icu
                          Use system ICU (located with pkgconfig)
  --with-intl-api, --with-intl-api=build, --without-intl-api
    Determine the status of the ECMAScript Internationalization API.  The first
    (or lack of any of these) builds and exposes the API.  The second builds it
    but doesn't use ICU or expose the API to script.  The third doesn't build
    ICU at all.

Here is mozmake --help output:

Usage: mozmake [options] [target] ...
Options:
  -b, -m                      Ignored for compatibility.
  -B, --always-make           Unconditionally make all targets.
  -C DIRECTORY, --directory=DIRECTORY
                              Change to DIRECTORY before doing anything.
  -d                          Print lots of debugging information.
  --debug[=FLAGS]             Print various types of debugging information.
  -e, --environment-overrides
                              Environment variables override makefiles.
  --eval=STRING               Evaluate STRING as a makefile statement.
  -f FILE, --file=FILE, --makefile=FILE
                              Read FILE as a makefile.
  -h, --help                  Print this message and exit.
  -i, --ignore-errors         Ignore errors from recipes.
  -I DIRECTORY, --include-dir=DIRECTORY
                              Search DIRECTORY for included makefiles.
  -j [N], --jobs[=N]          Allow N jobs at once; infinite jobs with no arg.
  -k, --keep-going            Keep going when some targets can't be made.
  -l [N], --load-average[=N], --max-load[=N]
                              Don't start multiple jobs unless load is below N.
  -L, --check-symlink-times   Use the latest mtime between symlinks and target.
  -n, --just-print, --dry-run, --recon
                              Don't actually run any recipe; just print them.
  -o FILE, --old-file=FILE, --assume-old=FILE
                              Consider FILE to be very old and don't remake it.
  -O[TYPE], --output-sync[=TYPE]
                              Synchronize output of parallel jobs by TYPE.
  -p, --print-data-base       Print make's internal database.
  -q, --question              Run no recipe; exit status says if up to date.
  -r, --no-builtin-rules      Disable the built-in implicit rules.
  -R, --no-builtin-variables  Disable the built-in variable settings.
  -s, --silent, --quiet       Don't echo recipes.
  -S, --no-keep-going, --stop
                              Turns off -k.
  -t, --touch                 Touch targets instead of remaking them.
  --trace                     Print tracing information.
  -v, --version               Print the version number of make and exit.
  -w, --print-directory       Print the current directory.
  --no-print-directory        Turn off -w, even if it was turned on implicitly.
  -W FILE, --what-if=FILE, --new-file=FILE, --assume-new=FILE
                              Consider FILE to be infinitely new.
  --warn-undefined-variables  Warn when an undefined variable is referenced.

This program built for Windows32
Report bugs to <[email protected]>

Fix type of FunctionClassPtr and ObjectClassPtr

From #198

* jdm is curious why FunctionClassPtr is a Class, while Int8ArrayClassPtr is a *const Class
 <mwu> jdm: looks like a bug. I think they should all be *const Class
<mwu> though.. this code is pretty clever, so I dunno
<mwu> probably a bug.

This is a bug in bindgen++.

Introduce something like CallArgs

Using barebones argv and argc is dangerous and annoying. We should add something like get CallArgsFromVp and have the CallArgs class be typesafe and fail on out of bounds access etc.

context private data not used

When compartments are created, they set_cx_private to stuff themsevles in the context. However, servo immediately stuff the page in there, so this leaks the context.

We should probably not use cx_private in rust-mozjs.

Need access to JSITER constants

I'm working on servo/servo#7254 and am utilizing this function. I need access to the constants below for the flags parameter:

http://mxr.mozilla.org/mozilla-central/source/js/src/jsfriendapi.h#945

#define JSITER_ENUMERATE  0x1   /* for-in compatible hidden default iterator */
#define JSITER_FOREACH    0x2   /* get obj[key] for each property */
#define JSITER_KEYVALUE   0x4   /* obsolete destructuring for-in wants [key, value] */
#define JSITER_OWNONLY    0x8   /* iterate over obj's own properties only */
#define JSITER_HIDDEN     0x10  /* also enumerate non-enumerable properties */
#define JSITER_SYMBOLS    0x20  /* also include symbol property keys */
#define JSITER_SYMBOLSONLY 0x40 /* exclude string property keys */

I'm not too familiar with the inner workings of this repo. How would one go about adding these?

Conversion to vector should throw a TypeError

Code is in src/conversions.rs, in impl<C: Clone, T: FromJSValConvertible<Config=C>> FromJSValConvertible for Vec<T> {.

Use throw_type_error() for the case where is_object() is false. The error should be something along the lines of "value is not an object".

Create a sample applications

As there is not yet any kind of documentation on how to use the rust-mozjs binding of the jsapi. It would be cool to have something that mimmick the sample jsapi helloworld app from mozilla. (By documentation I mean user guide and not just reference documentation).

As some things are a bit different, I wasn't able to build an application that works like the minimal application here:

https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/JSAPI_User_Guide

Unable to build on OSX 10.10 (Yosemite)

~/D/rust-mozjs (master|…) $ cargo build --verbose
   Compiling mozjs-sys v0.0.0 (https://github.com/servo/mozjs#47cd6a4e)
     Running make -f makefile.cargo
Failed to run custom build command for `mozjs-sys v0.0.0 (https://github.com/servo/mozjs#47cd6a4e)`
Process didn't exit successfully: `make -f makefile.cargo` (status=2)
--- stdout
cd /Users/coreyf/Downloads/rust-mozjs/target/native/mozjs-sys-c58a7d09513f4944 && /Users/coreyf/.cargo/git/checkouts/mozjs-2284529523a8d467/master/js/src/configure --enable-gczeal
creating cache ./config.cache
checking host system type... x86_64-apple-darwin14.0.0
checking target system type... x86_64-apple-darwin14.0.0
checking build system type... x86_64-apple-darwin14.0.0
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking for gcc-4.2... /usr/local/bin/gcc-4.2
checking for g++-4.2... /usr/local/bin/g++-4.2
checking for perl5... no
checking for perl... /usr/bin/perl
checking for gcc... /usr/local/bin/gcc-4.2
checking whether the C compiler (/usr/local/bin/gcc-4.2  ) works... yes
checking whether the C compiler (/usr/local/bin/gcc-4.2  ) is a cross-compiler... no
checking whether we are using GNU C... yes
checking whether /usr/local/bin/gcc-4.2 accepts -g... no
checking for c++... /usr/local/bin/g++-4.2
checking whether the C++ compiler (/usr/local/bin/g++-4.2  ) works... yes
checking whether the C++ compiler (/usr/local/bin/g++-4.2  ) is a cross-compiler... no
checking whether we are using GNU C++... yes
checking whether /usr/local/bin/g++-4.2 accepts -g... no
checking for ranlib... ranlib
checking for as... /usr/bin/as
checking for ar... ar
checking for ld... ld
checking for strip... strip
checking for windres... no
checking how to run the C preprocessor... /lib/cpp
checking how to run the C++ preprocessor... /lib/cpp
checking for sb-conf... no
checking for ve... no
checking for a BSD compatible install... /usr/local/bin/ginstall -c
checking whether ln -s works... yes
checking for minimum required perl version >= 5.006... 5.018002
checking for full perl installation... yes
checking for python2.7... /usr/local/bin/python2.7
checking for doxygen... :
checking for autoconf... /usr/local/bin/autoconf
checking for makedepend... /usr/local/bin/makedepend
checking for xargs... /usr/bin/xargs
checking for pbbuild... no
checking for xcodebuild... /usr/bin/xcodebuild
checking for sdp... /usr/bin/sdp
checking for gmake... no
checking for make... /usr/bin/make
checking for X... no
checking that static assertion macros used in autoconf tests work... yes
checking whether the C compiler supports -Werror=return-type... yes
checking whether the C compiler supports -Wtype-limits... no
checking whether the C compiler supports -Wempty-body... yes
checking whether the C compiler supports -Wno-overlength-strings... yes
checking whether the C compiler supports -Wno-variadic-macros... yes
checking whether the C++ compiler supports -Werror=return-type... yes
checking whether the C++ compiler supports -Wtype-limits... no
checking whether the C++ compiler supports -Wempty-body... yes
checking whether the C++ compiler supports -Wno-unused-local-typedefs... no
checking whether the C++ compiler supports -Wno-overlength-strings... yes
checking whether the C++ compiler supports -Wno-invalid-offsetof... yes
checking whether the C++ compiler supports -Wno-variadic-macros... yes
checking whether the C++ compiler supports -Wno-unused-but-set-variable... no
checking whether the C++ compiler supports -Wno-unused-variable... yes
checking whether the C++ compiler supports -Wno-uninitialized... no
checking whether the C++ compiler supports -Wno-undefined-inline... no
checking whether the C++ compiler supports -Wno-parentheses-equality... no
checking whether the C++ compiler supports -Wno-unused-function... yes
checking whether the C++ compiler supports -Wno-null-conversion... no
checking whether the C++ compiler supports -Wno-unused-private-field... no
checking whether ld has archive extraction flags... no
checking for 64-bit OS... yes
checking for Python version >= 2.5 but not 3.x... yes
checking for custom <stdint.h> implementation... none specified
checking for -framework ExceptionHandling... yes
checking for -dead_strip option to ld... yes
checking for ANSI C header files... no
checking for working const... yes
checking for mode_t... no
checking for off_t... no
checking for pid_t... no
checking for size_t... no
checking for __stdcall... no
checking for ssize_t... no
checking for st_blksize in struct stat... no
checking for siginfo_t... no
checking for the size of void*... 8
checking for the alignment of void*...
--- stderr
couldn't understand kern.osversion `14.0.0'
configure: error: No alignment found for void*
make: *** [all] Error 1

~/D/rust-mozjs (master|…) $

And here's some version information

~/D/rust-mozjs (master|…) $ rustc --version
rustc 0.12.0-nightly (060623488 2014-10-08 01:02:10 +0000)
~/D/rust-mozjs (master|…) $ gcc --version
Configured with: --prefix=/Applications/Xcode-Beta.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.0 (clang-600.0.53) (based on LLVM 3.5svn)
Target: x86_64-apple-darwin14.0.0
Thread model: posix
~/D/rust-mozjs (master|…)

I originally encountered this when trying to build servo

Kill trace.rs

We don't need it anymore, Servo uses JSTraceable directly now.

(Waiting for the SM upgrade so as not to worsen rebase issues)

Make Handle fields private

It's too easy for inexperienced JSAPI users to turn to manual Handle creation. We should hide the fields and add an unsafe from_rooted_location static method instead, so it's clearer what invariants must be upheld.

Error E0277 on nightly

error: the trait core::clone::Clone is not implemented for the type unsafe extern "C" fn(*mut jsapi::JSContext, jsapi::Handle<*mut jsapi::JSObject>, jsapi::Handle<jsapi::jsid>, jsapi::Handle<jsapi::Value>, core::option::Option<unsafe extern "C" fn(*mut jsapi::JSContext, jsapi::Handle<*mut jsapi::JSObject>, jsapi::Handle<jsapi::jsid>, jsapi::MutableHandle<jsapi::Value>) -> u8>, core::option::Option<unsafe extern "C" fn(*mut jsapi::JSContext, jsapi::Handle<*mut jsapi::JSObject>, jsapi::Handle<jsapi::jsid>, jsapi::MutableHandle<jsapi::Value>, *mut jsapi::ObjectOpResult) -> u8>, u32, *mut jsapi::ObjectOpResult) -> u8 [E0277]
/home/llacroix/.cargo/git/checkouts/rust-mozjs-ebb4917e843c0a11/master/src/jsapi.rs:980 pub defineProperty: DefinePropertyOp,
/home/llacroix/.cargo/git/checkouts/rust-mozjs-ebb4917e843c0a11/master/src/jsapi.rs:977:16: 977:21 note: in this expansion of #[derive_Clone](defined in /home/llacroix/.cargo/git/checkouts/rust-mozjs-ebb4917e843c0a11/master/src/jsapi.rs)

I'm on nightly from 17/09/2015

Intermittent crash when testing

Today the test build got a segfault on travis on #245 (see: https://travis-ci.org/servo/rust-mozjs/builds/114398074).

I was able to reproduce it intermittently. Here's the backtrace:

$ gdb ./target/debug/js-817a35fac43d5b89
Thread 10 "Analysis Helper" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffff6ae2700 (LWP 13337)]
0x00007ffff7432400 in __lll_unlock_elision () from /usr/lib/libpthread.so.0
(gdb) bt full
#0  0x00007ffff7432400 in __lll_unlock_elision () from /usr/lib/libpthread.so.0
No symbol table info available.
#1  0x00007ffff742cfb7 in pthread_cond_wait@@GLIBC_2.3.2 () from /usr/lib/libpthread.so.0
No symbol table info available.
#2  0x000055555576f379 in PR_WaitCondVar (cvar=0x7ffff4e0d040, 
    timeout=timeout@entry=4294967295)
    at /home/emilio/.multirust/toolchains/nightly/cargo/git/checkouts/mozjs-06d7f04b6dbb8a8e/master/mozjs/js/src/vm/PosixNSPR.cpp:286
No locals.
#3  0x000055555571e569 in js::GlobalHelperThreadState::wait (millis=0, 
    which=js::GlobalHelperThreadState::PRODUCER, this=<optimized out>)
    at /home/emilio/.multirust/toolchains/nightly/cargo/git/checkouts/mozjs-06d7f04b6dbb8a8e/master/mozjs/js/src/vm/HelperThreads.cpp:551
No locals.
#4  js::HelperThread::threadLoop (this=0x7ffff4e37100)
    at /home/emilio/.multirust/toolchains/nightly/cargo/git/checkouts/mozjs-06d7f04b6dbb8a8e/master/mozjs/js/src/vm/HelperThreads.cpp:1399
        ionCompile = false
        stackLimit = <optimized out>
#5  0x000055555576b029 in nspr::Thread::ThreadRoutine (arg=0x7ffff4e0c080)
    at /home/emilio/.multirust/toolchains/nightly/cargo/git/checkouts/mozjs-06d7f04b6dbb8a8e/master/mozjs/js/src/vm/PosixNSPR.cpp:45
        self = 0x7ffff4e0c080
#6  0x00007ffff7427424 in start_thread () from /usr/lib/libpthread.so.0
No symbol table info available.
#7  0x00007ffff6f50cbd in clone () from /usr/lib/libc.so.6

Running a single test at a time I don't seem able to reproduce the issue, maybe a race condition due to multiple runtimes started simultaneously?

Builds fail on Win64 MSVC ABI

I've tried twice on 2 different computers but it seems rust-mozjs fails when building on with the MSVC rust compiler. (I've built it with Debian x64 w/ Stable)

Does not compile on rust-nightly

The :s format trait has been removed from rust 0.13.

That results in the following error:

/home/mediremi/.cargo/git/checkouts/rust-mozjs-ab9bfe6e592bc16c/master/src/rust.rs:127:63: 127:71 error: unknown format trait `s`
/home/mediremi/.cargo/git/checkouts/rust-mozjs-ab9bfe6e592bc16c/master/src/rust.rs:127         debug!("Evaluating script from {:s} with content {}", filename, script);
                                                                                                                                                     ^~~~~~~~
/home/mediremi/.cargo/git/checkouts/rust-mozjs-ab9bfe6e592bc16c/master/src/rust.rs:157:40: 157:45 error: unknown format trait `s`
/home/mediremi/.cargo/git/checkouts/rust-mozjs-ab9bfe6e592bc16c/master/src/rust.rs:157     error!("Error at {:s}:{}: {:s}\n", fname, lineno, msg);
                                                                                                                              ^~~~~
/home/mediremi/.cargo/git/checkouts/rust-mozjs-ab9bfe6e592bc16c/master/src/rust.rs:157:55: 157:58 error: unknown format trait `s`
/home/mediremi/.cargo/git/checkouts/rust-mozjs-ab9bfe6e592bc16c/master/src/rust.rs:157     error!("Error at {:s}:{}: {:s}\n", fname, lineno, msg);
                                                                                                                                             ^~~
error: aborting due to 3 previous errors
Could not compile `js`.

Errors are not being reported

Out of the box, the registered error reporting function is not being called for me. I've narrowed it down to these two lines in Runtime::new():

            (*contextopts).set_dontReportUncaught_(true);
            (*contextopts).set_autoJSAPIOwnsErrorReporting_(true);

Unless both of these options are set to false, the error reporting function doesn't get called on error.

Implement AutoCheckCannotGC

#150 doesn't implement AutoCheckCannotGC. bindgen++ should add support for C++ references so we can enforce the use of AutoCheckCannotGC, and then we should implement AutoCheckCannotGC.

Remove old feature raw_pointer_derive

src/lib.rs:14:89: 14:107 warning: lint raw_pointer_derive has been removed: using derive with raw pointers is ok
src/lib.rs:14 #![allow(non_upper_case_globals, non_camel_case_types, non_snake_case, improper_ctypes, raw_pointer_derive)]
                                                                                                      ^~~~~~~~~~~~~~~~~~

Generate bindings per platform

Right now, there's a number of demangling functions which don't work since the mangled names contain types which are different between OSX/Linux or 32bit/64bit. Generating the bindings separately per platform will avoid this issue. This causes issues with the CEF port since the OSX linker wants all symbols to be defined.

CC @zmike

Consider having Runtime::new enter a request

#258 (comment)

AFAICT, there's no need to ever enter more than one request - or leave that request. We don't call js::SetActivityCallback, and I'm pretty sure that's the only thing triggered by rt->requestDepth being set to or changed from 0.

If that's true, we wouldn't have to deal with requests in any code downstream of this crate (which would make me very happy!).

Rewrite FromJSValConvertible to better support unions

There are three cases to consider when converting a JS value to a Rust value:

  1. Successful conversion
  2. Impossible to convert the value
  3. Exception is thrown from within the JS engine somewhere.

An example of case 3 happens when converting { get [Symbol.iterator]() { throw 7; } } to a sequence type.

Right now, the signature is

unsafe fn from_jsval(cx: *mut JSContext,
                     val: HandleValue,
                     option: Self::Config)
                     -> Result<Self, ()>

and we use throw_type_error to set a pending exception in the second case.

That implies it is impossible for callers to detect whether case 2 or 3 occurred. This is fine for most cases, but unions need to be able to make that distinction (and not set a pending exception for the second case).

Possible solutions

Just what I could come up with right now; feel free to propose other options.

Each section shows any enums used in the proposal, followed by the common conversion case and the union case.

Result<Self, Error>

enum Error {
    Case2(String),
    Case3
}

match T::from_jsval() {
    Ok(x) => x,
    Err(Case2(error)) => {
        throw_type_error(error);
        return Err(());
    }
    Err(Case3) => return Err(()),
}


match T::from_jsval() {
    Ok(x) => return Ok(Union::T(x)),
    Err(Case2(error)) => (),
    Err(Case3) => return Err(()),
}

Result<Result<Self, String>, ()>

match try!(T::from_jsval()) {
    Ok(x) => x,
    Err(error) => {
        throw_type_error(error);
        return Err(());
    }
}

match try!(T::from_jsval()) {
    Ok(x) => return Ok(Union::T(x)),
    Err(error) => ()
}

Result<ConversionResult<Self>, ()>

enum ConversionResult<T> {
    Success(T),
    Failure(String),
}

match try!(T::from_jsval()) {
    ConversionResult::Success(x) => x,
    ConversionResult::Failure(error) => {
        throw_type_error(error);
        return Err(());
    }
}

match try!(T::from_jsval()) {
    ConversionResult::Success(x) => return Ok(Union::T(x)),
    ConversionResult::Failure(error) => ()
}

ConversionResult<Self>

enum ConversionResult<T> {
    Case1(T),
    Case2(String),
    Case3
}

match T::from_jsval() {
    Case1(x) => x,
    Case2(error) => {
        throw_type_error(error);
        return Err(());
    }
    Case3 => return Err(()),
}

match T::from_jsval() {
    Case1(x) => return Ok(Union::T(x)),
    Case2(error) => (),
    Case3 => return Err(()),
}

CC @nox @GuillaumeGomez

Tests do not compile due to unresolved reference '__test' module

rustc no longer exposes the test runner entry point under '__test' and uses some autogenerated name.

src/lib.rs:139:50: 139:62 error: failed to resolve. Use of undeclared module `__test`
src/lib.rs:139     green::start(argc, argv, rustuv::event_loop, __test::main)
                                                                ^~~~~~~~~~~~
src/lib.rs:139:50: 139:62 error: unresolved name `__test::main`.
src/lib.rs:139     green::start(argc, argv, rustuv::event_loop, __test::main)

The attribute "reexport_test_harness_main" allows us to specify the name explicity and can be used instead.

Add high level jsval interface

Something along the lines of

impl JSVal {
  fn to_object() {...}
  fn to_int {...}
  ...
}

I'm tired of importing those RUST_JSVAL_TO_FOO functions everywhere in servo.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.