From 2e08fe36849fe97316381507c5560a5ddce44aa3 Mon Sep 17 00:00:00 2001
From: Vortex2Oblivion <73261680+Vortex2Oblivion@users.noreply.github.com>
Date: Sun, 21 Jan 2024 17:00:27 -0500
Subject: [PATCH] dumb
---
extraParams.hxml | 3 +-
hxpy/Python.hx | 31 +++----------------
.../demos/running code from a file/build.hxml | 2 +-
3 files changed, 8 insertions(+), 28 deletions(-)
diff --git a/extraParams.hxml b/extraParams.hxml
index 6d1ed9a..a3ed47f 100644
--- a/extraParams.hxml
+++ b/extraParams.hxml
@@ -1,2 +1,3 @@
-D HXCPP_M64
--D CONFIG_64
\ No newline at end of file
+-D CONFIG_64
+-D PY_SSIZE_T_CLEAN
\ No newline at end of file
diff --git a/hxpy/Python.hx b/hxpy/Python.hx
index 34206e1..fb3c896 100644
--- a/hxpy/Python.hx
+++ b/hxpy/Python.hx
@@ -2,12 +2,6 @@ package hxpy;
@:buildXml("")
@:include("Python.h")
-@:cppFileCode('
-#include
-#include
-using std::string;
-using namespace std;
-')
@:keep
/**
* Class that contains most of the variables and functions in hxpy!
@@ -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.
@@ -105,21 +90,15 @@ extern class Python
#endif
#include
#include
-#include
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+");
diff --git a/test/demos/running code from a file/build.hxml b/test/demos/running code from a file/build.hxml
index 1719eb1..714b97a 100644
--- a/test/demos/running code from a file/build.hxml
+++ b/test/demos/running code from a file/build.hxml
@@ -4,4 +4,4 @@
--dce full
-D HXCPP_M64
-D analyzer-optimize
---main Main
\ No newline at end of file
+--main Main