Module js_driver

This module manages all of the low-level details surrounding the linked-in driver.

Copyright © 2009-2010 Basho Technologies Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Authors: Kevin Smith (ksmith@basho.com).

Description

This module manages all of the low-level details surrounding the linked-in driver. It is reponsible for loading and unloading the driver as needed. This module is also reponsible for creating and destroying instances of Javascript VMs.

Data Types

init_fun()

init_fun() = function(port())

Function Index

define_js/2Define a Javascript expression: js_driver:define(Port, <<"var x = 100;">>).
define_js/4Define a Javascript expression: js_driver:define(Port, <<var blah = new Wubba();">>).
destroy/1Destroys a Javascript VM instance.
eval_js/2Evaluate a Javascript expression and return the result.
load_driver/0Attempt to load the Javascript driver.
new/0Create a new Javascript VM instance and preload Douglas Crockford's json2 converter (http://www.json.org/js.html).
new/2Create a new Javascript VM instance and preload Douglas Crockford's json2 converter (http://www.json.org/js.html).
new/3Create a new Javascript VM instance.
shutdown/1Destroys a Javascript VM instance and shuts down the underlying Javascript infrastructure.

Function Details

define_js/2

define_js(Ctx::port(), Js::binary()) -> ok | {error, any()}

Define a Javascript expression: js_driver:define(Port, <<"var x = 100;">>).

define_js/4

define_js(Ctx::port(), FileName::binary(), Js::binary(), Timeout::integer()) -> {ok, binary()} | {error, any()}

Define a Javascript expression: js_driver:define(Port, <<var blah = new Wubba();">>). Note: Filename is used only as a label for error reporting.

destroy/1

destroy(Ctx::port()) -> ok

Destroys a Javascript VM instance

eval_js/2

eval_js(Ctx::port(), Js::binary()) -> {ok, any()} | {error, any()}

Evaluate a Javascript expression and return the result

load_driver/0

load_driver() -> true | false

Attempt to load the Javascript driver

new/0

new() -> {ok, port()} | {error, atom()} | {error, any()}

Create a new Javascript VM instance and preload Douglas Crockford's json2 converter (http://www.json.org/js.html). Uses a default heap size of 8MB and a default thread stack size of 8KB.

new/2

new(ThreadStackSize::int(), HeapSize::int()) -> {ok, port()} | {error, atom()} | {error, any()}

Create a new Javascript VM instance and preload Douglas Crockford's json2 converter (http://www.json.org/js.html)

new/3

new(ThreadStackSize::int(), HeapSize::int(), Initializer::no_json | init_fun() | {ModName::atom(), FunName::atom()}) -> {ok, port()} | {error, atom()} | {error, any()}

Create a new Javascript VM instance. The function arguments control how the VM instance is initialized. User supplied initializers must return true or false.

shutdown/1

shutdown(Ctx::port()) -> ok

Destroys a Javascript VM instance and shuts down the underlying Javascript infrastructure. NOTE: No new VMs can be created after this call is made!


Generated by EDoc, Mar 10 2019, 17:17:23.