Re: How to inject code at the top and bottom of each method generated in cpp wrap file by SWIG?

Jim <[email protected]> Tue, 25 Apr 2023 10:29:44 +0800 (CST)
Newsgroups gmane.comp.programming.swig
Message-ID <[email protected]>


Hi Prajjwal,
 You can try this :


%typemap(ret) SWIGTYPE {
 //inject-1
} 


%typemap(ret) SWIGTYPE & {
 //inject-2
}


%typemap(ret) SWIGTYPE * {
 //inject-3
}


%typemap(check) SWIGTYPE * {
  //inject-4
}


%typemap(check) SWIGTYPE  {
  //inject-5
}



Note: keyword SWIGTYPE math any type(eg int\long\bool\T)。SWIGTYPE & match any reference type (eg. int & \ long & \ bool& \ T&)。 You can add different typemap according to your function type as needed。










At 2023-04-25 05:27:05, "prajjwal prem" <[email protected]> wrote:

Hi All,


How to inject code at the top and bottom of each method generated in cpp wrap file by SWIG?



For Example:

SWIGEXPORT int SWIGSTDCALL CSharp_swig_generated_method___(void *jarg1)

  {

    int jresult;    //SWIG generated

 

    // inject code here like mutex begin

 

    /*

        SWIG generated code

    */

 

    jresult = result;

 

    // inject code here like mutex end

 

    return jresult;

  }




Best regards,

Prajjwal

_______________________________________________
Swig-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/swig-user