Skip to content

Commit

Permalink
dumb
Browse files Browse the repository at this point in the history
  • Loading branch information
Vortex2Oblivion committed Jan 21, 2024
1 parent 17493c3 commit 2e08fe3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 28 deletions.
3 changes: 2 additions & 1 deletion extraParams.hxml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
-D HXCPP_M64
-D CONFIG_64
-D CONFIG_64
-D PY_SSIZE_T_CLEAN
31 changes: 5 additions & 26 deletions hxpy/Python.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@ package hxpy;

@:buildXml("<include name='${haxelib:hxpy}/hxpy/Build.xml' />")
@:include("Python.h")
@:cppFileCode('
#include <string>
#include <iostream>
using std::string;
using namespace std;
')
@:keep
/**
* Class that contains most of the variables and functions in hxpy!
Expand Down Expand Up @@ -72,19 +66,10 @@ extern class Python
* Function for loading Python code from a file.
* @param filetoParse The path of your Python script. (eg: script.py)
*/
public static function runSimpleFile(filetoParse:String):Void {
return untyped __cpp__('
PyObject *obj = Py_BuildValue("s", filetoParse.c_str());
FILE* PScriptFile = _Py_fopen_obj(obj, "r+");
if(PScriptFile){
PyRun_SimpleFile(PScriptFile, filetoParse);
fclose(PScriptFile);
}
else{
std::cout << "File Not Found!";
}
');
}
public static inline function runSimpleFile(filetoParse:String):Void {
@:privateAccess
File.runSimpleFile(filetoParse);
}

/**
*Function for closing a Python instance.
Expand All @@ -105,21 +90,15 @@ extern class Python
#endif
#include <string>
#include <iostream>
#include <pythonrun.h>
using std::string;
using namespace std;
')
/**
* Class that contains the function for running code from a file
* Cuz you cant use untyped cpp in extern classes. a.
* I don't know what any of this means lmao.
*/
class File {
/**
* Function for loading Python code from a file.
* @param filetoParse The path of your Python script. (eg: script.py)
*/
public static function runSimpleFile(filetoParse:String) {
private static function runSimpleFile(filetoParse:String) {
untyped __cpp__('
PyObject *obj = Py_BuildValue("s", filetoParse.c_str());
FILE* PScriptFile = _Py_fopen_obj(obj, "r+");
Expand Down
2 changes: 1 addition & 1 deletion test/demos/running code from a file/build.hxml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
--dce full
-D HXCPP_M64
-D analyzer-optimize
--main Main
--main Main

0 comments on commit 2e08fe3

Please sign in to comment.