MCPcopy Create free account
hub / github.com/BabylonJS/BabylonNative / ArrayBuffer

Class ArrayBuffer

Dependencies/napi/include/napi/napi.h:758–808  ·  view source on GitHub ↗

A JavaScript array buffer value.

Source from the content-addressed store, hash-verified

756
757 /// A JavaScript array buffer value.
758 class ArrayBuffer : public Object {
759 public:
760 /// Creates a new ArrayBuffer instance over a new automatically-allocated buffer.
761 static ArrayBuffer New(
762 napi_env env, ///< N-API environment
763 size_t byteLength ///< Length of the buffer to be allocated, in bytes
764 );
765
766 /// Creates a new ArrayBuffer instance, using an external buffer with specified byte length.
767 static ArrayBuffer New(
768 napi_env env, ///< N-API environment
769 void* externalData, ///< Pointer to the external buffer to be used by the array
770 size_t byteLength ///< Length of the external buffer to be used by the array, in bytes
771 );
772
773 /// Creates a new ArrayBuffer instance, using an external buffer with specified byte length.
774 template <typename Finalizer>
775 static ArrayBuffer New(
776 napi_env env, ///< N-API environment
777 void* externalData, ///< Pointer to the external buffer to be used by the array
778 size_t byteLength, ///< Length of the external buffer to be used by the array,
779 /// in bytes
780 Finalizer finalizeCallback ///< Function to be called when the array buffer is destroyed;
781 /// must implement `void operator()(Env env, void* externalData)`
782 );
783
784 /// Creates a new ArrayBuffer instance, using an external buffer with specified byte length.
785 template <typename Finalizer, typename Hint>
786 static ArrayBuffer New(
787 napi_env env, ///< N-API environment
788 void* externalData, ///< Pointer to the external buffer to be used by the array
789 size_t byteLength, ///< Length of the external buffer to be used by the array,
790 /// in bytes
791 Finalizer finalizeCallback, ///< Function to be called when the array buffer is destroyed;
792 /// must implement `void operator()(Env env, void* externalData, Hint* hint)`
793 Hint* finalizeHint ///< Hint (second parameter) to be passed to the finalize callback
794 );
795
796 ArrayBuffer(); ///< Creates a new _empty_ ArrayBuffer instance.
797 ArrayBuffer(napi_env env, napi_value value); ///< Wraps a N-API value primitive.
798
799 void* Data() const; ///< Gets a pointer to the data buffer.
800 size_t ByteLength() const; ///< Gets the length of the array buffer in bytes.
801
802 private:
803 mutable void* _data;
804 mutable size_t _length;
805
806 ArrayBuffer(napi_env env, napi_value value, void* data, size_t length);
807 void EnsureInfo() const;
808 };
809
810 /// A JavaScript typed-array value with unknown array type.
811 ///

Callers 2

NewMethod · 0.85
ArrayBufferMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected