Fix FileSystem.cpp build on GCC.
1 /* vim: set ts=4 sw=4 tw=99 et:
3 * Copyright (C) 2012 David Anderson
5 * This file is part of SourcePawn.
7 * SourcePawn is free software: you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License as published by the Free
9 * Software Foundation, either version 3 of the License, or (at your option)
12 * SourcePawn is distributed in the hope that it will be useful, but WITHOUT ANY
13 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along with
17 * SourcePawn. If not, see http://www.gnu.org/licenses/.
19 #ifndef _include_jitcraft_fixedarray_h_
20 #define _include_jitcraft_fixedarray_h_
26 // A fixed-length array that contains Object * slots.
27 class FixedArray : public Object
33 return reinterpret_cast<Object **>(this + 1);
37 static FixedArray *New(Zone *zone, unsigned length, Heap::Tenure tenure);
42 Object *at(size_t i) {
46 void set(Zone *zone, size_t i, Object *obj) {
48 write(zone, &vec()[i], obj);
51 return SizeFor(length());
54 static inline size_t SizeFor(unsigned length) {
55 return sizeof(FixedArray) + sizeof(Object *) * length;
58 static inline FixedArray *cast(Object *obj) {
59 assert(!obj || obj->is(MapKind_FixedArray));
60 return reinterpret_cast<FixedArray *>(obj);
64 // A fixed-length array containing raw bytes.
65 class ByteArray : public Object
70 static ByteArray *New(Zone *zone, unsigned length, Heap::Tenure tenure = Heap::Tenure_Default);
71 static ByteArray *New(Zone *zone, Handle<Map> map, unsigned length, Heap::Tenure tenure = Heap::Tenure_Default);
77 return Address(this) + offsetToElements();
80 return SizeFor(length());
83 static inline size_t offsetToElements() {
84 return sizeof(ByteArray);
87 static inline size_t SizeFor(unsigned length) {
88 return sizeof(ByteArray) + sizeof(uint8) * length;
91 static inline ByteArray *cast(Object *obj) {
92 assert(!obj || obj->is(MapKind_ByteArray));
93 return reinterpret_cast<ByteArray *>(obj);
99 #endif // _include_jitcraft_fixedarray_h_