Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.85 KB | None | 0 0
  1. C part :
  2.  
  3. mongo_connection_options * make_mongo_connection_options( char host[255], int port ){
  4.         mongo_connection_options *opts = malloc(sizeof(mongo_connection_options));
  5.         strcpy( opts->host , host );
  6.         opts->port = port;
  7.         return opts;
  8. }
  9.  
  10.  
  11. Perl6 part:
  12.  
  13. use NativeCall;
  14.  
  15. sub mongo_connect( OpaquePointer $client, OpaquePointer $options)
  16.     returns OpaquePointer
  17.     is native('libmongoc')
  18.   { ... }
  19.  
  20. sub make_mongo_connection_options( Str $host, Int $port )
  21.     returns OpaquePointer
  22.     is native('libmongoc')
  23.   { ... }
  24.  
  25. my OpaquePointer $connection;
  26. my $options = make_mongo_connection_options('localhost', 27017);
  27. my $answer = mongo_connect($connection,$options);
  28. 'done'.say;
  29.  
  30.  
  31. The problem is $options becomes a UnManagedStruct , and passing it to mongo_connect does not work ( no connection, silent fail )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement