cross-language

Allowing a method to lock its parent Object in Java

允我心安 提交于 2019-12-09 13:23:19
问题 Is there a way in Java to get a method to lock (mutex) the object which it is in? I know this sounds confusing but basically I wan't an equivelent to this snippet of C# but in Java. lock(this) { // Some code here... } I've been tasked with reimplementing an API written in .Net into Java, and I've been asked to keep the Java version as similar to the .Net version as humanly possible. This isn't helped by the fact that the .Net version looked like it was transcribed from a C++ version which I

Can you call Ada functions from C++?

这一生的挚爱 提交于 2019-12-04 08:41:43
I'm a complete Ada newbie, though I've used Pascal for 2-3 years during HS. IIRC, it is possible to call Pascal compiled functions from C/C++. Is it possible to call procedures & functions written in Ada from C++? VonC According to this old tutorial , it should be possible. However, as illustrated by this thread , you must be careful with the c++ extern "C" definitions of your Ada functions. Here's an example using g++/gnatmake 5.3.0: NOTE: Be careful when passing data between C++ and Ada ada_pkg.ads package Ada_Pkg is procedure DoSomething (Number : in Integer); pragma Export (C, DoSomething,

Allowing a method to lock its parent Object in Java

和自甴很熟 提交于 2019-12-03 16:17:41
Is there a way in Java to get a method to lock (mutex) the object which it is in? I know this sounds confusing but basically I wan't an equivelent to this snippet of C# but in Java. lock(this) { // Some code here... } I've been tasked with reimplementing an API written in .Net into Java, and I've been asked to keep the Java version as similar to the .Net version as humanly possible. This isn't helped by the fact that the .Net version looked like it was transcribed from a C++ version which I don't have access to. Anyway the above line appears in the C# version and I need something that does the

Add pointer to defined Objective-C class in .h file of Objective-C++

夙愿已清 提交于 2019-12-02 08:08:49
问题 Is possible to create class in Objective-C++ which has field that is a pointer to an Objective-C interface ( inside the .h file ) ? To clarify a little, I created one Objective-C interface: // Our platform independent class @interface LoggerDelegate : NSObject<SomeDelegate> @end I can create it inside .mm file and it works but it is meant for a global variable and I am not allowed to change its scope. So I would like to use it inside Logger.h : class Logger { public: private: LoggerDelegate*

Add pointer to defined Objective-C class in .h file of Objective-C++

半世苍凉 提交于 2019-12-02 07:16:10
Is possible to create class in Objective-C++ which has field that is a pointer to an Objective-C interface ( inside the .h file ) ? To clarify a little, I created one Objective-C interface: // Our platform independent class @interface LoggerDelegate : NSObject<SomeDelegate> @end I can create it inside .mm file and it works but it is meant for a global variable and I am not allowed to change its scope. So I would like to use it inside Logger.h : class Logger { public: private: LoggerDelegate* _ptr; //<--- pointer to the Objective-C interface }; When I define my interface inside Logger.mm it

Why does the Python/C API crash on PyRun_SimpleFile?

落花浮王杯 提交于 2019-11-29 01:36:38
I've been experimenting with embedding different scripting languages in a C++ application, currently I'm trying Stackless Python 3.1. I've tried several tutorials and examples, what few I can find, to try and run a simple script from an application. Py_Initialize(); FILE* PythonScriptFile = fopen("Python Scripts/Test.py", "r"); if(PythonScriptFile) { PyRun_SimpleFile(PythonScriptFile, "Python Scripts/Test.py"); fclose(PythonScriptFile); } Py_Finalize(); For some odd reason, running this piece of code results in an access violation at: PyRun_SimpleFile(PythonScriptFile, "Python Scripts/Test.py"

Why does the Python/C API crash on PyRun_SimpleFile?

五迷三道 提交于 2019-11-27 16:08:05
问题 I've been experimenting with embedding different scripting languages in a C++ application, currently I'm trying Stackless Python 3.1. I've tried several tutorials and examples, what few I can find, to try and run a simple script from an application. Py_Initialize(); FILE* PythonScriptFile = fopen("Python Scripts/Test.py", "r"); if(PythonScriptFile) { PyRun_SimpleFile(PythonScriptFile, "Python Scripts/Test.py"); fclose(PythonScriptFile); } Py_Finalize(); For some odd reason, running this piece

Instantiating a python class in C#

谁说我不能喝 提交于 2019-11-26 21:27:22
I've written a class in python that I want to wrap into a .net assembly via IronPython and instantiate in a C# application. I've migrated the class to IronPython, created a library assembly and referenced it. Now, how do I actually get an instance of that class? The class looks (partially) like this: class PokerCard: "A card for playing poker, immutable and unique." def __init__(self, cardName): The test stub I wrote in C# is: using System; namespace pokerapp { class Program { static void Main(string[] args) { var card = new PokerCard(); // I also tried new PokerCard("Ah") Console.WriteLine

Instantiating a python class in C#

怎甘沉沦 提交于 2019-11-26 09:06:23
问题 I\'ve written a class in python that I want to wrap into a .net assembly via IronPython and instantiate in a C# application. I\'ve migrated the class to IronPython, created a library assembly and referenced it. Now, how do I actually get an instance of that class? The class looks (partially) like this: class PokerCard: \"A card for playing poker, immutable and unique.\" def __init__(self, cardName): The test stub I wrote in C# is: using System; namespace pokerapp { class Program { static void

How to unserialize PHP Serialized array/variable/class and return suitable object in C#

萝らか妹 提交于 2019-11-26 06:08:34
问题 The goal is to unserialize a PHP serialized string and get sutable object in C# Is there any way to make this possible in C#(.Net)? To be more specific: We need to make an application which comunicates (Via HTTP) to specific website which returns the needed information. Fortunately/unfortunately we dont have permission to website so the data (array mostly) that is returned from website is PHP serialized. 回答1: Found solution: Sharp Serialization Library 回答2: I suppose using JSON as an