10
10
#include < string.h>
11
11
12
12
#define ALLOC_ID (0xA10C )
13
+ #define EXTERNAL_ARRAY_TYPES (V ) \
14
+ V (Int8, kExternalInt8Array ) \
15
+ V(Uint8, kExternalUint8Array ) \
16
+ V(Int16, kExternalInt16Array ) \
17
+ V(Uint16, kExternalUint16Array ) \
18
+ V(Int32, kExternalInt32Array ) \
19
+ V(Uint32, kExternalUint32Array ) \
20
+ V(Float, kExternalFloat32Array ) \
21
+ V(Double, kExternalFloat64Array ) \
22
+ V(Uint8Clamped, kExternalUint8ClampedArray )
23
+
24
+ #define MIN (a, b ) ((a) < (b) ? (a) : (b))
25
+ #define MAX (a, b ) ((a) > (b) ? (a) : (b))
26
+
13
27
14
28
namespace node {
15
29
namespace smalloc {
@@ -559,6 +573,7 @@ void Initialize(Handle<Object> exports,
559
573
Handle <Value> unused,
560
574
Handle <Context> context) {
561
575
Environment* env = Environment::GetCurrent (context);
576
+ Isolate* isolate = env->isolate ();
562
577
563
578
env->SetMethod (exports, " copyOnto" , CopyOnto);
564
579
env->SetMethod (exports, " sliceOnto" , SliceOnto);
@@ -573,6 +588,25 @@ void Initialize(Handle<Object> exports,
573
588
exports->Set (FIXED_ONE_BYTE_STRING (env->isolate (), " kMaxLength" ),
574
589
Uint32::NewFromUnsigned (env->isolate (), kMaxLength ));
575
590
591
+ Local<Object> types = Object::New (isolate);
592
+
593
+ uint32_t kMinType = ~0 ;
594
+ uint32_t kMaxType = 0 ;
595
+ #define V (name, value ) \
596
+ types->Set (FIXED_ONE_BYTE_STRING (env->isolate (), #name), \
597
+ Uint32::NewFromUnsigned (env->isolate (), v8::value)); \
598
+ kMinType = MIN (kMinType , v8::value); \
599
+ kMaxType = MAX (kMinType , v8::value);
600
+
601
+ EXTERNAL_ARRAY_TYPES (V)
602
+ #undef V
603
+
604
+ exports->Set (FIXED_ONE_BYTE_STRING (env->isolate (), " types" ), types);
605
+ exports->Set (FIXED_ONE_BYTE_STRING (env->isolate (), " kMinType" ),
606
+ Uint32::NewFromUnsigned (env->isolate (), kMinType ));
607
+ exports->Set (FIXED_ONE_BYTE_STRING (env->isolate (), " kMaxType" ),
608
+ Uint32::NewFromUnsigned (env->isolate (), kMaxType ));
609
+
576
610
HeapProfiler* heap_profiler = env->isolate ()->GetHeapProfiler ();
577
611
heap_profiler->SetWrapperClassInfoProvider (ALLOC_ID, WrapperInfo);
578
612
}
0 commit comments