logo
Tags down

shadow

Callback from C++ to C# using SWIG


By : Bouzoul Ferial
Date : September 15 2020, 02:00 PM
I hope this helps you . I got an answer for the above query and I am posting it here. You can also refer to this Link
After changing the SWIG interface code as below, it worked for me
code :
%module (directors="1") CppTestApp


%{
    #include "TestClass.h"

    #include "TestDataClass.h"
%}


 %include <windows.i>
 %include <std_string.i>

%feature("director") EventHandlerBase;

%include "TestClass.h"
%include "TestDataClass.h"
class MyEventHandler : EventHandlerBase
    {

        public override void handle()
        {
            System.Console.WriteLine("handling event...");
        }
    }


Share : facebook icon twitter icon

SWIG C++ bindings with callback


By : user2481304
Date : March 29 2020, 07:55 AM
this one helps. There is a way using the directors feature. Enable it for your KinectListener proxy, one line of code :
code :
%feature("director") KinectListener

Calling a Go callback function from C++ through SWIG


By : Katie K
Date : March 29 2020, 07:55 AM
wish help you to fix your issue Success! I have a solution that works:
The idea of what I did, is to wrap the callback with "directors", and "return" the Go function pointer back to Go, so it could be run in that context.
code :
class Callback {
 public:
  virtual void Run(void(*f)(void)) = 0;
  virtual ~Callback() {}
};

Callback* GlobalCallback;

void TestFunc(void(*f)(void)) {
  GlobalCallback->Run(f);
}
%{
#include "test.h"
%}

%module(directors="1") Callback
%feature("director");

%typemap(gotype) FUNC* "func()"
%typemap(in) FUNC* {
  $1 = (void(*)(void))$input;
}
%apply FUNC* { void(*)(void) };

%include "test.h"

%insert(go_wrapper) %{
type go_callback struct { }

func (c* go_callback) Run(f func()) {
  f()
}

func init() {
  SetGlobalCallback(NewDirectorCallback(&go_callback{}))                                                                                                     
}
%}

Tcl callback from C/C++ with SWIG


By : user6349124
Date : March 29 2020, 07:55 AM
wish of those help Understand in all this that Tcl's implementation is very much a C library, and so has C ways of doing things, not C++ ones. This might make
What you want is to put the C++ closure as a field in a struct that you allocate with new. You then cast the pointer to that struct as the ClientData argument to Tcl_CreateCommand; when the command is invoked, you'll get that pointer back as one of the arguments to the callback function, which you can then cast back to its real type and then invoke. When the command is deleted, you get another callback (if you ask for it) and that is a great time to delete the allocated struct. It sounds like a lot of work, but isn't actually.

Callback to SWIG class C++ to Java


By : Trọng Quyết
Date : March 29 2020, 07:55 AM
Hope this helps Java part of SWIG use callbacks wrapping named directors: http://www.swig.org/Doc2.0/Java.html#java_directors
interface file will be something like:
code :
%module(directors="1") modulename
%{
   #include "binded.h"
%}
%feature("director") callback;
%include "binded.h"

SWIG Callback with Output Parameters


By : user2022001
Date : March 29 2020, 07:55 AM
will be helpful for those in need The cpointer.i solution worked for me. You'd have to show a minimal, complete, verifiable example to fix your crash. I just changed the following files:
CPP.i:
code :
%module(directors="1") CPP
%{
#include "CPP.h"
%}
%feature("director") MyOp;
%include "cpointer.i"
%pointer_functions(int, intp);
%include "CPP.h"
import CPP
class PyOp(CPP.MyOp):
    def SetVal(self, val):
        i = CPP.intp_value(val)
        i += 2
        CPP.intp_assign(val,i)
print(CPP.Runner(PyOp()))
C:\>run
3
Related Posts Related Posts :
  • Not all code paths return a value, how do I solve this?
  • How to solve the Proxy Server 407 error in .NET.CORE
  • Why doesn't [EnableCors("*", "*", "*")] allow all requests?
  • Ef core 3.0 gives error when inserting record 'The property 'Id' on entity type 'ChannelTypeT' could not be found'
  • How can I get access to the IWebHostEnvironment from within an ASP.NET Core 3 controller?
  • I have exported my data from grivdview to excel file now I want to save it directly on desktop through code how can I do
  • creating a method to find the sum of first and last Queue members
  • Dynamic connection string database c#
  • Open XML - find and replace multiple placeholders in document template
  • Name a complex type
  • Negating a Task<bool> without await?
  • Saving XML file “on the fly” in c#
  • C# - Async method in SELECT LINQ operation
  • Entity Framework : ChangeTracker loads all my table elements
  • Access public method from another namespace in Unity
  • My LIST of customers gets populated but will not display in my Foreach loop in Server Side Blazor
  • c# delete multiple data from database at once
  • Running a method forever while running other methods
  • How to tell Application to read <runtime> from my custom app.config file instead of from default one
  • System.TypeLoadException occurred when i try to compile
  • How to create class variable name dynamically in C#
  • How to deal with a massive amount of conditions
  • How to create complex dynamic queries in EF Core 3.1 after breaking changes?
  • WCF inactivityTimeout
  • How to get the digits before some particular word using regex in c#?
  • When other controls is placed inside datagrid column it is not binding
  • Connect to a SQL Server database in WPF C# (.exe) application from any PC
  • Get instance of singleton service in startup
  • Access controls located on the main form when the child form closes
  • C# Regex to match single number among multiple numbers in a string
  • C# regex string that is not another string
  • Pass Image object as a parameter from C# to Python
  • C# winform Two timers access same variable
  • What type of collection should be returned from EFCore 3.1 in WebAPI?
  • Don't repeat return values in C#8 switch syntax
  • How to speed up this LINQ query with join?
  • What is the best way to pass between scenes?
  • How do i play an animation on a button press
  • winform will Timer.timer create an new thread?
  • How to call async lamba expression with LINQ Select?
  • How to link IObservable and IObserver in C#?
  • How to leverage dynamic programming inside of a Linq Where clause?
  • Handling SQL Server errors separately from other types of exceptions
  • Proper way to update the list of records in table using entity framework
  • chunk file into pieces
  • why I can't get txtBox2.Text and txtBox3.Text value?
  • How can I use one function, which belongs to two objects, for only one objects?
  • I want string to contain specific charachers
  • multiply chars from array in C#
  • Load file as byte array with no allocate it in memory C#
  • how to make Wait until all threads finished it's work from threadpool in c#
  • How to: Project Architecture for Unity3D or Spaghetti code?
  • How to catch expander header button click event
  • How do you return 2 variables in C#/csharp?
  • can i update the private static dateTime each time the task runs (C# - quartz-scheduler)
  • C# string.this int ' cannot be assigned to (it is read-only) REPLACE
  • Refresh List<> Binding Spinner MVVM Xamarin
  • xUnit class constructor should get arguments passed from theory test methods
  • Update textbox when I do an operation c#
  • Why output is 6 instead of other numbers?
  • shadow
    Privacy Policy - Terms - Contact Us © 35dp-dentalpractice.co.uk