MCPcopy Index your code
hub / github.com/node-ffi/node-ffi / variadic_function_generator

Function variadic_function_generator

lib/foreign_function_var.js:50–84  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

48 // what gets returned is another function that needs to be invoked with the rest
49 // of the variadic types that are being invoked from the function.
50 function variadic_function_generator () {
51 debug('variadic_function_generator invoked')
52
53 // first get the types of variadic args we are working with
54 var argTypes = fixedArgTypes.slice()
55 var key = fixedKey.slice()
56
57 for (var i = 0; i < arguments.length; i++) {
58 var type = ref.coerceType(arguments[i])
59 argTypes.push(type)
60
61 var ffi_type = Type(type)
62 assert(ffi_type.name)
63 key.push(getId(type))
64 }
65
66 // now figure out the return type
67 var rtnType = ref.coerceType(variadic_function_generator.returnType)
68 var rtnName = getId(rtnType)
69 assert(rtnName)
70
71 // first let's generate the key and see if we got a cache-hit
72 key = rtnName + key.join('')
73
74 var func = cache[key]
75 if (func) {
76 debug('cache hit for key:', key)
77 } else {
78 // create the `ffi_cif *` instance
79 debug('creating the variadic ffi_cif instance for key:', key)
80 var cif = CIF_var(returnType, argTypes, numFixedArgs, abi)
81 func = cache[key] = _ForeignFunction(cif, funcPtr, rtnType, argTypes)
82 }
83 return func
84 }
85
86 // set the return type. we set it as a property of the function generator to
87 // allow for monkey patching the return value in the very rare case where the

Callers

nothing calls this directly

Calls 3

TypeFunction · 0.85
getIdFunction · 0.85
CIF_varFunction · 0.85

Tested by

no test coverage detected