C++ Extension to Java template converter
I realized that the majority of the time taken on converting most extensions to java is spent on implementing the jump tables and creating the functions and getting the parameters.
This program takes your C++ MMF2 extension source code folder and generates a template Java file automatically. It does the following for you:
- Creates constants for each condition/action/expression
- Implements getNumberOfConditions()
- Implements the 'action','condition' and 'expression' functions.
- Generates functions for all your conditions, actions and expressions with the same names as in you C++ source code.
- Gets the parameters automatically for you
Here is an example on how it works:
Example main.cpp (simplified for your sake) :D
Generated Java template from the main.cpp file
Here is the program:
ExtensionToJava.exe (Requires .NET 3.5 runtime. You should already have it)
Source code (Visual Studio Project)
EDIT: It now also parses rSDK.
http://click.andersriggelsen.dk/exte...sionToJava.png
Re: C++ Extension to Java template converter
Wonderful! That will help a lot developers to convert their extensions! :D
Re: C++ Extension to Java template converter
Quote:
Originally Posted by Andos
I could expand it to parse rSDK as well if anyone want it.
Please do! :)
Re: C++ Extension to Java template converter
I updated it to also parse the rSDK now. I had no other test-projects than the rSDK template to work with, so please test it on your own rSDK extensions :)
Re: C++ Extension to Java template converter
Re: C++ Extension to Java template converter
I tried it with many rSDK extensions and all of them return unhandled exceptions. :(
This is what it gave me (German...):
Code:
System.NullReferenceException: Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.
bei ExtensionToJava.RsdkProcessor.ParseExtension(FileInfo maincpp)
bei ExtensionToJava.ConverterDialog.toolGenerateTemplate_Click(Object sender, EventArgs e)
bei System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
bei System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
bei System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
bei System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
bei System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
bei System.Windows.Forms.Control.WndProc(Message& m)
bei System.Windows.Forms.ToolStrip.WndProc(Message& m)
bei System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
bei System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Re: C++ Extension to Java template converter
Can you send me your main.cpp file? (maybe just a stripped version of it without the implementation code)
Thanks :)
Re: C++ Extension to Java template converter
I tracked down the problem. Just add some lines of code before the first CONDITION().
Example:
PHP Code:
// ============================================================================
//
// This file contains the actions, conditions and expressions your object uses
//
// ============================================================================
#include "common.h"
int foobar() { //
return 100; // This part will cause the exception
} //
// ============================================================================
//
// CONDITIONS
//
// ============================================================================
CONDITION(
/* ID */ 0,
/* Name */ "%o: %0 == %1",
/* Flags */ EVFLAGS_ALWAYS|EVFLAGS_NOTABLE,
/* Params */ (2,PARAM_NUMBER,"First number",PARAM_NUMBER,"Second number")
) {
int p1=Param(TYPE_INT);
int p2=Param(TYPE_INT);
return p1==p2;
}
Re: C++ Extension to Java template converter
Ah sorry, slight mistake in the parsing grammar. Will fix it soon :)
Re: C++ Extension to Java template converter
Try it again, I fixed the crash + another bug. :-)