language-interoperability

How to call java objects and functions from CPython?

半城伤御伤魂 提交于 2019-11-27 11:46:58
问题 I have a python program, which runs on the CPython implementation, and inside it I must call a function defined in a java program. How can I do this? It would be nice to be able to use some java objects too. Jython is not an option. I must run the python part in CPython. 回答1: The easiest thing to do is Write a trivial CLI for your java "function". (There's no such thing, so I'll assume you actually mean a method function of a Java class.) public class ExposeAMethod { public static void main(

What is marshalling? What is happening when something is “marshalled?”

别等时光非礼了梦想. 提交于 2019-11-27 09:18:58
问题 I know this question has been asked, at least here. But there wasn't a satisfactory answer, at least not to me. There is a lot of talk about marshalling as regards interoperating with unmanaged code, but what about marshalling from one thread to another, as we have to do in .NET sometimes. This makes me ask, what is marshalling, really? When you give a definition of marshalling, how would you define it so that it is explaining the case of interoperability, as well as the cases where you are

How do multiple languages interact in one project?

a 夏天 提交于 2019-11-26 22:28:58
问题 I heard some people program in multiple languages in one project. I can't imagine how the languages interact with each other. I mean there is no Java method like myProgram.callCfunction(parameters); never happens or am I wrong? 回答1: Having multiple languages in one project is actually quite common, however the principles behind are not always simple. In the simple case, different languages are compiled to the same code. For example, C and C++ code typically is compiled into machine assembler

What issues can I expect compiling C code with a C++ compiler?

纵饮孤独 提交于 2019-11-26 17:37:17
If you take an existing C code base and compile it with a C++ compiler, what sort of issues can you expect to crop up? For example, I think that assigning an integer to an value with an enumerated type will fail in C++, whereas it's legal (if a bit nasty) in C. If I don't wrap all my C files in extern C { ... } , am I going to get name-mangling where I least expect it? Is there some reason why I really shouldn't do this? For background, we have a very large code-base written in C. For a few years we've been jumping through hoops to do things that would come naturally via C++ ( homebrewe

Use C++ with Cocoa Instead of Objective-C?

牧云@^-^@ 提交于 2019-11-26 15:36:28
I would like to write applications that use C++ and the Cocoa frameworks because Apple is not making Carbon 64-bit capable. C++ seems to be pretty vanilla in its implementation on Linux and Windows but on Mac OS X it seems like additional Apple specific pieces of code are required (like an Obj-C wrapper). It also seems that Apple is forcing developers to write in Objective-C rather than C++, although I could be wrong. I am trying to find a path to write code on the Mac that would be easy to keep cross platform. Having to write code in C++ for Linux/Windows and then rewrite large portions in

How to pass an array of Swift strings to a C function taking a char ** parameter

末鹿安然 提交于 2019-11-26 14:46:41
I'm trying to interact with an old C terminal app from Swift. I've successfully integrated the source code and bridged the headers from C to Swift. The code compiles and runs from Xcode 6.3 beta. I've renamed the terminal app's main entry point to: int initialize(int argc, char **argv); Nevertheless, I'm struggling to pass the arguments from Swift to this C function. My challenge is to convert the arguments in the right format. Typical input from Swift would look like: let args = ["-c", "1.2.3.4", "-p", "8000"] I've tried messing with "cStringUsingEncoding(NSUTF8StringEncoding)" and

What issues can I expect compiling C code with a C++ compiler?

我们两清 提交于 2019-11-26 05:29:49
问题 If you take an existing C code base and compile it with a C++ compiler, what sort of issues can you expect to crop up? For example, I think that assigning an integer to an value with an enumerated type will fail in C++, whereas it\'s legal (if a bit nasty) in C. If I don\'t wrap all my C files in extern C { ... } , am I going to get name-mangling where I least expect it? Is there some reason why I really shouldn\'t do this? For background, we have a very large code-base written in C. For a

Use C++ with Cocoa Instead of Objective-C?

时光总嘲笑我的痴心妄想 提交于 2019-11-26 04:30:02
问题 I would like to write applications that use C++ and the Cocoa frameworks because Apple is not making Carbon 64-bit capable. C++ seems to be pretty vanilla in its implementation on Linux and Windows but on Mac OS X it seems like additional Apple specific pieces of code are required (like an Obj-C wrapper). It also seems that Apple is forcing developers to write in Objective-C rather than C++, although I could be wrong. I am trying to find a path to write code on the Mac that would be easy to

Call Python function from MATLAB

此生再无相见时 提交于 2019-11-26 02:17:01
问题 I need to call a Python function from MATLAB. how can I do this? 回答1: I had a similar requirement on my system and this was my solution: In MATLAB there is a function called perl.m, which allows you to call perl scripts from MATLAB. Depending on which version you are using it will be located somewhere like C:\Program Files\MATLAB\R2008a\toolbox\matlab\general\perl.m Create a copy called python.m, a quick search and replace of perl with python, double check the command path it sets up to point

How to show loading spinner in jQuery?

久未见 提交于 2019-11-25 21:52:38
问题 In Prototype I can show a \"loading...\" image with this code: var myAjax = new Ajax.Request( url, {method: \'get\', parameters: pars, onLoading: showLoad, onComplete: showResponse} ); function showLoad () { ... } In jQuery , I can load a server page into an element with this: $(\'#message\').load(\'index.php?pg=ajaxFlashcard\'); but how do I attach a loading spinner to this command as I did in Prototype? 回答1: There are a couple of ways. My preferred way is to attach a function to the