mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-21 06:45:39 -06:00
Tcc_Demo_Gui: Renaming package
git-svn-id: svn://ultimatepp.org/upp/trunk@1398 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
c99cdd7845
commit
a0e604f291
4 changed files with 0 additions and 113 deletions
|
|
@ -1,10 +0,0 @@
|
|||
LAYOUT(DaysLayout, 584, 452)
|
||||
ITEM(LineEdit, SourceCode, HSizePosZ(8, 8).VSizePosZ(76, 36))
|
||||
ITEM(Button, ButRun, SetLabel(t_("Compile + Run")).RightPosZ(8, 100).BottomPosZ(9, 23))
|
||||
ITEM(Label, dv___2, SetLabel(t_("Just modify source code and push \"Compile + Run\"")).SetFont(StdFont().Bold()).HSizePosZ(8, 8).TopPosZ(8, 19))
|
||||
ITEM(Label, dv___3, SetLabel(t_("Libs path:")).LeftPosZ(8, 68).TopPosZ(52, 19))
|
||||
ITEM(Label, dv___4, SetLabel(t_("Include path:")).LeftPosZ(8, 68).TopPosZ(32, 19))
|
||||
ITEM(EditString, EditLibsPath, SetFrame(ThinInsetFrame()).HSizePosZ(76, 8).TopPosZ(52, 19))
|
||||
ITEM(EditString, EditIncludePath, SetFrame(ThinInsetFrame()).HSizePosZ(76, 8).TopPosZ(32, 19))
|
||||
END_LAYOUT
|
||||
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
description "Tiny C Compiler wrapper Demo\377";
|
||||
|
||||
uses
|
||||
CtrlLib,
|
||||
Tcc;
|
||||
|
||||
file
|
||||
main.cpp,
|
||||
"Tcc Demo Gui.lay";
|
||||
|
||||
mainconfig
|
||||
"" = "GUI";
|
||||
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
#ifndef _Tcc_Demo_Gui_icpp_init_stub
|
||||
#define _Tcc_Demo_Gui_icpp_init_stub
|
||||
#include "CtrlLib/init"
|
||||
#include "Tcc/init"
|
||||
#endif
|
||||
|
|
@ -1,85 +0,0 @@
|
|||
#include <CtrlLib/CtrlLib.h>
|
||||
|
||||
using namespace Upp;
|
||||
|
||||
#define LAYOUTFILE <Tcc Demo Gui/Tcc Demo Gui.lay>
|
||||
#include <CtrlCore/lay.h>
|
||||
|
||||
class Tcc_Demo : public WithDaysLayout<TopWindow> {
|
||||
public:
|
||||
void RunProgram();
|
||||
|
||||
typedef Tcc_Demo CLASSNAME;
|
||||
Tcc_Demo();
|
||||
};
|
||||
|
||||
#include "Tcc/Tcc.h"
|
||||
|
||||
// Function to be called from the tcc program
|
||||
double plus(double a, double b)
|
||||
{
|
||||
return a + b;
|
||||
}
|
||||
|
||||
// Source code
|
||||
char my_program[] =
|
||||
"#include <stdio.h>\n"
|
||||
"#include <math.h>\n"
|
||||
"\n"
|
||||
"double plus(double a, double b); // External function has to be declared\n"
|
||||
"\n"
|
||||
"double pow2(double d)\n"
|
||||
"{\n"
|
||||
" return (d*d);\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"double test(double a, char *str)\n"
|
||||
"{\n"
|
||||
" if (a < 0.)\n"
|
||||
" throw(\"Argument is negative!\");\n"
|
||||
" double ret = 0;\n"
|
||||
" int i;\n"
|
||||
" for (i = 0; i < 10000000; ++i)\n"
|
||||
" ret += 0.000000001*pow2(sqrt(plus(a, 10)));\n"
|
||||
" snprintf(str, 1024, \"The result is %f\", ret);\n"
|
||||
" return ret;\n"
|
||||
"}";
|
||||
|
||||
void Tcc_Demo::RunProgram()
|
||||
{
|
||||
Tcc tcc;
|
||||
|
||||
// Set the right directories here
|
||||
tcc.AddIncludePath(EditIncludePath.GetData().ToString());
|
||||
tcc.AddLibraryPath(EditLibsPath.GetData().ToString());
|
||||
|
||||
try {
|
||||
tcc.Compile(SourceCode.GetData().ToString());
|
||||
|
||||
tcc.AddSymbol("plus", (void *)&plus);
|
||||
tcc.Link();
|
||||
double (*mytest1)(double, char *) = (double (*)(double, char *))tcc.GetSymbol("test");
|
||||
|
||||
char str[1024];
|
||||
double res = mytest1(90, str);
|
||||
PromptOK("\nThe result for Test is " + FormatDouble(res) + ". " + str);
|
||||
} catch(Exc err){
|
||||
Exclamation(DeQtfLf(err));
|
||||
}
|
||||
}
|
||||
|
||||
Tcc_Demo::Tcc_Demo()
|
||||
{
|
||||
CtrlLayout(*this, "Tcc Demo");
|
||||
ButRun.WhenPush = THISBACK(RunProgram);
|
||||
SourceCode.SetData(my_program);
|
||||
EditIncludePath <<= "...put here right path.../Tcc/lib/include"; //c:/desarrollo/aplicaciones/zlibs
|
||||
EditLibsPath <<= "...put here right path.../Tcc/lib/lib";
|
||||
SourceCode.SetFont(Courier(12));
|
||||
Sizeable();
|
||||
}
|
||||
|
||||
GUI_APP_MAIN
|
||||
{
|
||||
Tcc_Demo().Run();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue