0
0
mirror of https://github.com/phpv8/v8js.git synced 2025-01-08 23:21:52 +00:00

Merge pull request #133 from christiaan/update_readme

Update the Readme with setTimeLimit and setMemoryLimit
This commit is contained in:
Patrick Reilly 2015-01-03 12:58:42 -08:00
commit c9cc884131

212
README.md
View File

@ -81,89 +81,171 @@ PHP API
======= =======
```php ```php
class V8Js <?php
{ class V8Js
/* Constants */ {
/* Constants */
const string V8_VERSION; const V8_VERSION = '';
const int FLAG_NONE; const FLAG_NONE = 1;
const int FLAG_FORCE_ARRAY; const FLAG_FORCE_ARRAY = 2;
const int DEBUG_AUTO_BREAK_NEVER; const DEBUG_AUTO_BREAK_NEVER = 1;
const int DEBUG_AUTO_BREAK_ONCE; const DEBUG_AUTO_BREAK_ONCE = 2;
const int DEBUG_AUTO_BREAK_ALWAYS; const DEBUG_AUTO_BREAK_ALWAYS = 3;
/* Methods */
// Initializes and starts V8 engine and Returns new V8Js object with it's own V8 context. /* Methods */
public __construct ( [ string $object_name = "PHP" [, array $variables = NULL [, array $extensions = NULL [, bool $report_uncaught_exceptions = TRUE ] ] ] )
// Provide a function or method to be used to load required modules. This can be any valid PHP callable. /**
// The loader function will receive the normalised module path and should return Javascript code to be executed. * Initializes and starts V8 engine and Returns new V8Js object with it's own V8 context.
public setModuleLoader ( callable $loader ) * @param string $object_name
* @param array $variables
* @param array $extensions
* @param bool $report_uncaught_exceptions
*/
public function __construct($object_name = "PHP", array $variables = NULL, array $extensions = NULL, $report_uncaught_exceptions = TRUE)
{}
// Compiles and executes script in object's context with optional identifier string. /**
// A time limit (milliseconds) and/or memory limit (bytes) can be provided to restrict execution. These options will throw a V8JsTimeLimitException or V8JsMemoryLimitException. * Provide a function or method to be used to load required modules. This can be any valid PHP callable.
public mixed V8Js::executeString( string $script [, string $identifier [, int $flags = V8Js::FLAG_NONE [, int $time_limit = 0 [, int $memory_limit = 0]]]]) * The loader function will receive the normalised module path and should return Javascript code to be executed.
* @param callable $loader
*/
public function setModuleLoader(callable $loader)
{}
// Compiles a script in object's context with optional identifier string. /**
public mixed V8Js::compileString( string $script [, string $identifier ]) * Compiles and executes script in object's context with optional identifier string.
* A time limit (milliseconds) and/or memory limit (bytes) can be provided to restrict execution. These options will throw a V8JsTimeLimitException or V8JsMemoryLimitException.
* @param string $script
* @param string $identifier
* @param int $flags
* @param int $time_limit in milliseconds
* @param int $memory_limit in bytes
* @return mixed
*/
public function executeString($script, $identifier = '', $flags = V8Js::FLAG_NONE, $time_limit = 0, $memory_limit = 0)
{}
// Executes a precompiled script in object's context. /**
// A time limit (milliseconds) and/or memory limit (bytes) can be provided to restrict execution. These options will throw a V8JsTimeLimitException or V8JsMemoryLimitException. * Compiles a script in object's context with optional identifier string.
public mixed V8Js::executeScript( resource $script [, int $flags = V8Js::FLAG_NONE [, int $time_limit = 0 [, int $memory_limit = 0]]]) * @param $script
* @param string $identifier
* @return resource
*/
public function compileString($script, $identifier = '')
{}
// Returns uncaught pending exception or null if there is no pending exception. /**
public V8JsScriptException V8Js::getPendingException( ) * Executes a precompiled script in object's context.
* A time limit (milliseconds) and/or memory limit (bytes) can be provided to restrict execution. These options will throw a V8JsTimeLimitException or V8JsMemoryLimitException.
* @param resource $script
* @param int $flags
* @param int $time_limit
* @param int $memory_limit
*/
public function executeScript($script, $flags = V8Js::FLAG_NONE, $time_limit = 0 , $memory_limit = 0)
{}
// Clears the uncaught pending exception /**
public clearPendingException( ) * Set the time limit (in milliseconds) for this V8Js object
* works similar to the set_time_limit php
* @param int $limit
*/
public function setTimeLimit($limit)
{}
// Starts V8 debug agent for use with Google Chrome Developer Tools (Eclipse Plugin) /**
public bool startDebugAgent( [ string $agent_name = "V8Js" [, $port = 9222 [, $auto_break = V8Js::DEBUG_AUTO_BREAK_NEVER ] ] ] ) * Set the memory limit (in bytes) for this V8Js object
* @param int $limit
*/
public function setMemoryLimit($limit)
{}
/** Static methods **/ /**
* Returns uncaught pending exception or null if there is no pending exception.
* @return V8JsScriptException|null
*/
public function getPendingException()
{}
// Registers persistent context independent global Javascript extension. /**
// NOTE! These extensions exist until PHP is shutdown and they need to be registered before V8 is initialized. * Clears the uncaught pending exception
// For best performance V8 is initialized only once per process thus this call has to be done before any V8Js objects are created! */
public static bool V8Js::registerExtension( string $extension_name, string $code [, array $dependenciess [, bool $auto_enable = FALSE ] ] ) public function clearPendingException()
{}
// Returns extensions successfully registered with V8Js::registerExtension(). /**
public static array V8Js::getExtensions( ) * Starts V8 debug agent for use with Google Chrome Developer Tools (Eclipse Plugin)
} * @param string $agent_name
* @param int $port
* @param int $auto_break
* @return bool
*/
public function startDebugAgent($agent_name = "V8Js", $port = 9222, $auto_break = V8Js::DEBUG_AUTO_BREAK_NEVER)
{}
class V8JsException extends RuntimeException /** Static methods **/
{
}
final class V8JsScriptException extends V8JsException /**
{ * Registers persistent context independent global Javascript extension.
/* Properties */ * NOTE! These extensions exist until PHP is shutdown and they need to be registered before V8 is initialized.
protected string JsFileName = NULL; * For best performance V8 is initialized only once per process thus this call has to be done before any V8Js objects are created!
protected int JsLineNumber = NULL; * @param string $extension_name
protected int JsStartColumn = NULL; * @param string $code
protected int JsEndColumn = NULL; * @param array $dependencies
protected string JsSourceLine = NULL; * @param bool $auto_enable
protected string JsTrace = NULL; * @return bool
*/
/* Methods */ public static function registerExtension($extension_name, $code, array $dependencies, $auto_enable = FALSE)
final public string getJsFileName( ) {}
final public int getJsLineNumber( )
final public int getJsStartColumn( )
final public int getJsEndColumn( )
final public string getJsSourceLine( )
final public string getJsTrace( )
}
final class V8JsTimeLimitException extends V8JsException /**
{ * Returns extensions successfully registered with V8Js::registerExtension().
} * @return array|string[]
*/
public static function getExtensions()
{}
}
final class V8JsMemoryLimitException extends V8JsException final class V8JsScriptException extends Exception
{ {
} /**
* @return string
*/
final public function getJsFileName( ) {}
/**
* @return int
*/
final public function getJsLineNumber( ) {}
/**
* @return int
*/
final public function getJsStartColumn( ) {}
/**
* @return int
*/
final public function getJsEndColumn( ) {}
/**
* @return string
*/
final public function getJsSourceLine( ) {}
/**
* @return string
*/
final public function getJsTrace( ) {}
}
final class V8JsTimeLimitException extends Exception
{
}
final class V8JsMemoryLimitException extends Exception
{
}
``` ```
Javascript API Javascript API