Socket
Socket
Sign inDemoInstall

cbind

Package Overview
Dependencies
20
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.5 to 0.0.8

tests/clib.cc

15

index.js

@@ -61,6 +61,2 @@ var fs = require('fs');

console.log = console.warn;

@@ -84,2 +80,4 @@

console.log("Process type ident", typeIdent);
if(existingProcessedTypes[typeIdent]) {

@@ -105,3 +103,10 @@ console.log("Skipping due to already existing");

function processFunction(func) {
processType(func);
if(func.type.functionPointer) {
console.log("Processing return function pointer type", func.type);
processFunction(func.type);
console.log("End of processing return function pointer type");
}
else {
processType(func);
}
if(func.parameters) {

@@ -108,0 +113,0 @@ func.parameters.forEach(function(parameter) {

{
"name": "cbind",
"version": "0.0.5",
"version": "0.0.8",
"description": "Streamlined C/C++ v8 bindings generator for Node.JS inspired by tolua++ (requires C++11)",

@@ -16,3 +16,3 @@ "main": "index.js",

"nan": "1.0.0",
"nid-parser": "0.0.4",
"nid-parser": "0.0.5",
"pegjs": "~0.8.0"

@@ -19,0 +19,0 @@ },

@@ -46,3 +46,24 @@ node-![cbind](https://raw.githubusercontent.com/CodeCharmLtd/node-cbind/master/cbind.png)

<a name="complex_weird_cases_function_pointer_handling">
## Complex weird cases function pointer handling
Consider this definition (valid C!! - also valid NID):
```c++
void (*catch_and_return(void (*callback)(char* a, char* b, int* c), char *name_one, char* name_two, int* number))(char* a, char * b, int c);
```
Do you know what it does? Actually it is a declaration of function taking 4 arguments:
* `callback` - pointer to function `void(char* a, char* b, int* c)`
* `name_one` - string
* `name_two` - string
* `number` - pointer to number
This function returns another function pointer `void(char* a, char* b, int)`
It turns out cbind can generate bindings for this that fully work:
```js
bindings.catch_and_return(function(a, b, c) {
console.log(a, b, cBind.derefInt(c));
}, "str1", "str2", cBind.createInt(30))("FINAL", "TEST", 44);
```
## Supported and tested features

@@ -66,4 +87,5 @@

## Planned features
## Planned features / Not supported yet
* Function overloading.
* Attributes for calling native code asynchronously and returning values as promises (bluebird).

@@ -70,0 +92,0 @@ * Attributes for automatically handling native callbacks that have returned from a separate thread.

@@ -24,6 +24,6 @@

callCounter: 'number',
_doubleFunction: 'function',
_floatFunction: 'function',
_intFunction: 'function',
_voidFunction: 'function',
doubleFunction: 'function',
floatFunction: 'function',
intFunction: 'function',
voidFunction: 'function',
cStringFunction: 'function',

@@ -69,14 +69,14 @@ stdStringFunction: 'function',

it('should call void()', function() {
functions._voidFunction();
functions.voidFunction();
});
it('should call int()', function() {
functions._intFunction().should.equal(42);
functions.intFunction().should.equal(42);
});
it('should call float()', function() {
functions._floatFunction().should.equal(42);
functions.floatFunction().should.equal(42);
});
it('should call double()', function() {
functions._doubleFunction().should.equal(42);
functions.doubleFunction().should.equal(42);
});

@@ -83,0 +83,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc