Click here to Skip to main content
15,896,912 members

Comments by shahab96 (Top 6 by date)

shahab96 9-Dec-14 7:22am View    
Oh alright, thanks a lot!
shahab96 9-Dec-14 7:12am View    
Yes but that is what receives the string from the python script. What I am confused about is how to actually return the string from the script, as in Python you can't use a return statement outside a function and the way a script is handled is by using the lines

if __name__ == __main__:
<insert code="" here="">

and the return statement can't be used there.
shahab96 10-Jul-11 4:23am View    
Oops...i think the code tags made my includs invisible. I've included

1) windows.h
2) conio.h
3) cstdlib
4) iostream

and no the cstdlib and iostream includes are not followed by .h in my code either.
shahab96 10-Jul-11 4:19am View    
Yes i have and i think maybe posting my code will help.

This is the .dll project files.

GoCompile.h

#ifdef UNICODE
#undef UNICODE
#endif

#include <windows.h>
#include <conio.h>
#include <cstdlib>
#include <iostream>

using std::cout;
using std::cerr;
using std::endl;

#include <string>

using std::string;

string command;

extern "C" __declspec(dllexport) int _cdecl Compile(int argc, char* argv[]);
int getParametersForCompile(int argc, char* argv[]);
int getParametersForLinking(int argc, char* argv[]);


GoCompile.cpp

#include "GoCompile.h"

#define CLS system("cls")
#define getch() (option = _getch())

char option;

extern "C" __declspec(dllexport) int _cdecl Compile(int argc, char* argv[])
{
if(argc < 2)
{
cerr << "Invalid number of arguments." << endl;
return EXIT_FAILURE;
}
command = "8g ";
if(getParametersForCompile(argc, argv) & EXIT_FAILURE)
return EXIT_FAILURE;
if(getParametersForLinking(argc, argv) & EXIT_FAILURE)
return EXIT_FAILURE;
return EXIT_SUCCESS;
}

int getParametersForCompile(int argc, char* argv[])
{
cout << "Would you like to include packages from a specific directory? <y\n>" << endl;
if(getch() == 'y')
{
char directory[50];
cout << "Please enter the directory." << endl;
std::cin.getline(directory, 50);
command.append("-I ").append(directory).append(" ");
}
CLS;
cout << "Would you like to have the compiler print declarations? <y\n>" << endl;
if(getch() == 'y')
command.append("-d ");
CLS;
cout << "Would you like to have the compiler remove limits on errors printed? <y\n>" << endl;
if(getch() == 'y')
command.append("-e ");
CLS;
cout << "Would you like to have the compiler print the stack frame structure? <y\n>" << endl;
if(getch() == 'y')
command.append("-f ");
CLS;
cout << "Would you like the compile to panic on error? <y\n>" << endl;
if(getch() == 'y')
command.append("-h ");
CLS;
cout << "Would you like to specify the package name? <y\n>" << endl;
if(getch() == 'y')
{
char name[50];
cout << "Please enter the package name." << endl;
std::cin.getline(name, 50);
command.append("-k ").append(name).append(" ");
}
CLS;
cout << "Would you like to specify the name of the output file? <y\n>" << endl;
if(getch() == 'y')
{
char output[50];
cout << "Please enter the output file name. (Including extention)" << endl;
std::cin.getline(output, 50);
command.append("-o ").append(output).append(" ");
}
CLS;
cout << "Would you like the compiler to print the assembly language? <y\n>" << endl;
if(getch() == 'y')
command.append("-S ");
CLS;
cout << "Would you like the compiler to print the parse tree? <y\n>" << endl;
if(getch() == 'y')
command.append("-w ");
CLS;
cout << "Would you like the compiler to print lex tokens? <y\n>" << endl;
if(getch() == 'y')
command.append("-x ");
CLS;
string command_temp;
for(short i = 1;i < argc;i++)
{
command_temp = command;
if(system(command_temp.append(argv[i]).append(".go").c_str()) == 0)
continue;
else return EXIT_FAILURE;
}
cout << "Press any key to link files." << endl;
_getch();
return EXIT_SUCCESS;
}

int getParametersForLinking(int argc, char* argv[])
{
CLS;
cout << "Would you like to specify a name for the executable? <y\n>" << endl;
command = "8l ";
string command_temp;
if(getch() =='y')
{
char name[50];
cout << "Please enter the executable name" << endl;
std::cin.getline(name, 50);
command.append("-o ").append(name).append(" ");
}
for(short i = 1;i < argc;i++)
{
command_temp = command;
if(system(command_temp.append(argv[i]).append(".8").c_str()) == 0)
continue;
else return EXIT_FAILURE;
}
cout << "Linking Succesful. Press any key to end session" << endl;
_getch();
return EXIT_SUCCESS;
}
shahab96 10-Jul-11 4:16am View    
Deleted
Yes I have actually.... I'm posting up my code for anyone who can help.

GoCompile.h
<pre>
#ifdef UNICODE
#undef UNICODE
#endif
#include <windows.h>
#include <conio.h>
#include <cstdlib>
#include <iostream>
using std::cout;
using std::cerr;
using std::endl;
#include <string>
using std::string;
string command;
extern "C" __declspec(dllexport) int _cdecl Compile(int argc, char* argv[]);
int getParametersForCompile(int argc, char* argv[]);
int getParametersForLinking(int argc, char* argv[]);
</pre>
</pre>

GoCompile.cpp
<pre>include "GoCompile.h"

#define CLS system("cls")
#define getch() (option = _getch())

char option;

extern "C" __declspec(dllexport) int __cdecl Compile(int argc, char* argv[])
{
if(argc < 2)
{
cerr << "Invalid number of arguments." << endl;
return EXIT_FAILURE;
}
command = "8g ";
if(getParametersForCompile(argc, argv) & EXIT_FAILURE)
return EXIT_FAILURE;
if(getParametersForLinking(argc, argv) & EXIT_FAILURE)
return EXIT_FAILURE;
return EXIT_SUCCESS;
}

int getParametersForCompile(int argc, char* argv[])
{
cout << "Would you like to include packages from a specific directory? <y\n>" << endl;
if(getch() == 'y')
{
char directory[50];
cout << "Please enter the directory." << endl;
std::cin.getline(directory, 50);
command.append("-I ").append(directory).append(" ");
}
CLS;
cout << "Would you like to have the compiler print declarations? <y\n>" << endl;
if(getch() == 'y')
command.append("-d ");
CLS;
cout << "Would you like to have the compiler remove limits on errors printed? <y\n>" << endl;
if(getch() == 'y')
command.append("-e ");
CLS;
cout << "Would you like to have the compiler print the stack frame structure? <y\n>" << endl;
if(getch() == 'y')
command.append("-f ");
CLS;
cout << "Would you like the compile to panic on error? <y\n>" << endl;
if(getch() == 'y')
command.append("-h ");
CLS;
cout << "Would you like to specify the package name? <y\n>" << endl;
if(getch() == 'y')
{
char name[50];
cout << "Please enter the package name." << endl;
std::cin.getline(name, 50);
command.append("-k ").append(name).append(" ");
}
CLS;
cout << "Would you like to specify the name of the output file? <y\n>" << endl;
if(getch() == 'y')
{
char output[50];
cout << "Please enter the output file name. (Including extention)" << endl;
std::cin.getline(output, 50);
command.append("-o ").append(output).append(" ");
}
CLS;
cout << "Would you like the compiler to print the assembly language? <y\n>" << endl;
if(getch() == 'y')
command.append("-S ");
CLS;
cout << "Would you like the compiler to print the parse tree? <y\n>" << endl;
if(getch() == 'y')
command.append("-w ");
CLS;
cout << "Would you like the compiler to print lex tokens? <y\n>" << endl;
if(getch() == 'y')
command.append("-x ");
CLS;
string command_temp;
for(short i = 1;i < argc;i++)
{
command_temp = command;
if(system(command_temp.append(argv[i]).append(".go").c_str()) == 0)
continue;
else return EXIT_FAILURE;
}
cout << "Press any key to link files." << endl;
_getch();
return EXIT_SUCCESS;
}

int getParametersForLinking(int argc, char* argv[])
{
CLS;
cout << "Would you like to specify a name for the executable? <y\n>" << endl;
command = "8l ";
string command_temp;
if(getch() =='y')
{
char name[50];
cout << "Please enter the executable name" << endl;
std::cin.getline(name, 50);
command.append("-o ").append(name).append(" ");
}
for(short i = 1;i < argc;i++)
{
command_temp = command;
if(system(command_temp.append(argv[i]).append(".8").c_str()) == 0)
continue;
else return EXIT_FAILURE;
}
cout <<