lib/foreign_function_var.js
function variadic_function_generator () {
    debug('variadic_function_generator invoked');

    // first get the types of variadic args we are working with
    const argTypes = fixedArgTypes.slice();
    let key = fixedKey.slice();

    for (let i = 0; i < arguments.length; i++) {
      const type = ref.coerceType(arguments[i]);
      argTypes.push(type);

      const ffi_type = Type(type);
      assert(ffi_type.name);
      key.push(getId(type));
    }

    // now figure out the return type
    const rtnType = ref.coerceType(variadic_function_generator.returnType);
    const rtnName = getId(rtnType);
    assert(rtnName);

    // first let's generate the key and see if we got a cache-hit
    key = rtnName + key.join('');

    let func = cache[key];
    if (func) {
      debug('cache hit for key:', key);
    } else {
      // create the `ffi_cif *` instance
      debug('creating the variadic ffi_cif instance for key:', key);
      const cif = CIF_var(returnType, argTypes, numFixedArgs, abi);
      func = cache[key] = _ForeignFunction(cif, funcPtr, rtnType, argTypes);
    }
    return func;
  }
function variadic_function_generator () {
    debug('variadic_function_generator invoked');

    // first get the types of variadic args we are working with
    const argTypes = fixedArgTypes.slice();
    let key = fixedKey.slice();

    for (let i = 0; i < arguments.length; i++) {
      const type = ref.coerceType(arguments[i]);
      argTypes.push(type);

      const ffi_type = Type(type);
      assert(ffi_type.name);
      key.push(getId(type));
    }

    // now figure out the return type
    const rtnType = ref.coerceType(variadic_function_generator.returnType);
    const rtnName = getId(rtnType);
    assert(rtnName);

    // first let's generate the key and see if we got a cache-hit
    key = rtnName + key.join('');

    let func = cache[key];
    if (func) {
      debug('cache hit for key:', key);
    } else {
      // create the `ffi_cif *` instance
      debug('creating the variadic ffi_cif instance for key:', key);
      const cif = CIF_var(returnType, argTypes, numFixedArgs, abi);
      func = cache[key] = _ForeignFunction(cif, funcPtr, rtnType, argTypes);
    }
    return func;
  }
function variadic_function_generator ( ) { debug ( 'variadic_function_generator invoked' ) ; // first get the types of variadic args we are working with const argTypes = fixedArgTypes . slice ( ) ; let key = fixedKey . slice ( ) ; for ( let i = 0 ; i < arguments . length ; i ++ ) { const type = ref . coerceType ( arguments [ i ] ) ; argTypes . push ( type ) ; const ffi_type = Type ( type ) ; assert ( ffi_type . name ) ; key . push ( getId ( type ) ) ; } // now figure out the return type const rtnType = ref . coerceType ( variadic_function_generator . returnType ) ; const rtnName = getId ( rtnType ) ; assert ( rtnName ) ; // first let's generate the key and see if we got a cache-hit key = rtnName + key . join ( '' ) ; let func = cache [ key ] ; if ( func ) { debug ( 'cache hit for key:' , key ) ; } else { // create the `ffi_cif *` instance debug ( 'creating the variadic ffi_cif instance for key:' , key ) ; const cif = CIF_var ( returnType , argTypes , numFixedArgs , abi ) ; func = cache [ key ] = _ForeignFunction ( cif , funcPtr , rtnType , argTypes ) ; } return func ; }
what gets returned is another function that needs to be invoked with the rest of the variadic types that are being invoked from the function.
what gets returned is another function that needs to be invoked with the rest of the variadic types that are being invoked from the function .