cross-language

Wrapping C create and destroy functions using a smart pointer

♀尐吖头ヾ 提交于 2020-02-26 09:55:12
问题 I have some C API that handles object creation and destruction, it provides: createObject(...) and destroy(...) . I want to wrap it into some more modern construction/destruction mechanisms and use them with smart pointers. I am afraid that at some point I will forget to destroy the object, or some exception will occur. I am aware of custom deleter function for shared_ptr , but I can't explicitly call new , because createOjbect function handles initialization. Can I use STL smart pointers in

How can I throw an NSError from a Swift class and catch it in an Objective-C class?

北城余情 提交于 2020-01-24 22:11:49
问题 I need to implement a try-catch structure in Objective-C to handle Swift thrown NSErrors. I've written an NetService manager with Swift code and I am implementing it on an already existent Objective-C UI. However, whenever I throw an error from my Swift class, the try-catch structure fails to catch the error and proceeds to the finally block. Swift error definition: enum NEONetServiceErrors: Int { case requestMadeWithoutIp } struct NEONetServiceErrorStrings { let requestMadeWithoutIp = [

How can I throw an NSError from a Swift class and catch it in an Objective-C class?

我的未来我决定 提交于 2020-01-24 22:11:31
问题 I need to implement a try-catch structure in Objective-C to handle Swift thrown NSErrors. I've written an NetService manager with Swift code and I am implementing it on an already existent Objective-C UI. However, whenever I throw an error from my Swift class, the try-catch structure fails to catch the error and proceeds to the finally block. Swift error definition: enum NEONetServiceErrors: Int { case requestMadeWithoutIp } struct NEONetServiceErrorStrings { let requestMadeWithoutIp = [

Can you call Ada functions from C++?

邮差的信 提交于 2019-12-21 14:37:24
问题 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++? 回答1: 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. 回答2: Here's an example using g++/gnatmake 5.3.0: NOTE: Be careful when passing data between C++ and Ada

Flex — C++ connection?

こ雲淡風輕ζ 提交于 2019-12-11 07:15:11
问题 How do I connect a Flex Application( Internet Site ) and C++ togehter ? a minimalistic example from what i mean (User Story): Frank goes to www.myflexsite.de there are 2 textboxes and 1 Button( Label = add two numbers) . He inserts 2 in the first textbox and 5 in the ohter. Now he clicks on the add button. The Backend : We have a add.cpp file where an add method is defined : int add(int a, int b ) ... After Frank clicked on the "add two numbers" Button the add-method in the C++ file is called

Blending languages - Python and Objective-C

拈花ヽ惹草 提交于 2019-12-11 00:27:18
问题 I know Objective-C++ can exist because Objective-C and C++ share common ground in C. But how can Objective-C coexist with Python? I know it must be possible because wxPython uses Cocoa to draw interfaces. I'm writing a card game engine for OS X. It will be able to play more than one game (Klondike, Spider, Free Cell, maybe even Hearts or Poker). It's going to work with Game Center, so I need to have the Cocoa framework available, but I'd like to write a Python API, so I can write the games

What is a Cobol 88-type equivalent in another languages?

陌路散爱 提交于 2019-12-10 15:46:48
问题 I'm learning COBOL now and really liking the 88-type of variables, and I want to know if there are anything like them in another languages (most known languages also, such as C, Objective-C), even using a library. The only thing I can think being similar is using #define booleanResult (variableName==95) But it isn't possible to set boolenResult to true and make variableName assume 95 as value. 回答1: 05 nicely-named-data PIC X. 88 a-meangingful-condition VALUE "A". 88 another-meaingingful

How to compare different language String values in JAVA?

妖精的绣舞 提交于 2019-12-10 11:41:33
问题 In my web application I am using two different Languages namely English and Arabic . I have a search box in my web application in which if we search by name or part of the name then it will retrieve the values from DB by comparing the "Hometown" of the user Explanation: Like if a user belongs to hometown "California" and he searches a name say "Victor" then my query will first see the people who are having the same hometown "California" and in the list of people who have "California" as