25
25
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
26
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
/** \mainpage V8 API Reference Guide
30
Add text to introduce,
32
point back to code.google.com/apis/v8/index.html
28
/** V8 API Reference Guide
30
V8 is Google's open source JavaScript engine. This set of documents
31
provides reference material generated from the V8 header file, v8.h.
33
For introductory material see http://code.google.com/apis/v8/
42
46
typedef int int32_t;
43
47
typedef unsigned int uint32_t;
44
typedef unsigned short uint16_t;
45
typedef long long int64_t;
48
typedef unsigned short uint16_t; // NOLINT
49
typedef long long int64_t; // NOLINT
51
// Setup for Windows DLL export/import. When building the V8 DLL the
52
// BUILDING_V8_SHARED needs to be defined. When building a program which uses
53
// the V8 DLL USING_V8_SHARED needs to be defined. When either building the V8
54
// static library or building a program which uses the V8 static library neither
55
// BUILDING_V8_SHARED nor USING_V8_SHARED should be defined.
56
// The reason for having both EXPORT and EXPORT_INLINE is that classes which
57
// have their code inside this header file needs to have __declspec(dllexport)
58
// when building the DLL but cannot have __declspec(dllimport) when building
59
// a program which uses the DLL.
60
#if defined(BUILDING_V8_SHARED) && defined(USING_V8_SHARED)
61
#error both BUILDING_V8_SHARED and USING_V8_SHARED are set - please check the\
62
build configuration to ensure that at most one of these is set
65
#ifdef BUILDING_V8_SHARED
66
#define EXPORT __declspec(dllexport)
67
#define EXPORT_INLINE __declspec(dllexport)
69
#define EXPORT __declspec(dllimport)
74
#endif // BUILDING_V8_SHARED
47
78
#include <stdint.h>
80
// Setup for Linux shared library export. There is no need to destinguish
81
// neither between building or using the V8 shared library nor between using
82
// the shared or static V8 library as there is on Windows. Therefore there is
83
// on checking of BUILDING_V8_SHARED and USING_V8_SHARED.
84
#if defined(__GNUC__) && (__GNUC__ >= 4)
85
#define EXPORT __attribute__ ((visibility("default")))
86
#define EXPORT_INLINE __attribute__ ((visibility("default")))
87
#else // defined(__GNUC__) && (__GNUC__ >= 4)
90
#endif // defined(__GNUC__) && (__GNUC__ >= 4)
51
95
* The v8 javascript engine.
210
254
* handle scope are destroyed when the handle scope is destroyed. Hence it
211
255
* is not necessary to explicitly deallocate local handles.
213
template <class T> class Local : public Handle<T> {
257
template <class T> class EXPORT_INLINE Local : public Handle<T> {
216
260
template <class S> inline Local(Local<S> that)
348
392
* handle and may deallocate it. The behavior of accessing a handle
349
393
* for which the handle scope has been deleted is undefined.
395
class EXPORT HandleScope {
353
397
HandleScope() : previous_(current_), is_closed_(false) {
354
398
current_.extensions = 0;
446
490
* compiling it, and stored between compilations. When script data
447
491
* is given to the compile method compilation will be faster.
493
class EXPORT ScriptData { // NOLINT
451
495
virtual ~ScriptData() { }
452
496
static ScriptData* PreCompile(const char* input, int length);
461
505
* The origin, within a file, of a script.
507
class EXPORT ScriptOrigin {
465
509
ScriptOrigin(Handle<Value> resource_name,
466
510
Handle<Integer> resource_line_offset = Handle<Integer>(),
633
677
* The superclass of primitive values. See ECMA-262 4.3.2.
635
class Primitive : public Value { };
679
class EXPORT Primitive : public Value { };
639
683
* A primitive boolean value (ECMA-262, 4.3.14). Either the true
640
684
* or false value.
642
class Boolean : public Primitive {
686
class EXPORT Boolean : public Primitive {
645
689
static inline Handle<Boolean> New(bool value);
690
734
* ExternalStringResource to manage the life cycle of the underlying
693
class ExternalStringResource {
737
class EXPORT ExternalStringResource { // NOLINT
696
740
* Override the destructor to manage the life cycle of the underlying
821
865
* A javascript number value (ECMA-262, 4.3.20)
823
class Number : public Primitive {
867
class EXPORT Number : public Primitive {
826
870
static Local<Number> New(double value);
869
913
* An instance of the built-in Date constructor (ECMA-262, 15.9).
871
class Date : public Value {
915
class EXPORT Date : public Value {
873
917
static Local<Value> New(double time);
885
929
* A javascript object (ECMA-262, 4.3.3)
887
class Object : public Value {
931
class EXPORT Object : public Value {
889
933
bool Set(Handle<Value> key,
890
934
Handle<Value> value,
962
1006
* A javascript function object (ECMA-262, 15.3).
964
class Function : public Object {
1008
class EXPORT Function : public Object {
966
1010
Local<Object> NewInstance();
967
1011
Local<Object> NewInstance(int argc, Handle<Value> argv[]);
979
1023
* mainly used to associate c++ data structures with javascript
982
class External : public Value {
1026
class EXPORT External : public Value {
984
1028
static Local<External> New(void* value);
985
1029
static External* Cast(Value* obj);
996
1040
* The superclass of object and function templates.
998
class Template : public Data {
1042
class EXPORT Template : public Data {
1000
1044
/** Adds a property to each instance created by this template.*/
1001
1045
void Set(Handle<String> name, Handle<Data> value,
1015
1059
* including the receiver, the number and values of arguments, and
1016
1060
* the holder of the function.
1062
class EXPORT Arguments {
1020
1064
inline int Length() const;
1021
1065
inline Local<Value> operator[](int i) const;
1045
1089
* The information passed to an accessor callback about the context
1046
1090
* of the property access.
1048
class AccessorInfo {
1092
class EXPORT AccessorInfo {
1050
1094
inline AccessorInfo(Local<Object> self,
1051
1095
Local<Value> data,
1266
1310
* child_instance.instance_accessor calls InstanceAccessorCallback
1267
1311
* child_instance.instance_property == 3;
1269
class FunctionTemplate : public Template {
1313
class EXPORT FunctionTemplate : public Template {
1271
1315
/** Creates a function template.*/
1272
1316
static Local<FunctionTemplate> New(InvocationCallback callback = 0,
1339
1383
* ObjectTemplate: (TODO(758124): Add comments.)
1341
class ObjectTemplate : public Template {
1385
class EXPORT ObjectTemplate : public Template {
1343
1387
static Local<ObjectTemplate> New();
1344
1388
/** Creates a new instance of this template.*/
1433
1477
* A function signature which specifies which receivers and arguments
1434
1478
* in can legally be called with.
1436
class Signature : public Data {
1480
class EXPORT Signature : public Data {
1438
1482
static Local<Signature> New(Handle<FunctionTemplate> receiver =
1439
1483
Handle<FunctionTemplate>(),
1448
1492
* A utility for determining the type of objects based on which
1449
1493
* template they were constructed from.
1451
class TypeSwitch : public Data {
1495
class EXPORT TypeSwitch : public Data {
1453
1497
static Local<TypeSwitch> New(Handle<FunctionTemplate> type);
1454
1498
static Local<TypeSwitch> New(int argc, Handle<FunctionTemplate> types[]);
1495
void RegisterExtension(Extension* extension);
1539
void EXPORT RegisterExtension(Extension* extension);
1501
class DeclareExtension {
1545
class EXPORT DeclareExtension {
1503
1547
inline DeclareExtension(Extension* extension) {
1504
1548
RegisterExtension(extension);
1509
1553
// --- S t a t i c s ---
1512
Handle<Primitive> Undefined();
1513
Handle<Primitive> Null();
1514
Handle<Boolean> True();
1515
Handle<Boolean> False();
1556
Handle<Primitive> EXPORT Undefined();
1557
Handle<Primitive> EXPORT Null();
1558
Handle<Boolean> EXPORT True();
1559
Handle<Boolean> EXPORT False();
1519
1563
* A set of constraints that specifies the limits of the runtime's
1522
class ResourceConstraints {
1566
class EXPORT ResourceConstraints {
1524
1568
ResourceConstraints();
1525
1569
int max_young_space_size() { return max_young_space_size_; }
1553
1597
* operation; the caller must return immediately and only after the exception
1554
1598
* has been handled does it become legal to invoke javascript operations.
1556
Handle<Value> ThrowException(Handle<Value> exception);
1600
Handle<Value> EXPORT ThrowException(Handle<Value> exception);
1559
1603
* Create new error objects by calling the corresponding error object
1560
1604
* constructor with the message.
1606
class EXPORT Exception {
1564
1608
static Local<Value> RangeError(Handle<String> message);
1565
1609
static Local<Value> ReferenceError(Handle<String> message);
1634
1678
static void SetFlagsFromString(const char* str, int length);
1681
* Sets v8 flags from command line.
1682
* TODO(758124): Describe flags?
1684
static void SetFlagsFromCommandLine(int* argc,
1636
1688
/** Get the version string. */
1637
1689
static const char* GetVersion();
1766
class ExtensionConfiguration {
1818
class EXPORT ExtensionConfiguration {
1768
1820
ExtensionConfiguration(int name_count, const char* names[])
1769
1821
: name_count_(name_count), names_(names) { }