Forward.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /*
  2. * Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
  3. * All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. *
  8. * 1. Redistributions of source code must retain the above copyright notice, this
  9. * list of conditions and the following disclaimer.
  10. *
  11. * 2. Redistributions in binary form must reproduce the above copyright notice,
  12. * this list of conditions and the following disclaimer in the documentation
  13. * and/or other materials provided with the distribution.
  14. *
  15. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  16. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  17. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  18. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  19. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  20. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  21. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  22. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  23. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  24. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25. */
  26. #pragma once
  27. #define JS_DECLARE_NATIVE_FUNCTION(name) \
  28. static JS::Value name(JS::Interpreter&, JS::GlobalObject&)
  29. #define JS_DECLARE_NATIVE_GETTER(name) \
  30. static JS::Value name(JS::Interpreter&, JS::GlobalObject&)
  31. #define JS_DECLARE_NATIVE_SETTER(name) \
  32. static void name(JS::Interpreter&, JS::GlobalObject&, JS::Value)
  33. #define JS_DEFINE_NATIVE_FUNCTION(name) \
  34. JS::Value name([[maybe_unused]] JS::Interpreter& interpreter, [[maybe_unused]] JS::GlobalObject& global_object)
  35. #define JS_DEFINE_NATIVE_GETTER(name) \
  36. JS::Value name([[maybe_unused]] JS::Interpreter& interpreter, [[maybe_unused]] JS::GlobalObject& global_object)
  37. #define JS_DEFINE_NATIVE_SETTER(name) \
  38. void name([[maybe_unused]] JS::Interpreter& interpreter, [[maybe_unused]] JS::GlobalObject& global_object, JS::Value value)
  39. #define JS_ENUMERATE_NATIVE_OBJECTS \
  40. __JS_ENUMERATE(Array, array, ArrayPrototype, ArrayConstructor) \
  41. __JS_ENUMERATE(BigIntObject, bigint, BigIntPrototype, BigIntConstructor) \
  42. __JS_ENUMERATE(BooleanObject, boolean, BooleanPrototype, BooleanConstructor) \
  43. __JS_ENUMERATE(Date, date, DatePrototype, DateConstructor) \
  44. __JS_ENUMERATE(Error, error, ErrorPrototype, ErrorConstructor) \
  45. __JS_ENUMERATE(Function, function, FunctionPrototype, FunctionConstructor) \
  46. __JS_ENUMERATE(NumberObject, number, NumberPrototype, NumberConstructor) \
  47. __JS_ENUMERATE(Object, object, ObjectPrototype, ObjectConstructor) \
  48. __JS_ENUMERATE(ProxyObject, proxy, ProxyPrototype, ProxyConstructor) \
  49. __JS_ENUMERATE(RegExpObject, regexp, RegExpPrototype, RegExpConstructor) \
  50. __JS_ENUMERATE(StringObject, string, StringPrototype, StringConstructor) \
  51. __JS_ENUMERATE(SymbolObject, symbol, SymbolPrototype, SymbolConstructor)
  52. #define JS_ENUMERATE_ERROR_SUBCLASSES \
  53. __JS_ENUMERATE(EvalError, eval_error, EvalErrorPrototype, EvalErrorConstructor) \
  54. __JS_ENUMERATE(InternalError, internal_error, InternalErrorPrototype, InternalErrorConstructor) \
  55. __JS_ENUMERATE(InvalidCharacterError, invalid_character_error, InvalidCharacterErrorPrototype, InvalidCharacterErrorConstructor) \
  56. __JS_ENUMERATE(RangeError, range_error, RangeErrorPrototype, RangeErrorConstructor) \
  57. __JS_ENUMERATE(ReferenceError, reference_error, ReferenceErrorPrototype, ReferenceErrorConstructor) \
  58. __JS_ENUMERATE(SyntaxError, syntax_error, SyntaxErrorPrototype, SyntaxErrorConstructor) \
  59. __JS_ENUMERATE(TypeError, type_error, TypeErrorPrototype, TypeErrorConstructor) \
  60. __JS_ENUMERATE(URIError, uri_error, URIErrorPrototype, URIErrorConstructor)
  61. #define JS_ENUMERATE_ITERATOR_PROTOTYPES \
  62. __JS_ENUMERATE(Iterator, iterator) \
  63. __JS_ENUMERATE(ArrayIterator, array_iterator) \
  64. __JS_ENUMERATE(StringIterator, string_iterator)
  65. #define JS_ENUMERATE_BUILTIN_TYPES \
  66. JS_ENUMERATE_NATIVE_OBJECTS \
  67. JS_ENUMERATE_ERROR_SUBCLASSES
  68. #define JS_ENUMERATE_WELL_KNOWN_SYMBOLS \
  69. __JS_ENUMERATE(iterator, iterator) \
  70. __JS_ENUMERATE(asyncIterator, async_iterator) \
  71. __JS_ENUMERATE(match, match) \
  72. __JS_ENUMERATE(matchAll, match_all) \
  73. __JS_ENUMERATE(replace, replace) \
  74. __JS_ENUMERATE(search, search) \
  75. __JS_ENUMERATE(split, split) \
  76. __JS_ENUMERATE(hasInstance, has_instance) \
  77. __JS_ENUMERATE(isConcatSpreadable, is_concat_spreadable) \
  78. __JS_ENUMERATE(unscopables, unscopables) \
  79. __JS_ENUMERATE(species, species) \
  80. __JS_ENUMERATE(toPrimitive, to_primitive) \
  81. __JS_ENUMERATE(toStringTag, to_string_tag)
  82. namespace JS {
  83. class ASTNode;
  84. class BigInt;
  85. class BoundFunction;
  86. class Cell;
  87. class DeferGC;
  88. class Error;
  89. class Exception;
  90. class Expression;
  91. class Accessor;
  92. class GlobalObject;
  93. class HandleImpl;
  94. class Heap;
  95. class HeapBlock;
  96. class Interpreter;
  97. class LexicalEnvironment;
  98. class MarkedValueList;
  99. class NativeProperty;
  100. class PrimitiveString;
  101. class Reference;
  102. class ScopeNode;
  103. class Shape;
  104. class Statement;
  105. class Symbol;
  106. class Token;
  107. class Uint8ClampedArray;
  108. class Value;
  109. enum class DeclarationKind;
  110. #define __JS_ENUMERATE(ClassName, snake_name, ConstructorName, PrototypeName) \
  111. class ClassName; \
  112. class ConstructorName; \
  113. class PrototypeName;
  114. JS_ENUMERATE_BUILTIN_TYPES
  115. #undef __JS_ENUMERATE
  116. struct Argument;
  117. template<class T>
  118. class Handle;
  119. }