1010#include < string.h>
1111
1212#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+
1327
1428namespace node {
1529namespace smalloc {
@@ -559,6 +573,7 @@ void Initialize(Handle<Object> exports,
559573 Handle<Value> unused,
560574 Handle<Context> context) {
561575 Environment* env = Environment::GetCurrent (context);
576+ Isolate* isolate = env->isolate ();
562577
563578 env->SetMethod (exports, " copyOnto" , CopyOnto);
564579 env->SetMethod (exports, " sliceOnto" , SliceOnto);
@@ -573,6 +588,25 @@ void Initialize(Handle<Object> exports,
573588 exports->Set (FIXED_ONE_BYTE_STRING (env->isolate (), " kMaxLength" ),
574589 Uint32::NewFromUnsigned (env->isolate (), kMaxLength ));
575590
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+
576610 HeapProfiler* heap_profiler = env->isolate ()->GetHeapProfiler ();
577611 heap_profiler->SetWrapperClassInfoProvider (ALLOC_ID, WrapperInfo);
578612}
0 commit comments