How to use the ref-napi.reinterpret function in ref-napi

To help you get started, we’ve selected a few ref-napi 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 ibm-messaging / mq-mqi-nodejs / lib / mqiutils.js View on Github external
exports.getMQICharV = function(c) {
  if (c && c.VSPtr && c.VSLength > 0) {
    var s = ref.reinterpret(c.VSPtr,c.VSLength,'utf8');
    c.VSPtr = ref.NULL; // encourage GC to reclaim buffer
    return s;
  } else {
    c.VSPtr = ref.NULL;
    c.VSLength = 0;
    c.VSBufSize = 0;
    return null;
  }
};
github ibm-messaging / mq-mqi-nodejs / lib / mqi.js View on Github external
case MQC.MQTYPE_INT16:
      if (le) {
        value = valuePtr.readInt16LE(0);
      } else {
        value = valuePtr.readInt16BE(0);
      }
      break;
    case MQC.MQTYPE_INT32:
      if (le) {
        value = valuePtr.readInt32LE(0);
      } else {
        value = valuePtr.readInt32BE(0);
      }
      break;
    case MQC.MQTYPE_STRING:
      value = ref.reinterpret(valuePtr,jsPropsLen,'utf8');
      break;
    case MQC.MQTYPE_BOOLEAN:
      if (le) {
        value = valuePtr.readInt32LE(0) != 0;
      } else {
        value = valuePtr.readInt32BE(0) !=0 ;
      }
      break;
    case MQC.MQTYPE_BYTE_STRING:
      value = valuePtr;
      break;
    default:
      debugLog("Unknown property type %d",jsType);
      value = valuePtr;
      break;
    }