1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- 2 * vim: set ts=8 sts=2 et sw=2 tw=80: 3 * This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 /* A JS_STREAMS_CLASS_SPEC macro for defining streams classes. */ 8 9 #ifndef builtin_streams_ClassSpecMacro_h 10 #define builtin_streams_ClassSpecMacro_h 11 12 #include "gc/AllocKind.h" // js::gc::AllocKind 13 #include "js/Class.h" // js::ClassSpec, JSClass, JSCLASS_HAS_{CACHED_PROTO,RESERVED_SLOTS}, JS_NULL_CLASS_OPS 14 #include "js/ProtoKey.h" // JSProto_* 15 #include "vm/GlobalObject.h" // js::GenericCreate{Constructor,Prototype} 16 17 #define JS_STREAMS_CLASS_SPEC(cls, nCtorArgs, nSlots, specFlags, classFlags, \ 18 classOps) \ 19 const js::ClassSpec cls::classSpec_ = { \ 20 js::GenericCreateConstructor<cls::constructor, nCtorArgs, \ 21 js::gc::AllocKind::FUNCTION>, \ 22 js::GenericCreatePrototype<cls>, \ 23 nullptr, \ 24 nullptr, \ 25 cls##_methods, \ 26 cls##_properties, \ 27 nullptr, \ 28 specFlags}; \ 29 \ 30 const JSClass cls::class_ = {#cls, \ 31 JSCLASS_HAS_RESERVED_SLOTS(nSlots) | \ 32 JSCLASS_HAS_CACHED_PROTO(JSProto_##cls) | \ 33 classFlags, \ 34 classOps, &cls::classSpec_}; \ 35 \ 36 const JSClass cls::protoClass_ = {#cls ".prototype", \ 37 JSCLASS_HAS_CACHED_PROTO(JSProto_##cls), \ 38 JS_NULL_CLASS_OPS, &cls::classSpec_}; 39 40 #endif // builtin_streams_ClassSpecMacro_h 41