How to use the ref.refType function in ref

To help you get started, we’ve selected a few ref examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lmangani / nDPI-node / src / pcap.js View on Github external
pcap_parser.on('globalHeader', function (globalHeader) {
	ndpi.init();
	// ndpi.addProtocolHandler(onProto);
	var ltype = new Buffer(globalHeader.linkLayerType);
	ltype.type = ref.refType(pcap_t);
	ndpi.setDatalinkType(ltype.ref())
});
github nikhilk / node-tensorflow / src / interop / libtensorflow.js View on Github external
'complex': 8,
  'int64': 9,
  'bool': 10,
  'qint8': 11,
  'quint8': 12,
  'qint32': 13,
  'bfloat16': 14
};
var _dataTypeNames = _buildEnumLookup(dataTypes);


// Type definitions
var types = {
  Pointer: ref.refType('void'),
  Status: ref.refType('void'),
  Tensor: ref.refType('void'),
  Session: ref.refType('void'),
  SessionOptions: ref.refType('void'),
  LongLongArray: refArray('longlong'),
  FloatArray: refArray('float'),
  StringArray: refArray('string')
};
types.TensorArray = refArray(types.Tensor);


// TensorFlow library definition

var tensorflow =
  ffi.defineLibrary(path.join(__dirname, 'libtensorflow'))
     .export('createStatus', 'TF_NewStatus', types.Status)
     .export('deleteStatus', 'TF_DeleteStatus', 'void', types.Status)
     .export('updateStatus', 'TF_SetStatus',
github icyphy / ptII / org / terraswarm / gdp / js / simpleReader.js View on Github external
//CJS         GDP_MODE_ANY = 0,       // no mode specified
//CJS         GDP_MODE_RO = 1,        // read only
//CJS         GDP_MODE_AO = 2,        // append only
//CJS } gdp_iomode_t;
var GDP_MODE_ANY = 0;
var GDP_MODE_RO  = 1;
var GDP_MODE_AO  = 2;
var gdp_iomode_t = ref.types.int;  //?? check this - enum === int ?

var char_t = ref.types.char;
var buf_t = ref_array(char_t);

//CJS // an open handle on a GCL (opaque)
//CJS typedef struct gdp_gcl          gdp_gcl_t;
var gdp_gcl_t       = ref.types.void;  // opaque for us up here in JS
var gdp_gcl_tPtr    = ref.refType(gdp_gcl_t);
var gdp_gcl_tPtrPtr = ref.refType(gdp_gcl_tPtr);

//CJS typedef struct gdp_datum        gdp_datum_t;
var gdp_datum_t       = ref.types.void;  // opaque for us up here in JS
var gdp_datum_tPtr    = ref.refType(gdp_datum_t);
var gdp_datum_tPtrPtr = ref.refType(gdp_datum_tPtr);  //?? not used yet??

//CJS typedef struct gdp_event        gdp_event_t;
var gdp_event_t       = ref.types.void;  // opaque for us up here in JS
var gdp_event_tPtr    = ref.refType(gdp_event_t);
var gdp_event_tPtrPtr = ref.refType(gdp_event_tPtr);  //?? not used yet??

// From gdp/gdp_buf.h
//CJS typedef struct evbuffer gdp_buf_t;
var gdp_buf_t       = ref.types.void;  // opaque for us up here in JS
var gdp_buf_tPtr    = ref.refType(gdp_buf_t);
github lmangani / ndpi-beat / ndpibeat.js View on Github external
// TODO: better UTF-16 and UTF-32 encoding
  var _buf = new Buffer((val.length + 1) * runner.wchar_size)
  _buf.fill(0)
  var l = 0
  for (var i = runner.wchar_size - 1; i < _buf.length; i += runner.wchar_size) {
    _buf[i] = val.charCodeAt(l++)
  }
  return buf.writePointer(_buf, offset)
};

runner.callback_Ptr = ArrayType(runner.wchar_t);

/* APP VARS */
runner.voidPtr = exports.voidPtr = ref.refType(ref.types.void);
runner.uint8_t = exports.uint8_t = runner.voidPtr;
runner.uint8_tPtr = exports.uint8_tPtr = ref.refType(runner.uint8_t);
runner.callback = exports.callback = ffi.Function(ref.types.void, [
  ref.types.int32,
  ref.refType(ref.types.uchar)
]);
runner.pcap_t = exports.pcap_t = runner.voidPtr;
runner.pcap_tPtr = exports.pcap_tPtr = ref.refType(runner.pcap_t);
runner.pcap_handler = exports.pcap_handler = ffi.Function(ref.types.void, [
  ref.refType(ref.types.uchar),
  runner.voidPtr,
  ref.refType(ref.types.uchar)
]);
runner.pcap_handlerPtr = exports.pcap_handlerPtr = ref.refType(runner.pcap_handler);

// PCAP Header
var pcap_pkthdr = Struct({
  'ts_sec': 'long',
github zetsin / node-sdl2 / dep / SDL_test_harness.js View on Github external
var string = exports.string = ref.types.CString
var SDLTest_TestCaseReference = exports.SDLTest_TestCaseReference = Struct({
	testCase: SDLTest_TestCaseFp,
	name: string,
	description: string,
	enabled: int32,
})
var SDLTest_TestCaseReference_ptr = exports.SDLTest_TestCaseReference_ptr = ref.refType(SDLTest_TestCaseReference)
var SDLTest_TestCaseReference_ptr_ptr = exports.SDLTest_TestCaseReference_ptr_ptr = ref.refType(SDLTest_TestCaseReference_ptr)
var SDLTest_TestSuiteReference = exports.SDLTest_TestSuiteReference = Struct({
	name: string,
	testSetUp: SDLTest_TestCaseSetUpFp,
	testCases: SDLTest_TestCaseReference_ptr_ptr,
	testTearDown: SDLTest_TestCaseTearDownFp,
})
var SDLTest_TestSuiteReference_ptr = exports.SDLTest_TestSuiteReference_ptr = ref.refType(SDLTest_TestSuiteReference)
var c__F_SDLTest_RunSuites_arr = ArrayType(SDLTest_TestSuiteReference_ptr, 0)

FFI.Library(process.platform == 'win32' ? 'SDL2' : 'libSDL2', {
	SDLTest_RunSuites: [ int32, [ c__F_SDLTest_RunSuites_arr, string, int32, string, int32, ] ],
}, exports)
github smartkids77 / ArcSoft_FreeSDK_Demo / FR / nodejs / ArcSoftFR.js View on Github external
function compareFaceSimilarity(hEngine, faceFeatureA, faceFeatureB) {
    var pfSimilScore = new Buffer(ref.sizeof.float);
    pfSimilScore.type = ref.refType(ref.types.float);
    pfSimilScore.writeFloatLE(0, 0.0);
    var ret = Library.AFR_FSDK_FacePairMatching(hEngine, faceFeatureA.ref(), faceFeatureB.ref(), pfSimilScore);
    if (ret != 0) {
        console.log('AFR_FSDK_FacePairMatching failed:ret == ' + ret);
        return 0.0;
    }
    return pfSimilScore.readFloatLE(0);
}
github trueinteractions / tint2 / modules / Bridge / win32.js View on Github external
function PTR(type){
  return ref.refType(type);
}
github Icenium / icenium-cli / lib / platforms / ios.js View on Github external
(function() {
	"use strict";
	var ffi = require('ffi'),
		ref = require('ref'),
		Struct = require('ref-struct'),
		osPath = require('path'),
		os = require('os'),
		fs = require('fs'),
		net = require('net');

	var intPtr = ref.refType(ref.types.int),
		uintPtr = ref.refType(ref.types.uint),
		voidPtr = ref.refType(ref.types.void),
		charPtr = ref.refType(ref.types.char),
		ptrToVoidPtr = ref.refType(ref.refType(ref.types.void)),
 		POINTER_SIZE = ref.sizeof.pointer;

	var ADNCI_MSG_CONNECTED = 1,
		ADNCI_MSG_DISCONNECTED = 2,
		ADNCI_MSG_UNKNOWN = 3,
		kCFStringEncodingUTF8 = 0x08000100,
		kCFNumberSInt32Type = 3;

	var _device = null,
		am_device_p = voidPtr,
		CFStringRef = voidPtr,
		CFDictionaryRef = voidPtr,
		AFCConnectionRef = voidPtr,
		AFCFileRef = ref.types.uint64;
github liesen / spotify-api-server / ffi / libspotify.js View on Github external
var FFI = require('ffi'),
    ArrayType = require('ref-array'),
    Struct = require('ref-struct'),
    ref = require('ref');
var voidPtr = ref.refType(ref.types.void);
var charPtr = ref.refType(ref.types.char);
exports.CONSTANTS = {
    sp_error: {
        '0': 'SP_ERROR_OK',
        '1': 'SP_ERROR_BAD_API_VERSION',
        '2': 'SP_ERROR_API_INITIALIZATION_FAILED',
        '3': 'SP_ERROR_TRACK_NOT_PLAYABLE',
        '5': 'SP_ERROR_BAD_APPLICATION_KEY',
        '6': 'SP_ERROR_BAD_USERNAME_OR_PASSWORD',
        '7': 'SP_ERROR_USER_BANNED',
        '8': 'SP_ERROR_UNABLE_TO_CONTACT_SERVER',
        '9': 'SP_ERROR_CLIENT_TOO_OLD',
        '10': 'SP_ERROR_OTHER_PERMANENT',
        '11': 'SP_ERROR_BAD_USER_AGENT',
        '12': 'SP_ERROR_MISSING_CALLBACK',
        '13': 'SP_ERROR_INVALID_INDATA',
github CatalystCode / windows-registry-node / lib / types.js View on Github external
var ref = require('ref');

var types = {
    REGSAM: ref.types.ulong,
    DWORD: ref.types.uint32,
    ULONG: ref.types.ulong,
    HWND: ref.refType(ref.types.void),
    BYTE: ref.types.uint8,
    HKEY: ref.refType(ref.types.void),
    PVOID: ref.refType('pointer'),
    HANDLE: ref.refType(ref.types.void),
    HINSTANCE: ref.refType(ref.types.void),
    LPCTSTR: ref.refType(ref.types.CString),
    STRING: ref.types.CString,
    INT: ref.types.int,
    LPVOID: ref.refType(ref.types.void)
};

types.PHKEY = ref.refType(types.HKEY);
types.LPBYTE = ref.refType(types.BYTE);
types.LPDWORD = ref.refType(types.DWORD);
module.exports = types;

ref

Turn Buffer instances into "pointers"

MIT
Latest version published 7 years ago

Package Health Score

51 / 100
Full package analysis

Popular ref functions