code-translation

How to convert C++ Code to C [closed]

自作多情 提交于 2019-12-27 10:39:18
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed last year . I have some C++ code. In the code there are many classes defined, their member functions, constructors, destructors for those classes, few template classes and lots of C++ stuff. Now I need to convert the source to plain C code. I the have following questions: Is there any tool to convert C++ code and header files

Convert C# to VB,NET: Event with a delegate type that has a return type

感情迁移 提交于 2019-12-25 08:59:23
问题 This is the original source-code written in C# public delegate Unit UnitResolveEventHandler(object sender, ResolveEventArgs args); public event UnitResolveEventHandler UnitResolve; public static Unit GetUnitByName(string name) { Instance.unitsByName.TryGetValue(name, out result); if (Instance.UnitResolve != null) { foreach (UnitResolveEventHandler handler in Instance.UnitResolve.GetInvocationList()) { result = handler(Instance, new ResolveEventArgs(name)); } } } Using an online translator, I

Translate MSDN example from C# to C++/CLI

大城市里の小女人 提交于 2019-12-24 09:58:55
问题 this is a code sample from Microsoft(MSDN) (build sql dependency application) , could you please help me translate this code from c# into C++/CLI, I've been trying I, but I'm not really good in c++. private void dependency_OnChange( object sender, SqlNotificationEventArgs e) { // This event will occur on a thread pool thread. // Updating the UI from a worker thread is not permitted. // The following code checks to see if it is safe to // update the UI. ISynchronizeInvoke i =

Equivalent of (IntPtr)1 in VBNET?

流过昼夜 提交于 2019-12-22 06:59:39
问题 I've taken a piece of code from a @Hans Passant code from here: Bold text in MessageBox this is the C# code: SendMessage(hText, WM_SETFONT, mFont.ToHfont(), (IntPtr)1) Which would be the translation into vb.net? This will not work (cant be compiled): SendMessage(hText, WM_SETFONT, mFont.ToHfont(), DirectCast(1, IntPtr)) 回答1: Try this: SendMessage(hText, WM_SETFONT, mFont.ToHfont(), New IntPtr(1)) 来源: https://stackoverflow.com/questions/19283287/equivalent-of-intptr1-in-vbnet

How do I start writing a transpiler? Is it even possible?

北战南征 提交于 2019-12-20 08:55:44
问题 Due to confidentiality reasons, I might not be able to describe in pin point details but here is the scenario. Various devices that have streaming apps have different languages with different apis, though they accomplish the same thing. So, when you want to write a streaming app for one platform, you have to start from scratch while copying the same app for other platform, which is writing redundant logic. I want to design a transpiler, that takes code in one language, and produces code for

How do I start writing a transpiler? Is it even possible?

霸气de小男生 提交于 2019-12-20 08:55:15
问题 Due to confidentiality reasons, I might not be able to describe in pin point details but here is the scenario. Various devices that have streaming apps have different languages with different apis, though they accomplish the same thing. So, when you want to write a streaming app for one platform, you have to start from scratch while copying the same app for other platform, which is writing redundant logic. I want to design a transpiler, that takes code in one language, and produces code for

C99 printf formatters vs C++11 user-defined-literals

允我心安 提交于 2019-12-18 12:47:50
问题 This code: #define __STDC_FORMAT_MACROS #include <inttypes.h> #include <stdio.h> #include <stdlib.h> #include <stdint.h> int main(int argc,char **argv) { uint64_t val=1234567890; printf("%"PRId64"\n",val); exit(0); } Works for C99, C++03, C++11 according to GCC 4.5, but fails on C++11 according to GCC 4.7.1. Adding a space before PRId64 lets GCC 4.7.1 compile it. Which one is correct? 回答1: gcc 4.7.1 is correct. According to the standard, c++11 2.2 Phases of translation [lex.phases] 1 - The

Java code transform at compile time

大兔子大兔子 提交于 2019-12-18 10:57:17
问题 I would like to transform java source code at compile time just before passing the source code to the compiler. In other word I would like to create a preprocessor able to transform "bla bla bla" into any other code such as: new MyClass("bla", 3) My actual motivation is to do string encryption, as explained here Some people suggest writing custom annotation processors but as far as I understand annotations: they can be used to generate new class file, but not to transform existing code before

Java code transform at compile time

只谈情不闲聊 提交于 2019-12-18 10:57:15
问题 I would like to transform java source code at compile time just before passing the source code to the compiler. In other word I would like to create a preprocessor able to transform "bla bla bla" into any other code such as: new MyClass("bla", 3) My actual motivation is to do string encryption, as explained here Some people suggest writing custom annotation processors but as far as I understand annotations: they can be used to generate new class file, but not to transform existing code before

Conversion from JavaScript to Python code? [closed]

Deadly 提交于 2019-12-18 10:46:18
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 years ago . Is there a relatively quick program out there to accomplish at least the basics of this? Just a few regexes? I'm willing to do some manual conversion, but this is a pretty big set of scripts. 回答1: Updated Now several (4) years later this (almost certainly) can be done; though certainly not with RegEx. I suggest