diff --git a/.gitignore b/.gitignore index a8f0b03d6..e43464f53 100644 --- a/.gitignore +++ b/.gitignore @@ -89,6 +89,7 @@ ENV/ .ropeproject Binaries/ +Intermediate/ python35/ python27/ *.un~ diff --git a/README.md b/README.md index f18f3d6b9..68ed706f1 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,23 @@ # UnrealEnginePython Embed Python in Unreal Engine 4 -Teaser: https://twitter.com/KNLstudio/status/932657812466843648 +Teaser (by Kite & Lightning): https://twitter.com/KNLstudio/status/932657812466843648 + +Fixing Mixamo RootMotion tuturial: https://github.com/20tab/UnrealEnginePython/blob/master/tutorials/FixingMixamoRootMotionWithPython.md + +Funny snippets for working with StaticMesh and SkeletalMesh assets: https://github.com/20tab/UnrealEnginePython/blob/master/tutorials/SnippetsForStaticAndSkeletalMeshes.md + +More tutorials: https://github.com/20tab/UnrealEnginePython/tree/master/tutorials + +# Project Status (IMPORTANT) + +Currently (as april 2020) the project is on hold: between 2016 and 2018 20tab invested lot of resources in it but unfortunately epic (during 2018) decided to suddenly release its own implementation and the request made for a megagrant in 2019 by the original plugin author was rejected too. + +As this plugin (still) has way more features than the Epic one and many contributors, **we are currently looking for new maintainers** helping us to keep it alive, checking PR and issues. If you are interested in working on it a few hours a week, drop us a line at info@20tab.com to discuss about it. + +If you are interested in game logic scripting/modding in Unreal Engine 4 consider giving a look at the LuaMachine project (https://github.com/rdeioris/LuaMachine/). + +The plugin should work up to unreal engine version 4.23 and there are forks/pull requests for 4.24. Since 4.25 Epic refactored the UProperty subsystem, so if you want to port the plugin to a version >= 4.25 you should make a lot of search & replace (basically renaming UProperty to FProperty and Cast to CastField should be enough) # How and Why ? @@ -24,10 +40,12 @@ Once the plugin is installed and enabled, you get access to the 'PythonConsole' All of the exposed engine features are under the 'unreal_engine' virtual module (it is completely coded in c into the plugin, so do not expect to run 'import unreal_engine' from a standard python shell) -The currently supported Unreal Engine versions are 4.12, 4.13, 4.14, 4.15, 4.16, 4.17, 4.18 and 4.19 +The minimal supported Unreal Engine version is 4.12, while the latest is 4.23 We support official python.org releases as well as IntelPython and Anaconda distributions. +Note: this plugin has nothing to do with the experimental 'PythonScriptPlugin' included in Unreal Engine >= 4.19. We aim at full integration with engine and editor (included the Slate api, check here: https://github.com/20tab/UnrealEnginePython/blob/master/docs/Slate_API.md), as well as support for the vast majority of python features like asyncio, coroutines, generators, threads and third party modules. + # Binary installation on Windows (64 bit) Check in the releases page (https://github.com/20tab/UnrealEnginePython/releases) if there is a binary version that matches your configuration (otherwise open an issue asking us for it [please specify the python version too]) and download it. @@ -157,9 +175,14 @@ Just remove the .so files in Plugins/UnrealEnginePython/Binaries/Linux and pull At the next run the build procedure wil be started again. +Android Deployment +------------------ + +Check https://github.com/20tab/UnrealEnginePython/blob/master/docs/Android.md + # Installation on other platforms -Currently only Windows, MacOSX and Linux are supported. We are investigating Android support too via the kivy project. +Currently only Windows, MacOSX, Linux and Android are supported. # Using Python with Unreal Engine (finally) @@ -418,6 +441,27 @@ vec = self.uobject.GetActorLocation() Reflection based functions are those in camelcase (or with the first capital letter). Native functions instead follow the python style, with lower case, underscore-as-separator function names. +Note that, in editor builds, when you change the property of an archetype (included ClassDefaultObject) via __setattr__ all of the archtype instances will be updated too. + +To be more clear: + +```python +your_blueprint.GeneratedClass.get_cdo().CharacterMovement.MaxWalkSpeed = 600.0 +``` + +is a super shortcut for: + +```python +your_blueprint.GeneratedClass.get_cdo().CharacterMovement.pre_edit_change('MaxWalkSpeed') +your_blueprint.GeneratedClass.get_cdo().CharacterMovement.set_property('MaxWalkSpeed', 600.0) +your_blueprint.GeneratedClass.get_cdo().CharacterMovement.post_edit_change_property('MaxWalkSpeed') +for instance in your_blueprint.GeneratedClass.get_cdo().CharacterMovement.get_archetype_instances(): + instance.pre_edit_change('MaxWalkSpeed') + instance.set_property('MaxWalkSpeed', 600.0) + instance.post_edit_change_property('MaxWalkSpeed') +``` + + The automagic UClass, UStruct and UEnums mappers ------------------------------------------------ @@ -465,8 +509,6 @@ if is_hitting_something: ue.log(hit_result) ``` -Remember that structs are passed by value (not by ref like UObject's), so a dedicated unreal_engine.UScriptStruct python class is exposed. - To create a new struct instance you can do: ```python @@ -487,29 +529,8 @@ To access the fields of a struct just call the fields() method. A good example of struct usage is available here: https://github.com/20tab/UnrealEnginePython/blob/master/docs/Settings.md -As structs are passed by value, you need to pay attention when manipulating structs fields that are structs by themselves: - -```python -from unreal_engine.structs import TerrificStruct, DumbStruct - -ts = TerrificStruct() -ts.dumb = DumbStruct(Foo=17, Bar=22) - -# will not modify the original DumbStruct but a copy of it !!! -ts.dumb.Foo = 22 -``` - -You can eventually force structs to be passed by ref (extremely dangerous as the internal C pointer could be a dangling one) using the ref() function: - -```python -from unreal_engine.structs import TerrificStruct, DumbStruct - -ts = TerrificStruct() -ts.dumb = DumbStruct(Foo=17, Bar=22) -# ref() will return a pointer to a struct -ts.ref().dumb.foo().Foo = 22 -``` +More details here: https://github.com/20tab/UnrealEnginePython/blob/master/docs/MemoryManagement.md The ue_site.py file ------------------- @@ -675,6 +696,7 @@ The following parameters are supported: * `RelativeAdditionalModulesPath`: like AdditionalModulesPath, but the path is relative to the /Content directory * `ZipPath`: allow to specify a .zip file that is added to sys.path * `RelativeZipPath`: like ZipPath, but the path is relative to the /Content directory +* `ImportModules: comma/space/semicolon separated list of modules to import on startup (after ue_site) Example: @@ -778,55 +800,81 @@ It allows you to run, create, modify and delete scripts directly from the UE edi The first pull request for the editor has been issued by https://github.com/sun5471 so many thanks to him ;) -Integration with PyQT ---------------------- +Integration with Qt4/Qt5/PySide2 +-------------------------------- -To correctly integrates PyQT with UnrealEngine the python plugin must correctly setup the GIL (and this is done) and exceptions must be managed ad-hoc (not doing it will result in a deadlock whenever a qt signal handler raises an exception) +Thanks to solid GIL management, you can integrate Qt python apps in Unreal Engine 4. -This is an example of having a QT window along the editor to trigger asset reimporting (pay attention to the sys.excepthook usage): +Pay attention to not call app.exec_() as it will result in Qt taking control of the UE loop. Instead use a ticker to integrate the Qt loop in the editor loop: -```py -from PyQt5.QtWidgets import QApplication, QWidget, QListWidget -import unreal_engine as ue +```python + +# save it as ueqt.py import sys -import traceback +import unreal_engine as ue +import PySide2 +from PySide2 import QtWidgets -def ue_exception(_type, value, back): - ue.log_error(value) - tb_lines = traceback.format_exception(_type, value, back) - for line in tb_lines: - ue.log_error(line) +app = QtWidgets.QApplication(sys.argv) -sys.excepthook = ue_exception +def ticker_loop(delta_time): + app.processEvents() + return True -skeletal_mappings = {} +ticker = ue.add_ticker(ticker_loop) +``` +now you can start writing your gui (this is a simple example loading asset thumbnail): -def selected_skeletal_mesh(item): - uobject = skeletal_mappings[item.data()] - ue.log('Ready to reimport: ' + uobject.get_name()) - uobject.asset_reimport() +```python +import ueqt +from PySide2 import QtCore, QtWidgets, QtGui +import unreal_engine as ue -#check if an instance of the application is already running -app = QApplication.instance() -if app is None: - app = QApplication([]) -else: - print("App already running.") +from unreal_engine import FARFilter -win = QWidget() -win.setWindowTitle('Unreal Engine 4 skeletal meshes reimporter') +_filter = FARFilter() +_filter.class_names = ['SkeletalMesh', 'Material'] -wlist = QListWidget(win) -for asset in ue.get_assets_by_class('SkeletalMesh'): - wlist.addItem(asset.get_name()) - skeletal_mappings[asset.get_name()] = asset - -wlist.clicked.connect(selected_skeletal_mesh) -wlist.show() +class MyWidget(QtWidgets.QWidget): + def __init__(self): + super().__init__() + self.vertical = QtWidgets.QVBoxLayout() + self.scroll = QtWidgets.QScrollArea() + self.content = QtWidgets.QWidget() + self.scroll.setWidget(self.content) + self.scroll.setWidgetResizable(True) + self.layout = QtWidgets.QVBoxLayout() + + for asset_data in ue.get_assets_by_filter(_filter, True): + try: + thumbnail = asset_data.get_thumbnail() + except: + continue + + label = QtWidgets.QLabel() + data = thumbnail.get_uncompressed_image_data() + image = QtGui.QImage(data, 256, 256, QtGui.QImage.Format_RGB32) + label.setPixmap(QtGui.QPixmap.fromImage(image).scaled(256, 256)) + self.layout.addWidget(label) -win.show() + self.content.setLayout(self.layout) + self.vertical.addWidget(self.scroll) + self.setLayout(self.vertical) + + + +widget = MyWidget() +widget.resize(800, 600) +widget.show() + +root_window = ue.get_editor_window() +root_window.set_as_owner(widget.winId()) ``` +(no need to allocate a new Qt app, or start it, as the UE4 Editor, thanks to to ueqt module is now the Qt app itself) + +Note the 2 final lines: they 'attach' the Qt window as a 'child' of the editor root window. Note that on windows platform this is not simple parenting but 'ownership'. + Memory management ----------------- @@ -836,6 +884,7 @@ Starting from release 20180226 a new memory management system has been added (FU The same system works for delegates, as well as Slate. +More details here: https://github.com/20tab/UnrealEnginePython/blob/master/docs/MemoryManagement.md Unit Testing ------------ @@ -846,25 +895,14 @@ To run the unit tests (ensure to run them on an empty/useless project to avoid m ```python import unreal_engine as ue -ue.sandbox_exec(ue.find_plugin('UnrealEnginePython').get_base_dir() + '/run_tests.py') +ue.py_exec(ue.find_plugin('UnrealEnginePython').get_base_dir() + '/run_tests.py') ``` if you plan to add new features to the plugin, including a test suite in your pull request will be really appreciated ;) -Threading (Experimental) +Threading ------------------------ -By default the plugin is compiled without effective python threads support. This is for 2 main reasons: - -* we still do not have numbers about the performance impact of constantly acquiring and releasing the GIL -* we need a better test suite - -By the way, if you want to play with experimental threading support, just uncomment - -```c -//#define UEPY_THREADING 1 -``` - -on top of UnrealEnginePythonPrivatePCH.h and rebuild the plugin. +Since release 20180624 threading is fully supported. As with native threads, do not modify (included deletion) UObjects from non-main threads. @@ -880,7 +918,7 @@ Sometimes you may have a UObject and know that it is backed by a python object. This would be resolved as shown below: -``` +```python import unreal_engine as ue class Explosive: @@ -906,18 +944,18 @@ What is going on here in `BadGuy` is that self.uobject is a reference to the PyA Status and Known issues ----------------------- -The project could be considered in beta state. - Exposing the full ue4 api is a huge amount of work, feel free to make pull requests for your specific needs. We still do not have a plugin icon ;) +We try to do our best to "protect" the user, but you can effectively crash UE from python as you are effectively calling the C/C++ api + Contacts and Commercial Support ------------------------------- -If you want to contact us (for help, support, sponsorship), drop a mail to info at 20tab.com or follow @unbit on twitter +If you need commercial support for UnrealEnginePython just drop a mail to info at 20tab.com -We offer commercial support for both UnrealEngine and UnrealEnginePython, again drop a mail to info at 20tab.com for more infos +Follow @unbit on twitter for news about the project Special Thanks -------------- @@ -928,3 +966,4 @@ Such a big project requires constant sponsorship, special thanks go to: * GoodTH.INC https://www.goodthinc.com/ (they are sponsoring the sequencer api) +* Quixel AB https://megascans.se/ (built their integration tool over UnrealEnginePython giving us tons of useful feedbacks and ideas) diff --git a/Source/PythonAutomation/Private/PythonAutomationModule.cpp b/Source/PythonAutomation/Private/PythonAutomationModule.cpp new file mode 100644 index 000000000..063581df7 --- /dev/null +++ b/Source/PythonAutomation/Private/PythonAutomationModule.cpp @@ -0,0 +1,20 @@ +// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved. + +#include "PythonAutomationModule.h" +#include "UnrealEnginePython.h" +#include "UEPyFAutomationEditorCommonUtils.h" + +IMPLEMENT_MODULE(FPythonAutomationModule, PythonAutomation); + + +void FPythonAutomationModule::StartupModule() +{ + FScopePythonGIL gil; + PyObject *py_automation_module = ue_py_register_module("unreal_engine.automation"); + ue_python_init_fautomation_editor_common_utils(py_automation_module); +} + +void FPythonAutomationModule::ShutdownModule() +{ + +} diff --git a/Source/PythonAutomation/Private/UEPyFAutomationEditorCommonUtils.cpp b/Source/PythonAutomation/Private/UEPyFAutomationEditorCommonUtils.cpp new file mode 100644 index 000000000..d0576d48d --- /dev/null +++ b/Source/PythonAutomation/Private/UEPyFAutomationEditorCommonUtils.cpp @@ -0,0 +1,90 @@ + +#include "UEPyFAutomationEditorCommonUtils.h" + +#include "UnrealEnginePython.h" +#include "Engine/World.h" + + +static PyObject *py_ue_fautomation_editor_common_utils_run_pie(PyObject *cls, PyObject * args) +{ + Py_BEGIN_ALLOW_THREADS; + FAutomationEditorCommonUtils::RunPIE(); + Py_END_ALLOW_THREADS; + Py_RETURN_NONE; +} + +static PyObject *py_ue_fautomation_editor_common_utils_load_map(PyObject *cls, PyObject * args) +{ + char *map_name; + if (!PyArg_ParseTuple(args, "s:load_map", &map_name)) + return nullptr; + Py_BEGIN_ALLOW_THREADS; + FAutomationEditorCommonUtils::LoadMap(FString(UTF8_TO_TCHAR(map_name))); + Py_END_ALLOW_THREADS; + Py_RETURN_NONE; +} + +static PyObject *py_ue_fautomation_editor_common_utils_create_new_map(PyObject *cls, PyObject * args) +{ + Py_RETURN_UOBJECT(FAutomationEditorCommonUtils::CreateNewMap()); +} + +static PyMethodDef ue_PyFAutomationEditorCommonUtils_methods[] = { + { "run_pie", (PyCFunction)py_ue_fautomation_editor_common_utils_run_pie, METH_VARARGS | METH_CLASS, "" }, + { "load_map", (PyCFunction)py_ue_fautomation_editor_common_utils_load_map, METH_VARARGS | METH_CLASS, "" }, + { "create_new_map", (PyCFunction)py_ue_fautomation_editor_common_utils_create_new_map, METH_VARARGS | METH_CLASS, "" }, + + { NULL } /* Sentinel */ +}; + + +static PyTypeObject ue_PyFAutomationEditorCommonUtilsType = { + PyVarObject_HEAD_INIT(NULL, 0) + "unreal_engine.FAutomationEditorCommonUtils", /* tp_name */ + sizeof(ue_PyFAutomationEditorCommonUtils), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + "Unreal Engine AutomationEditorCommonUtils", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + ue_PyFAutomationEditorCommonUtils_methods, /* tp_methods */ + 0, + 0, +}; + +static int py_ue_fautomation_editor_common_utils_init(ue_PyFAutomationEditorCommonUtils *self, PyObject * args) +{ + PyErr_SetString(PyExc_Exception, "FAutomationEditorCommonUtils is a singleton"); + return -1; +} + +void ue_python_init_fautomation_editor_common_utils(PyObject *ue_module) +{ + ue_PyFAutomationEditorCommonUtilsType.tp_new = PyType_GenericNew; + ue_PyFAutomationEditorCommonUtilsType.tp_init = (initproc)py_ue_fautomation_editor_common_utils_init; + + if (PyType_Ready(&ue_PyFAutomationEditorCommonUtilsType) < 0) + return; + + Py_INCREF(&ue_PyFAutomationEditorCommonUtilsType); + PyModule_AddObject(ue_module, "FAutomationEditorCommonUtils", (PyObject *)&ue_PyFAutomationEditorCommonUtilsType); +} diff --git a/Source/PythonAutomation/Private/UEPyFAutomationEditorCommonUtils.h b/Source/PythonAutomation/Private/UEPyFAutomationEditorCommonUtils.h new file mode 100644 index 000000000..b4b870bb9 --- /dev/null +++ b/Source/PythonAutomation/Private/UEPyFAutomationEditorCommonUtils.h @@ -0,0 +1,13 @@ +#pragma once + +#include "UnrealEnginePython.h" + +#include "Tests/AutomationEditorCommon.h" + +typedef struct +{ + PyObject_HEAD + /* Type-specific fields go here. */ +} ue_PyFAutomationEditorCommonUtils; + +void ue_python_init_fautomation_editor_common_utils(PyObject *); diff --git a/Source/PythonAutomation/Public/PythonAutomationModule.h b/Source/PythonAutomation/Public/PythonAutomationModule.h new file mode 100644 index 000000000..bc19a062e --- /dev/null +++ b/Source/PythonAutomation/Public/PythonAutomationModule.h @@ -0,0 +1,18 @@ +// Copyright 1998-2018 20Tab S.r.l. All Rights Reserved. + +#pragma once + +#include "CoreMinimal.h" +#if ENGINE_MAJOR_VERSION==4 && ENGINE_MINOR_VERSION>=22 +#include "Modules/ModuleInterface.h" +#else +#include "ModuleInterface.h" +#endif + +class FPythonAutomationModule : public IModuleInterface +{ +public: + virtual void StartupModule(); + virtual void ShutdownModule(); + +}; diff --git a/Source/PythonAutomation/PythonAutomation.Build.cs b/Source/PythonAutomation/PythonAutomation.Build.cs new file mode 100644 index 000000000..e2f80b814 --- /dev/null +++ b/Source/PythonAutomation/PythonAutomation.Build.cs @@ -0,0 +1,36 @@ +// Copyright 1998-2018 20Tab S.r.l All Rights Reserved. + +using UnrealBuildTool; +using System.IO; + +public class PythonAutomation : ModuleRules +{ +#if WITH_FORWARDED_MODULE_RULES_CTOR + public PythonAutomation(ReadOnlyTargetRules Target) : base(Target) +#else + public PythonAutomation(TargetInfo Target) +#endif + { + PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs; + string enableUnityBuild = System.Environment.GetEnvironmentVariable("UEP_ENABLE_UNITY_BUILD"); + bFasterWithoutUnity = string.IsNullOrEmpty(enableUnityBuild); + + PrivateIncludePaths.AddRange( + new string[] { + "PythonConsole/Private", + // ... add other private include paths required here ... + } + ); + + PrivateDependencyModuleNames.AddRange( + new string[] { + "Core", + "CoreUObject", // @todo Mac: for some reason it's needed to link in debug on Mac + "Engine", + "UnrealEd", + "UnrealEnginePython" + } + ); + + } +} diff --git a/Source/PythonConsole/Private/PyFbxFactory.cpp b/Source/PythonConsole/Private/PyFbxFactory.cpp index 3cbf1a1a2..9161ad480 100644 --- a/Source/PythonConsole/Private/PyFbxFactory.cpp +++ b/Source/PythonConsole/Private/PyFbxFactory.cpp @@ -1,7 +1,7 @@ -#include "PythonConsolePrivatePCH.h" #include "PyFbxFactory.h" #include "FbxMeshUtils.h" +#include "Runtime/Launch/Resources/Version.h" UPyFbxFactory::UPyFbxFactory(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) @@ -24,6 +24,23 @@ void UPyFbxFactory::PostInitProperties() { ImportUI->MeshTypeToImport = FBXIT_MAX; } +UObject * UPyFbxFactory::FactoryCreateFile(UClass* InClass, UObject* InParent, FName InName, EObjectFlags Flags, const FString& Filename, const TCHAR* Parms, FFeedbackContext* Warn, bool& bOutOperationCanceled) +{ +#if ENGINE_MINOR_VERSION >= 20 + if (ImportUI->MeshTypeToImport == FBXIT_MAX) + { + if (!DetectImportType(UFactory::CurrentFilename)) + { + return nullptr; + } + } + FbxMeshUtils::SetImportOption(ImportUI); + // ensure auto-detect is skipped + bDetectImportTypeOnImport = false; +#endif + return Super::FactoryCreateFile(InClass, InParent, InName, Flags, Filename, Parms, Warn, bOutOperationCanceled); +} + UObject *UPyFbxFactory::FactoryCreateBinary ( UClass * InClass, diff --git a/Source/PythonConsole/Private/PythonConsoleModule.cpp b/Source/PythonConsole/Private/PythonConsoleModule.cpp index 0569edec5..59eefaec3 100644 --- a/Source/PythonConsole/Private/PythonConsoleModule.cpp +++ b/Source/PythonConsole/Private/PythonConsoleModule.cpp @@ -1,10 +1,10 @@ // Copyright 1998-2016 Epic Games, Inc. All Rights Reserved. -#include "PythonConsolePrivatePCH.h" +#include "PythonConsoleModule.h" #include "SPythonConsole.h" #include "SPythonLog.h" #include "Editor/WorkspaceMenuStructure/Public/WorkspaceMenuStructureModule.h" -#include "SDockTab.h" +#include "Runtime/Slate/Public/Widgets/Docking/SDockTab.h" #include "Editor/WorkspaceMenuStructure/Public/WorkspaceMenuStructure.h" IMPLEMENT_MODULE( FPythonConsoleModule, PythonConsole ); @@ -93,71 +93,4 @@ TSharedRef< SWidget > FPythonConsoleModule::MakeConsoleInputBox( TSharedPtr< SEd TSharedRef< SPythonConsoleInputBox > NewConsoleInputBox = SNew( SPythonConsoleInputBox ); OutExposedEditableTextBox = NewConsoleInputBox->GetEditableTextBox(); return NewConsoleInputBox; -} - - -void FPythonConsoleModule::TogglePythonConsoleForWindow( const TSharedRef< SWindow >& Window, const EPythonConsoleStyle::Type InStyle, const FPythonConsoleDelegates& PythonConsoleDelegates ) -{ - bool bShouldOpen = true; - // Close an existing console box, if there is one - TSharedPtr< SWidget > PinnedPythonConsole( PythonConsole.Pin() ); - if( PinnedPythonConsole.IsValid() ) - { - // If the console is already open close it unless it is in a different window. In that case reopen it on that window - bShouldOpen = false; - TSharedPtr< SWindow > WindowForExistingConsole = FSlateApplication::Get().FindWidgetWindow(PinnedPythonConsole.ToSharedRef()); - if (WindowForExistingConsole.IsValid()) - { - WindowForExistingConsole->RemoveOverlaySlot(PinnedPythonConsole.ToSharedRef()); - PythonConsole.Reset(); - } - - if( WindowForExistingConsole != Window ) - { - // Console is being opened on another window - bShouldOpen = true; - } - } - - TSharedPtr ActiveTab = FGlobalTabmanager::Get()->GetActiveTab(); - if (ActiveTab.IsValid() && ActiveTab->GetLayoutIdentifier() == FTabId(PythonConsoleModule::PythonLogTabName)) - { - FGlobalTabmanager::Get()->DrawAttention(ActiveTab.ToSharedRef()); - bShouldOpen = false; - } - - if( bShouldOpen ) - { - const EPythonConsoleStyle::Type PythonConsoleStyle = InStyle; - TSharedRef< SPythonConsole > PythonConsoleRef = SNew( SPythonConsole, PythonConsoleStyle, this, &PythonConsoleDelegates ); - PythonConsole = PythonConsoleRef; - - const int32 MaximumZOrder = MAX_int32; - Window->AddOverlaySlot( MaximumZOrder ) - .VAlign(VAlign_Bottom) - .HAlign(HAlign_Center) - .Padding( 10.0f ) - [ - PythonConsoleRef - ]; - - // Force keyboard focus - PythonConsoleRef->SetFocusToEditableText(); - } -} - - -void FPythonConsoleModule::ClosePythonConsole() -{ - TSharedPtr< SWidget > PinnedPythonConsole( PythonConsole.Pin() ); - - if( PinnedPythonConsole.IsValid() ) - { - TSharedPtr< SWindow > WindowForExistingConsole = FSlateApplication::Get().FindWidgetWindow(PinnedPythonConsole.ToSharedRef()); - if (WindowForExistingConsole.IsValid()) - { - WindowForExistingConsole->RemoveOverlaySlot( PinnedPythonConsole.ToSharedRef() ); - PythonConsole.Reset(); - } - } } \ No newline at end of file diff --git a/Source/PythonConsole/Private/PythonConsolePrivatePCH.h b/Source/PythonConsole/Private/PythonConsolePrivatePCH.h deleted file mode 100644 index 7d5eec1f9..000000000 --- a/Source/PythonConsole/Private/PythonConsolePrivatePCH.h +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved. - -#pragma once - -#include "UnrealEd.h" -#include "PythonConsoleModule.h" -#include "SlateBasics.h" - - diff --git a/Source/PythonConsole/Private/PythonScriptFactory.cpp b/Source/PythonConsole/Private/PythonScriptFactory.cpp index 1b1828a7c..91f7cad58 100644 --- a/Source/PythonConsole/Private/PythonScriptFactory.cpp +++ b/Source/PythonConsole/Private/PythonScriptFactory.cpp @@ -1,4 +1,3 @@ -#include "PythonConsolePrivatePCH.h" #include "PythonScriptFactory.h" #include "PythonScript.h" diff --git a/Source/PythonConsole/Private/SPythonConsole.cpp b/Source/PythonConsole/Private/SPythonConsole.cpp index 7f3590f32..7d9fa36da 100644 --- a/Source/PythonConsole/Private/SPythonConsole.cpp +++ b/Source/PythonConsole/Private/SPythonConsole.cpp @@ -1,6 +1,6 @@ // Copyright 1998-2016 Epic Games, Inc. All Rights Reserved. -#include "PythonConsolePrivatePCH.h" +#include "SPythonConsole.h" #include "PythonConsoleModule.h" #include "SPythonConsole.h" #include "SPythonLog.h" diff --git a/Source/PythonConsole/Private/SPythonConsole.h b/Source/PythonConsole/Private/SPythonConsole.h index b74d72252..23341f023 100644 --- a/Source/PythonConsole/Private/SPythonConsole.h +++ b/Source/PythonConsole/Private/SPythonConsole.h @@ -2,6 +2,9 @@ #pragma once +#include "Runtime/SlateCore/Public/SlateCore.h" +#include "EditorStyle.h" +#include "PythonConsoleModule.h" /** * Debug console widget, designed to be summoned on top of a viewport or window @@ -10,14 +13,14 @@ class SPythonConsole : public SCompoundWidget { public: - SLATE_BEGIN_ARGS( SPythonConsole ) + SLATE_BEGIN_ARGS(SPythonConsole) { } SLATE_END_ARGS() - /** Constructs this widget */ - void Construct( const FArguments& InArgs, const EPythonConsoleStyle::Type InStyle, FPythonConsoleModule* PythonConsoleModule, const FPythonConsoleDelegates* PythonConsoleDelegates ); + /** Constructs this widget */ + void Construct(const FArguments& InArgs, const EPythonConsoleStyle::Type InStyle, FPythonConsoleModule* PythonConsoleModule, const FPythonConsoleDelegates* PythonConsoleDelegates); /** Call to set focus to this debug console's editable text box */ void SetFocusToEditableText(); diff --git a/Source/PythonConsole/Private/SPythonLog.cpp b/Source/PythonConsole/Private/SPythonLog.cpp index 14c74b28f..555141be4 100644 --- a/Source/PythonConsole/Private/SPythonLog.cpp +++ b/Source/PythonConsole/Private/SPythonLog.cpp @@ -1,14 +1,17 @@ // Copyright 1998-2016 Epic Games, Inc. All Rights Reserved. -#include "PythonConsolePrivatePCH.h" #include "SPythonLog.h" -#include "SScrollBorder.h" +#include "Runtime/Slate/Public/Widgets/Layout/SScrollBorder.h" #include "GameFramework/GameMode.h" #include "Engine/LocalPlayer.h" #include "GameFramework/GameState.h" -#include "SSearchBox.h" +#include "Runtime/Slate/Public/Widgets/Input/SSearchBox.h" #include "Runtime/Launch/Resources/Version.h" -//#include "UnrealEnginePython.h" +#include "Runtime/Slate/Public/Framework/Text/SlateTextLayout.h" +#include "Editor/EditorStyle/Public/Classes/EditorStyleSettings.h" +#include "SlateBasics.h" +#include "EditorStyle.h" + #define LOCTEXT_NAMESPACE "PythonConsole" diff --git a/Source/PythonConsole/Private/SPythonLog.h b/Source/PythonConsole/Private/SPythonLog.h index 8f3e0d511..c521e972a 100644 --- a/Source/PythonConsole/Private/SPythonLog.h +++ b/Source/PythonConsole/Private/SPythonLog.h @@ -1,10 +1,12 @@ // Copyright 1998-2016 Epic Games, Inc. All Rights Reserved. #pragma once -#include "BaseTextLayoutMarshaller.h" -#include "TextFilterExpressionEvaluator.h" - -#include "UnrealEnginePython/Public/UnrealEnginePython.h" +#include "Runtime/Slate/Public/Framework/Text/BaseTextLayoutMarshaller.h" +#include "Runtime/Core/Public/Misc/TextFilterExpressionEvaluator.h" +#include "Runtime/SlateCore/Public/SlateCore.h" +#include "UnrealEnginePython.h" +#include "Runtime/Slate/Public/Widgets/Input/SMultiLineEditableTextBox.h" +#include "Runtime/Slate/Public/Widgets/Input/SEditableTextBox.h" class FPythonLogTextLayoutMarshaller; class SSearchBox; diff --git a/Source/PythonConsole/Public/PyFbxFactory.h b/Source/PythonConsole/Public/PyFbxFactory.h index a26a10461..e405df7cb 100644 --- a/Source/PythonConsole/Public/PyFbxFactory.h +++ b/Source/PythonConsole/Public/PyFbxFactory.h @@ -15,6 +15,7 @@ class UPyFbxFactory : public UFbxFactory virtual bool ConfigureProperties() override; virtual void PostInitProperties() override; + virtual UObject * FactoryCreateFile(UClass* InClass, UObject* InParent, FName InName, EObjectFlags Flags, const FString& Filename, const TCHAR* Parms, FFeedbackContext* Warn, bool& bOutOperationCanceled) override; virtual UObject * FactoryCreateBinary ( UClass * InClass, diff --git a/Source/PythonConsole/Public/PythonConsoleModule.h b/Source/PythonConsole/Public/PythonConsoleModule.h index 7d5189b48..2e037a254 100644 --- a/Source/PythonConsole/Public/PythonConsoleModule.h +++ b/Source/PythonConsole/Public/PythonConsoleModule.h @@ -1,8 +1,8 @@ -// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved. +// Copyright 1998-2018 20Tab S.r.l. All Rights Reserved. #pragma once -#include "SlateBasics.h" +#include "Runtime/Slate/Public/SlateBasics.h" /** Style of the debug console */ namespace EPythonConsoleStyle @@ -33,12 +33,6 @@ class FPythonConsoleModule : public IModuleInterface output log DLL is unloaded on the fly. */ virtual TSharedRef< SWidget > MakeConsoleInputBox( TSharedPtr< SEditableTextBox >& OutExposedEditableTextBox ) const; - /** Opens a debug console in the specified window, if not already open */ - virtual void TogglePythonConsoleForWindow( const TSharedRef< SWindow >& Window, const EPythonConsoleStyle::Type InStyle, const FPythonConsoleDelegates& PythonConsoleDelegates ); - - /** Closes the debug console for the specified window */ - virtual void ClosePythonConsole(); - private: diff --git a/Source/PythonConsole/PythonConsole.Build.cs b/Source/PythonConsole/PythonConsole.Build.cs index 5fa8b759b..29476f1dc 100644 --- a/Source/PythonConsole/PythonConsole.Build.cs +++ b/Source/PythonConsole/PythonConsole.Build.cs @@ -11,6 +11,10 @@ public PythonConsole(ReadOnlyTargetRules Target) : base(Target) public PythonConsole(TargetInfo Target) #endif { + PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs; + string enableUnityBuild = System.Environment.GetEnvironmentVariable("UEP_ENABLE_UNITY_BUILD"); + bFasterWithoutUnity = string.IsNullOrEmpty(enableUnityBuild); + PrivateIncludePaths.AddRange( new string[] { "PythonConsole/Private", diff --git a/Source/PythonEditor/Private/DirectoryScanner.cpp b/Source/PythonEditor/Private/DirectoryScanner.cpp index 1edc98793..ff4c6b085 100644 --- a/Source/PythonEditor/Private/DirectoryScanner.cpp +++ b/Source/PythonEditor/Private/DirectoryScanner.cpp @@ -1,7 +1,8 @@ // Copyright 1998-2016 Epic Games, Inc. All Rights Reserved. -#include "PythonEditorPrivatePCH.h" #include "DirectoryScanner.h" +#include "Runtime/Core/Public/Misc/IQueuedWork.h" +#include "Runtime/Core/Public/GenericPlatform/GenericPlatformFile.h" #include "PythonProjectItem.h" TArray FDirectoryScanner::CommandQueue; diff --git a/Source/PythonEditor/Private/PYRichTextSyntaxHighlighterTextLayoutMarshaller.cpp b/Source/PythonEditor/Private/PYRichTextSyntaxHighlighterTextLayoutMarshaller.cpp index b6303bf18..f0b15596e 100644 --- a/Source/PythonEditor/Private/PYRichTextSyntaxHighlighterTextLayoutMarshaller.cpp +++ b/Source/PythonEditor/Private/PYRichTextSyntaxHighlighterTextLayoutMarshaller.cpp @@ -1,8 +1,8 @@ // Copyright 1998-2016 Epic Games, Inc. All Rights Reserved. -#include "PythonEditorPrivatePCH.h" #include "PYRichTextSyntaxHighlighterTextLayoutMarshaller.h" #include "WhiteSpaceTextRun.h" +#include "Runtime/Launch/Resources/Version.h" FPYRichTextSyntaxHighlighterTextLayoutMarshaller::FPYRichTextSyntaxHighlighterTextLayoutMarshaller(TSharedPtr< FPythonSyntaxTokenizer > InTokenizer, const FSyntaxTextStyle& InSyntaxTextStyle) : Tokenizer(MoveTemp(InTokenizer)) @@ -311,7 +311,11 @@ void FPYRichTextSyntaxHighlighterTextLayoutMarshaller::ParseTokens(const FString FRunInfo RunInfo(TEXT("SyntaxHighlight.PY.Normal")); FTextBlockStyle TextBlockStyle = SyntaxTextStyle.NormalTextStyle; +#if ENGINE_MINOR_VERSION >= 18 + const bool bIsWhitespace = FString(TokenText).TrimEnd().IsEmpty(); +#else const bool bIsWhitespace = FString(TokenText).TrimTrailing().IsEmpty(); +#endif if(!bIsWhitespace) { bool bHasMatchedSyntax = false; diff --git a/Source/PythonEditor/Private/PYRichTextSyntaxHighlighterTextLayoutMarshaller.h b/Source/PythonEditor/Private/PYRichTextSyntaxHighlighterTextLayoutMarshaller.h index 52ce856a3..2db325648 100644 --- a/Source/PythonEditor/Private/PYRichTextSyntaxHighlighterTextLayoutMarshaller.h +++ b/Source/PythonEditor/Private/PYRichTextSyntaxHighlighterTextLayoutMarshaller.h @@ -1,10 +1,11 @@ // Copyright 1998-2016 Epic Games, Inc. All Rights Reserved. #pragma once - +#include "Runtime/SlateCore/Public/Styling/SlateTypes.h" #include "PythonSyntaxTokenizer.h" -#include "PlainTextLayoutMarshaller.h" -#include "ITextDecorator.h" +#include "Runtime/Slate/Public/Framework/Text/PlainTextLayoutMarshaller.h" +#include "Runtime/Slate/Public/Framework/Text/ITextDecorator.h" +#include "PythonEditorStyle.h" class FPYRichTextSyntaxHighlighterTextLayoutMarshaller : public FPlainTextLayoutMarshaller diff --git a/Source/PythonEditor/Private/PythonEditor.cpp b/Source/PythonEditor/Private/PythonEditor.cpp index 5c72aa548..42bbf9e5e 100644 --- a/Source/PythonEditor/Private/PythonEditor.cpp +++ b/Source/PythonEditor/Private/PythonEditor.cpp @@ -1,10 +1,13 @@ // Copyright 1998-2016 Epic Games, Inc. All Rights Reserved. -#include "PythonEditorPrivatePCH.h" -#include "ModuleManager.h" +#include "Runtime/Core/Public/Modules/ModuleManager.h" #include "AssetToolsModule.h" -#include "AssetEditorToolkit.h" +#include "Editor/UnrealEd/Public/Toolkits/AssetEditorToolkit.h" #include "LevelEditor.h" +#include "PythonEditorStyle.h" +#include "PythonProjectEditor.h" +#include "PythonProject.h" +#include "Runtime/Slate/Public/Framework/MultiBox/MultiBoxBuilder.h" static const FName PythonEditorTabName( TEXT( "PythonEditor" ) ); diff --git a/Source/PythonEditor/Private/PythonEditorCustomization.cpp b/Source/PythonEditor/Private/PythonEditorCustomization.cpp index 3211546fb..b3fd53ce9 100644 --- a/Source/PythonEditor/Private/PythonEditorCustomization.cpp +++ b/Source/PythonEditor/Private/PythonEditorCustomization.cpp @@ -1,6 +1,5 @@ // Copyright 1998-2016 Epic Games, Inc. All Rights Reserved. -#include "PythonEditorPrivatePCH.h" #include "PythonEditorCustomization.h" UPythonEditorCustomization::UPythonEditorCustomization(const FObjectInitializer& ObjectInitializer) diff --git a/Source/PythonEditor/Private/PythonEditorCustomization.h b/Source/PythonEditor/Private/PythonEditorCustomization.h index 581b9f178..4565247e3 100644 --- a/Source/PythonEditor/Private/PythonEditorCustomization.h +++ b/Source/PythonEditor/Private/PythonEditorCustomization.h @@ -2,6 +2,7 @@ #pragma once +#include "UnrealEd.h" #include "PythonEditorCustomization.generated.h" USTRUCT() diff --git a/Source/PythonEditor/Private/PythonEditorPrivatePCH.h b/Source/PythonEditor/Private/PythonEditorPrivatePCH.h deleted file mode 100644 index dac15ddc2..000000000 --- a/Source/PythonEditor/Private/PythonEditorPrivatePCH.h +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved. - -#pragma once - - -/* Private dependencies - *****************************************************************************/ - -#include "Core.h" -#include "CoreUObject.h" -#include "SlateBasics.h" -#include "EditorStyle.h" -#include "PropertyEditing.h" -#include "UnrealEd.h" -#include "DirectoryWatcherModule.h" -#include "IPluginManager.h" - - -/* Private includes - *****************************************************************************/ - -#include "PythonEditorStyle.h" -#include "PythonProject.h" -#include "PythonProjectEditorCommands.h" -#include "PythonProjectEditor.h" -#include "PythonProjectItem.h" -#include "UnrealEnginePython/Public/UnrealEnginePython.h" - diff --git a/Source/PythonEditor/Private/PythonEditorStyle.cpp b/Source/PythonEditor/Private/PythonEditorStyle.cpp index 02da9d8cc..06f30e2ec 100644 --- a/Source/PythonEditor/Private/PythonEditorStyle.cpp +++ b/Source/PythonEditor/Private/PythonEditorStyle.cpp @@ -1,7 +1,11 @@ // Copyright 1998-2016 Epic Games, Inc. All Rights Reserved. -#include "PythonEditorPrivatePCH.h" +#include "PythonEditorStyle.h" #include "EditorStyleSet.h" +#include "SlateCore.h" +#include "Runtime/SlateCore/Public/Styling/SlateStyle.h" +#include "Runtime/Projects/Public/Interfaces/IPluginManager.h" + TSharedPtr< FSlateStyleSet > FPythonEditorStyle::StyleSet = nullptr; @@ -33,12 +37,12 @@ static const FVector2D Icon267x140(170.0f, 50.0f); void FPythonEditorStyle::Initialize() { // Only register once - if( StyleSet.IsValid() ) + if (StyleSet.IsValid()) { return; } - StyleSet = MakeShareable(new FSlateStyleSet("PythonEditor") ); + StyleSet = MakeShareable(new FSlateStyleSet("PythonEditor")); StyleSet->SetContentRoot(IPluginManager::Get().FindPlugin("UnrealEnginePython")->GetBaseDir() / TEXT("Resources")); @@ -58,13 +62,13 @@ void FPythonEditorStyle::Initialize() StyleSet->Set("PythonEditor.SaveAll.Small", new IMAGE_BRUSH("UI/SaveAll_40x", Icon16x16)); StyleSet->Set("PythonEditor.Execute", new IMAGE_BRUSH("UI/Excute_x40", Icon40x40)); StyleSet->Set("PythonEditor.Execute.Small", new IMAGE_BRUSH("UI/Excute_x40", Icon16x16)); - StyleSet->Set("PythonEditor.ExecuteInSandbox", new IMAGE_BRUSH("UI/Excute_x40", Icon40x40)); - StyleSet->Set("PythonEditor.ExecuteInSandbox.Small", new IMAGE_BRUSH("UI/Excute_x40", Icon16x16)); + StyleSet->Set("PythonEditor.ExecuteInMainThread", new IMAGE_BRUSH("UI/Excute_x40", Icon40x40)); + StyleSet->Set("PythonEditor.ExecuteInMainThread.Small", new IMAGE_BRUSH("UI/Excute_x40", Icon16x16)); StyleSet->Set("PythonEditor.PEP8ize", new IMAGE_BRUSH("UI/Excute_x40", Icon40x40)); StyleSet->Set("PythonEditor.PEP8ize.Small", new IMAGE_BRUSH("UI/Excute_x40", Icon16x16)); } - const FSlateFontInfo Consolas10 = TTF_FONT("Font/DroidSansMono", 9); + const FSlateFontInfo Consolas10 = TTF_FONT("Font/DroidSansMono", 9); const FTextBlockStyle NormalText = FTextBlockStyle() .SetFont(Consolas10) @@ -88,28 +92,28 @@ void FPythonEditorStyle::Initialize() StyleSet->Set("SyntaxHighlight.PY.Define", FTextBlockStyle(NormalText).SetColorAndOpacity(FLinearColor(FColor(0xffa6e22a)))); // light grey - StyleSet->Set("TextEditor.Border", new BOX_BRUSH("UI/TextEditorBorder", FMargin(4.0f/16.0f), FLinearColor(0.02f,0.02f,0.02f,1))); + StyleSet->Set("TextEditor.Border", new BOX_BRUSH("UI/TextEditorBorder", FMargin(4.0f / 16.0f), FLinearColor(0.02f, 0.02f, 0.02f, 1))); const FEditableTextBoxStyle EditableTextBoxStyle = FEditableTextBoxStyle() - .SetBackgroundImageNormal( FSlateNoResource() ) - .SetBackgroundImageHovered( FSlateNoResource() ) - .SetBackgroundImageFocused( FSlateNoResource() ) - .SetBackgroundImageReadOnly( FSlateNoResource() ); - + .SetBackgroundImageNormal(FSlateNoResource()) + .SetBackgroundImageHovered(FSlateNoResource()) + .SetBackgroundImageFocused(FSlateNoResource()) + .SetBackgroundImageReadOnly(FSlateNoResource()); + StyleSet->Set("TextEditor.EditableTextBox", EditableTextBoxStyle); } // Project editor { - StyleSet->Set("ProjectEditor.Border", new BOX_BRUSH("UI/TextEditorBorder", FMargin(4.0f/16.0f), FLinearColor(0.048f,0.048f,0.048f,1))); + StyleSet->Set("ProjectEditor.Border", new BOX_BRUSH("UI/TextEditorBorder", FMargin(4.0f / 16.0f), FLinearColor(0.048f, 0.048f, 0.048f, 1))); - StyleSet->Set("ProjectEditor.Icon.Project", new IMAGE_BRUSH("UI/FolderClosed", Icon16x16, FLinearColor(0.25f,0.25f,0.25f,1))); - StyleSet->Set("ProjectEditor.Icon.Folder", new IMAGE_BRUSH("UI/FolderClosed", Icon16x16, FLinearColor(0.25f,0.25f,0.25f,1))); + StyleSet->Set("ProjectEditor.Icon.Project", new IMAGE_BRUSH("UI/FolderClosed", Icon16x16, FLinearColor(0.25f, 0.25f, 0.25f, 1))); + StyleSet->Set("ProjectEditor.Icon.Folder", new IMAGE_BRUSH("UI/FolderClosed", Icon16x16, FLinearColor(0.25f, 0.25f, 0.25f, 1))); StyleSet->Set("ProjectEditor.Icon.File", new IMAGE_BRUSH("UI/PythonEditor_16x", Icon16x16)); StyleSet->Set("ProjectEditor.Icon.GenericFile", new IMAGE_BRUSH("UI/GenericFile", Icon16x16)); } - FSlateStyleRegistry::RegisterSlateStyle( *StyleSet.Get() ); + FSlateStyleRegistry::RegisterSlateStyle(*StyleSet.Get()); } #undef IMAGE_BRUSH @@ -120,17 +124,17 @@ void FPythonEditorStyle::Initialize() void FPythonEditorStyle::Shutdown() { - if( StyleSet.IsValid() ) + if (StyleSet.IsValid()) { - FSlateStyleRegistry::UnRegisterSlateStyle( *StyleSet.Get() ); - ensure( StyleSet.IsUnique() ); + FSlateStyleRegistry::UnRegisterSlateStyle(*StyleSet.Get()); + ensure(StyleSet.IsUnique()); StyleSet.Reset(); } } const ISlateStyle& FPythonEditorStyle::Get() { - return *( StyleSet.Get() ); + return *(StyleSet.Get()); } const FName& FPythonEditorStyle::GetStyleSetName() diff --git a/Source/PythonEditor/Private/PythonEditorStyle.h b/Source/PythonEditor/Private/PythonEditorStyle.h index a411d1bf3..036858eeb 100644 --- a/Source/PythonEditor/Private/PythonEditorStyle.h +++ b/Source/PythonEditor/Private/PythonEditorStyle.h @@ -2,7 +2,7 @@ #pragma once -#include "SlateStyle.h" +#include "Runtime/SlateCore/Public/Styling/SlateStyle.h" class FPythonEditorStyle { diff --git a/Source/PythonEditor/Private/PythonProject.cpp b/Source/PythonEditor/Private/PythonProject.cpp index 50cfd4377..d49148fe3 100644 --- a/Source/PythonEditor/Private/PythonProject.cpp +++ b/Source/PythonEditor/Private/PythonProject.cpp @@ -1,11 +1,12 @@ // Copyright 1998-2016 Epic Games, Inc. All Rights Reserved. -#include "PythonEditorPrivatePCH.h" +#include "PythonProject.h" +#include "UnrealEnginePython.h" UPythonProject::UPythonProject(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) { FUnrealEnginePythonModule &PythonModule = FModuleManager::GetModuleChecked("UnrealEnginePython"); - Path = PythonModule.ScriptsPath; + Path = PythonModule.ScriptsPaths[0]; } diff --git a/Source/PythonEditor/Private/PythonProjectEditor.cpp b/Source/PythonEditor/Private/PythonProjectEditor.cpp index acd711638..33b2a56c8 100644 --- a/Source/PythonEditor/Private/PythonProjectEditor.cpp +++ b/Source/PythonEditor/Private/PythonProjectEditor.cpp @@ -1,12 +1,18 @@ // Copyright 1998-2016 Epic Games, Inc. All Rights Reserved. -#include "PythonEditorPrivatePCH.h" +#include "PythonProjectEditor.h" #include "SPythonEditor.h" #include "SPythonProjectEditor.h" -#include "SDockTab.h" +#include "Runtime/Slate/Public/Widgets/Docking/SDockTab.h" #include "PythonProjectEditorToolbar.h" #include "Editor/Kismet/Public/WorkflowOrientedApp/WorkflowUObjectDocuments.h" #include "Editor/Kismet/Public/WorkflowOrientedApp/ApplicationMode.h" +#include "PythonProjectItem.h" +#include "PythonEditorStyle.h" +#include "PythonProject.h" +#include "PythonProjectEditorCommands.h" +#include "Runtime/Core/Public/HAL/PlatformFilemanager.h" +#include "Runtime/Core/Public/Misc/MessageDialog.h" #define LOCTEXT_NAMESPACE "PythonEditor" TWeakPtr FPythonProjectEditor::PythonEditor; @@ -267,11 +273,12 @@ void FPythonProjectEditor::BindCommands() FExecuteAction::CreateSP(this, &FPythonProjectEditor::Execute_Internal), FCanExecuteAction::CreateSP(this, &FPythonProjectEditor::CanExecute) ); - - ToolkitCommands->MapAction(FPythonProjectEditorCommands::Get().ExecuteInSandbox, - FExecuteAction::CreateSP(this, &FPythonProjectEditor::ExecuteInSandbox_Internal), +#if PLATFORM_MAC + ToolkitCommands->MapAction(FPythonProjectEditorCommands::Get().ExecuteInMainThread, + FExecuteAction::CreateSP(this, &FPythonProjectEditor::ExecuteInMainThread_Internal), FCanExecuteAction::CreateSP(this, &FPythonProjectEditor::CanExecute) ); +#endif ToolkitCommands->MapAction(FPythonProjectEditorCommands::Get().PEP8ize, FExecuteAction::CreateSP(this, &FPythonProjectEditor::PEP8ize_Internal), @@ -498,34 +505,37 @@ void FPythonProjectEditor::Execute_Internal() Execute(); } -void FPythonProjectEditor::PEP8ize_Internal() -{ - PEP8ize(); -} - -void FPythonProjectEditor::ExecuteInSandbox_Internal() +#if PLATFORM_MAC +void FPythonProjectEditor::ExecuteInMainThread_Internal() { - Execute(); + ExecuteInMainThread(); } - -bool FPythonProjectEditor::Execute() +bool FPythonProjectEditor::ExecuteInMainThread() { if (DocumentManager.IsValid() && DocumentManager->GetActiveTab().IsValid()) { TSharedRef PythonEditorRef = StaticCastSharedRef(DocumentManager->GetActiveTab()->GetContent()); - PythonEditorRef->Execute(); + PythonEditorRef->ExecuteInMainThread(); } return true; } -bool FPythonProjectEditor::ExecuteInSandbox() + +#endif + +void FPythonProjectEditor::PEP8ize_Internal() +{ + PEP8ize(); +} + +bool FPythonProjectEditor::Execute() { if (DocumentManager.IsValid() && DocumentManager->GetActiveTab().IsValid()) { TSharedRef PythonEditorRef = StaticCastSharedRef(DocumentManager->GetActiveTab()->GetContent()); - PythonEditorRef->ExecuteInSandbox(); + PythonEditorRef->Execute(); } return true; @@ -561,4 +571,4 @@ bool FPythonProjectEditor::CanExecute() const } ////////////////////////////////////////////////////////////////////////// -#undef LOCTEXT_NAMESPACE \ No newline at end of file +#undef LOCTEXT_NAMESPACE diff --git a/Source/PythonEditor/Private/PythonProjectEditor.h b/Source/PythonEditor/Private/PythonProjectEditor.h index c44886bbd..0dfe50f73 100644 --- a/Source/PythonEditor/Private/PythonProjectEditor.h +++ b/Source/PythonEditor/Private/PythonProjectEditor.h @@ -2,8 +2,9 @@ #pragma once -#include "WorkflowCentricApplication.h" +#include "Editor/Kismet/Public/WorkflowOrientedApp/WorkflowCentricApplication.h" #include "Editor/Kismet/Public/WorkflowOrientedApp/WorkflowTabManager.h" +#include "Runtime/Launch/Resources/Version.h" class FPythonProjectEditor : public FWorkflowCentricApplication, public FGCObject { @@ -61,7 +62,9 @@ class FPythonProjectEditor : public FWorkflowCentricApplication, public FGCObjec bool Execute(); - bool ExecuteInSandbox(); +#if PLATFORM_MAC + bool ExecuteInMainThread(); +#endif bool PEP8ize(); @@ -82,7 +85,9 @@ class FPythonProjectEditor : public FWorkflowCentricApplication, public FGCObjec void Execute_Internal(); - void ExecuteInSandbox_Internal(); +#if PLATFORM_MAC + void ExecuteInMainThread_Internal(); +#endif void PEP8ize_Internal(); @@ -105,4 +110,9 @@ class FPythonProjectEditor : public FWorkflowCentricApplication, public FGCObjec TSharedPtr ToolbarBuilder; static TWeakPtr PythonEditor; + + virtual bool CanSaveAsset() const override { return false; } +#if ENGINE_MINOR_VERSION > 17 + virtual bool CanFindInContentBrowser() const override { return false; } +#endif }; diff --git a/Source/PythonEditor/Private/PythonProjectEditorCommands.cpp b/Source/PythonEditor/Private/PythonProjectEditorCommands.cpp index 84ef134d0..598049d73 100644 --- a/Source/PythonEditor/Private/PythonProjectEditorCommands.cpp +++ b/Source/PythonEditor/Private/PythonProjectEditorCommands.cpp @@ -1,7 +1,7 @@ // Copyright 1998-2016 Epic Games, Inc. All Rights Reserved. -#include "PythonEditorPrivatePCH.h" - +#include "PythonProjectEditorCommands.h" +#include "PythonEditorStyle.h" #define LOCTEXT_NAMESPACE "PythonProjectEditorCommands" @@ -21,7 +21,9 @@ void FPythonProjectEditorCommands::RegisterCommands() UI_COMMAND(Save, "Save", "Save the currently active document.", EUserInterfaceActionType::Button, FInputGesture(EModifierKey::Control, EKeys::S)); UI_COMMAND(SaveAll, "Save All", "Save all open documents.", EUserInterfaceActionType::Button, FInputGesture(EModifierKey::Control | EModifierKey::Shift, EKeys::S)); UI_COMMAND(Execute, "Execute", "Execute Current Python File.", EUserInterfaceActionType::Button, FInputGesture(EModifierKey::Control, EKeys::Enter)); - UI_COMMAND(ExecuteInSandbox, "Execute In Sandbox", "Execute Current Python File in a Sandbox.", EUserInterfaceActionType::Button, FInputGesture(EModifierKey::Control | EModifierKey::Shift, EKeys::Enter)); +#if PLATFORM_MAC + UI_COMMAND(ExecuteInMainThread, "Execute In Main Thread", "Execute Current Python File in the Main Thread.", EUserInterfaceActionType::Button, FInputGesture(EModifierKey::Control | EModifierKey::Shift, EKeys::Enter)); +#endif UI_COMMAND(PEP8ize, "PEP8-ize", "Enforce PEP8 to the current code.", EUserInterfaceActionType::Button, FInputGesture(EModifierKey::Control | EModifierKey::Shift, EKeys::P)); } diff --git a/Source/PythonEditor/Private/PythonProjectEditorCommands.h b/Source/PythonEditor/Private/PythonProjectEditorCommands.h index e80d753e4..d87beb93f 100644 --- a/Source/PythonEditor/Private/PythonProjectEditorCommands.h +++ b/Source/PythonEditor/Private/PythonProjectEditorCommands.h @@ -2,7 +2,7 @@ #pragma once -#include "Commands.h" +#include "Runtime/Slate/Public/Framework/Commands/Commands.h" class FPythonProjectEditorCommands : public TCommands { @@ -15,8 +15,10 @@ class FPythonProjectEditorCommands : public TCommands Save; TSharedPtr SaveAll; TSharedPtr Execute; - TSharedPtr ExecuteInSandbox; +#if PLATFORM_MAC + TSharedPtr ExecuteInMainThread; +#endif TSharedPtr PEP8ize; /** Initialize commands */ virtual void RegisterCommands() override; -}; \ No newline at end of file +}; diff --git a/Source/PythonEditor/Private/PythonProjectEditorToolbar.cpp b/Source/PythonEditor/Private/PythonProjectEditorToolbar.cpp index 4731a1d02..8b47d47b4 100644 --- a/Source/PythonEditor/Private/PythonProjectEditorToolbar.cpp +++ b/Source/PythonEditor/Private/PythonProjectEditorToolbar.cpp @@ -1,10 +1,12 @@ // Copyright 1998-2016 Epic Games, Inc. All Rights Reserved. -#include "PythonEditorPrivatePCH.h" #include "PythonProjectEditorToolbar.h" #include "LevelEditorActions.h" #include "SourceCodeNavigation.h" #include "EditorStyleSet.h" +#include "Runtime/Slate/Public/Framework/MultiBox/MultiBoxExtender.h" +#include "PythonProjectEditor.h" +#include "PythonProjectEditorCommands.h" void FPythonProjectEditorToolbar::AddEditorToolbar(TSharedPtr Extender) @@ -36,9 +38,11 @@ void FPythonProjectEditorToolbar::FillEditorToolbar(FToolBarBuilder& ToolbarBuil ToolbarBuilder.BeginSection(TEXT("CodeExcute")); { ToolbarBuilder.AddToolBarButton(FPythonProjectEditorCommands::Get().Execute); - ToolbarBuilder.AddToolBarButton(FPythonProjectEditorCommands::Get().ExecuteInSandbox); +#if PLATFORM_MAC + ToolbarBuilder.AddToolBarButton(FPythonProjectEditorCommands::Get().ExecuteInMainThread); +#endif ToolbarBuilder.AddToolBarButton(FPythonProjectEditorCommands::Get().PEP8ize); } ToolbarBuilder.EndSection(); -} \ No newline at end of file +} diff --git a/Source/PythonEditor/Private/PythonProjectEditorToolbar.h b/Source/PythonEditor/Private/PythonProjectEditorToolbar.h index 5d12de604..3b2dee5b9 100644 --- a/Source/PythonEditor/Private/PythonProjectEditorToolbar.h +++ b/Source/PythonEditor/Private/PythonProjectEditorToolbar.h @@ -2,6 +2,9 @@ #pragma once +#include "PythonProjectEditor.h" +#include "Runtime/Slate/Public/Framework/MultiBox/MultiBoxBuilder.h" + class FPythonProjectEditorToolbar : public TSharedFromThis { public: diff --git a/Source/PythonEditor/Private/PythonProjectItem.cpp b/Source/PythonEditor/Private/PythonProjectItem.cpp index 615c6fcd0..a7440c0b0 100644 --- a/Source/PythonEditor/Private/PythonProjectItem.cpp +++ b/Source/PythonEditor/Private/PythonProjectItem.cpp @@ -1,6 +1,5 @@ // Copyright 1998-2016 Epic Games, Inc. All Rights Reserved. -#include "PythonEditorPrivatePCH.h" #include "PythonProjectItem.h" #include "DirectoryScanner.h" #include "Developer/DirectoryWatcher/Public/IDirectoryWatcher.h" diff --git a/Source/PythonEditor/Private/PythonProjectItem.h b/Source/PythonEditor/Private/PythonProjectItem.h index 4d3372fb7..7e4363e28 100644 --- a/Source/PythonEditor/Private/PythonProjectItem.h +++ b/Source/PythonEditor/Private/PythonProjectItem.h @@ -2,6 +2,7 @@ #pragma once +#include "UnrealEd.h" #include "PythonProjectItem.generated.h" /** Types of project items. Note that the enum ordering determines the tree sorting */ diff --git a/Source/PythonEditor/Private/PythonSyntaxTokenizer.cpp b/Source/PythonEditor/Private/PythonSyntaxTokenizer.cpp index 91c587cb6..e4e14ef46 100644 --- a/Source/PythonEditor/Private/PythonSyntaxTokenizer.cpp +++ b/Source/PythonEditor/Private/PythonSyntaxTokenizer.cpp @@ -1,8 +1,7 @@ // Copyright 1998-2016 Epic Games, Inc. All Rights Reserved. -#include "PythonEditorPrivatePCH.h" #include "PythonSyntaxTokenizer.h" -#include "BreakIterator.h" +#include "Runtime/Core/Public/Internationalization/BreakIterator.h" TSharedRef< FPythonSyntaxTokenizer > FPythonSyntaxTokenizer::Create(TArray InRules) { diff --git a/Source/PythonEditor/Private/PythonSyntaxTokenizer.h b/Source/PythonEditor/Private/PythonSyntaxTokenizer.h index 4235cf8df..a016b055a 100644 --- a/Source/PythonEditor/Private/PythonSyntaxTokenizer.h +++ b/Source/PythonEditor/Private/PythonSyntaxTokenizer.h @@ -1,6 +1,8 @@ // Copyright 1998-2016 Epic Games, Inc. All Rights Reserved. #pragma once +#include "Runtime/Slate/Public/Framework/Text/SyntaxTokenizer.h" + /** * Tokenize the text based upon the given rule set */ diff --git a/Source/PythonEditor/Private/SProjectViewItem.cpp b/Source/PythonEditor/Private/SProjectViewItem.cpp index b99afa509..5a5e993d3 100644 --- a/Source/PythonEditor/Private/SProjectViewItem.cpp +++ b/Source/PythonEditor/Private/SProjectViewItem.cpp @@ -1,9 +1,9 @@ // Copyright 1998-2016 Epic Games, Inc. All Rights Reserved. -#include "PythonEditorPrivatePCH.h" #include "SProjectViewItem.h" -#include "SInlineEditableTextBlock.h" -#include "BreakIterator.h" +#include "Runtime/Slate/Public/Widgets/Text/SInlineEditableTextBlock.h" +#include "Runtime/Core/Public/Internationalization/BreakIterator.h" +#include "PythonEditorStyle.h" #define LOCTEXT_NAMESPACE "ProjectViewItem" diff --git a/Source/PythonEditor/Private/SProjectViewItem.h b/Source/PythonEditor/Private/SProjectViewItem.h index 3cce4f8cf..2ebf7a507 100644 --- a/Source/PythonEditor/Private/SProjectViewItem.h +++ b/Source/PythonEditor/Private/SProjectViewItem.h @@ -2,6 +2,9 @@ #pragma once +#include "SlateCore.h" +#include "PythonProjectItem.h" + class SProjectViewItem : public SCompoundWidget { public: diff --git a/Source/PythonEditor/Private/SPythonEditableText.cpp b/Source/PythonEditor/Private/SPythonEditableText.cpp index a08562204..d91ba2a80 100644 --- a/Source/PythonEditor/Private/SPythonEditableText.cpp +++ b/Source/PythonEditor/Private/SPythonEditableText.cpp @@ -1,7 +1,8 @@ // Copyright 1998-2016 Epic Games, Inc. All Rights Reserved. -#include "PythonEditorPrivatePCH.h" #include "SPythonEditableText.h" +#include "PythonEditorStyle.h" +#include "Runtime/Slate/Public/Framework/Application/SlateApplication.h" void SPythonEditableText::Construct(const FArguments& InArgs) @@ -20,6 +21,7 @@ void SPythonEditableText::Construct(const FArguments& InArgs) .OnCursorMoved(this, &SPythonEditableText::OnCursorMoved) ); OnExecuted = InArgs._OnExecuted; + CurrentScale = 1; } FReply SPythonEditableText::OnKeyChar(const FGeometry& MyGeometry, const FCharacterEvent& InCharacterEvent) @@ -32,11 +34,10 @@ FReply SPythonEditableText::OnKeyChar(const FGeometry& MyGeometry, const FCharac return Reply; } Reply = FReply::Handled(); + // substitute tab, with 4 spaces if (Character == TEXT('\t')) { - FString String; - String.AppendChar(Character); - InsertTextAtCursor(String); + InsertTextAtCursor(FString(" ")); } //else if (Character == TEXT('(')) //{ @@ -71,17 +72,41 @@ FReply SPythonEditableText::OnKeyChar(const FGeometry& MyGeometry, const FCharac return Reply; } +FReply SPythonEditableText::OnMouseWheel(const FGeometry& MyGeometry, const FPointerEvent& InPointerEvent) +{ + if (FSlateApplication::Get().GetModifierKeys().IsControlDown()) + { + if (InPointerEvent.GetWheelDelta() > 0) + { + CurrentScale += 0.1; + } + else if (InPointerEvent.GetWheelDelta() < 0) + { + CurrentScale -= 0.1; + } + + if (CurrentScale < 1) + CurrentScale = 1; + SetRenderTransform(FSlateRenderTransform(CurrentScale)); + return FReply::Handled(); + } + return SMultiLineEditableText::OnMouseWheel(MyGeometry, InPointerEvent); +} + FReply SPythonEditableText::OnKeyDown(const FGeometry& MyGeometry, const FKeyEvent& InKeyEvent) { FReply Reply = FReply::Unhandled(); - if (InKeyEvent.GetKeyCode() == 9) { + if (InKeyEvent.GetKeyCode() == 9) + { Reply = FReply::Handled(); } - else if (InKeyEvent.IsControlDown() && InKeyEvent.GetKeyCode() == 13) { + else if (InKeyEvent.IsControlDown() && InKeyEvent.GetKeyCode() == 13) + { Reply = FReply::Handled(); OnExecuted.Execute(); } - else { + else + { Reply = SMultiLineEditableText::OnKeyDown(MyGeometry, InKeyEvent); } diff --git a/Source/PythonEditor/Private/SPythonEditableText.h b/Source/PythonEditor/Private/SPythonEditableText.h index 0c96034c1..ade80446d 100644 --- a/Source/PythonEditor/Private/SPythonEditableText.h +++ b/Source/PythonEditor/Private/SPythonEditableText.h @@ -2,7 +2,7 @@ #pragma once -#include "SMultiLineEditableText.h" +#include "Runtime/Slate/Public/Widgets/Text/SMultiLineEditableText.h" class SPythonEditableText : public SMultiLineEditableText { @@ -39,9 +39,12 @@ class SPythonEditableText : public SMultiLineEditableText private: virtual FReply OnKeyChar(const FGeometry& MyGeometry,const FCharacterEvent& InCharacterEvent) override; virtual FReply OnKeyDown(const FGeometry& MyGeometry, const FKeyEvent& InKeyEvent) override; + virtual FReply OnMouseWheel(const FGeometry& MyGeometry, const FPointerEvent& InPointerEvent) override; FOnExecuted OnExecuted; + float CurrentScale; + int32 CurrentLine; int32 CurrentColumn; }; \ No newline at end of file diff --git a/Source/PythonEditor/Private/SPythonEditor.cpp b/Source/PythonEditor/Private/SPythonEditor.cpp index e8eaafa5d..cec7cff05 100644 --- a/Source/PythonEditor/Private/SPythonEditor.cpp +++ b/Source/PythonEditor/Private/SPythonEditor.cpp @@ -1,10 +1,16 @@ // Copyright 1998-2016 Epic Games, Inc. All Rights Reserved. -#include "PythonEditorPrivatePCH.h" #include "SPythonEditor.h" -#include "SMultiLineEditableText.h" +#include "Runtime/Slate/Public/Widgets/Text/SMultiLineEditableText.h" #include "PYRichTextSyntaxHighlighterTextLayoutMarshaller.h" #include "SPythonEditableText.h" +#include "Runtime/Core/Public/Misc/FileHelper.h" +#include "PythonProjectItem.h" +#include "Runtime/Slate/Public/Widgets/Layout/SGridPanel.h" +#include "PythonEditorStyle.h" +#include "Runtime/Slate/Public/Widgets/Text/STextBlock.h" +#include "Runtime/Slate/Public/Widgets/Layout/SScrollBar.h" +#include "UnrealEnginePython.h" #define LOCTEXT_NAMESPACE "PythonEditor" @@ -108,17 +114,20 @@ void SPythonEditor::Execute() const PythonModule.RunString(TCHAR_TO_UTF8(*SelectionString)); } -void SPythonEditor::ExecuteInSandbox() const +#if PLATFORM_MAC +void SPythonEditor::ExecuteInMainThread() const { Save(); FUnrealEnginePythonModule &PythonModule = FModuleManager::GetModuleChecked("UnrealEnginePython"); - + FString SelectionString = PythonEditableText->GetSelectedText().ToString(); if (SelectionString.Len() == 0) { SelectionString = PythonEditableText->GetText().ToString(); } - PythonModule.RunStringSandboxed(TCHAR_TO_UTF8(*SelectionString)); + PythonModule.RunStringInMainThread(TCHAR_TO_UTF8(*SelectionString)); } +#endif + void SPythonEditor::PEP8ize() const { @@ -144,9 +153,9 @@ FText SPythonEditor::GetLineAndColumn() const int32 Column; PythonEditableText->GetLineAndColumn(Line, Column); - FString LineAndColumn = FString::Printf(TEXT("Line: %d Column: %d"), Line, Column); + FString LineAndColumn = FString::Printf(TEXT("Line: %d Column: %d"), Line + 1, Column); return FText::FromString(LineAndColumn); } -#undef LOCTEXT_NAMESPACE \ No newline at end of file +#undef LOCTEXT_NAMESPACE diff --git a/Source/PythonEditor/Private/SPythonEditor.h b/Source/PythonEditor/Private/SPythonEditor.h index 701de077e..81b73a366 100644 --- a/Source/PythonEditor/Private/SPythonEditor.h +++ b/Source/PythonEditor/Private/SPythonEditor.h @@ -2,6 +2,9 @@ #pragma once +#include "SlateCore.h" +#include "Runtime/Slate/Public/Widgets/Layout/SScrollBar.h" + class SPythonEditor : public SCompoundWidget { public: @@ -16,7 +19,9 @@ class SPythonEditor : public SCompoundWidget void Execute() const; - void ExecuteInSandbox() const; +#if PLATFORM_MAC + void ExecuteInMainThread() const; +#endif void GotoLineAndColumn(int32 LineNumber, int32 ColumnNumber); @@ -35,4 +40,4 @@ class SPythonEditor : public SCompoundWidget TSharedPtr PythonEditableText; mutable bool bDirty; -}; \ No newline at end of file +}; diff --git a/Source/PythonEditor/Private/SPythonProjectEditor.cpp b/Source/PythonEditor/Private/SPythonProjectEditor.cpp index f3240b843..de83047d1 100644 --- a/Source/PythonEditor/Private/SPythonProjectEditor.cpp +++ b/Source/PythonEditor/Private/SPythonProjectEditor.cpp @@ -1,10 +1,12 @@ // Copyright 1998-2016 Epic Games, Inc. All Rights Reserved. -#include "PythonEditorPrivatePCH.h" #include "SPythonProjectEditor.h" #include "SProjectViewItem.h" #include "DirectoryScanner.h" -#include "SThrobber.h" +#include "Runtime/Slate/Public/Widgets/Images/SThrobber.h" +#include "PythonEditorStyle.h" +#include "PythonProjectEditor.h" +#include "PythonProject.h" #define LOCTEXT_NAMESPACE "PythonProjectEditor" diff --git a/Source/PythonEditor/Private/SPythonProjectEditor.h b/Source/PythonEditor/Private/SPythonProjectEditor.h index 9479a7545..1e4d524ea 100644 --- a/Source/PythonEditor/Private/SPythonProjectEditor.h +++ b/Source/PythonEditor/Private/SPythonProjectEditor.h @@ -2,6 +2,10 @@ #pragma once +#include "SlateCore.h" +#include "Runtime/Slate/Public/Widgets/Views/STreeView.h" +#include "PythonProjectItem.h" + class SPythonProjectEditor : public SCompoundWidget { public: diff --git a/Source/PythonEditor/Private/WhiteSpaceTextRun.cpp b/Source/PythonEditor/Private/WhiteSpaceTextRun.cpp index d035f96c1..c25e4477d 100644 --- a/Source/PythonEditor/Private/WhiteSpaceTextRun.cpp +++ b/Source/PythonEditor/Private/WhiteSpaceTextRun.cpp @@ -1,7 +1,8 @@ // Copyright 1998-2016 Epic Games, Inc. All Rights Reserved. -#include "PythonEditorPrivatePCH.h" #include "WhiteSpaceTextRun.h" +#include "Runtime/Slate/Public/Framework/Application/SlateApplication.h" +#include "Runtime/SlateCore/Public/Fonts/FontMeasure.h" TSharedRef< FWhiteSpaceTextRun > FWhiteSpaceTextRun::Create( const FRunInfo& InRunInfo, const TSharedRef< const FString >& InText, const FTextBlockStyle& Style, const FTextRange& InRange, int32 NumSpacesPerTab ) { diff --git a/Source/PythonEditor/Private/WhiteSpaceTextRun.h b/Source/PythonEditor/Private/WhiteSpaceTextRun.h index f742b896c..1b52e0006 100644 --- a/Source/PythonEditor/Private/WhiteSpaceTextRun.h +++ b/Source/PythonEditor/Private/WhiteSpaceTextRun.h @@ -2,7 +2,7 @@ #pragma once -#include "SlateTextRun.h" +#include "Runtime/Slate/Public/Framework/Text/SlateTextRun.h" class FWhiteSpaceTextRun : public FSlateTextRun { diff --git a/Source/PythonEditor/PythonEditor.Build.cs b/Source/PythonEditor/PythonEditor.Build.cs index ecd04d8b8..11b024164 100644 --- a/Source/PythonEditor/PythonEditor.Build.cs +++ b/Source/PythonEditor/PythonEditor.Build.cs @@ -10,6 +10,11 @@ public PythonEditor(ReadOnlyTargetRules Target) : base(Target) public PythonEditor(TargetInfo Target) #endif { + + PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs; + string enableUnityBuild = System.Environment.GetEnvironmentVariable("UEP_ENABLE_UNITY_BUILD"); + bFasterWithoutUnity = string.IsNullOrEmpty(enableUnityBuild); + PrivateIncludePaths.AddRange( new string[] { "PythonEditor/Private", diff --git a/Source/UnrealEnginePython/Private/Blueprint/UEPyEdGraph.cpp b/Source/UnrealEnginePython/Private/Blueprint/UEPyEdGraph.cpp index 1e82e45d7..a3e53b7c5 100644 --- a/Source/UnrealEnginePython/Private/Blueprint/UEPyEdGraph.cpp +++ b/Source/UnrealEnginePython/Private/Blueprint/UEPyEdGraph.cpp @@ -1,9 +1,10 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPyEdGraph.h" #if WITH_EDITOR #include "Runtime/Engine/Classes/EdGraph/EdGraph.h" #include "Editor/BlueprintGraph/Classes/K2Node_CallFunction.h" +#include "Editor/BlueprintGraph/Classes/K2Node_DynamicCast.h" #include "Editor/BlueprintGraph/Classes/EdGraphSchema_K2.h" #include "Editor/BlueprintGraph/Classes/K2Node_CustomEvent.h" #include "Editor/BlueprintGraph/Classes/K2Node_VariableGet.h" @@ -12,6 +13,7 @@ #include "Editor/BlueprintGraph/Classes/EdGraphSchema_K2_Actions.h" #include "Editor/AIGraph/Classes/AIGraph.h" #include "Editor/AIGraph/Classes/AIGraphNode.h" +#include "Editor/BlueprintGraph/Classes/K2Node_FunctionEntry.h" PyObject *py_ue_graph_add_node_call_function(ue_PyUObject * self, PyObject * args) { @@ -289,56 +291,56 @@ PyObject *py_ue_graph_add_node(ue_PyUObject * self, PyObject * args) PyObject *py_node_class; int x = 0; int y = 0; - PyObject *py_data = nullptr; + char *metadata = nullptr; + PyObject *py_data = nullptr; + if (!PyArg_ParseTuple(args, "O|iisO:graph_add_node", &py_node_class, &x, &y, &metadata, &py_data)) { - return NULL; + return nullptr; } - if (!self->ue_object->IsA()) - { + UEdGraph *graph = ue_py_check_type(self); + if (!graph) return PyErr_Format(PyExc_Exception, "uobject is not a UEdGraph"); - } - - UEdGraph *graph = (UEdGraph *)self->ue_object; - if (!ue_is_pyuobject(py_node_class)) - { + UObject *u_obj = ue_py_check_type(py_node_class); + if (!u_obj) return PyErr_Format(PyExc_Exception, "argument is not a UObject"); - } UEdGraphNode *node = nullptr; - ue_PyUObject *py_obj = (ue_PyUObject *)py_node_class; - if (py_obj->ue_object->IsA()) + if (UClass *u_class = Cast(u_obj)) { - UClass *u_class = (UClass *)py_obj->ue_object; if (!u_class->IsChildOf()) { return PyErr_Format(PyExc_Exception, "argument is not a child of UEdGraphNode"); } - node = (UEdGraphNode *)NewObject(graph, u_class); + node = NewObject(graph, u_class); node->PostLoad(); } - else if (py_obj->ue_object->IsA()) + else { - node = (UEdGraphNode *)py_obj->ue_object; - if (node->GetOuter() != graph) + node = Cast(u_obj); + if (node) { - node->Rename(*node->GetName(), graph); + if (node->GetOuter() != graph) + + node->Rename(*node->GetName(), graph); } } if (!node) - { return PyErr_Format(PyExc_Exception, "argument is not a supported type"); - } + node->CreateNewGuid(); node->PostPlacedNewNode(); node->SetFlags(RF_Transactional); - node->AllocateDefaultPins(); + if (node->Pins.Num() == 0) + { + node->AllocateDefaultPins(); + } node->NodePosX = x; node->NodePosY = y; @@ -379,6 +381,183 @@ PyObject *py_ue_graph_add_node(ue_PyUObject * self, PyObject * args) Py_RETURN_UOBJECT(node); } +PyObject *py_ue_graph_remove_node(ue_PyUObject * self, PyObject * args) +{ + + ue_py_check(self); + + PyObject *py_node_class; + int x = 0; + int y = 0; + + char *metadata = nullptr; + PyObject *py_data = nullptr; + + if (!PyArg_ParseTuple(args, "O|iisO:graph_remove_node", &py_node_class, &x, &y, &metadata, &py_data)) + { + return nullptr; + } + + UEdGraph *graph = ue_py_check_type(self); + if (!graph) + return PyErr_Format(PyExc_Exception, "uobject is not a UEdGraph"); + + UObject *u_obj = ue_py_check_type(py_node_class); + if (!u_obj) + return PyErr_Format(PyExc_Exception, "argument is not a UObject"); + + UEdGraphNode *node = nullptr; + + if (UClass *u_class = Cast(u_obj)) + { + if (!u_class->IsChildOf()) + { + return PyErr_Format(PyExc_Exception, "argument is not a child of UEdGraphNode"); + } + node = NewObject(graph, u_class); + node->PostLoad(); + } + else + { + node = Cast(u_obj); + if (node) + { + if (node->GetOuter() != graph) + + node->Rename(*node->GetName(), graph); + } + } + + if (!node) + return PyErr_Format(PyExc_Exception, "argument is not a supported type"); + + graph->RemoveNode(node); + + if (UBlueprint *bp = Cast(node->GetGraph()->GetOuter())) + { + FBlueprintEditorUtils::MarkBlueprintAsStructurallyModified(bp); + } + + Py_RETURN_NONE; +} + +PyObject *py_ue_graph_reconstruct_node(ue_PyUObject * self, PyObject * args) +{ + + ue_py_check(self); + + PyObject *py_node_class; + int x = 0; + int y = 0; + + char *metadata = nullptr; + PyObject *py_data = nullptr; + + if (!PyArg_ParseTuple(args, "O|iisO:graph_reconstruct_node", &py_node_class, &x, &y, &metadata, &py_data)) + { + return nullptr; + } + + UEdGraph *graph = ue_py_check_type(self); + if (!graph) + return PyErr_Format(PyExc_Exception, "uobject is not a UEdGraph"); + + UObject *u_obj = ue_py_check_type(py_node_class); + if (!u_obj) + return PyErr_Format(PyExc_Exception, "argument is not a UObject"); + + UEdGraphNode *node = nullptr; + + if (UClass *u_class = Cast(u_obj)) + { + if (!u_class->IsChildOf()) + { + return PyErr_Format(PyExc_Exception, "argument is not a child of UEdGraphNode"); + } + node = NewObject(graph, u_class); + node->PostLoad(); + } + else + { + node = Cast(u_obj); + if (node) + { + if (node->GetOuter() != graph) + + node->Rename(*node->GetName(), graph); + } + } + + if (!node) + return PyErr_Format(PyExc_Exception, "argument is not a supported type"); + + //graph->RemoveNode(node); + node->ReconstructNode(); + + if (UBlueprint *bp = Cast(node->GetGraph()->GetOuter())) + { + FBlueprintEditorUtils::MarkBlueprintAsStructurallyModified(bp); + } + + Py_RETURN_NONE; +} + +PyObject *py_ue_graph_add_node_dynamic_cast(ue_PyUObject * self, PyObject * args) +{ + + ue_py_check(self); + + PyObject *py_node_class; + int x = 0; + int y = 0; + + char *metadata = nullptr; + PyObject *py_data = nullptr; + + if(!PyArg_ParseTuple(args, "O|iis:graph_add_node_dynamic_cast", &py_node_class, &x, &y, &metadata)) + { + return nullptr; + } + + UEdGraph *graph = ue_py_check_type(self); + if(!graph) + return PyErr_Format(PyExc_Exception, "uobject is not a UEdGraph"); + + UClass *u_class = ue_py_check_type(py_node_class); + if(!u_class) + return PyErr_Format(PyExc_Exception, "argument is not a UClass"); + + UK2Node_DynamicCast *node = NewObject(graph); + node->TargetType = u_class; +#if ENGINE_MINOR_VERSION > 15 + node->SetPurity(false); +#endif + node->AllocateDefaultPins(); + + node->CreateNewGuid(); + node->PostPlacedNewNode(); + node->SetFlags(RF_Transactional); + node->NodePosX = x; + node->NodePosY = y; + + if(metadata == nullptr || strlen(metadata) == 0) + { + UEdGraphSchema_K2::SetNodeMetaData(node, FNodeMetadata::DefaultGraphNode); + } + else + { + UEdGraphSchema_K2::SetNodeMetaData(node, FName(UTF8_TO_TCHAR(metadata))); + } + graph->AddNode(node); + + if(UBlueprint *bp = Cast(node->GetGraph()->GetOuter())) + { + FBlueprintEditorUtils::MarkBlueprintAsStructurallyModified(bp); + } + + Py_RETURN_UOBJECT(node); +} + PyObject *py_ue_node_pins(ue_PyUObject * self, PyObject * args) { @@ -431,8 +610,7 @@ PyObject *py_ue_node_allocate_default_pins(ue_PyUObject * self, PyObject * args) node->AllocateDefaultPins(); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyObject *py_ue_node_reconstruct(ue_PyUObject * self, PyObject * args) @@ -446,8 +624,7 @@ PyObject *py_ue_node_reconstruct(ue_PyUObject * self, PyObject * args) node->GetSchema()->ReconstructNode(*node); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyObject *py_ue_node_find_pin(ue_PyUObject * self, PyObject * args) @@ -474,9 +651,62 @@ PyObject *py_ue_node_find_pin(ue_PyUObject * self, PyObject * args) return PyErr_Format(PyExc_Exception, "unable to find pin \"%s\"", name); } - PyObject *ret = py_ue_new_edgraphpin(pin); - Py_INCREF(ret); - return ret; + return py_ue_new_edgraphpin(pin); +} + +PyObject *py_ue_node_function_entry_set_pure(ue_PyUObject * self, PyObject * args) +{ + + ue_py_check(self); + + PyObject *py_bool = nullptr; + if (!PyArg_ParseTuple(args, "O:node_function_entry_set_pure", &py_bool)) + { + return nullptr; + } + + UK2Node_FunctionEntry *node = ue_py_check_type(self); + if (!node) + return PyErr_Format(PyExc_Exception, "uobject is not a K2Node_FunctionEntry"); + + UEdGraph *graph = node->GetGraph(); + + if (!graph) + return PyErr_Format(PyExc_Exception, "unable to get graph from node"); + + UBlueprint *blueprint = FBlueprintEditorUtils::FindBlueprintForGraph(graph); + if (!blueprint) + return PyErr_Format(PyExc_Exception, "unable to get blueprint from node"); + + UClass *Class = blueprint->SkeletonGeneratedClass; + UFunction *function = nullptr; + for (TFieldIterator FunctionIt(Class, EFieldIteratorFlags::IncludeSuper); FunctionIt; ++FunctionIt) + { + if (*FunctionIt->GetName() == graph->GetName()) + { + function = *FunctionIt; + break; + } + } + + if (!function) + return PyErr_Format(PyExc_Exception, "unable to get function from node"); + + node->Modify(); + function->Modify(); + + if (PyObject_IsTrue(py_bool)) + { + function->FunctionFlags |= FUNC_BlueprintPure; + node->AddExtraFlags(FUNC_BlueprintPure); + } + else + { + function->FunctionFlags &= ~FUNC_BlueprintPure; + node->ClearExtraFlags(FUNC_BlueprintPure); + } + + Py_RETURN_NONE; } PyObject *py_ue_node_create_pin(ue_PyUObject * self, PyObject * args) @@ -522,8 +752,59 @@ PyObject *py_ue_node_create_pin(ue_PyUObject * self, PyObject * args) FBlueprintEditorUtils::MarkBlueprintAsStructurallyModified(bp); } - PyObject *ret = py_ue_new_edgraphpin(pin); - Py_INCREF(ret); - return ret; + return py_ue_new_edgraphpin(pin); +} + + +PyObject *py_ue_node_pin_type_changed(ue_PyUObject * self, PyObject * args) +{ + + ue_py_check(self); + + PyObject *py_pin; + if (!PyArg_ParseTuple(args, "O:node_pin_type_changed", &py_pin)) + { + return nullptr; + } + + UEdGraphNode *node = ue_py_check_type(self); + if (!node) + return PyErr_Format(PyExc_Exception, "uobject is not a UEdGraphNode"); + + ue_PyEdGraphPin *pin = py_ue_is_edgraphpin(py_pin); + if (!pin) + return PyErr_Format(PyExc_Exception, "argument is not a EdGraphPin"); + + node->PinTypeChanged(pin->pin); + + Py_RETURN_NONE; +} + +PyObject *py_ue_node_pin_default_value_changed(ue_PyUObject * self, PyObject * args) +{ + + ue_py_check(self); + + PyObject *py_pin; + if (!PyArg_ParseTuple(args, "O:node_pin_default_value_changed", &py_pin)) + { + return nullptr; + } + + UEdGraphNode *node = ue_py_check_type(self); + if (!node) + return PyErr_Format(PyExc_Exception, "uobject is not a UEdGraphNode"); + + ue_PyEdGraphPin *pin = py_ue_is_edgraphpin(py_pin); + if (!pin) + return PyErr_Format(PyExc_Exception, "argument is not a EdGraphPin"); + + node->PinDefaultValueChanged(pin->pin); + + Py_RETURN_NONE; } + + + + #endif diff --git a/Source/UnrealEnginePython/Private/Blueprint/UEPyEdGraph.h b/Source/UnrealEnginePython/Private/Blueprint/UEPyEdGraph.h index d14c85770..e0fd0fe69 100644 --- a/Source/UnrealEnginePython/Private/Blueprint/UEPyEdGraph.h +++ b/Source/UnrealEnginePython/Private/Blueprint/UEPyEdGraph.h @@ -2,7 +2,10 @@ -#include "UnrealEnginePython.h" +#include "UEPyModule.h" +#include "UEPyCallable.h" + +#include "UEPyEdGraphPin.h" #if WITH_EDITOR PyObject *py_ue_graph_add_node_call_function(ue_PyUObject *, PyObject *); @@ -10,14 +13,23 @@ PyObject *py_ue_graph_add_node_custom_event(ue_PyUObject *, PyObject *); PyObject *py_ue_graph_add_node_variable_get(ue_PyUObject *, PyObject *); PyObject *py_ue_graph_add_node_variable_set(ue_PyUObject *, PyObject *); PyObject *py_ue_graph_add_node(ue_PyUObject *, PyObject *); +PyObject *py_ue_graph_add_node_dynamic_cast(ue_PyUObject *, PyObject *); PyObject *py_ue_graph_add_node_event(ue_PyUObject *, PyObject *); +PyObject *py_ue_graph_reconstruct_node(ue_PyUObject *, PyObject *); +PyObject *py_ue_graph_remove_node(ue_PyUObject *, PyObject *); + PyObject *py_ue_graph_get_good_place_for_new_node(ue_PyUObject *, PyObject *); PyObject *py_ue_node_pins(ue_PyUObject *, PyObject *); PyObject *py_ue_node_find_pin(ue_PyUObject *, PyObject *); PyObject *py_ue_node_create_pin(ue_PyUObject *, PyObject *); +PyObject *py_ue_node_pin_type_changed(ue_PyUObject *, PyObject *); +PyObject *py_ue_node_pin_default_value_changed(ue_PyUObject *, PyObject *); + +PyObject *py_ue_node_function_entry_set_pure(ue_PyUObject *, PyObject *); + PyObject *py_ue_node_get_title(ue_PyUObject *, PyObject *); PyObject *py_ue_node_allocate_default_pins(ue_PyUObject *, PyObject *); PyObject *py_ue_node_reconstruct(ue_PyUObject *, PyObject *); diff --git a/Source/UnrealEnginePython/Private/Blueprint/UEPyEdGraphPin.cpp b/Source/UnrealEnginePython/Private/Blueprint/UEPyEdGraphPin.cpp index c9fc2441c..283079f31 100644 --- a/Source/UnrealEnginePython/Private/Blueprint/UEPyEdGraphPin.cpp +++ b/Source/UnrealEnginePython/Private/Blueprint/UEPyEdGraphPin.cpp @@ -1,84 +1,134 @@ +#include "UEPyEdGraphPin.h" #if WITH_EDITOR - -#include "UnrealEnginePythonPrivatePCH.h" #include "Runtime/Engine/Classes/EdGraph/EdGraphPin.h" #include "Editor/UnrealEd/Public/Kismet2/BlueprintEditorUtils.h" -static PyObject *py_ue_edgraphpin_make_link_to(ue_PyEdGraphPin *self, PyObject * args) { +static PyObject *py_ue_edgraphpin_make_link_to(ue_PyEdGraphPin *self, PyObject * args) +{ PyObject *other_pin; - if (!PyArg_ParseTuple(args, "O:make_link_to", &other_pin)) { + if (!PyArg_ParseTuple(args, "O:make_link_to", &other_pin)) + { return NULL; } ue_PyEdGraphPin *py_other_pin = py_ue_is_edgraphpin(other_pin); - if (!py_other_pin) { + if (!py_other_pin) + { return PyErr_Format(PyExc_Exception, "argument is not a UEdGraphPin"); } self->pin->MakeLinkTo(py_other_pin->pin); - if (UBlueprint *bp = Cast(self->pin->GetOwningNode()->GetGraph()->GetOuter())) { + if (UBlueprint *bp = Cast(self->pin->GetOwningNode()->GetGraph()->GetOuter())) + { FBlueprintEditorUtils::MarkBlueprintAsStructurallyModified(bp); } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } -static PyObject *py_ue_edgraphpin_connect(ue_PyEdGraphPin *self, PyObject * args) { +static PyObject *py_ue_edgraphpin_connect(ue_PyEdGraphPin *self, PyObject * args) +{ PyObject *other_pin; - if (!PyArg_ParseTuple(args, "O:connect", &other_pin)) { + if (!PyArg_ParseTuple(args, "O:connect", &other_pin)) + { return NULL; } ue_PyEdGraphPin *py_other_pin = py_ue_is_edgraphpin(other_pin); - if (!py_other_pin) { + if (!py_other_pin) + { return PyErr_Format(PyExc_Exception, "argument is not a UEdGraphPin"); } - if (!self->pin->GetSchema()->TryCreateConnection(self->pin, py_other_pin->pin)) { + if (!self->pin->GetSchema()->TryCreateConnection(self->pin, py_other_pin->pin)) + { return PyErr_Format(PyExc_Exception, "unable to connect pins"); } - if (UBlueprint *bp = Cast(self->pin->GetOwningNode()->GetGraph()->GetOuter())) { + if (UBlueprint *bp = Cast(self->pin->GetOwningNode()->GetGraph()->GetOuter())) + { FBlueprintEditorUtils::MarkBlueprintAsStructurallyModified(bp); } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } -static PyObject *py_ue_edgraphpin_break_link_to(ue_PyEdGraphPin *self, PyObject * args) { +static PyObject *py_ue_edgraphpin_break_link_to(ue_PyEdGraphPin *self, PyObject * args) +{ PyObject *other_pin; - if (!PyArg_ParseTuple(args, "O:break_link_to", &other_pin)) { + if (!PyArg_ParseTuple(args, "O:break_link_to", &other_pin)) + { return NULL; } ue_PyEdGraphPin *py_other_pin = py_ue_is_edgraphpin(other_pin); - if (!py_other_pin) { + if (!py_other_pin) + { return PyErr_Format(PyExc_Exception, "argument is not a UEdGraphPin"); } self->pin->BreakLinkTo(py_other_pin->pin); - if (UBlueprint *bp = Cast(self->pin->GetOwningNode()->GetGraph()->GetOuter())) { + if (UBlueprint *bp = Cast(self->pin->GetOwningNode()->GetGraph()->GetOuter())) + { + FBlueprintEditorUtils::MarkBlueprintAsStructurallyModified(bp); + } + + Py_RETURN_NONE; +} + +static PyObject *py_ue_edgraphpin_break_all_pin_links(ue_PyEdGraphPin *self, PyObject * args) +{ + PyObject *py_notify_nodes = nullptr; + if (!PyArg_ParseTuple(args, "O:break_all_pin_links", &py_notify_nodes)) + { + return NULL; + } + + bool notify_nodes = true; + if (py_notify_nodes && !PyObject_IsTrue(py_notify_nodes)) + notify_nodes = false; + + self->pin->BreakAllPinLinks(notify_nodes); + + if (UBlueprint *bp = Cast(self->pin->GetOwningNode()->GetGraph()->GetOuter())) + { FBlueprintEditorUtils::MarkBlueprintAsStructurallyModified(bp); } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; +} + +static PyObject *py_ue_edgraphpin_get_linked_to(ue_PyEdGraphPin * self, PyObject * args) +{ + PyObject *pins = PyList_New(0); + + TArray Links = self->pin->LinkedTo; + + for (int32 i = 0; i < Links.Num(); i++) + { + UEdGraphPin *pin = Links[i]; + ue_PyUObject *item = (ue_PyUObject *)py_ue_new_edgraphpin(pin); + if (item) + PyList_Append(pins, (PyObject *)item); + } + return pins; } static PyMethodDef ue_PyEdGraphPin_methods[] = { { "make_link_to", (PyCFunction)py_ue_edgraphpin_make_link_to, METH_VARARGS, "" }, { "break_link_to", (PyCFunction)py_ue_edgraphpin_break_link_to, METH_VARARGS, "" }, + { "break_all_pin_links", (PyCFunction)py_ue_edgraphpin_break_all_pin_links, METH_VARARGS, "" }, + { "get_linked_to", (PyCFunction)py_ue_edgraphpin_get_linked_to, METH_VARARGS, "" }, { "connect", (PyCFunction)py_ue_edgraphpin_connect, METH_VARARGS, "" }, { NULL } /* Sentinel */ }; -static PyObject *py_ue_edgraphpin_get_name(ue_PyEdGraphPin *self, void *closure) { +static PyObject *py_ue_edgraphpin_get_name(ue_PyEdGraphPin *self, void *closure) +{ #if ENGINE_MINOR_VERSION > 18 return PyUnicode_FromString(TCHAR_TO_UTF8(*(self->pin->PinName.ToString()))); #else @@ -86,7 +136,8 @@ static PyObject *py_ue_edgraphpin_get_name(ue_PyEdGraphPin *self, void *closure) #endif } -static PyObject *py_ue_edgraphpin_get_category(ue_PyEdGraphPin *self, void *closure) { +static PyObject *py_ue_edgraphpin_get_category(ue_PyEdGraphPin *self, void *closure) +{ #if ENGINE_MINOR_VERSION > 18 return PyUnicode_FromString(TCHAR_TO_UTF8(*(self->pin->PinType.PinCategory.ToString()))); #else @@ -94,7 +145,8 @@ static PyObject *py_ue_edgraphpin_get_category(ue_PyEdGraphPin *self, void *clos #endif } -static PyObject *py_ue_edgraphpin_get_sub_category(ue_PyEdGraphPin *self, void *closure) { +static PyObject *py_ue_edgraphpin_get_sub_category(ue_PyEdGraphPin *self, void *closure) +{ #if ENGINE_MINOR_VERSION > 18 return PyUnicode_FromString(TCHAR_TO_UTF8(*(self->pin->PinType.PinSubCategory.ToString()))); #else @@ -102,13 +154,16 @@ static PyObject *py_ue_edgraphpin_get_sub_category(ue_PyEdGraphPin *self, void * #endif } -static PyObject *py_ue_edgraphpin_get_default_value(ue_PyEdGraphPin *self, void *closure) { +static PyObject *py_ue_edgraphpin_get_default_value(ue_PyEdGraphPin *self, void *closure) +{ return PyUnicode_FromString(TCHAR_TO_UTF8(*(self->pin->DefaultValue))); } -static int py_ue_edgraphpin_set_default_value(ue_PyEdGraphPin *self, PyObject *value, void *closure) { - if (value && PyUnicode_Check(value)) { - char *str = PyUnicode_AsUTF8(value); +static int py_ue_edgraphpin_set_default_value(ue_PyEdGraphPin *self, PyObject *value, void *closure) +{ + if (value && PyUnicodeOrString_Check(value)) + { + const char *str = UEPyUnicode_AsUTF8(value); self->pin->DefaultValue = UTF8_TO_TCHAR(str); return 0; } @@ -116,16 +171,39 @@ static int py_ue_edgraphpin_set_default_value(ue_PyEdGraphPin *self, PyObject *v return -1; } -static PyObject *py_ue_edgraphpin_get_default_object(ue_PyEdGraphPin *self, void *closure) { +static PyObject *py_ue_edgraphpin_get_default_text_value(ue_PyEdGraphPin *self, void *closure) +{ + return PyUnicode_FromString(TCHAR_TO_UTF8(*(self->pin->DefaultTextValue.ToString()))); +} + +static int py_ue_edgraphpin_set_default_text_value(ue_PyEdGraphPin *self, PyObject *value, void *closure) +{ + if (value && PyUnicodeOrString_Check(value)) + { + const char *str = UEPyUnicode_AsUTF8(value); + self->pin->DefaultTextValue = FText::FromString(UTF8_TO_TCHAR(str)); + return 0; + } + PyErr_SetString(PyExc_TypeError, "value is not a string"); + return -1; +} + + + +static PyObject *py_ue_edgraphpin_get_default_object(ue_PyEdGraphPin *self, void *closure) +{ UObject *u_object = self->pin->DefaultObject; - if (!u_object) { + if (!u_object) + { Py_RETURN_NONE; } Py_RETURN_UOBJECT(u_object); } -static int py_ue_edgraphpin_set_default_object(ue_PyEdGraphPin *self, PyObject *value, void *closure) { - if (value && ue_is_pyuobject(value)) { +static int py_ue_edgraphpin_set_default_object(ue_PyEdGraphPin *self, PyObject *value, void *closure) +{ + if (value && ue_is_pyuobject(value)) + { ue_PyUObject *py_obj = (ue_PyUObject *)value; self->pin->DefaultObject = py_obj->ue_object; return 0; @@ -134,11 +212,53 @@ static int py_ue_edgraphpin_set_default_object(ue_PyEdGraphPin *self, PyObject * return -1; } +static int py_ue_edgraphpin_set_category(ue_PyEdGraphPin *self, PyObject *value, void *closure) +{ + if (value && PyUnicodeOrString_Check(value)) + { + const char *str = UEPyUnicode_AsUTF8(value); +#if ENGINE_MINOR_VERSION > 18 + self->pin->PinType.PinCategory = FName(UTF8_TO_TCHAR(str)); +#else + self->pin->PinType.PinCategory = FString(UTF8_TO_TCHAR(str)); +#endif + return 0; + } + PyErr_SetString(PyExc_TypeError, "value is not a string"); + return -1; +} + +static int py_ue_edgraphpin_set_sub_category(ue_PyEdGraphPin *self, PyObject *value, void *closure) +{ + if (value) + { + if (ue_is_pyuobject(value)) + { + ue_PyUObject *py_obj = (ue_PyUObject *)value; + self->pin->PinType.PinSubCategoryObject = py_obj->ue_object; + return 0; + } + if (PyUnicodeOrString_Check(value)) + { + const char *str = UEPyUnicode_AsUTF8(value); +#if ENGINE_MINOR_VERSION > 18 + self->pin->PinType.PinSubCategory = FName(UTF8_TO_TCHAR(str)); +#else + self->pin->PinType.PinSubCategory = FString(UTF8_TO_TCHAR(str)); +#endif + return 0; + } + } + PyErr_SetString(PyExc_TypeError, "value is not a UObject"); + return -1; +} + static PyGetSetDef ue_PyEdGraphPin_getseters[] = { { (char*)"name", (getter)py_ue_edgraphpin_get_name, NULL, (char *)"", NULL }, - { (char*)"category", (getter)py_ue_edgraphpin_get_category, NULL, (char *)"", NULL }, - { (char*)"sub_category", (getter)py_ue_edgraphpin_get_sub_category, NULL, (char *)"", NULL }, + { (char*)"category", (getter)py_ue_edgraphpin_get_category, (setter)py_ue_edgraphpin_set_category, (char *)"", NULL }, + { (char*)"sub_category", (getter)py_ue_edgraphpin_get_sub_category, (setter)py_ue_edgraphpin_set_sub_category, (char *)"", NULL }, { (char*)"default_value", (getter)py_ue_edgraphpin_get_default_value, (setter)py_ue_edgraphpin_set_default_value, (char *)"", NULL }, + { (char*)"default_text_value", (getter)py_ue_edgraphpin_get_default_text_value, (setter)py_ue_edgraphpin_set_default_text_value, (char *)"", NULL }, { (char*)"default_object", (getter)py_ue_edgraphpin_get_default_object, (setter)py_ue_edgraphpin_set_default_object, (char *)"", NULL }, { NULL } /* Sentinel */ }; @@ -187,7 +307,8 @@ static PyTypeObject ue_PyEdGraphPinType = { }; -void ue_python_init_edgraphpin(PyObject *ue_module) { +void ue_python_init_edgraphpin(PyObject *ue_module) +{ ue_PyEdGraphPinType.tp_new = PyType_GenericNew; if (PyType_Ready(&ue_PyEdGraphPinType) < 0) @@ -197,16 +318,18 @@ void ue_python_init_edgraphpin(PyObject *ue_module) { PyModule_AddObject(ue_module, "EdGraphPin", (PyObject *)&ue_PyEdGraphPinType); } -PyObject *py_ue_new_edgraphpin(UEdGraphPin *pin) { +PyObject *py_ue_new_edgraphpin(UEdGraphPin *pin) +{ ue_PyEdGraphPin *ret = (ue_PyEdGraphPin *)PyObject_New(ue_PyEdGraphPin, &ue_PyEdGraphPinType); ret->pin = pin; return (PyObject *)ret; } -ue_PyEdGraphPin *py_ue_is_edgraphpin(PyObject *obj) { +ue_PyEdGraphPin *py_ue_is_edgraphpin(PyObject *obj) +{ if (!PyObject_IsInstance(obj, (PyObject *)&ue_PyEdGraphPinType)) return nullptr; return (ue_PyEdGraphPin *)obj; } -#endif \ No newline at end of file +#endif diff --git a/Source/UnrealEnginePython/Private/Blueprint/UEPyEdGraphPin.h b/Source/UnrealEnginePython/Private/Blueprint/UEPyEdGraphPin.h index 3d32a54a1..3883bac69 100644 --- a/Source/UnrealEnginePython/Private/Blueprint/UEPyEdGraphPin.h +++ b/Source/UnrealEnginePython/Private/Blueprint/UEPyEdGraphPin.h @@ -1,15 +1,18 @@ #pragma once +#include "UEPyModule.h" + #if WITH_EDITOR -#include "UnrealEnginePython.h" + #include "Runtime/Engine/Classes/EdGraph/EdGraphPin.h" -typedef struct { +typedef struct +{ PyObject_HEAD - /* Type-specific fields go here. */ - UEdGraphPin *pin; + /* Type-specific fields go here. */ + UEdGraphPin *pin; } ue_PyEdGraphPin; PyObject *py_ue_new_edgraphpin(UEdGraphPin *); diff --git a/Source/UnrealEnginePython/Private/CollectionManager/UEPyICollectionManager.cpp b/Source/UnrealEnginePython/Private/CollectionManager/UEPyICollectionManager.cpp index d75ce9153..b91116dfe 100644 --- a/Source/UnrealEnginePython/Private/CollectionManager/UEPyICollectionManager.cpp +++ b/Source/UnrealEnginePython/Private/CollectionManager/UEPyICollectionManager.cpp @@ -1,8 +1,7 @@ -#if WITH_EDITOR -#include "UnrealEnginePythonPrivatePCH.h" - #include "UEPyICollectionManager.h" +#if WITH_EDITOR + #include "Developer/CollectionManager/Public/CollectionManagerModule.h" static PyObject *py_ue_icollection_manager_get_collections(PyObject *cls, PyObject * args) @@ -11,7 +10,8 @@ static PyObject *py_ue_icollection_manager_get_collections(PyObject *cls, PyObje ICollectionManager &CollectionManager = FCollectionManagerModule::GetModule().Get(); TArray collections; CollectionManager.GetCollections(collections); - for (FCollectionNameType name_type : collections) { + for (FCollectionNameType name_type : collections) + { PyList_Append(py_list, Py_BuildValue((char *)"(si)", TCHAR_TO_UTF8(*name_type.Name.ToString()), (int)name_type.Type)); } return py_list; @@ -41,7 +41,8 @@ static PyObject *py_ue_icollection_manager_get_root_collections(PyObject *cls, P ICollectionManager &CollectionManager = FCollectionManagerModule::GetModule().Get(); TArray collections; CollectionManager.GetRootCollections(collections); - for (FCollectionNameType name_type : collections) { + for (FCollectionNameType name_type : collections) + { PyList_Append(py_list, Py_BuildValue((char *)"(si)", TCHAR_TO_UTF8(*name_type.Name.ToString()), (int)name_type.Type)); } return py_list; @@ -59,7 +60,8 @@ static PyObject *py_ue_icollection_manager_get_child_collection_names(PyObject * ICollectionManager &CollectionManager = FCollectionManagerModule::GetModule().Get(); TArray names; CollectionManager.GetChildCollectionNames(FName(UTF8_TO_TCHAR(name)), (ECollectionShareType::Type)type, (ECollectionShareType::Type)child_type, names); - for (FName cname : names) { + for (FName cname : names) + { PyList_Append(py_list, PyUnicode_FromString(TCHAR_TO_UTF8(*cname.ToString()))); } return py_list; @@ -77,7 +79,8 @@ static PyObject *py_ue_icollection_manager_get_child_collections(PyObject *cls, ICollectionManager &CollectionManager = FCollectionManagerModule::GetModule().Get(); TArray collections; CollectionManager.GetChildCollections(FName(UTF8_TO_TCHAR(name)), (ECollectionShareType::Type)type, collections); - for (FCollectionNameType name_type : collections) { + for (FCollectionNameType name_type : collections) + { PyList_Append(py_list, Py_BuildValue((char *)"(si)", TCHAR_TO_UTF8(*name_type.Name.ToString()), (int)name_type.Type)); } return py_list; @@ -93,7 +96,8 @@ static PyObject *py_ue_icollection_manager_get_collection_names(PyObject *cls, P ICollectionManager &CollectionManager = FCollectionManagerModule::GetModule().Get(); TArray names; CollectionManager.GetCollectionNames((ECollectionShareType::Type)type, names); - for (FName name : names) { + for (FName name : names) + { PyList_Append(py_list, PyUnicode_FromString(TCHAR_TO_UTF8(*name.ToString()))); } return py_list; @@ -109,7 +113,8 @@ static PyObject *py_ue_icollection_manager_get_root_collection_names(PyObject *c ICollectionManager &CollectionManager = FCollectionManagerModule::GetModule().Get(); TArray names; CollectionManager.GetRootCollectionNames((ECollectionShareType::Type)type, names); - for (FName name : names) { + for (FName name : names) + { PyList_Append(py_list, PyUnicode_FromString(TCHAR_TO_UTF8(*name.ToString()))); } return py_list; @@ -394,7 +399,8 @@ static PyObject *py_ue_icollection_manager_get_assets_in_collection(PyObject *cl if (CollectionManager.GetAssetsInCollection(FName(UTF8_TO_TCHAR(name)), (ECollectionShareType::Type)type, paths, (ECollectionRecursionFlags::Flags)recursion)) { PyObject *py_list = PyList_New(0); - for (FName path : paths) { + for (FName path : paths) + { PyList_Append(py_list, PyUnicode_FromString(TCHAR_TO_UTF8(*path.ToString()))); } return py_list; @@ -418,7 +424,8 @@ static PyObject *py_ue_icollection_manager_get_objects_in_collection(PyObject *c if (CollectionManager.GetObjectsInCollection(FName(UTF8_TO_TCHAR(name)), (ECollectionShareType::Type)type, paths, (ECollectionRecursionFlags::Flags)recursion)) { PyObject *py_list = PyList_New(0); - for (FName path : paths) { + for (FName path : paths) + { PyList_Append(py_list, PyUnicode_FromString(TCHAR_TO_UTF8(*path.ToString()))); } return py_list; @@ -442,7 +449,8 @@ static PyObject *py_ue_icollection_manager_get_classes_in_collection(PyObject *c if (CollectionManager.GetClassesInCollection(FName(UTF8_TO_TCHAR(name)), (ECollectionShareType::Type)type, paths, (ECollectionRecursionFlags::Flags)recursion)) { PyObject *py_list = PyList_New(0); - for (FName path : paths) { + for (FName path : paths) + { PyList_Append(py_list, PyUnicode_FromString(TCHAR_TO_UTF8(*path.ToString()))); } return py_list; diff --git a/Source/UnrealEnginePython/Private/ConsoleManager/UEPyIConsoleManager.cpp b/Source/UnrealEnginePython/Private/ConsoleManager/UEPyIConsoleManager.cpp index 31af0269e..b3b7c7d62 100644 --- a/Source/UnrealEnginePython/Private/ConsoleManager/UEPyIConsoleManager.cpp +++ b/Source/UnrealEnginePython/Private/ConsoleManager/UEPyIConsoleManager.cpp @@ -1,6 +1,3 @@ - -#include "UnrealEnginePythonPrivatePCH.h" - #include "UEPyIConsoleManager.h" static PyObject *py_ue_iconsole_manager_add_history_entry(PyObject *cls, PyObject * args) @@ -437,6 +434,10 @@ static PyObject *py_ue_iconsole_manager_unregister_object(PyObject *cls, PyObjec return PyErr_Format(PyExc_Exception, "unable to find console object \"%s\"", key); } + + FPythonSmartConsoleDelegate::UnregisterPyDelegate(c_object); + + IConsoleManager::Get().UnregisterConsoleObject(c_object, false); Py_RETURN_NONE; @@ -542,6 +543,9 @@ void FPythonSmartConsoleDelegate::OnConsoleCommand(const TArray < FString > & In Py_DECREF(ret); } +// static TArray declaration +TArray FPythonSmartConsoleDelegate::PyDelegatesMapping; + static PyObject *py_ue_iconsole_manager_register_command(PyObject *cls, PyObject * args) { char *key; @@ -568,10 +572,14 @@ static PyObject *py_ue_iconsole_manager_register_command(PyObject *cls, PyObject FConsoleCommandWithArgsDelegate console_delegate; console_delegate.BindSP(py_delegate, &FPythonSmartConsoleDelegate::OnConsoleCommand); - if (!IConsoleManager::Get().RegisterConsoleCommand(UTF8_TO_TCHAR(key), help ? UTF8_TO_TCHAR(help) : UTF8_TO_TCHAR(key), console_delegate, 0)) - { + + + c_object = IConsoleManager::Get().RegisterConsoleCommand(UTF8_TO_TCHAR(key), help ? UTF8_TO_TCHAR(help) : UTF8_TO_TCHAR(key), console_delegate, 0); + if (!c_object) return PyErr_Format(PyExc_Exception, "unable to register console command \"%s\"", key); - } + + // this allows the delegates to not be destroyed + FPythonSmartConsoleDelegate::RegisterPyDelegate(c_object, py_delegate); Py_RETURN_NONE; } diff --git a/Source/UnrealEnginePython/Private/ConsoleManager/UEPyIConsoleManager.h b/Source/UnrealEnginePython/Private/ConsoleManager/UEPyIConsoleManager.h index 01815ccfd..eb88b2077 100644 --- a/Source/UnrealEnginePython/Private/ConsoleManager/UEPyIConsoleManager.h +++ b/Source/UnrealEnginePython/Private/ConsoleManager/UEPyIConsoleManager.h @@ -1,20 +1,59 @@ #pragma once -#include "UnrealEnginePython.h" +#include "UEPyModule.h" #include "Runtime/Core/Public/HAL/IConsoleManager.h" typedef struct { PyObject_HEAD - /* Type-specific fields go here. */ + /* Type-specific fields go here. */ } ue_PyIConsoleManager; +class FPythonSmartConsoleDelegate; +struct FPythonSmartConsoleDelegatePair +{ + IConsoleObject *Key; + TSharedRef Value; + + FPythonSmartConsoleDelegatePair(IConsoleObject *InKey, TSharedRef InValue) : Key(InKey), Value(InValue) + { + + } +}; + class FPythonSmartConsoleDelegate : public FPythonSmartDelegate { public: void OnConsoleCommand(const TArray < FString > &InArgs); + + static void RegisterPyDelegate(IConsoleObject *InKey, TSharedRef InValue) + { + FPythonSmartConsoleDelegatePair Pair(InKey, InValue); + PyDelegatesMapping.Add(Pair); + } + + static void UnregisterPyDelegate(IConsoleObject *Key) + { + int32 Index = -1; + for (int32 i = 0; i < PyDelegatesMapping.Num(); i++) + { + if (PyDelegatesMapping[i].Key == Key) + { + Index = i; + break; + } + } + + if (Index >= 0) + { + PyDelegatesMapping.RemoveAt(Index); + } + } + +private: + static TArray PyDelegatesMapping; }; void ue_python_init_iconsole_manager(PyObject *); diff --git a/Source/UnrealEnginePython/Private/Fbx/UEPyFbx.h b/Source/UnrealEnginePython/Private/Fbx/UEPyFbx.h index 4991574ac..feff5f8a8 100644 --- a/Source/UnrealEnginePython/Private/Fbx/UEPyFbx.h +++ b/Source/UnrealEnginePython/Private/Fbx/UEPyFbx.h @@ -1,6 +1,7 @@ #pragma once + #if ENGINE_MINOR_VERSION > 12 -#include "UnrealEnginePython.h" +#include "UEPyModule.h" #if WITH_EDITOR diff --git a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxIOSettings.cpp b/Source/UnrealEnginePython/Private/Fbx/UEPyFbxIOSettings.cpp index a7091921c..c736e7f08 100644 --- a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxIOSettings.cpp +++ b/Source/UnrealEnginePython/Private/Fbx/UEPyFbxIOSettings.cpp @@ -1,5 +1,6 @@ +#include "UEPyFbxIOSettings.h" + #if ENGINE_MINOR_VERSION > 12 -#include "UnrealEnginePythonPrivatePCH.h" #if WITH_EDITOR @@ -42,15 +43,18 @@ static PyTypeObject ue_PyFbxIOSettingsType = { 0, /* tp_getset */ }; -static int py_ue_fbx_io_settings_init(ue_PyFbxIOSettings *self, PyObject * args) { +static int py_ue_fbx_io_settings_init(ue_PyFbxIOSettings *self, PyObject * args) +{ PyObject *py_object; char *name; - if (!PyArg_ParseTuple(args, "Os", &py_object, &name)) { + if (!PyArg_ParseTuple(args, "Os", &py_object, &name)) + { return -1; } ue_PyFbxManager *py_fbx_manager = py_ue_is_fbx_manager(py_object); - if (!py_fbx_manager) { + if (!py_fbx_manager) + { PyErr_SetString(PyExc_Exception, "argument is not a FbxManager"); return -1; } @@ -59,7 +63,8 @@ static int py_ue_fbx_io_settings_init(ue_PyFbxIOSettings *self, PyObject * args) return 0; } -void ue_python_init_fbx_io_settings(PyObject *ue_module) { +void ue_python_init_fbx_io_settings(PyObject *ue_module) +{ ue_PyFbxIOSettingsType.tp_new = PyType_GenericNew;; ue_PyFbxIOSettingsType.tp_init = (initproc)py_ue_fbx_io_settings_init; if (PyType_Ready(&ue_PyFbxIOSettingsType) < 0) @@ -69,7 +74,8 @@ void ue_python_init_fbx_io_settings(PyObject *ue_module) { PyModule_AddObject(ue_module, "FbxIOSettings", (PyObject *)&ue_PyFbxIOSettingsType); } -ue_PyFbxIOSettings *py_ue_is_fbx_io_settings(PyObject *obj) { +ue_PyFbxIOSettings *py_ue_is_fbx_io_settings(PyObject *obj) +{ if (!PyObject_IsInstance(obj, (PyObject *)&ue_PyFbxIOSettingsType)) return nullptr; return (ue_PyFbxIOSettings *)obj; diff --git a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxIOSettings.h b/Source/UnrealEnginePython/Private/Fbx/UEPyFbxIOSettings.h index 0b3bf55a5..9515ddec9 100644 --- a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxIOSettings.h +++ b/Source/UnrealEnginePython/Private/Fbx/UEPyFbxIOSettings.h @@ -1,14 +1,21 @@ #pragma once -#include "UnrealEnginePython.h" +#include "UEPyModule.h" #if WITH_EDITOR +#if PLATFORM_LINUX +#if defined(__clang__) +#pragma clang diagnostic ignored "-Wnull-dereference" +#endif +#endif + #include -struct ue_PyFbxIOSettings { +struct ue_PyFbxIOSettings +{ PyObject_HEAD - /* Type-specific fields go here. */ - FbxIOSettings *fbx_io_settings; + /* Type-specific fields go here. */ + FbxIOSettings *fbx_io_settings; }; diff --git a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxImporter.cpp b/Source/UnrealEnginePython/Private/Fbx/UEPyFbxImporter.cpp index 96f003948..432271a18 100644 --- a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxImporter.cpp +++ b/Source/UnrealEnginePython/Private/Fbx/UEPyFbxImporter.cpp @@ -1,4 +1,4 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPyFbxImporter.h" #if ENGINE_MINOR_VERSION > 12 #if WITH_EDITOR diff --git a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxImporter.h b/Source/UnrealEnginePython/Private/Fbx/UEPyFbxImporter.h index 551bb36df..57ed9d573 100644 --- a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxImporter.h +++ b/Source/UnrealEnginePython/Private/Fbx/UEPyFbxImporter.h @@ -1,14 +1,21 @@ #pragma once -#include "UnrealEnginePython.h" +#include "UEPyModule.h" #if WITH_EDITOR +#if PLATFORM_LINUX +#if defined(__clang__) +#pragma clang diagnostic ignored "-Wnull-dereference" +#endif +#endif + #include -struct ue_PyFbxImporter { +struct ue_PyFbxImporter +{ PyObject_HEAD - /* Type-specific fields go here. */ - FbxImporter *fbx_importer; + /* Type-specific fields go here. */ + FbxImporter *fbx_importer; }; diff --git a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxManager.cpp b/Source/UnrealEnginePython/Private/Fbx/UEPyFbxManager.cpp index b62a20ba8..0a8fe98f1 100644 --- a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxManager.cpp +++ b/Source/UnrealEnginePython/Private/Fbx/UEPyFbxManager.cpp @@ -1,18 +1,22 @@ +#include "UEPyFbxManager.h" + #if ENGINE_MINOR_VERSION > 12 -#include "UnrealEnginePythonPrivatePCH.h" #if WITH_EDITOR #include "UEPyFbx.h" -static PyObject *py_ue_fbx_manager_set_io_settings(ue_PyFbxManager *self, PyObject *args) { +static PyObject *py_ue_fbx_manager_set_io_settings(ue_PyFbxManager *self, PyObject *args) +{ PyObject *py_object; - if (!PyArg_ParseTuple(args, "O", &py_object)) { + if (!PyArg_ParseTuple(args, "O", &py_object)) + { return nullptr; } ue_PyFbxIOSettings *py_fbx_io_settings = py_ue_is_fbx_io_settings(py_object); - if (!py_fbx_io_settings) { + if (!py_fbx_io_settings) + { return PyErr_Format(PyExc_Exception, "argument is not a FbxIOSettings"); } @@ -21,14 +25,17 @@ static PyObject *py_ue_fbx_manager_set_io_settings(ue_PyFbxManager *self, PyObje Py_RETURN_NONE; } -static PyObject *py_ue_fbx_manager_create_missing_bind_poses(ue_PyFbxManager *self, PyObject *args) { +static PyObject *py_ue_fbx_manager_create_missing_bind_poses(ue_PyFbxManager *self, PyObject *args) +{ PyObject *py_object; - if (!PyArg_ParseTuple(args, "O", &py_object)) { + if (!PyArg_ParseTuple(args, "O", &py_object)) + { return nullptr; } ue_PyFbxScene *py_fbx_scene = py_ue_is_fbx_scene(py_object); - if (!py_fbx_scene) { + if (!py_fbx_scene) + { return PyErr_Format(PyExc_Exception, "argument is not a FbxScene"); } @@ -44,7 +51,8 @@ static PyMethodDef ue_PyFbxManager_methods[] = { { NULL } /* Sentinel */ }; -static void ue_py_fbx_manager_dealloc(ue_PyFbxManager *self) { +static void ue_py_fbx_manager_dealloc(ue_PyFbxManager *self) +{ if (self->fbx_manager) self->fbx_manager->Destroy(); #if PY_MAJOR_VERSION < 3 @@ -87,12 +95,14 @@ static PyTypeObject ue_PyFbxManagerType = { 0, /* tp_getset */ }; -static int py_ue_fbx_manager_init(ue_PyFbxManager *self, PyObject * args) { +static int py_ue_fbx_manager_init(ue_PyFbxManager *self, PyObject * args) +{ self->fbx_manager = FbxManager::Create(); return 0; } -void ue_python_init_fbx_manager(PyObject *ue_module) { +void ue_python_init_fbx_manager(PyObject *ue_module) +{ ue_PyFbxManagerType.tp_new = PyType_GenericNew;; ue_PyFbxManagerType.tp_init = (initproc)py_ue_fbx_manager_init; if (PyType_Ready(&ue_PyFbxManagerType) < 0) @@ -103,13 +113,15 @@ void ue_python_init_fbx_manager(PyObject *ue_module) { } -ue_PyFbxManager *py_ue_is_fbx_manager(PyObject *obj) { +ue_PyFbxManager *py_ue_is_fbx_manager(PyObject *obj) +{ if (!PyObject_IsInstance(obj, (PyObject *)&ue_PyFbxManagerType)) return nullptr; return (ue_PyFbxManager *)obj; } -void ue_python_init_fbx(PyObject *module) { +void ue_python_init_fbx(PyObject *module) +{ ue_python_init_fbx_manager(module); ue_python_init_fbx_io_settings(module); ue_python_init_fbx_importer(module); diff --git a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxManager.h b/Source/UnrealEnginePython/Private/Fbx/UEPyFbxManager.h index 1f15f0a62..59695148d 100644 --- a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxManager.h +++ b/Source/UnrealEnginePython/Private/Fbx/UEPyFbxManager.h @@ -1,14 +1,22 @@ #pragma once -#include "UnrealEnginePython.h" +#include "UEPyModule.h" #if WITH_EDITOR +#if PLATFORM_LINUX +#if defined(__clang__) +#pragma clang diagnostic ignored "-Wnull-dereference" +#endif +#endif + + #include -struct ue_PyFbxManager { +struct ue_PyFbxManager +{ PyObject_HEAD - /* Type-specific fields go here. */ - FbxManager *fbx_manager; + /* Type-specific fields go here. */ + FbxManager *fbx_manager; }; diff --git a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxMesh.cpp b/Source/UnrealEnginePython/Private/Fbx/UEPyFbxMesh.cpp index cf367203e..b54d12aa0 100644 --- a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxMesh.cpp +++ b/Source/UnrealEnginePython/Private/Fbx/UEPyFbxMesh.cpp @@ -1,9 +1,11 @@ -#include "UnrealEnginePythonPrivatePCH.h" -#include "UEPyFbx.h" + +#include "UEPyFbxMesh.h" #if WITH_EDITOR #if ENGINE_MINOR_VERSION > 12 +#include "UEPyFbx.h" + static PyObject *py_ue_fbx_mesh_get_polygon_count(ue_PyFbxMesh *self, PyObject *args) { return PyLong_FromLong(self->fbx_mesh->GetPolygonCount()); diff --git a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxMesh.h b/Source/UnrealEnginePython/Private/Fbx/UEPyFbxMesh.h index be525201f..5e5d41594 100644 --- a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxMesh.h +++ b/Source/UnrealEnginePython/Private/Fbx/UEPyFbxMesh.h @@ -1,16 +1,22 @@ #pragma once -#include "UnrealEnginePython.h" +#include "UEPyModule.h" #if WITH_EDITOR #if ENGINE_MINOR_VERSION > 12 +#if PLATFORM_LINUX +#if defined(__clang__) +#pragma clang diagnostic ignored "-Wnull-dereference" +#endif +#endif + #include struct ue_PyFbxMesh { PyObject_HEAD - /* Type-specific fields go here. */ - FbxMesh *fbx_mesh; + /* Type-specific fields go here. */ + FbxMesh *fbx_mesh; }; diff --git a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxNode.cpp b/Source/UnrealEnginePython/Private/Fbx/UEPyFbxNode.cpp index 15dfa0170..976fe8602 100644 --- a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxNode.cpp +++ b/Source/UnrealEnginePython/Private/Fbx/UEPyFbxNode.cpp @@ -1,88 +1,111 @@ -#include "UnrealEnginePythonPrivatePCH.h" -#include "UEPyFbx.h" +#include "UEPyFbxNode.h" #if WITH_EDITOR #if ENGINE_MINOR_VERSION > 12 -static PyObject *py_ue_fbx_node_get_child_count(ue_PyFbxNode *self, PyObject *args) { + +#include "UEPyFbx.h" + + +static PyObject *py_ue_fbx_node_get_child_count(ue_PyFbxNode *self, PyObject *args) +{ return PyLong_FromLong(self->fbx_node->GetChildCount()); } -static PyObject *py_ue_fbx_node_get_name(ue_PyFbxNode *self, PyObject *args) { +static PyObject *py_ue_fbx_node_get_name(ue_PyFbxNode *self, PyObject *args) +{ return PyUnicode_FromString(self->fbx_node->GetName()); } -static PyObject *py_ue_fbx_node_get_local_translation(ue_PyFbxNode *self, PyObject *args) { +static PyObject *py_ue_fbx_node_get_local_translation(ue_PyFbxNode *self, PyObject *args) +{ FbxDouble3 fbx_vec = self->fbx_node->LclTranslation.Get(); return py_ue_new_fvector(FVector(fbx_vec[0], fbx_vec[1], fbx_vec[2])); } -static PyObject *py_ue_fbx_node_get_local_rotation(ue_PyFbxNode *self, PyObject *args) { +static PyObject *py_ue_fbx_node_get_local_rotation(ue_PyFbxNode *self, PyObject *args) +{ FbxDouble3 fbx_vec = self->fbx_node->LclRotation.Get(); return py_ue_new_fvector(FVector(fbx_vec[0], fbx_vec[1], fbx_vec[2])); } -static PyObject *py_ue_fbx_node_get_local_scaling(ue_PyFbxNode *self, PyObject *args) { +static PyObject *py_ue_fbx_node_get_local_scaling(ue_PyFbxNode *self, PyObject *args) +{ FbxDouble3 fbx_vec = self->fbx_node->LclScaling.Get(); return py_ue_new_fvector(FVector(fbx_vec[0], fbx_vec[1], fbx_vec[2])); } -static PyObject *py_ue_fbx_node_get_child(ue_PyFbxNode *self, PyObject *args) { +static PyObject *py_ue_fbx_node_get_child(ue_PyFbxNode *self, PyObject *args) +{ int index; - if (!PyArg_ParseTuple(args, "i", &index)) { + if (!PyArg_ParseTuple(args, "i", &index)) + { return nullptr; } FbxNode *fbx_node = self->fbx_node->GetChild(index); - if (!fbx_node) { + if (!fbx_node) + { return PyErr_Format(PyExc_Exception, "unable to retrieve FbxNode at index %d", index); } return py_ue_new_fbx_node(fbx_node); } -static PyObject *py_ue_fbx_node_get_parent(ue_PyFbxNode *self, PyObject *args) { +static PyObject *py_ue_fbx_node_get_parent(ue_PyFbxNode *self, PyObject *args) +{ FbxNode *fbx_node = self->fbx_node->GetParent(); - if (!fbx_node) { + if (!fbx_node) + { return PyErr_Format(PyExc_Exception, "unable to retrieve FbxNode parent"); } return py_ue_new_fbx_node(fbx_node); } -static PyObject *py_ue_fbx_node_get_node_attribute(ue_PyFbxNode *self, PyObject *args) { +static PyObject *py_ue_fbx_node_get_node_attribute(ue_PyFbxNode *self, PyObject *args) +{ FbxNodeAttribute *fbx_node_attribute = self->fbx_node->GetNodeAttribute(); - if (!fbx_node_attribute) { + if (!fbx_node_attribute) + { return PyErr_Format(PyExc_Exception, "unable to retrieve FbxNodeAttribute"); } return py_ue_new_fbx_object(fbx_node_attribute); } -static PyObject *py_ue_fbx_node_get_node_attribute_count(ue_PyFbxNode *self, PyObject *args) { +static PyObject *py_ue_fbx_node_get_node_attribute_count(ue_PyFbxNode *self, PyObject *args) +{ return PyLong_FromLong(self->fbx_node->GetNodeAttributeCount()); } -static PyObject *py_ue_fbx_node_get_node_attribute_by_index(ue_PyFbxNode *self, PyObject *args) { +static PyObject *py_ue_fbx_node_get_node_attribute_by_index(ue_PyFbxNode *self, PyObject *args) +{ int index; - if (!PyArg_ParseTuple(args, "i", &index)) { + if (!PyArg_ParseTuple(args, "i", &index)) + { return nullptr; } FbxNodeAttribute *fbx_node_attribute = self->fbx_node->GetNodeAttributeByIndex(index); - if (!fbx_node_attribute) { + if (!fbx_node_attribute) + { return PyErr_Format(PyExc_Exception, "unable to retrieve FbxNodeAttribute at index %d", index); } return py_ue_new_fbx_object(fbx_node_attribute); } -static PyObject *py_ue_fbx_node_get_mesh(ue_PyFbxNode *self, PyObject *args) { +static PyObject *py_ue_fbx_node_get_mesh(ue_PyFbxNode *self, PyObject *args) +{ FbxMesh *fbx_mesh = self->fbx_node->GetMesh(); - if (!fbx_mesh) { + if (!fbx_mesh) + { return PyErr_Format(PyExc_Exception, "unable to retrieve FbxMesh from FbxNode"); } return py_ue_new_fbx_mesh(fbx_mesh); } -static PyObject *py_ue_fbx_node_evaluate_local_transform(ue_PyFbxNode *self, PyObject *args) { +static PyObject *py_ue_fbx_node_evaluate_local_transform(ue_PyFbxNode *self, PyObject *args) +{ float t; - if (!PyArg_ParseTuple(args, "f", &t)) { + if (!PyArg_ParseTuple(args, "f", &t)) + { return nullptr; } FbxTime time; @@ -98,9 +121,11 @@ static PyObject *py_ue_fbx_node_evaluate_local_transform(ue_PyFbxNode *self, PyO return py_ue_new_ftransform(transform); } -static PyObject *py_ue_fbx_node_evaluate_global_transform(ue_PyFbxNode *self, PyObject *args) { +static PyObject *py_ue_fbx_node_evaluate_global_transform(ue_PyFbxNode *self, PyObject *args) +{ float t; - if (!PyArg_ParseTuple(args, "f", &t)) { + if (!PyArg_ParseTuple(args, "f", &t)) + { return nullptr; } FbxTime time; @@ -166,15 +191,18 @@ static PyTypeObject ue_PyFbxNodeType = { 0, /* tp_getset */ }; -static int py_ue_fbx_node_init(ue_PyFbxNode *self, PyObject * args) { +static int py_ue_fbx_node_init(ue_PyFbxNode *self, PyObject * args) +{ PyObject *py_object; char *name; - if (!PyArg_ParseTuple(args, "Os", &py_object, &name)) { + if (!PyArg_ParseTuple(args, "Os", &py_object, &name)) + { return -1; } ue_PyFbxManager *py_fbx_manager = py_ue_is_fbx_manager(py_object); - if (!py_fbx_manager) { + if (!py_fbx_manager) + { PyErr_SetString(PyExc_Exception, "argument is not a FbxManager"); return -1; } @@ -183,7 +211,8 @@ static int py_ue_fbx_node_init(ue_PyFbxNode *self, PyObject * args) { return 0; } -void ue_python_init_fbx_node(PyObject *ue_module) { +void ue_python_init_fbx_node(PyObject *ue_module) +{ ue_PyFbxNodeType.tp_new = PyType_GenericNew;; ue_PyFbxNodeType.tp_init = (initproc)py_ue_fbx_node_init; if (PyType_Ready(&ue_PyFbxNodeType) < 0) @@ -193,13 +222,15 @@ void ue_python_init_fbx_node(PyObject *ue_module) { PyModule_AddObject(ue_module, "FbxNode", (PyObject *)&ue_PyFbxNodeType); } -PyObject *py_ue_new_fbx_node(FbxNode *fbx_node) { +PyObject *py_ue_new_fbx_node(FbxNode *fbx_node) +{ ue_PyFbxNode *ret = (ue_PyFbxNode *)PyObject_New(ue_PyFbxNode, &ue_PyFbxNodeType); ret->fbx_node = fbx_node; return (PyObject *)ret; } -ue_PyFbxNode *py_ue_is_fbx_node(PyObject *obj) { +ue_PyFbxNode *py_ue_is_fbx_node(PyObject *obj) +{ if (!PyObject_IsInstance(obj, (PyObject *)&ue_PyFbxNodeType)) return nullptr; return (ue_PyFbxNode *)obj; diff --git a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxNode.h b/Source/UnrealEnginePython/Private/Fbx/UEPyFbxNode.h index 2fd7d6f84..276dc2487 100644 --- a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxNode.h +++ b/Source/UnrealEnginePython/Private/Fbx/UEPyFbxNode.h @@ -1,14 +1,22 @@ #pragma once -#include "UnrealEnginePython.h" +#include "UEPyModule.h" #if WITH_EDITOR #if ENGINE_MINOR_VERSION > 12 + +#if PLATFORM_LINUX +#if defined(__clang__) +#pragma clang diagnostic ignored "-Wnull-dereference" +#endif +#endif + #include -struct ue_PyFbxNode { +struct ue_PyFbxNode +{ PyObject_HEAD - /* Type-specific fields go here. */ - FbxNode *fbx_node; + /* Type-specific fields go here. */ + FbxNode *fbx_node; }; @@ -19,4 +27,4 @@ PyObject *py_ue_new_fbx_node(FbxNode *); ue_PyFbxNode *py_ue_is_fbx_node(PyObject *); #endif -#endif \ No newline at end of file +#endif diff --git a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxObject.cpp b/Source/UnrealEnginePython/Private/Fbx/UEPyFbxObject.cpp index b9d902a32..a4937b7e3 100644 --- a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxObject.cpp +++ b/Source/UnrealEnginePython/Private/Fbx/UEPyFbxObject.cpp @@ -1,28 +1,36 @@ -#if ENGINE_MINOR_VERSION > 12 -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPyFbxObject.h" + +#if ENGINE_MINOR_VERSION > 12 #if WITH_EDITOR #include "UEPyFbx.h" -static PyObject *py_ue_fbx_object_get_name(ue_PyFbxObject *self, PyObject *args) { +#include "Runtime/Engine/Classes/Curves/RichCurve.h" + +static PyObject *py_ue_fbx_object_get_name(ue_PyFbxObject *self, PyObject *args) +{ return PyUnicode_FromString(self->fbx_object->GetName()); } -static PyObject *py_ue_fbx_object_get_class_name(ue_PyFbxObject *self, PyObject *args) { +static PyObject *py_ue_fbx_object_get_class_name(ue_PyFbxObject *self, PyObject *args) +{ return PyUnicode_FromString(self->fbx_object->GetClassId().GetName()); } -static PyObject *py_ue_fbx_object_get_member_count(ue_PyFbxObject *self, PyObject *args) { +static PyObject *py_ue_fbx_object_get_member_count(ue_PyFbxObject *self, PyObject *args) +{ FbxCollection *fbx_collection = FbxCast(self->fbx_object); if (!fbx_collection) return PyErr_Format(PyExc_Exception, "unable to cast to FbxCollection"); return PyLong_FromLong(fbx_collection->GetMemberCount()); } -static PyObject *py_ue_fbx_object_get_member(ue_PyFbxObject *self, PyObject *args) { +static PyObject *py_ue_fbx_object_get_member(ue_PyFbxObject *self, PyObject *args) +{ int index; - if (!PyArg_ParseTuple(args, "i", &index)) { + if (!PyArg_ParseTuple(args, "i", &index)) + { return nullptr; } FbxCollection *fbx_collection = FbxCast(self->fbx_object); @@ -34,14 +42,17 @@ static PyObject *py_ue_fbx_object_get_member(ue_PyFbxObject *self, PyObject *arg return py_ue_new_fbx_object(fbx_collection->GetMember(index)); } -static PyObject *py_ue_fbx_object_get_next_property(ue_PyFbxObject *self, PyObject *args) { +static PyObject *py_ue_fbx_object_get_next_property(ue_PyFbxObject *self, PyObject *args) +{ PyObject *py_object; - if (!PyArg_ParseTuple(args, "O", &py_object)) { + if (!PyArg_ParseTuple(args, "O", &py_object)) + { return nullptr; } ue_PyFbxProperty *py_fbx_property = py_ue_is_fbx_property(py_object); - if (!py_fbx_property) { + if (!py_fbx_property) + { return PyErr_Format(PyExc_Exception, "argument is not a FbxProperty"); } @@ -51,30 +62,35 @@ static PyObject *py_ue_fbx_object_get_next_property(ue_PyFbxObject *self, PyObje return py_ue_new_fbx_property(fbx_property); } -static PyObject *py_ue_fbx_object_get_first_property(ue_PyFbxObject *self, PyObject *args) { +static PyObject *py_ue_fbx_object_get_first_property(ue_PyFbxObject *self, PyObject *args) +{ FbxProperty fbx_property = self->fbx_object->GetFirstProperty(); if (!fbx_property.IsValid()) Py_RETURN_NONE; return py_ue_new_fbx_property(fbx_property); } -static PyObject *py_ue_fbx_object_get_channels_count(ue_PyFbxObject *self, PyObject *args) { +static PyObject *py_ue_fbx_object_get_channels_count(ue_PyFbxObject *self, PyObject *args) +{ FbxAnimCurveNode *fbx_anim_curve_node = FbxCast(self->fbx_object); if (!fbx_anim_curve_node) return PyErr_Format(PyExc_Exception, "object is not a FbxAnimCurveNode"); return PyLong_FromLong(fbx_anim_curve_node->GetChannelsCount()); } -static PyObject *py_ue_fbx_object_to_node(ue_PyFbxObject *self, PyObject *args) { +static PyObject *py_ue_fbx_object_to_node(ue_PyFbxObject *self, PyObject *args) +{ FbxNode *fbx_node = FbxCast(self->fbx_object); if (!fbx_node) return PyErr_Format(PyExc_Exception, "object is not a FbxNode"); return py_ue_new_fbx_node(fbx_node); } -static PyObject *py_ue_fbx_object_get_channel_name(ue_PyFbxObject *self, PyObject *args) { +static PyObject *py_ue_fbx_object_get_channel_name(ue_PyFbxObject *self, PyObject *args) +{ int index; - if (!PyArg_ParseTuple(args, "i", &index)) { + if (!PyArg_ParseTuple(args, "i", &index)) + { return nullptr; } FbxAnimCurveNode *fbx_anim_curve_node = FbxCast(self->fbx_object); @@ -83,9 +99,11 @@ static PyObject *py_ue_fbx_object_get_channel_name(ue_PyFbxObject *self, PyObjec return PyUnicode_FromString(fbx_anim_curve_node->GetChannelName(index)); } -static PyObject *py_ue_fbx_object_get_curve_count(ue_PyFbxObject *self, PyObject *args) { +static PyObject *py_ue_fbx_object_get_curve_count(ue_PyFbxObject *self, PyObject *args) +{ int channel; - if (!PyArg_ParseTuple(args, "i", &channel)) { + if (!PyArg_ParseTuple(args, "i", &channel)) + { return nullptr; } FbxAnimCurveNode *fbx_anim_curve_node = FbxCast(self->fbx_object); @@ -94,10 +112,12 @@ static PyObject *py_ue_fbx_object_get_curve_count(ue_PyFbxObject *self, PyObject return PyLong_FromLong(fbx_anim_curve_node->GetCurveCount(channel)); } -static PyObject *py_ue_fbx_object_get_curve(ue_PyFbxObject *self, PyObject *args) { +static PyObject *py_ue_fbx_object_get_curve(ue_PyFbxObject *self, PyObject *args) +{ int channel; int index = 0; - if (!PyArg_ParseTuple(args, "i|i:get_curve", &channel, &index)) { + if (!PyArg_ParseTuple(args, "i|i:get_curve", &channel, &index)) + { return nullptr; } FbxAnimCurveNode *fbx_anim_curve_node = FbxCast(self->fbx_object); @@ -109,16 +129,19 @@ static PyObject *py_ue_fbx_object_get_curve(ue_PyFbxObject *self, PyObject *args return py_ue_new_fbx_object(fbx_anim_curve_node->GetCurve(channel, index)); } -static PyObject *py_ue_fbx_object_key_get_count(ue_PyFbxObject *self, PyObject *args) { +static PyObject *py_ue_fbx_object_key_get_count(ue_PyFbxObject *self, PyObject *args) +{ FbxAnimCurve *fbx_anim_curve = FbxCast(self->fbx_object); if (!fbx_anim_curve) return PyErr_Format(PyExc_Exception, "object is not a FbxAnimCurve"); return PyLong_FromLong(fbx_anim_curve->KeyGetCount()); } -static PyObject *py_ue_fbx_object_key_get_value(ue_PyFbxObject *self, PyObject *args) { +static PyObject *py_ue_fbx_object_key_get_value(ue_PyFbxObject *self, PyObject *args) +{ int index; - if (!PyArg_ParseTuple(args, "i", &index)) { + if (!PyArg_ParseTuple(args, "i", &index)) + { return nullptr; } FbxAnimCurve *fbx_anim_curve = FbxCast(self->fbx_object); @@ -127,9 +150,11 @@ static PyObject *py_ue_fbx_object_key_get_value(ue_PyFbxObject *self, PyObject * return PyFloat_FromDouble(fbx_anim_curve->KeyGetValue(index)); } -static PyObject *py_ue_fbx_object_key_get_seconds(ue_PyFbxObject *self, PyObject *args) { +static PyObject *py_ue_fbx_object_key_get_seconds(ue_PyFbxObject *self, PyObject *args) +{ int index; - if (!PyArg_ParseTuple(args, "i", &index)) { + if (!PyArg_ParseTuple(args, "i", &index)) + { return nullptr; } FbxAnimCurve *fbx_anim_curve = FbxCast(self->fbx_object); @@ -138,9 +163,11 @@ static PyObject *py_ue_fbx_object_key_get_seconds(ue_PyFbxObject *self, PyObject return PyFloat_FromDouble(fbx_anim_curve->KeyGetTime(index).GetSecondDouble()); } -static PyObject *py_ue_fbx_object_key_get_left_tangent(ue_PyFbxObject *self, PyObject *args) { +static PyObject *py_ue_fbx_object_key_get_left_tangent(ue_PyFbxObject *self, PyObject *args) +{ int index; - if (!PyArg_ParseTuple(args, "i", &index)) { + if (!PyArg_ParseTuple(args, "i", &index)) + { return nullptr; } FbxAnimCurve *fbx_anim_curve = FbxCast(self->fbx_object); @@ -149,9 +176,11 @@ static PyObject *py_ue_fbx_object_key_get_left_tangent(ue_PyFbxObject *self, PyO return PyFloat_FromDouble(fbx_anim_curve->KeyGetLeftDerivative(index)); } -static PyObject *py_ue_fbx_object_key_get_right_tangent(ue_PyFbxObject *self, PyObject *args) { +static PyObject *py_ue_fbx_object_key_get_right_tangent(ue_PyFbxObject *self, PyObject *args) +{ int index; - if (!PyArg_ParseTuple(args, "i", &index)) { + if (!PyArg_ParseTuple(args, "i", &index)) + { return nullptr; } FbxAnimCurve *fbx_anim_curve = FbxCast(self->fbx_object); @@ -160,9 +189,11 @@ static PyObject *py_ue_fbx_object_key_get_right_tangent(ue_PyFbxObject *self, Py return PyFloat_FromDouble(fbx_anim_curve->KeyGetRightDerivative(index)); } -static PyObject *py_ue_fbx_object_key_get_interp_mode(ue_PyFbxObject *self, PyObject *args) { +static PyObject *py_ue_fbx_object_key_get_interp_mode(ue_PyFbxObject *self, PyObject *args) +{ int index; - if (!PyArg_ParseTuple(args, "i", &index)) { + if (!PyArg_ParseTuple(args, "i", &index)) + { return nullptr; } FbxAnimCurve *fbx_anim_curve = FbxCast(self->fbx_object); @@ -194,9 +225,11 @@ static PyObject *py_ue_fbx_object_key_get_interp_mode(ue_PyFbxObject *self, PyOb return PyLong_FromUnsignedLong(uint64(Mode)); } -static PyObject *py_ue_fbx_object_key_get_tangent_mode(ue_PyFbxObject *self, PyObject *args) { +static PyObject *py_ue_fbx_object_key_get_tangent_mode(ue_PyFbxObject *self, PyObject *args) +{ int index; - if (!PyArg_ParseTuple(args, "i", &index)) { + if (!PyArg_ParseTuple(args, "i", &index)) + { return nullptr; } FbxAnimCurve *fbx_anim_curve = FbxCast(self->fbx_object); @@ -205,8 +238,8 @@ static PyObject *py_ue_fbx_object_key_get_tangent_mode(ue_PyFbxObject *self, PyO ERichCurveTangentMode Mode = RCTM_Auto; // Convert the interpolation type from FBX to Unreal. - if ( fbx_anim_curve->KeyGetInterpolation(index) == - FbxAnimCurveDef::eInterpolationCubic ) + if (fbx_anim_curve->KeyGetInterpolation(index) == + FbxAnimCurveDef::eInterpolationCubic) { switch (fbx_anim_curve->KeyGetTangentMode(index)) { @@ -295,15 +328,18 @@ static PyTypeObject ue_PyFbxObjectType = { 0, /* tp_getset */ }; -static int py_ue_fbx_object_init(ue_PyFbxObject *self, PyObject * args) { +static int py_ue_fbx_object_init(ue_PyFbxObject *self, PyObject * args) +{ PyObject *py_object; char *name; - if (!PyArg_ParseTuple(args, "Os", &py_object, &name)) { + if (!PyArg_ParseTuple(args, "Os", &py_object, &name)) + { return -1; } ue_PyFbxManager *py_fbx_manager = py_ue_is_fbx_manager(py_object); - if (!py_fbx_manager) { + if (!py_fbx_manager) + { PyErr_SetString(PyExc_Exception, "argument is not a FbxManager"); return -1; } @@ -312,7 +348,8 @@ static int py_ue_fbx_object_init(ue_PyFbxObject *self, PyObject * args) { return 0; } -void ue_python_init_fbx_object(PyObject *ue_module) { +void ue_python_init_fbx_object(PyObject *ue_module) +{ ue_PyFbxObjectType.tp_new = PyType_GenericNew;; ue_PyFbxObjectType.tp_init = (initproc)py_ue_fbx_object_init; if (PyType_Ready(&ue_PyFbxObjectType) < 0) @@ -322,13 +359,15 @@ void ue_python_init_fbx_object(PyObject *ue_module) { PyModule_AddObject(ue_module, "FbxObject", (PyObject *)&ue_PyFbxObjectType); } -PyObject *py_ue_new_fbx_object(FbxObject *fbx_object) { +PyObject *py_ue_new_fbx_object(FbxObject *fbx_object) +{ ue_PyFbxObject *ret = (ue_PyFbxObject *)PyObject_New(ue_PyFbxObject, &ue_PyFbxObjectType); ret->fbx_object = fbx_object; return (PyObject *)ret; } -ue_PyFbxObject *py_ue_is_fbx_object(PyObject *obj) { +ue_PyFbxObject *py_ue_is_fbx_object(PyObject *obj) +{ if (!PyObject_IsInstance(obj, (PyObject *)&ue_PyFbxObjectType)) return nullptr; return (ue_PyFbxObject *)obj; diff --git a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxObject.h b/Source/UnrealEnginePython/Private/Fbx/UEPyFbxObject.h index 0ebb320ef..0b80931ce 100644 --- a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxObject.h +++ b/Source/UnrealEnginePython/Private/Fbx/UEPyFbxObject.h @@ -1,8 +1,15 @@ #pragma once -#include "UnrealEnginePython.h" +#include "UEPyModule.h" #if WITH_EDITOR + +#if PLATFORM_LINUX +#if defined(__clang__) +#pragma clang diagnostic ignored "-Wnull-dereference" +#endif +#endif + #include struct ue_PyFbxObject { diff --git a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxPose.cpp b/Source/UnrealEnginePython/Private/Fbx/UEPyFbxPose.cpp index b332503ac..6d0390297 100644 --- a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxPose.cpp +++ b/Source/UnrealEnginePython/Private/Fbx/UEPyFbxPose.cpp @@ -1,47 +1,59 @@ +#include "UEPyFbxPose.h" + #if ENGINE_MINOR_VERSION > 12 -#include "UnrealEnginePythonPrivatePCH.h" #if WITH_EDITOR #include "UEPyFbx.h" -static PyObject *py_ue_fbx_pose_get_count(ue_PyFbxPose *self, PyObject *args) { +static PyObject *py_ue_fbx_pose_get_count(ue_PyFbxPose *self, PyObject *args) +{ return PyLong_FromLong(self->fbx_pose->GetCount()); } -static PyObject *py_ue_fbx_pose_get_name(ue_PyFbxPose *self, PyObject *args) { +static PyObject *py_ue_fbx_pose_get_name(ue_PyFbxPose *self, PyObject *args) +{ return PyUnicode_FromString(self->fbx_pose->GetName()); } -static PyObject *py_ue_fbx_pose_is_bind_pose(ue_PyFbxPose *self, PyObject *args) { - if (self->fbx_pose->IsBindPose()) { +static PyObject *py_ue_fbx_pose_is_bind_pose(ue_PyFbxPose *self, PyObject *args) +{ + if (self->fbx_pose->IsBindPose()) + { Py_RETURN_TRUE; } Py_RETURN_FALSE; } -static PyObject *py_ue_fbx_pose_is_rest_pose(ue_PyFbxPose *self, PyObject *args) { - if (self->fbx_pose->IsRestPose()) { +static PyObject *py_ue_fbx_pose_is_rest_pose(ue_PyFbxPose *self, PyObject *args) +{ + if (self->fbx_pose->IsRestPose()) + { Py_RETURN_TRUE; } Py_RETURN_FALSE; } -static PyObject *py_ue_fbx_pose_get_node(ue_PyFbxPose *self, PyObject *args) { +static PyObject *py_ue_fbx_pose_get_node(ue_PyFbxPose *self, PyObject *args) +{ int index; - if (!PyArg_ParseTuple(args, "i", &index)) { + if (!PyArg_ParseTuple(args, "i", &index)) + { return nullptr; } FbxNode *fbx_node = self->fbx_pose->GetNode(index); - if (!fbx_node) { + if (!fbx_node) + { return PyErr_Format(PyExc_Exception, "unable to retrieve FbxNode at index %d", index); } return py_ue_new_fbx_node(fbx_node); } -static PyObject *py_ue_fbx_pose_find(ue_PyFbxPose *self, PyObject *args) { +static PyObject *py_ue_fbx_pose_find(ue_PyFbxPose *self, PyObject *args) +{ PyObject *py_obj; - if (!PyArg_ParseTuple(args, "O", &py_obj)) { + if (!PyArg_ParseTuple(args, "O", &py_obj)) + { return nullptr; } @@ -56,12 +68,14 @@ static PyObject *py_ue_fbx_pose_find(ue_PyFbxPose *self, PyObject *args) { return PyLong_FromLong(index); } -static PyObject *py_ue_fbx_pose_get_transform(ue_PyFbxPose *self, PyObject *args) { +static PyObject *py_ue_fbx_pose_get_transform(ue_PyFbxPose *self, PyObject *args) +{ int index; - if (!PyArg_ParseTuple(args, "i", &index)) { + if (!PyArg_ParseTuple(args, "i", &index)) + { return nullptr; } - + FbxMatrix fbx_matrix = self->fbx_pose->GetMatrix(index); FbxAMatrix matrix = *(FbxAMatrix *)&fbx_matrix; FTransform transform; @@ -118,15 +132,18 @@ static PyTypeObject ue_PyFbxPoseType = { 0, /* tp_getset */ }; -static int py_ue_fbx_pose_init(ue_PyFbxPose *self, PyObject * args) { +static int py_ue_fbx_pose_init(ue_PyFbxPose *self, PyObject * args) +{ PyObject *py_object; char *name; - if (!PyArg_ParseTuple(args, "Os", &py_object, &name)) { + if (!PyArg_ParseTuple(args, "Os", &py_object, &name)) + { return -1; } ue_PyFbxManager *py_fbx_manager = py_ue_is_fbx_manager(py_object); - if (!py_fbx_manager) { + if (!py_fbx_manager) + { PyErr_SetString(PyExc_Exception, "argument is not a FbxManager"); return -1; } @@ -135,7 +152,8 @@ static int py_ue_fbx_pose_init(ue_PyFbxPose *self, PyObject * args) { return 0; } -void ue_python_init_fbx_pose(PyObject *ue_module) { +void ue_python_init_fbx_pose(PyObject *ue_module) +{ ue_PyFbxPoseType.tp_new = PyType_GenericNew;; ue_PyFbxPoseType.tp_init = (initproc)py_ue_fbx_pose_init; if (PyType_Ready(&ue_PyFbxPoseType) < 0) @@ -145,7 +163,8 @@ void ue_python_init_fbx_pose(PyObject *ue_module) { PyModule_AddObject(ue_module, "FbxPose", (PyObject *)&ue_PyFbxPoseType); } -PyObject *py_ue_new_fbx_pose(FbxPose *fbx_pose) { +PyObject *py_ue_new_fbx_pose(FbxPose *fbx_pose) +{ ue_PyFbxPose *ret = (ue_PyFbxPose *)PyObject_New(ue_PyFbxPose, &ue_PyFbxPoseType); ret->fbx_pose = fbx_pose; return (PyObject *)ret; diff --git a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxPose.h b/Source/UnrealEnginePython/Private/Fbx/UEPyFbxPose.h index 5c8bda476..7d0f1a163 100644 --- a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxPose.h +++ b/Source/UnrealEnginePython/Private/Fbx/UEPyFbxPose.h @@ -1,19 +1,26 @@ #pragma once -#include "UnrealEnginePython.h" +#include "UEPyModule.h" #if WITH_EDITOR +#if PLATFORM_LINUX +#if defined(__clang__) +#pragma clang diagnostic ignored "-Wnull-dereference" +#endif +#endif + #include -struct ue_PyFbxPose { +struct ue_PyFbxPose +{ PyObject_HEAD - /* Type-specific fields go here. */ - FbxPose *fbx_pose; + /* Type-specific fields go here. */ + FbxPose *fbx_pose; }; void ue_python_init_fbx_pose(PyObject *); -PyObject *py_ue_new_fbx_pose(FbxNode *); +PyObject *py_ue_new_fbx_pose(FbxPose *); #endif diff --git a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxProperty.cpp b/Source/UnrealEnginePython/Private/Fbx/UEPyFbxProperty.cpp index 62a076746..37eaa2a2a 100644 --- a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxProperty.cpp +++ b/Source/UnrealEnginePython/Private/Fbx/UEPyFbxProperty.cpp @@ -1,33 +1,40 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPyFbxProperty.h" #if ENGINE_MINOR_VERSION > 12 #if WITH_EDITOR #include "UEPyFbx.h" -static PyObject *py_ue_fbx_property_get_name(ue_PyFbxProperty *self, PyObject *args) { +static PyObject *py_ue_fbx_property_get_name(ue_PyFbxProperty *self, PyObject *args) +{ return PyUnicode_FromString(self->fbx_property.GetName()); } -static PyObject *py_ue_fbx_property_get_double3(ue_PyFbxProperty *self, PyObject *args) { +static PyObject *py_ue_fbx_property_get_double3(ue_PyFbxProperty *self, PyObject *args) +{ FbxDouble3 value = self->fbx_property.Get(); return Py_BuildValue((char *)"(fff)", value[0], value[1], value[2]); } -static PyObject *py_ue_fbx_property_get_string(ue_PyFbxProperty *self, PyObject *args) { - return PyUnicode_FromString(self->fbx_property.Get()); +static PyObject *py_ue_fbx_property_get_string(ue_PyFbxProperty *self, PyObject *args) +{ + return PyUnicode_FromString(self->fbx_property.Get()); } -static PyObject *py_ue_fbx_property_is_valid(ue_PyFbxProperty *self, PyObject *args) { - if (self->fbx_property.IsValid()) { +static PyObject *py_ue_fbx_property_is_valid(ue_PyFbxProperty *self, PyObject *args) +{ + if (self->fbx_property.IsValid()) + { Py_RETURN_TRUE; } Py_RETURN_FALSE; } -static PyObject *py_ue_fbx_property_get_curve_node(ue_PyFbxProperty *self, PyObject *args) { +static PyObject *py_ue_fbx_property_get_curve_node(ue_PyFbxProperty *self, PyObject *args) +{ PyObject *py_object; - if (!PyArg_ParseTuple(args, "O", &py_object)) { + if (!PyArg_ParseTuple(args, "O", &py_object)) + { return nullptr; } @@ -45,10 +52,28 @@ static PyObject *py_ue_fbx_property_get_curve_node(ue_PyFbxProperty *self, PyObj return py_ue_new_fbx_object(fbx_anim_curve_node); } +static PyObject *py_ue_fbx_property_get_bool(ue_PyFbxProperty *self, PyObject *args) +{ + if (self->fbx_property.Get()) + Py_RETURN_TRUE; + + Py_RETURN_FALSE; + +} + +static PyObject *py_ue_fbx_property_get_int(ue_PyFbxProperty *self, PyObject *args) +{ + return PyLong_FromLong(self->fbx_property.Get()); + +} + + static PyMethodDef ue_PyFbxProperty_methods[] = { { "get_name", (PyCFunction)py_ue_fbx_property_get_name, METH_VARARGS, "" }, { "get_double3", (PyCFunction)py_ue_fbx_property_get_double3, METH_VARARGS, "" }, - { "get_string", (PyCFunction)py_ue_fbx_property_get_string, METH_VARARGS, "" }, + { "get_string", (PyCFunction)py_ue_fbx_property_get_string, METH_VARARGS, "" }, + { "get_bool", (PyCFunction)py_ue_fbx_property_get_bool, METH_VARARGS, "" }, + { "get_int", (PyCFunction)py_ue_fbx_property_get_int, METH_VARARGS, "" }, { "is_valid", (PyCFunction)py_ue_fbx_property_is_valid, METH_VARARGS, "" }, { "get_curve_node", (PyCFunction)py_ue_fbx_property_get_curve_node, METH_VARARGS, "" }, { NULL } /* Sentinel */ @@ -87,12 +112,14 @@ static PyTypeObject ue_PyFbxPropertyType = { 0, /* tp_getset */ }; -static int py_ue_fbx_property_init(ue_PyFbxProperty *self, PyObject * args) { +static int py_ue_fbx_property_init(ue_PyFbxProperty *self, PyObject * args) +{ PyErr_SetString(PyExc_Exception, "instantiating a new FbxProperty is currently not supported"); return -1; } -void ue_python_init_fbx_property(PyObject *ue_module) { +void ue_python_init_fbx_property(PyObject *ue_module) +{ ue_PyFbxPropertyType.tp_new = PyType_GenericNew;; ue_PyFbxPropertyType.tp_init = (initproc)py_ue_fbx_property_init; if (PyType_Ready(&ue_PyFbxPropertyType) < 0) @@ -102,13 +129,15 @@ void ue_python_init_fbx_property(PyObject *ue_module) { PyModule_AddObject(ue_module, "FbxProperty", (PyObject *)&ue_PyFbxPropertyType); } -PyObject *py_ue_new_fbx_property(FbxProperty fbx_property) { +PyObject *py_ue_new_fbx_property(FbxProperty fbx_property) +{ ue_PyFbxProperty *ret = (ue_PyFbxProperty *)PyObject_New(ue_PyFbxProperty, &ue_PyFbxPropertyType); ret->fbx_property = fbx_property; return (PyObject *)ret; } -ue_PyFbxProperty *py_ue_is_fbx_property(PyObject *obj) { +ue_PyFbxProperty *py_ue_is_fbx_property(PyObject *obj) +{ if (!PyObject_IsInstance(obj, (PyObject *)&ue_PyFbxPropertyType)) return nullptr; return (ue_PyFbxProperty *)obj; diff --git a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxProperty.h b/Source/UnrealEnginePython/Private/Fbx/UEPyFbxProperty.h index 9ec42ff2e..225f967f9 100644 --- a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxProperty.h +++ b/Source/UnrealEnginePython/Private/Fbx/UEPyFbxProperty.h @@ -1,8 +1,14 @@ #pragma once -#include "UnrealEnginePython.h" +#include "UEPyModule.h" #if WITH_EDITOR +#if PLATFORM_LINUX +#if defined(__clang__) +#pragma clang diagnostic ignored "-Wnull-dereference" +#endif +#endif + #include struct ue_PyFbxProperty { diff --git a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxScene.cpp b/Source/UnrealEnginePython/Private/Fbx/UEPyFbxScene.cpp index 33700db16..8fd9ca67c 100644 --- a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxScene.cpp +++ b/Source/UnrealEnginePython/Private/Fbx/UEPyFbxScene.cpp @@ -1,30 +1,37 @@ +#include "UEPyFbxScene.h" #if ENGINE_MINOR_VERSION > 12 -#include "UnrealEnginePythonPrivatePCH.h" + #if WITH_EDITOR #include "UEPyFbx.h" -static PyObject *py_ue_fbx_scene_get_root_node(ue_PyFbxScene *self, PyObject *args) { +static PyObject *py_ue_fbx_scene_get_root_node(ue_PyFbxScene *self, PyObject *args) +{ FbxNode *fbx_node = self->fbx_scene->GetRootNode(); - if (!fbx_node) { + if (!fbx_node) + { return PyErr_Format(PyExc_Exception, "unable to get RootNode from FbxScene"); } return py_ue_new_fbx_node(fbx_node); } -static PyObject *py_ue_fbx_scene_get_src_object_count(ue_PyFbxScene *self, PyObject *args) { +static PyObject *py_ue_fbx_scene_get_src_object_count(ue_PyFbxScene *self, PyObject *args) +{ return PyLong_FromLong(self->fbx_scene->GetSrcObjectCount()); } -static PyObject *py_ue_fbx_scene_get_pose_count(ue_PyFbxScene *self, PyObject *args) { +static PyObject *py_ue_fbx_scene_get_pose_count(ue_PyFbxScene *self, PyObject *args) +{ return PyLong_FromLong(self->fbx_scene->GetPoseCount()); } -static PyObject *py_ue_fbx_scene_get_src_object(ue_PyFbxScene *self, PyObject *args) { +static PyObject *py_ue_fbx_scene_get_src_object(ue_PyFbxScene *self, PyObject *args) +{ int index; - if (!PyArg_ParseTuple(args, "i", &index)) { + if (!PyArg_ParseTuple(args, "i", &index)) + { return nullptr; } FbxObject *fbx_object = self->fbx_scene->GetSrcObject(index); @@ -34,9 +41,11 @@ static PyObject *py_ue_fbx_scene_get_src_object(ue_PyFbxScene *self, PyObject *a return py_ue_new_fbx_object(fbx_object); } -static PyObject *py_ue_fbx_scene_get_pose(ue_PyFbxScene *self, PyObject *args) { +static PyObject *py_ue_fbx_scene_get_pose(ue_PyFbxScene *self, PyObject *args) +{ int index; - if (!PyArg_ParseTuple(args, "i", &index)) { + if (!PyArg_ParseTuple(args, "i", &index)) + { return nullptr; } FbxPose *fbx_pose = self->fbx_scene->GetPose(index); @@ -46,7 +55,8 @@ static PyObject *py_ue_fbx_scene_get_pose(ue_PyFbxScene *self, PyObject *args) { return py_ue_new_fbx_pose(fbx_pose); } -static PyObject *py_ue_fbx_scene_convert(ue_PyFbxScene *self, PyObject *args) { +static PyObject *py_ue_fbx_scene_convert(ue_PyFbxScene *self, PyObject *args) +{ FbxScene *scene = self->fbx_scene; FbxAxisSystem::ECoordSystem coord_system = FbxAxisSystem::eRightHanded; @@ -55,7 +65,8 @@ static PyObject *py_ue_fbx_scene_convert(ue_PyFbxScene *self, PyObject *args) { FbxAxisSystem unreal(up_vector, front_vector, coord_system); - if (scene->GetGlobalSettings().GetAxisSystem() != unreal) { + if (scene->GetGlobalSettings().GetAxisSystem() != unreal) + { FbxRootNodeUtility::RemoveAllFbxRoots(scene); unreal.ConvertScene(scene); } @@ -65,12 +76,14 @@ static PyObject *py_ue_fbx_scene_convert(ue_PyFbxScene *self, PyObject *args) { Py_RETURN_NONE; } -static PyObject *py_ue_fbx_scene_triangulate(ue_PyFbxScene *self, PyObject *args) { +static PyObject *py_ue_fbx_scene_triangulate(ue_PyFbxScene *self, PyObject *args) +{ FbxScene *scene = self->fbx_scene; FbxGeometryConverter converter(scene->GetFbxManager()); - if (converter.Triangulate(scene, true)) { + if (converter.Triangulate(scene, true)) + { Py_RETURN_TRUE; } @@ -121,15 +134,18 @@ static PyTypeObject ue_PyFbxSceneType = { 0, /* tp_getset */ }; -static int py_ue_fbx_scene_init(ue_PyFbxScene *self, PyObject * args) { +static int py_ue_fbx_scene_init(ue_PyFbxScene *self, PyObject * args) +{ PyObject *py_object; char *name; - if (!PyArg_ParseTuple(args, "Os", &py_object, &name)) { + if (!PyArg_ParseTuple(args, "Os", &py_object, &name)) + { return -1; } ue_PyFbxManager *py_fbx_manager = py_ue_is_fbx_manager(py_object); - if (!py_fbx_manager) { + if (!py_fbx_manager) + { PyErr_SetString(PyExc_Exception, "argument is not a FbxManager"); return -1; } @@ -138,7 +154,8 @@ static int py_ue_fbx_scene_init(ue_PyFbxScene *self, PyObject * args) { return 0; } -void ue_python_init_fbx_scene(PyObject *ue_module) { +void ue_python_init_fbx_scene(PyObject *ue_module) +{ ue_PyFbxSceneType.tp_new = PyType_GenericNew;; ue_PyFbxSceneType.tp_init = (initproc)py_ue_fbx_scene_init; if (PyType_Ready(&ue_PyFbxSceneType) < 0) @@ -148,7 +165,8 @@ void ue_python_init_fbx_scene(PyObject *ue_module) { PyModule_AddObject(ue_module, "FbxScene", (PyObject *)&ue_PyFbxSceneType); } -ue_PyFbxScene *py_ue_is_fbx_scene(PyObject *obj) { +ue_PyFbxScene *py_ue_is_fbx_scene(PyObject *obj) +{ if (!PyObject_IsInstance(obj, (PyObject *)&ue_PyFbxSceneType)) return nullptr; return (ue_PyFbxScene *)obj; diff --git a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxScene.h b/Source/UnrealEnginePython/Private/Fbx/UEPyFbxScene.h index 9ec9e31ac..761c35a8f 100644 --- a/Source/UnrealEnginePython/Private/Fbx/UEPyFbxScene.h +++ b/Source/UnrealEnginePython/Private/Fbx/UEPyFbxScene.h @@ -1,8 +1,14 @@ #pragma once -#include "UnrealEnginePython.h" +#include "UEPyModule.h" #if WITH_EDITOR +#if PLATFORM_LINUX +#if defined(__clang__) +#pragma clang diagnostic ignored "-Wnull-dereference" +#endif +#endif + #include struct ue_PyFbxScene { diff --git a/Source/UnrealEnginePython/Private/Http/UEPyIHttpBase.cpp b/Source/UnrealEnginePython/Private/Http/UEPyIHttpBase.cpp index 0c87f6960..1ee41c1b2 100644 --- a/Source/UnrealEnginePython/Private/Http/UEPyIHttpBase.cpp +++ b/Source/UnrealEnginePython/Private/Http/UEPyIHttpBase.cpp @@ -1,48 +1,58 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPyIHttpBase.h" -static PyObject *py_ue_ihttp_base_get_content_length(ue_PyIHttpBase *self, PyObject * args) { +static PyObject *py_ue_ihttp_base_get_content_length(ue_PyIHttpBase *self, PyObject * args) +{ return PyLong_FromLong((int)self->http_base->GetContentLength()); } -static PyObject *py_ue_ihttp_base_get_url(ue_PyIHttpBase *self, PyObject * args) { +static PyObject *py_ue_ihttp_base_get_url(ue_PyIHttpBase *self, PyObject * args) +{ return PyUnicode_FromString(TCHAR_TO_UTF8(*self->http_base->GetURL())); } -static PyObject *py_ue_ihttp_base_get_content_type(ue_PyIHttpBase *self, PyObject * args) { +static PyObject *py_ue_ihttp_base_get_content_type(ue_PyIHttpBase *self, PyObject * args) +{ return PyUnicode_FromString(TCHAR_TO_UTF8(*self->http_base->GetContentType())); } -static PyObject *py_ue_ihttp_base_get_content(ue_PyIHttpBase *self, PyObject * args) { +static PyObject *py_ue_ihttp_base_get_content(ue_PyIHttpBase *self, PyObject * args) +{ TArray data = self->http_base->GetContent(); return PyBytes_FromStringAndSize((char *)data.GetData(), data.Num()); } -static PyObject *py_ue_ihttp_base_get_header(ue_PyIHttpBase *self, PyObject * args) { +static PyObject *py_ue_ihttp_base_get_header(ue_PyIHttpBase *self, PyObject * args) +{ char *key; - if (!PyArg_ParseTuple(args, "s:get_header", &key)) { + if (!PyArg_ParseTuple(args, "s:get_header", &key)) + { return NULL; } return PyUnicode_FromString(TCHAR_TO_UTF8(*self->http_base->GetHeader(UTF8_TO_TCHAR(key)))); } -static PyObject *py_ue_ihttp_base_get_url_parameter(ue_PyIHttpBase *self, PyObject * args) { +static PyObject *py_ue_ihttp_base_get_url_parameter(ue_PyIHttpBase *self, PyObject * args) +{ char *key; - if (!PyArg_ParseTuple(args, "s:get_url_parameter", &key)) { + if (!PyArg_ParseTuple(args, "s:get_url_parameter", &key)) + { return NULL; } return PyUnicode_FromString(TCHAR_TO_UTF8(*self->http_base->GetURLParameter(UTF8_TO_TCHAR(key)))); } -static PyObject *py_ue_ihttp_base_get_all_headers(ue_PyIHttpBase *self, PyObject * args) { +static PyObject *py_ue_ihttp_base_get_all_headers(ue_PyIHttpBase *self, PyObject * args) +{ TArray headers = self->http_base->GetAllHeaders(); PyObject *py_headers = PyList_New(0); - for (FString item : headers) { + for (FString item : headers) + { PyObject *py_header = PyUnicode_FromString(TCHAR_TO_UTF8(*item)); PyList_Append(py_headers, py_header); Py_DECREF(py_header); @@ -102,7 +112,8 @@ PyTypeObject ue_PyIHttpBaseType = { }; -void ue_python_init_ihttp_base(PyObject *ue_module) { +void ue_python_init_ihttp_base(PyObject *ue_module) +{ ue_PyIHttpBaseType.tp_new = PyType_GenericNew; if (PyType_Ready(&ue_PyIHttpBaseType) < 0) diff --git a/Source/UnrealEnginePython/Private/Http/UEPyIHttpBase.h b/Source/UnrealEnginePython/Private/Http/UEPyIHttpBase.h index e6a68a83f..05f26e807 100644 --- a/Source/UnrealEnginePython/Private/Http/UEPyIHttpBase.h +++ b/Source/UnrealEnginePython/Private/Http/UEPyIHttpBase.h @@ -1,6 +1,6 @@ #pragma once -#include "UnrealEnginePython.h" +#include "UEPyModule.h" #include "Runtime/Online/HTTP/Public/HttpModule.h" #include "Runtime/Online/HTTP/Public/Interfaces/IHttpBase.h" diff --git a/Source/UnrealEnginePython/Private/Http/UEPyIHttpRequest.cpp b/Source/UnrealEnginePython/Private/Http/UEPyIHttpRequest.cpp index 5147c25c9..c44d2985c 100644 --- a/Source/UnrealEnginePython/Private/Http/UEPyIHttpRequest.cpp +++ b/Source/UnrealEnginePython/Private/Http/UEPyIHttpRequest.cpp @@ -1,5 +1,7 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPyIHttpRequest.h" + +#include "UEPyIHttpResponse.h" #include "Runtime/Online/HTTP/Public/HttpManager.h" @@ -14,8 +16,7 @@ static PyObject *py_ue_ihttp_request_set_verb(ue_PyIHttpRequest *self, PyObject self->http_request->SetVerb(UTF8_TO_TCHAR(verb)); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject *py_ue_ihttp_request_set_url(ue_PyIHttpRequest *self, PyObject * args) @@ -29,8 +30,7 @@ static PyObject *py_ue_ihttp_request_set_url(ue_PyIHttpRequest *self, PyObject * self->http_request->SetURL(UTF8_TO_TCHAR(url)); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject *py_ue_ihttp_request_set_header(ue_PyIHttpRequest *self, PyObject * args) @@ -45,8 +45,7 @@ static PyObject *py_ue_ihttp_request_set_header(ue_PyIHttpRequest *self, PyObjec self->http_request->SetHeader(UTF8_TO_TCHAR(key), UTF8_TO_TCHAR(value)); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject *py_ue_ihttp_request_append_to_header(ue_PyIHttpRequest *self, PyObject * args) @@ -61,8 +60,7 @@ static PyObject *py_ue_ihttp_request_append_to_header(ue_PyIHttpRequest *self, P self->http_request->AppendToHeader(UTF8_TO_TCHAR(key), UTF8_TO_TCHAR(value)); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject *py_ue_ihttp_request_set_content(ue_PyIHttpRequest *self, PyObject * args) @@ -74,9 +72,9 @@ static PyObject *py_ue_ihttp_request_set_content(ue_PyIHttpRequest *self, PyObje return NULL; } - if (PyUnicode_Check(py_obj)) + if (PyUnicodeOrString_Check(py_obj)) { - self->http_request->SetContentAsString(UTF8_TO_TCHAR(PyUnicode_AsUTF8(py_obj))); + self->http_request->SetContentAsString(UTF8_TO_TCHAR(UEPyUnicode_AsUTF8(py_obj))); } else if (PyBytes_Check(py_obj)) { @@ -88,8 +86,7 @@ static PyObject *py_ue_ihttp_request_set_content(ue_PyIHttpRequest *self, PyObje self->http_request->SetContent(data); } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject *py_ue_ihttp_request_tick(ue_PyIHttpRequest *self, PyObject * args) @@ -105,24 +102,21 @@ static PyObject *py_ue_ihttp_request_tick(ue_PyIHttpRequest *self, PyObject * ar self->http_request->Tick(delta_seconds); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject *py_ue_ihttp_request_process_request(ue_PyIHttpRequest *self, PyObject * args) { self->http_request->ProcessRequest(); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject *py_ue_ihttp_request_cancel_request(ue_PyIHttpRequest *self, PyObject * args) { self->http_request->CancelRequest(); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject *py_ue_ihttp_request_get_status(ue_PyIHttpRequest *self, PyObject * args) @@ -160,7 +154,7 @@ void FPythonSmartHttpDelegate::OnRequestComplete(FHttpRequestPtr request, FHttpR return; } - PyObject *ret = PyObject_CallFunction(py_callable, (char *)"OOO", py_http_request, py_ue_new_ihttp_response(response.Get()), successful ? Py_True : Py_False); + PyObject *ret = PyObject_CallFunction(py_callable, (char *)"ONO", py_http_request, py_ue_new_ihttp_response(response.Get()), successful ? Py_True : Py_False); if (!ret) { unreal_engine_py_log_error(); @@ -208,6 +202,8 @@ static PyObject *py_ue_ihttp_request_bind_on_process_request_complete(ue_PyIHttp py_delegate->SetPyHttpRequest(self); self->http_request->OnProcessRequestComplete().BindSP(py_delegate, &FPythonSmartHttpDelegate::OnRequestComplete); + self->on_process_request_complete = py_delegate; + Py_RETURN_NONE; } @@ -264,6 +260,8 @@ static void ue_PyIHttpRequest_dealloc(ue_PyIHttpRequest *self) #if defined(UEPY_MEMORY_DEBUG) UE_LOG(LogPython, Warning, TEXT("Destroying ue_PyIHttpRequest %p mapped to IHttpRequest %p"), self, &self->http_request.Get()); #endif + self->on_process_request_complete = nullptr; + self->on_request_progress = nullptr; Py_DECREF(self->py_dict); Py_TYPE(self)->tp_free((PyObject *)self); } @@ -310,6 +308,8 @@ static int ue_py_ihttp_request_init(ue_PyIHttpRequest *self, PyObject *args, PyO return -1; } new(&self->http_request) TSharedRef(FHttpModule::Get().CreateRequest()); + new(&self->on_process_request_complete) TSharedPtr(nullptr); + new(&self->on_request_progress) TSharedPtr(nullptr); self->py_dict = PyDict_New(); if (verb) { diff --git a/Source/UnrealEnginePython/Private/Http/UEPyIHttpRequest.h b/Source/UnrealEnginePython/Private/Http/UEPyIHttpRequest.h index 4873942f6..c1c7d65bc 100644 --- a/Source/UnrealEnginePython/Private/Http/UEPyIHttpRequest.h +++ b/Source/UnrealEnginePython/Private/Http/UEPyIHttpRequest.h @@ -1,23 +1,25 @@ #pragma once -#include "UnrealEnginePython.h" +#include "UEPyModule.h" #include "Runtime/Online/HTTP/Public/Interfaces/IHttpRequest.h" #include "Runtime/Online/HTTP/Public/HttpModule.h" - +#include "UEPyIHttpBase.h" extern PyTypeObject ue_PyIHttpBaseType; -typedef struct { +class FPythonSmartHttpDelegate; + +typedef struct +{ ue_PyIHttpBase base; /* Type-specific fields go here. */ TSharedRef http_request; + TSharedPtr on_process_request_complete; + TSharedPtr on_request_progress; PyObject *py_dict; } ue_PyIHttpRequest; - -void ue_python_init_ihttp_request(PyObject *); - class FPythonSmartHttpDelegate : public FPythonSmartDelegate { @@ -25,14 +27,20 @@ class FPythonSmartHttpDelegate : public FPythonSmartDelegate void OnRequestComplete(FHttpRequestPtr request, FHttpResponsePtr response, bool successful); void OnRequestProgress(FHttpRequestPtr request, int32 sent, int32 received); - void SetPyHttpRequest(ue_PyIHttpRequest *request) { + void SetPyHttpRequest(ue_PyIHttpRequest *request) + { py_http_request = request; Py_INCREF(py_http_request); } - ~FPythonSmartHttpDelegate() { + ~FPythonSmartHttpDelegate() + { Py_XDECREF(py_http_request); } protected: - ue_PyIHttpRequest *py_http_request; + ue_PyIHttpRequest * py_http_request; }; + + + +void ue_python_init_ihttp_request(PyObject *); \ No newline at end of file diff --git a/Source/UnrealEnginePython/Private/Http/UEPyIHttpResponse.cpp b/Source/UnrealEnginePython/Private/Http/UEPyIHttpResponse.cpp index 1dd21189a..93652e691 100644 --- a/Source/UnrealEnginePython/Private/Http/UEPyIHttpResponse.cpp +++ b/Source/UnrealEnginePython/Private/Http/UEPyIHttpResponse.cpp @@ -1,13 +1,15 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPyIHttpResponse.h" -static PyObject *py_ue_ihttp_response_get_response_code(ue_PyIHttpResponse *self, PyObject * args) { +static PyObject *py_ue_ihttp_response_get_response_code(ue_PyIHttpResponse *self, PyObject * args) +{ return PyLong_FromLong(self->http_response->GetResponseCode()); } -static PyObject *py_ue_ihttp_response_get_content_as_string(ue_PyIHttpResponse *self, PyObject * args) { +static PyObject *py_ue_ihttp_response_get_content_as_string(ue_PyIHttpResponse *self, PyObject * args) +{ return PyUnicode_FromString(TCHAR_TO_UTF8(*self->http_response->GetContentAsString())); } @@ -57,7 +59,8 @@ static PyTypeObject ue_PyIHttpResponseType = { 0, }; -void ue_python_init_ihttp_response(PyObject *ue_module) { +void ue_python_init_ihttp_response(PyObject *ue_module) +{ ue_PyIHttpResponseType.tp_new = PyType_GenericNew; ue_PyIHttpResponseType.tp_base = &ue_PyIHttpBaseType; @@ -69,7 +72,8 @@ void ue_python_init_ihttp_response(PyObject *ue_module) { PyModule_AddObject(ue_module, "IHttpResponse", (PyObject *)&ue_PyIHttpResponseType); } -PyObject *py_ue_new_ihttp_response(IHttpResponse *response) { +PyObject *py_ue_new_ihttp_response(IHttpResponse *response) +{ ue_PyIHttpResponse *ret = (ue_PyIHttpResponse *)PyObject_New(ue_PyIHttpResponse, &ue_PyIHttpResponseType); ret->http_response = response; ret->base.http_base = response; diff --git a/Source/UnrealEnginePython/Private/Http/UEPyIHttpResponse.h b/Source/UnrealEnginePython/Private/Http/UEPyIHttpResponse.h index 52250bbe7..65c199bee 100644 --- a/Source/UnrealEnginePython/Private/Http/UEPyIHttpResponse.h +++ b/Source/UnrealEnginePython/Private/Http/UEPyIHttpResponse.h @@ -1,13 +1,16 @@ #pragma once -#include "UnrealEnginePython.h" +#include "UEPyModule.h" #include "Runtime/Online/HTTP/Public/Interfaces/IHttpResponse.h" #include "Runtime/Online/HTTP/Public/HttpModule.h" +#include "UEPyIHttpBase.h" + extern PyTypeObject ue_PyIHttpBaseType; -typedef struct { +typedef struct +{ ue_PyIHttpBase base; /* Type-specific fields go here. */ IHttpResponse *http_response; diff --git a/Source/UnrealEnginePython/Private/MaterialEditorUtilities/UEPyFMaterialEditorUtilities.cpp b/Source/UnrealEnginePython/Private/MaterialEditorUtilities/UEPyFMaterialEditorUtilities.cpp index 661105f14..0b80f1466 100644 --- a/Source/UnrealEnginePython/Private/MaterialEditorUtilities/UEPyFMaterialEditorUtilities.cpp +++ b/Source/UnrealEnginePython/Private/MaterialEditorUtilities/UEPyFMaterialEditorUtilities.cpp @@ -1,12 +1,9 @@ -#include "UnrealEnginePythonPrivatePCH.h" - -#if WITH_EDITOR - #include "UEPyFMaterialEditorUtilities.h" +#if WITH_EDITOR - - +#include "Materials/Material.h" +#include "Runtime/Engine/Classes/EdGraph/EdGraph.h" static PyObject *py_ue_paste_nodes_here(PyObject *cls, PyObject * args) { diff --git a/Source/UnrealEnginePython/Private/MaterialEditorUtilities/UEPyFMaterialEditorUtilities.h b/Source/UnrealEnginePython/Private/MaterialEditorUtilities/UEPyFMaterialEditorUtilities.h index 7e6b7d5d3..d0fbc49c0 100644 --- a/Source/UnrealEnginePython/Private/MaterialEditorUtilities/UEPyFMaterialEditorUtilities.h +++ b/Source/UnrealEnginePython/Private/MaterialEditorUtilities/UEPyFMaterialEditorUtilities.h @@ -1,6 +1,6 @@ #pragma once -#include "UnrealEnginePython.h" +#include "UEPyModule.h" #if WITH_EDITOR diff --git a/Source/UnrealEnginePython/Private/PyActor.cpp b/Source/UnrealEnginePython/Private/PyActor.cpp index a7fa60170..763d91fb6 100644 --- a/Source/UnrealEnginePython/Private/PyActor.cpp +++ b/Source/UnrealEnginePython/Private/PyActor.cpp @@ -1,9 +1,7 @@ // Copyright 20Tab S.r.l. -#include "UnrealEnginePythonPrivatePCH.h" #include "PyActor.h" - -#include "PythonDelegate.h" +#include "UEPyModule.h" APyActor::APyActor() { @@ -275,7 +273,7 @@ FString APyActor::CallPythonActorMethodString(FString method_name, FString args) return FString(); } - char *str_ret = PyUnicode_AsUTF8(py_str); + const char *str_ret = UEPyUnicode_AsUTF8(py_str); FString ret_fstring = FString(UTF8_TO_TCHAR(str_ret)); diff --git a/Source/UnrealEnginePython/Private/PyCharacter.cpp b/Source/UnrealEnginePython/Private/PyCharacter.cpp index ce5954922..e104a1851 100644 --- a/Source/UnrealEnginePython/Private/PyCharacter.cpp +++ b/Source/UnrealEnginePython/Private/PyCharacter.cpp @@ -1,9 +1,8 @@ // Copyright 20Tab S.r.l. -#include "UnrealEnginePythonPrivatePCH.h" #include "PyCharacter.h" - - +#include "UEPyModule.h" +#include "Components/InputComponent.h" APyCharacter::APyCharacter() { @@ -18,7 +17,7 @@ APyCharacter::APyCharacter() // Called when the game starts void APyCharacter::PreInitializeComponents() { - + Super::PreInitializeComponents(); @@ -30,13 +29,15 @@ void APyCharacter::PreInitializeComponents() FScopePythonGIL gil; py_uobject = ue_get_python_uobject(this); - if (!py_uobject) { + if (!py_uobject) + { unreal_engine_py_log_error(); return; } PyObject *py_character_module = PyImport_ImportModule(TCHAR_TO_UTF8(*PythonModule)); - if (!py_character_module) { + if (!py_character_module) + { unreal_engine_py_log_error(); return; } @@ -44,7 +45,8 @@ void APyCharacter::PreInitializeComponents() #if WITH_EDITOR // todo implement autoreload with a dictionary of module timestamps py_character_module = PyImport_ReloadModule(py_character_module); - if (!py_character_module) { + if (!py_character_module) + { unreal_engine_py_log_error(); return; } @@ -56,13 +58,15 @@ void APyCharacter::PreInitializeComponents() PyObject *py_character_module_dict = PyModule_GetDict(py_character_module); PyObject *py_character_class = PyDict_GetItemString(py_character_module_dict, TCHAR_TO_UTF8(*PythonClass)); - if (!py_character_class) { + if (!py_character_class) + { UE_LOG(LogPython, Error, TEXT("Unable to find class %s in module %s"), *PythonClass, *PythonModule); return; } py_character_instance = PyObject_CallObject(py_character_class, NULL); - if (!py_character_instance) { + if (!py_character_instance) + { unreal_engine_py_log_error(); return; } @@ -72,7 +76,8 @@ void APyCharacter::PreInitializeComponents() PyObject_SetAttrString(py_character_instance, (char *)"uobject", (PyObject *)py_uobject); // disable ticking if no tick method is exposed - if (!PyObject_HasAttrString(py_character_instance, (char *)"tick") || PythonTickForceDisabled) { + if (!PyObject_HasAttrString(py_character_instance, (char *)"tick") || PythonTickForceDisabled) + { SetActorTickEnabled(false); } @@ -81,12 +86,14 @@ void APyCharacter::PreInitializeComponents() ue_bind_events_for_py_class_by_attribute(this, py_character_instance); - if (!PyObject_HasAttrString(py_character_instance, (char *)"pre_initialize_components")) { + if (!PyObject_HasAttrString(py_character_instance, (char *)"pre_initialize_components")) + { return; } PyObject *pic_ret = PyObject_CallMethod(py_character_instance, (char *)"pre_initialize_components", NULL); - if (!pic_ret) { + if (!pic_ret) + { unreal_engine_py_log_error(); return; } @@ -106,7 +113,8 @@ void APyCharacter::PostInitializeComponents() return; PyObject *pic_ret = PyObject_CallMethod(py_character_instance, (char *)"post_initialize_components", NULL); - if (!pic_ret) { + if (!pic_ret) + { unreal_engine_py_log_error(); return; } @@ -127,7 +135,8 @@ void APyCharacter::BeginPlay() return; PyObject *bp_ret = PyObject_CallMethod(py_character_instance, (char *)"begin_play", NULL); - if (!bp_ret) { + if (!bp_ret) + { unreal_engine_py_log_error(); return; } @@ -138,7 +147,7 @@ void APyCharacter::BeginPlay() // Called every frame void APyCharacter::Tick(float DeltaTime) { - + Super::Tick(DeltaTime); @@ -150,7 +159,8 @@ void APyCharacter::Tick(float DeltaTime) // no need to check for method availability, we did it in begin_play PyObject *ret = PyObject_CallMethod(py_character_instance, (char *)"tick", (char *)"f", DeltaTime); - if (!ret) { + if (!ret) + { unreal_engine_py_log_error(); return; } @@ -160,7 +170,7 @@ void APyCharacter::Tick(float DeltaTime) void APyCharacter::CallPyCharacterMethod(FString method_name, FString args) { - + if (!py_character_instance) return; @@ -168,14 +178,17 @@ void APyCharacter::CallPyCharacterMethod(FString method_name, FString args) FScopePythonGIL gil; PyObject *ret = nullptr; - if (args.IsEmpty()) { + if (args.IsEmpty()) + { ret = PyObject_CallMethod(py_character_instance, TCHAR_TO_UTF8(*method_name), NULL); } - else { + else + { ret = PyObject_CallMethod(py_character_instance, TCHAR_TO_UTF8(*method_name), (char *)"s", TCHAR_TO_UTF8(*args)); } - if (!ret) { + if (!ret) + { unreal_engine_py_log_error(); return; } @@ -184,7 +197,7 @@ void APyCharacter::CallPyCharacterMethod(FString method_name, FString args) void APyCharacter::SetPythonAttrObject(FString attr, UObject *object) { - + if (!py_character_instance) return; @@ -192,109 +205,118 @@ void APyCharacter::SetPythonAttrObject(FString attr, UObject *object) FScopePythonGIL gil; ue_PyUObject *py_obj = ue_get_python_uobject(object); - if (!py_obj) { + if (!py_obj) + { PyErr_Format(PyExc_Exception, "PyUObject is in invalid state"); unreal_engine_py_log_error(); return; } - if (PyObject_SetAttrString(py_character_instance, TCHAR_TO_UTF8(*attr), (PyObject *)py_obj) < 0) { + if (PyObject_SetAttrString(py_character_instance, TCHAR_TO_UTF8(*attr), (PyObject *)py_obj) < 0) + { UE_LOG(LogPython, Error, TEXT("Unable to set attribute %s"), *attr); } } void APyCharacter::SetPythonAttrString(FString attr, FString s) { - + if (!py_character_instance) return; FScopePythonGIL gil; - if (PyObject_SetAttrString(py_character_instance, TCHAR_TO_UTF8(*attr), PyUnicode_FromString(TCHAR_TO_UTF8(*s))) < 0) { + if (PyObject_SetAttrString(py_character_instance, TCHAR_TO_UTF8(*attr), PyUnicode_FromString(TCHAR_TO_UTF8(*s))) < 0) + { UE_LOG(LogPython, Error, TEXT("Unable to set attribute %s"), *attr); } } void APyCharacter::SetPythonAttrFloat(FString attr, float f) { - + if (!py_character_instance) return; FScopePythonGIL gil; - if (PyObject_SetAttrString(py_character_instance, TCHAR_TO_UTF8(*attr), PyFloat_FromDouble(f)) < 0) { + if (PyObject_SetAttrString(py_character_instance, TCHAR_TO_UTF8(*attr), PyFloat_FromDouble(f)) < 0) + { UE_LOG(LogPython, Error, TEXT("Unable to set attribute %s"), *attr); } } void APyCharacter::SetPythonAttrInt(FString attr, int n) { - + if (!py_character_instance) return; FScopePythonGIL gil; - if (PyObject_SetAttrString(py_character_instance, TCHAR_TO_UTF8(*attr), PyLong_FromLong(n)) < 0) { + if (PyObject_SetAttrString(py_character_instance, TCHAR_TO_UTF8(*attr), PyLong_FromLong(n)) < 0) + { UE_LOG(LogPython, Error, TEXT("Unable to set attribute %s"), *attr); } } void APyCharacter::SetPythonAttrVector(FString attr, FVector vec) { - + if (!py_character_instance) return; FScopePythonGIL gil; - if (PyObject_SetAttrString(py_character_instance, TCHAR_TO_UTF8(*attr), py_ue_new_fvector(vec)) < 0) { + if (PyObject_SetAttrString(py_character_instance, TCHAR_TO_UTF8(*attr), py_ue_new_fvector(vec)) < 0) + { UE_LOG(LogPython, Error, TEXT("Unable to set attribute %s"), *attr); } } void APyCharacter::SetPythonAttrRotator(FString attr, FRotator rot) { - + if (!py_character_instance) return; FScopePythonGIL gil; - if (PyObject_SetAttrString(py_character_instance, TCHAR_TO_UTF8(*attr), py_ue_new_frotator(rot)) < 0) { + if (PyObject_SetAttrString(py_character_instance, TCHAR_TO_UTF8(*attr), py_ue_new_frotator(rot)) < 0) + { UE_LOG(LogPython, Error, TEXT("Unable to set attribute %s"), *attr); } } void APyCharacter::SetPythonAttrBool(FString attr, bool b) { - + if (!py_character_instance) return; FScopePythonGIL gil; - + PyObject *py_bool = Py_False; - if (b) { + if (b) + { py_bool = Py_True; } - if (PyObject_SetAttrString(py_character_instance, TCHAR_TO_UTF8(*attr), py_bool) < 0) { + if (PyObject_SetAttrString(py_character_instance, TCHAR_TO_UTF8(*attr), py_bool) < 0) + { UE_LOG(LogPython, Error, TEXT("Unable to set attribute %s"), *attr); } } bool APyCharacter::CallPyCharacterMethodBool(FString method_name, FString args) { - + if (!py_character_instance) return false; @@ -302,20 +324,24 @@ bool APyCharacter::CallPyCharacterMethodBool(FString method_name, FString args) FScopePythonGIL gil; PyObject *ret = nullptr; - if (args.IsEmpty()) { + if (args.IsEmpty()) + { ret = PyObject_CallMethod(py_character_instance, TCHAR_TO_UTF8(*method_name), NULL); } - else { + else + { ret = PyObject_CallMethod(py_character_instance, TCHAR_TO_UTF8(*method_name), (char *)"s", TCHAR_TO_UTF8(*args)); } - - if (!ret) { + + if (!ret) + { unreal_engine_py_log_error(); return false; } - if (PyObject_IsTrue(ret)) { + if (PyObject_IsTrue(ret)) + { Py_DECREF(ret); return true; } @@ -326,7 +352,7 @@ bool APyCharacter::CallPyCharacterMethodBool(FString method_name, FString args) float APyCharacter::CallPyCharacterMethodFloat(FString method_name, FString args) { - + if (!py_character_instance) return false; @@ -334,22 +360,26 @@ float APyCharacter::CallPyCharacterMethodFloat(FString method_name, FString args FScopePythonGIL gil; PyObject *ret = nullptr; - if (args.IsEmpty()) { + if (args.IsEmpty()) + { ret = PyObject_CallMethod(py_character_instance, TCHAR_TO_UTF8(*method_name), NULL); } - else { + else + { ret = PyObject_CallMethod(py_character_instance, TCHAR_TO_UTF8(*method_name), (char *)"s", TCHAR_TO_UTF8(*args)); } - if (!ret) { + if (!ret) + { unreal_engine_py_log_error(); return false; } float value = 0; - if (PyNumber_Check(ret)) { + if (PyNumber_Check(ret)) + { PyObject *py_value = PyNumber_Float(ret); value = PyFloat_AsDouble(py_value); Py_DECREF(py_value); @@ -361,7 +391,7 @@ float APyCharacter::CallPyCharacterMethodFloat(FString method_name, FString args FString APyCharacter::CallPyCharacterMethodString(FString method_name, FString args) { - + if (!py_character_instance) return FString(); @@ -369,25 +399,29 @@ FString APyCharacter::CallPyCharacterMethodString(FString method_name, FString a FScopePythonGIL gil; PyObject *ret = nullptr; - if (args.IsEmpty()) { + if (args.IsEmpty()) + { ret = PyObject_CallMethod(py_character_instance, TCHAR_TO_UTF8(*method_name), NULL); } - else { + else + { ret = PyObject_CallMethod(py_character_instance, TCHAR_TO_UTF8(*method_name), (char *)"s", TCHAR_TO_UTF8(*args)); } - if (!ret) { + if (!ret) + { unreal_engine_py_log_error(); return FString(); } PyObject *py_str = PyObject_Str(ret); - if (!py_str) { + if (!py_str) + { Py_DECREF(ret); return FString(); } - char *str_ret = PyUnicode_AsUTF8(py_str); + const char *str_ret = UEPyUnicode_AsUTF8(py_str); FString ret_fstring = FString(UTF8_TO_TCHAR(str_ret)); @@ -409,7 +443,8 @@ void APyCharacter::SetupPlayerInputComponent(class UInputComponent* input) // no need to check for method availability, we did it in begin_play PyObject *ret = PyObject_CallMethod(py_character_instance, (char *)"setup_player_input_component", (char *)"O", ue_get_python_uobject(input)); - if (!ret) { + if (!ret) + { unreal_engine_py_log_error(); return; } @@ -423,10 +458,12 @@ void APyCharacter::EndPlay(const EEndPlayReason::Type EndPlayReason) FScopePythonGIL gil; - if (PyObject_HasAttrString(py_character_instance, (char *)"end_play")) { + if (PyObject_HasAttrString(py_character_instance, (char *)"end_play")) + { PyObject *ep_ret = PyObject_CallMethod(py_character_instance, (char *)"end_play", (char*)"i", (int)EndPlayReason); - if (!ep_ret) { + if (!ep_ret) + { unreal_engine_py_log_error(); } @@ -445,7 +482,7 @@ APyCharacter::~APyCharacter() Py_XDECREF(py_character_instance); - + #if defined(UEPY_MEMORY_DEBUG) UE_LOG(LogPython, Warning, TEXT("Python ACharacter (mapped to %p) wrapper XDECREF'ed"), py_uobject ? py_uobject->py_proxy : nullptr); #endif diff --git a/Source/UnrealEnginePython/Private/PyCommandlet.cpp b/Source/UnrealEnginePython/Private/PyCommandlet.cpp index 33c243450..701f05348 100644 --- a/Source/UnrealEnginePython/Private/PyCommandlet.cpp +++ b/Source/UnrealEnginePython/Private/PyCommandlet.cpp @@ -1,9 +1,13 @@ // Copyright 20Tab S.r.l. -#include "UnrealEnginePythonPrivatePCH.h" #include "PyCommandlet.h" -#include "Regex.h" +#include "UEPyModule.h" +#if WITH_EDITOR +#include "Editor.h" +#endif + +#include "Runtime/Core/Public/Internationalization/Regex.h" UPyCommandlet::UPyCommandlet(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) @@ -15,6 +19,12 @@ int32 UPyCommandlet::Main(const FString& CommandLine) { FScopePythonGIL gil; +#if WITH_EDITOR + // this allows commandlet's to use factories + GEditor->Trans = GEditor->CreateTrans(); + +#endif + TArray Tokens, Switches; TMap Params; ParseCommandLine(*CommandLine, Tokens, Switches, Params); @@ -30,7 +40,11 @@ int32 UPyCommandlet::Main(const FString& CommandLine) const FRegexPattern myPattern(RegexString); FRegexMatcher myMatcher(myPattern, *CommandLine); myMatcher.FindNext(); +#if ENGINE_MINOR_VERSION >= 18 + FString PyCommandLine = myMatcher.GetCaptureGroup(0).TrimStart().TrimEnd(); +#else FString PyCommandLine = myMatcher.GetCaptureGroup(0).Trim().TrimTrailing(); +#endif TArray PyArgv; PyArgv.Add(FString()); @@ -76,14 +90,20 @@ int32 UPyCommandlet::Main(const FString& CommandLine) { #if PY_MAJOR_VERSION >= 3 argv[i] = (wchar_t*)malloc(PyArgv[i].Len() + 1); -#if defined(UNREAL_ENGINE_PYTHON_ON_MAC) || defined(UNREAL_ENGINE_PYTHON_ON_LINUX) +#if PLATFORM_MAC || PLATFORM_LINUX + #if ENGINE_MINOR_VERSION >= 20 + wcsncpy(argv[i], (const wchar_t *) TCHAR_TO_WCHAR(*PyArgv[i].ReplaceEscapedCharWithChar()), PyArgv[i].Len() + 1); + #else wcsncpy(argv[i], *PyArgv[i].ReplaceEscapedCharWithChar(), PyArgv[i].Len() + 1); + #endif +#elif PLATFORM_ANDROID + wcsncpy(argv[i], (const wchar_t *)*PyArgv[i].ReplaceEscapedCharWithChar(), PyArgv[i].Len() + 1); #else wcscpy_s(argv[i], PyArgv[i].Len() + 1, *PyArgv[i].ReplaceEscapedCharWithChar()); #endif #else argv[i] = (char*)malloc(PyArgv[i].Len() + 1); -#if defined(UNREAL_ENGINE_PYTHON_ON_MAC) || defined(UNREAL_ENGINE_PYTHON_ON_LINUX) +#if PLATFORM_MAC || PLATFORM_LINUX || PLATFORM_ANDROID strncpy(argv[i], TCHAR_TO_UTF8(*PyArgv[i].ReplaceEscapedCharWithChar()), PyArgv[i].Len() + 1); #else strcpy_s(argv[i], PyArgv[i].Len() + 1, TCHAR_TO_UTF8(*PyArgv[i].ReplaceEscapedCharWithChar())); @@ -93,8 +113,12 @@ int32 UPyCommandlet::Main(const FString& CommandLine) PySys_SetArgv(PyArgv.Num(), argv); + Py_BEGIN_ALLOW_THREADS; + FUnrealEnginePythonModule &PythonModule = FModuleManager::GetModuleChecked("UnrealEnginePython"); PythonModule.BrutalFinalize = true; PythonModule.RunFile(TCHAR_TO_UTF8(*Filepath)); + + Py_END_ALLOW_THREADS; return 0; } diff --git a/Source/UnrealEnginePython/Private/PyHUD.cpp b/Source/UnrealEnginePython/Private/PyHUD.cpp index dbedc3027..0d31b1ab4 100644 --- a/Source/UnrealEnginePython/Private/PyHUD.cpp +++ b/Source/UnrealEnginePython/Private/PyHUD.cpp @@ -1,6 +1,6 @@ -#include "UnrealEnginePythonPrivatePCH.h" -#include "PyHUD.h" +#include "PyHUD.h" +#include "UEPyModule.h" #include "PythonDelegate.h" APyHUD::APyHUD() @@ -228,7 +228,7 @@ FString APyHUD::CallPythonHUDMethodString(FString method_name, FString args) return FString(); } - char *str_ret = PyUnicode_AsUTF8(py_str); + const char *str_ret = UEPyUnicode_AsUTF8(py_str); FString ret_fstring = FString(UTF8_TO_TCHAR(str_ret)); diff --git a/Source/UnrealEnginePython/Private/PyNativeWidgetHost.cpp b/Source/UnrealEnginePython/Private/PyNativeWidgetHost.cpp index 486887f6b..ed63392c9 100644 --- a/Source/UnrealEnginePython/Private/PyNativeWidgetHost.cpp +++ b/Source/UnrealEnginePython/Private/PyNativeWidgetHost.cpp @@ -1,7 +1,6 @@ -#include "UnrealEnginePythonPrivatePCH.h" + #include "PyNativeWidgetHost.h" -#include "UnrealEnginePython.h" diff --git a/Source/UnrealEnginePython/Private/PyPawn.cpp b/Source/UnrealEnginePython/Private/PyPawn.cpp index 066716863..e10d9f8e7 100644 --- a/Source/UnrealEnginePython/Private/PyPawn.cpp +++ b/Source/UnrealEnginePython/Private/PyPawn.cpp @@ -1,6 +1,6 @@ -#include "UnrealEnginePythonPrivatePCH.h" -#include "PyPawn.h" +#include "PyPawn.h" +#include "UEPyModule.h" APyPawn::APyPawn() { @@ -225,7 +225,7 @@ FString APyPawn::CallPythonPawnMethodString(FString method_name) return FString(); } - char *str_ret = PyUnicode_AsUTF8(py_str); + const char *str_ret = UEPyUnicode_AsUTF8(py_str); FString ret_fstring = FString(UTF8_TO_TCHAR(str_ret)); diff --git a/Source/UnrealEnginePython/Private/PyUserWidget.cpp b/Source/UnrealEnginePython/Private/PyUserWidget.cpp index a7efd3b92..c2fcebf71 100644 --- a/Source/UnrealEnginePython/Private/PyUserWidget.cpp +++ b/Source/UnrealEnginePython/Private/PyUserWidget.cpp @@ -1,4 +1,4 @@ -#include "UnrealEnginePythonPrivatePCH.h" + #include "PyUserWidget.h" #include "PyNativeWidgetHost.h" @@ -10,6 +10,8 @@ #include "Widgets/Layout/SBox.h" #include "UMGStyle.h" #include "Runtime/UMG/Public/Blueprint/WidgetTree.h" +#include "Slate/UEPyFKeyEvent.h" +#include "Slate/UEPyFPointerEvent.h" void UPyUserWidget::NativeConstruct() { @@ -70,10 +72,18 @@ void UPyUserWidget::NativeConstruct() PyObject_SetAttrString(py_user_widget_instance, (char*)"uobject", (PyObject *)py_uobject); if (PythonTickForceDisabled) +#if ENGINE_MINOR_VERSION < 20 bCanEverTick = false; +#else + bHasScriptImplementedTick = false; +#endif if (PythonPaintForceDisabled) +#if ENGINE_MINOR_VERSION < 20 bCanEverPaint = false; +#else + bHasScriptImplementedPaint = false; +#endif if (!PyObject_HasAttrString(py_user_widget_instance, (char *)"construct")) return; @@ -329,22 +339,55 @@ bool UPyUserWidget::NativeIsInteractable() const return false; } +#if ENGINE_MINOR_VERSION < 20 void UPyUserWidget::NativePaint(FPaintContext & InContext) const +#else +int32 UPyUserWidget::NativePaint(const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyCullingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled) const +#endif { + +#if ENGINE_MINOR_VERSION >= 20 + FPaintContext InContext(AllottedGeometry, MyCullingRect, OutDrawElements, LayerId, InWidgetStyle, bParentEnabled); +#endif + if (!py_user_widget_instance) +#if ENGINE_MINOR_VERSION >= 20 + return -1; +#else return; +#endif FScopePythonGIL gil; if (!PyObject_HasAttrString(py_user_widget_instance, (char *)"paint")) +#if ENGINE_MINOR_VERSION >= 20 + return -1; +#else return; +#endif PyObject *ret = PyObject_CallMethod(py_user_widget_instance, (char *)"paint", (char *)"O", py_ue_new_fpaint_context(InContext)); if (!ret) { unreal_engine_py_log_error(); +#if ENGINE_MINOR_VERSION >= 20 + return -1; +#else return; +#endif } +#if ENGINE_MINOR_VERSION >= 20 + int32 RetValue = -1; + if (PyNumber_Check(ret)) + { + PyObject *py_value = PyNumber_Long(ret); + RetValue = PyLong_AsLong(py_value); + Py_DECREF(py_value); + } +#endif Py_DECREF(ret); +#if ENGINE_MINOR_VERSION >= 20 + return RetValue; +#endif } UPyUserWidget::UPyUserWidget(const FObjectInitializer& ObjectInitializer) diff --git a/Source/UnrealEnginePython/Private/PythonBlueprintFunctionLibrary.cpp b/Source/UnrealEnginePython/Private/PythonBlueprintFunctionLibrary.cpp index 0bc4837ce..2bef39d34 100644 --- a/Source/UnrealEnginePython/Private/PythonBlueprintFunctionLibrary.cpp +++ b/Source/UnrealEnginePython/Private/PythonBlueprintFunctionLibrary.cpp @@ -1,14 +1,15 @@ -#include "UnrealEnginePythonPrivatePCH.h" + #include "PythonBlueprintFunctionLibrary.h" -void UPythonBlueprintFunctionLibrary::ExecutePythonScript(FString script) { +void UPythonBlueprintFunctionLibrary::ExecutePythonScript(FString script) +{ FUnrealEnginePythonModule &PythonModule = FModuleManager::GetModuleChecked("UnrealEnginePython"); PythonModule.RunFile(TCHAR_TO_UTF8(*script)); } void UPythonBlueprintFunctionLibrary::ExecutePythonString(const FString& PythonCmd) { - FUnrealEnginePythonModule &PythonModule = FModuleManager::GetModuleChecked("UnrealEnginePython"); - PythonModule.RunString(TCHAR_TO_UTF8(*PythonCmd)); + FUnrealEnginePythonModule &PythonModule = FModuleManager::GetModuleChecked("UnrealEnginePython"); + PythonModule.RunString(TCHAR_TO_UTF8(*PythonCmd)); } diff --git a/Source/UnrealEnginePython/Private/PythonComponent.cpp b/Source/UnrealEnginePython/Private/PythonComponent.cpp index 1d8879494..11082d6ac 100644 --- a/Source/UnrealEnginePython/Private/PythonComponent.cpp +++ b/Source/UnrealEnginePython/Private/PythonComponent.cpp @@ -1,7 +1,6 @@ -#include "UnrealEnginePythonPrivatePCH.h" -#include "PythonComponent.h" - +#include "PythonComponent.h" +#include "UEPyModule.h" UPythonComponent::UPythonComponent() { @@ -14,24 +13,30 @@ UPythonComponent::UPythonComponent() PythonTickForceDisabled = false; PythonDisableAutoBinding = false; + PythonTickEnableGenerator = false; bWantsInitializeComponent = true; + + py_generator = nullptr; } -void UPythonComponent::InitializePythonComponent() { +void UPythonComponent::InitializePythonComponent() +{ if (PythonModule.IsEmpty()) return; FScopePythonGIL gil; py_uobject = ue_get_python_uobject(this); - if (!py_uobject) { + if (!py_uobject) + { unreal_engine_py_log_error(); return; } PyObject *py_component_module = PyImport_ImportModule(TCHAR_TO_UTF8(*PythonModule)); - if (!py_component_module) { + if (!py_component_module) + { unreal_engine_py_log_error(); return; } @@ -39,7 +44,8 @@ void UPythonComponent::InitializePythonComponent() { #if WITH_EDITOR // todo implement autoreload with a dictionary of module timestamps py_component_module = PyImport_ReloadModule(py_component_module); - if (!py_component_module) { + if (!py_component_module) + { unreal_engine_py_log_error(); return; } @@ -51,13 +57,15 @@ void UPythonComponent::InitializePythonComponent() { PyObject *py_component_module_dict = PyModule_GetDict(py_component_module); PyObject *py_component_class = PyDict_GetItemString(py_component_module_dict, TCHAR_TO_UTF8(*PythonClass)); - if (!py_component_class) { + if (!py_component_class) + { UE_LOG(LogPython, Error, TEXT("Unable to find class %s in module %s"), *PythonClass, *PythonModule); return; } py_component_instance = PyObject_CallObject(py_component_class, NULL); - if (!py_component_instance) { + if (!py_component_instance) + { unreal_engine_py_log_error(); return; } @@ -68,7 +76,8 @@ void UPythonComponent::InitializePythonComponent() { // disable ticking if no tick method is exposed - if (!PyObject_HasAttrString(py_component_instance, (char *)"tick") || PythonTickForceDisabled) { + if (!PyObject_HasAttrString(py_component_instance, (char *)"tick") || PythonTickForceDisabled) + { PrimaryComponentTick.bCanEverTick = false; PrimaryComponentTick.SetTickFunctionEnable(false); } @@ -78,12 +87,14 @@ void UPythonComponent::InitializePythonComponent() { ue_bind_events_for_py_class_by_attribute(this, py_component_instance); - if (!PyObject_HasAttrString(py_component_instance, (char *)"initialize_component")) { + if (!PyObject_HasAttrString(py_component_instance, (char *)"initialize_component")) + { return; } PyObject *ic_ret = PyObject_CallMethod(py_component_instance, (char *)"initialize_component", NULL); - if (!ic_ret) { + if (!ic_ret) + { unreal_engine_py_log_error(); } Py_XDECREF(ic_ret); @@ -107,12 +118,14 @@ void UPythonComponent::BeginPlay() FScopePythonGIL gil; - if (!PyObject_HasAttrString(py_component_instance, (char *)"begin_play")) { + if (!PyObject_HasAttrString(py_component_instance, (char *)"begin_play")) + { return; } PyObject *bp_ret = PyObject_CallMethod(py_component_instance, (char *)"begin_play", NULL); - if (!bp_ret) { + if (!bp_ret) + { unreal_engine_py_log_error(); } Py_XDECREF(bp_ret); @@ -126,10 +139,12 @@ void UPythonComponent::EndPlay(const EEndPlayReason::Type EndPlayReason) FScopePythonGIL gil; - if (PyObject_HasAttrString(py_component_instance, (char *)"end_play")) { + if (PyObject_HasAttrString(py_component_instance, (char *)"end_play")) + { PyObject *ep_ret = PyObject_CallMethod(py_component_instance, (char *)"end_play", (char*)"i", (int)EndPlayReason); - if (!ep_ret) { + if (!ep_ret) + { unreal_engine_py_log_error(); } @@ -151,13 +166,40 @@ void UPythonComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActo FScopePythonGIL gil; + if (PythonTickEnableGenerator && py_generator) + { + PyObject *ret = PyIter_Next(py_generator); + if (!ret) + { + if (PyErr_Occurred()) + { + unreal_engine_py_log_error(); + } + Py_DECREF(py_generator); + py_generator = nullptr; + return; + } + Py_DECREF(ret); + return; + } + // no need to check for method availability, we did it in component initialization PyObject *ret = PyObject_CallMethod(py_component_instance, (char *)"tick", (char *)"f", DeltaTime); - if (!ret) { + if (!ret) + { unreal_engine_py_log_error(); return; } + + if (PythonTickEnableGenerator) + { + py_generator = PyObject_GetIter(ret); + if (!py_generator) + { + UE_LOG(LogPython, Error, TEXT("tick is not a python generator")); + } + } Py_DECREF(ret); } @@ -170,14 +212,17 @@ void UPythonComponent::CallPythonComponentMethod(FString method_name, FString ar FScopePythonGIL gil; PyObject *ret = nullptr; - if (args.IsEmpty()) { + if (args.IsEmpty()) + { ret = PyObject_CallMethod(py_component_instance, TCHAR_TO_UTF8(*method_name), NULL); } - else { + else + { ret = PyObject_CallMethod(py_component_instance, TCHAR_TO_UTF8(*method_name), (char *)"s", TCHAR_TO_UTF8(*args)); } - if (!ret) { + if (!ret) + { unreal_engine_py_log_error(); return; } @@ -192,13 +237,15 @@ void UPythonComponent::SetPythonAttrObject(FString attr, UObject *object) FScopePythonGIL gil; ue_PyUObject *py_obj = ue_get_python_uobject(object); - if (!py_obj) { + if (!py_obj) + { PyErr_Format(PyExc_Exception, "PyUObject is in invalid state"); unreal_engine_py_log_error(); return; } - if (PyObject_SetAttrString(py_component_instance, TCHAR_TO_UTF8(*attr), (PyObject *)py_obj) < 0) { + if (PyObject_SetAttrString(py_component_instance, TCHAR_TO_UTF8(*attr), (PyObject *)py_obj) < 0) + { UE_LOG(LogPython, Error, TEXT("Unable to set attribute %s"), *attr); } } @@ -210,7 +257,8 @@ void UPythonComponent::SetPythonAttrString(FString attr, FString s) FScopePythonGIL gil; - if (PyObject_SetAttrString(py_component_instance, TCHAR_TO_UTF8(*attr), PyUnicode_FromString(TCHAR_TO_UTF8(*s))) < 0) { + if (PyObject_SetAttrString(py_component_instance, TCHAR_TO_UTF8(*attr), PyUnicode_FromString(TCHAR_TO_UTF8(*s))) < 0) + { UE_LOG(LogPython, Error, TEXT("Unable to set attribute %s"), *attr); } } @@ -222,7 +270,8 @@ void UPythonComponent::SetPythonAttrFloat(FString attr, float f) FScopePythonGIL gil; - if (PyObject_SetAttrString(py_component_instance, TCHAR_TO_UTF8(*attr), PyFloat_FromDouble(f)) < 0) { + if (PyObject_SetAttrString(py_component_instance, TCHAR_TO_UTF8(*attr), PyFloat_FromDouble(f)) < 0) + { UE_LOG(LogPython, Error, TEXT("Unable to set attribute %s"), *attr); } } @@ -236,7 +285,8 @@ void UPythonComponent::SetPythonAttrInt(FString attr, int n) FScopePythonGIL gil; - if (PyObject_SetAttrString(py_component_instance, TCHAR_TO_UTF8(*attr), PyLong_FromLong(n)) < 0) { + if (PyObject_SetAttrString(py_component_instance, TCHAR_TO_UTF8(*attr), PyLong_FromLong(n)) < 0) + { UE_LOG(LogPython, Error, TEXT("Unable to set attribute %s"), *attr); } } @@ -248,7 +298,8 @@ void UPythonComponent::SetPythonAttrVector(FString attr, FVector vec) FScopePythonGIL gil; - if (PyObject_SetAttrString(py_component_instance, TCHAR_TO_UTF8(*attr), py_ue_new_fvector(vec)) < 0) { + if (PyObject_SetAttrString(py_component_instance, TCHAR_TO_UTF8(*attr), py_ue_new_fvector(vec)) < 0) + { UE_LOG(LogPython, Error, TEXT("Unable to set attribute %s"), *attr); } } @@ -260,7 +311,8 @@ void UPythonComponent::SetPythonAttrRotator(FString attr, FRotator rot) FScopePythonGIL gil; - if (PyObject_SetAttrString(py_component_instance, TCHAR_TO_UTF8(*attr), py_ue_new_frotator(rot)) < 0) { + if (PyObject_SetAttrString(py_component_instance, TCHAR_TO_UTF8(*attr), py_ue_new_frotator(rot)) < 0) + { UE_LOG(LogPython, Error, TEXT("Unable to set attribute %s"), *attr); } } @@ -273,11 +325,13 @@ void UPythonComponent::SetPythonAttrBool(FString attr, bool b) FScopePythonGIL gil; PyObject *py_bool = Py_False; - if (b) { + if (b) + { py_bool = Py_True; } - if (PyObject_SetAttrString(py_component_instance, TCHAR_TO_UTF8(*attr), py_bool) < 0) { + if (PyObject_SetAttrString(py_component_instance, TCHAR_TO_UTF8(*attr), py_bool) < 0) + { UE_LOG(LogPython, Error, TEXT("Unable to set attribute %s"), *attr); } } @@ -290,20 +344,24 @@ bool UPythonComponent::CallPythonComponentMethodBool(FString method_name, FStrin FScopePythonGIL gil; PyObject *ret = nullptr; - if (args.IsEmpty()) { + if (args.IsEmpty()) + { ret = PyObject_CallMethod(py_component_instance, TCHAR_TO_UTF8(*method_name), NULL); } - else { + else + { ret = PyObject_CallMethod(py_component_instance, TCHAR_TO_UTF8(*method_name), (char *)"s", TCHAR_TO_UTF8(*args)); } - if (!ret) { + if (!ret) + { unreal_engine_py_log_error(); return false; } - if (PyObject_IsTrue(ret)) { + if (PyObject_IsTrue(ret)) + { Py_DECREF(ret); return true; } @@ -320,22 +378,26 @@ float UPythonComponent::CallPythonComponentMethodFloat(FString method_name, FStr FScopePythonGIL gil; PyObject *ret = nullptr; - if (args.IsEmpty()) { + if (args.IsEmpty()) + { ret = PyObject_CallMethod(py_component_instance, TCHAR_TO_UTF8(*method_name), NULL); } - else { + else + { ret = PyObject_CallMethod(py_component_instance, TCHAR_TO_UTF8(*method_name), (char *)"s", TCHAR_TO_UTF8(*args)); } - if (!ret) { + if (!ret) + { unreal_engine_py_log_error(); return 0; } float value = 0; - if (PyNumber_Check(ret)) { + if (PyNumber_Check(ret)) + { PyObject *py_value = PyNumber_Float(ret); value = PyFloat_AsDouble(py_value); Py_DECREF(py_value); @@ -353,22 +415,26 @@ int UPythonComponent::CallPythonComponentMethodInt(FString method_name, FString FScopePythonGIL gil; PyObject *ret = nullptr; - if (args.IsEmpty()) { + if (args.IsEmpty()) + { ret = PyObject_CallMethod(py_component_instance, TCHAR_TO_UTF8(*method_name), NULL); } - else { + else + { ret = PyObject_CallMethod(py_component_instance, TCHAR_TO_UTF8(*method_name), (char *)"s", TCHAR_TO_UTF8(*args)); } - if (!ret) { + if (!ret) + { unreal_engine_py_log_error(); return 0; } int value = 0; - if (PyNumber_Check(ret)) { + if (PyNumber_Check(ret)) + { PyObject *py_value = PyNumber_Long(ret); value = PyLong_AsLong(py_value); Py_DECREF(py_value); @@ -386,25 +452,29 @@ FString UPythonComponent::CallPythonComponentMethodString(FString method_name, F FScopePythonGIL gil; PyObject *ret = nullptr; - if (args.IsEmpty()) { + if (args.IsEmpty()) + { ret = PyObject_CallMethod(py_component_instance, TCHAR_TO_UTF8(*method_name), NULL); } - else { + else + { ret = PyObject_CallMethod(py_component_instance, TCHAR_TO_UTF8(*method_name), (char *)"s", TCHAR_TO_UTF8(*args)); } - if (!ret) { + if (!ret) + { unreal_engine_py_log_error(); return FString(); } PyObject *py_str = PyObject_Str(ret); - if (!py_str) { + if (!py_str) + { Py_DECREF(ret); return FString(); } - char *str_ret = PyUnicode_AsUTF8(py_str); + const char *str_ret = UEPyUnicode_AsUTF8(py_str); FString ret_fstring = FString(UTF8_TO_TCHAR(str_ret)); @@ -421,24 +491,29 @@ UObject *UPythonComponent::CallPythonComponentMethodObject(FString method_name, FScopePythonGIL gil; PyObject *ret = nullptr; - if (!arg) { + if (!arg) + { ret = PyObject_CallMethod(py_component_instance, TCHAR_TO_UTF8(*method_name), NULL); } - else { + else + { PyObject *py_arg_uobject = (PyObject *)ue_get_python_uobject(arg); - if (!py_arg_uobject) { + if (!py_arg_uobject) + { unreal_engine_py_log_error(); return nullptr; } ret = PyObject_CallMethod(py_component_instance, TCHAR_TO_UTF8(*method_name), (char *)"O", py_arg_uobject); } - if (!ret) { + if (!ret) + { unreal_engine_py_log_error(); return nullptr; } - if (ue_is_pyuobject(ret)) { + if (ue_is_pyuobject(ret)) + { ue_PyUObject *py_obj = (ue_PyUObject *)ret; return py_obj->ue_object; } @@ -446,7 +521,8 @@ UObject *UPythonComponent::CallPythonComponentMethodObject(FString method_name, } #if ENGINE_MINOR_VERSION >= 15 -TMap UPythonComponent::CallPythonComponentMethodMap(FString method_name, FString args){ +TMap UPythonComponent::CallPythonComponentMethodMap(FString method_name, FString args) +{ TMap output_map; if (!py_component_instance) @@ -455,38 +531,44 @@ TMap UPythonComponent::CallPythonComponentMethodMap(FString me FScopePythonGIL gil; PyObject *ret = nullptr; - if (args.IsEmpty()) { + if (args.IsEmpty()) + { ret = PyObject_CallMethod(py_component_instance, TCHAR_TO_UTF8(*method_name), NULL); } - else { + else + { ret = PyObject_CallMethod(py_component_instance, TCHAR_TO_UTF8(*method_name), (char *)"s", TCHAR_TO_UTF8(*args)); } - if (!ret) { + if (!ret) + { unreal_engine_py_log_error(); return output_map; } - if (!PyDict_Check(ret)) { + if (!PyDict_Check(ret)) + { UE_LOG(LogPython, Error, TEXT("return value is not a dict")); return output_map; } - PyObject *py_keys = PyDict_Keys(ret); + PyObject *py_keys = PyDict_Keys(ret); Py_ssize_t len = PyList_Size(py_keys); - for (Py_ssize_t i = 0; i < len; i++) { + for (Py_ssize_t i = 0; i < len; i++) + { PyObject *py_key = PyList_GetItem(py_keys, i); PyObject *py_str_key = PyObject_Str(py_key); PyObject *py_str_value = PyObject_Str(PyDict_GetItem(ret, py_key)); - if (!py_str_key || !py_str_value) { + if (!py_str_key || !py_str_value) + { Py_DECREF(ret); return output_map; } - char *str_key = PyUnicode_AsUTF8(py_str_key); - char *str_value = PyUnicode_AsUTF8(py_str_value); + const char *str_key = UEPyUnicode_AsUTF8(py_str_key); + const char *str_value = UEPyUnicode_AsUTF8(py_str_value); FString ret_fstring_key = FString(UTF8_TO_TCHAR(str_key)); FString ret_fstring_value = FString(UTF8_TO_TCHAR(str_value)); @@ -513,33 +595,39 @@ void UPythonComponent::CallPythonComponentMethodStringArray(FString method_name, FScopePythonGIL gil; PyObject *ret = nullptr; - if (args.IsEmpty()) { + if (args.IsEmpty()) + { ret = PyObject_CallMethod(py_component_instance, TCHAR_TO_UTF8(*method_name), NULL); } - else { + else + { ret = PyObject_CallMethod(py_component_instance, TCHAR_TO_UTF8(*method_name), (char *)"s", TCHAR_TO_UTF8(*args)); } - if (!ret) { + if (!ret) + { unreal_engine_py_log_error(); return; } - if (!PyList_Check(ret)) { + if (!PyList_Check(ret)) + { UE_LOG(LogPython, Error, TEXT("return value is not a list")); return; } Py_ssize_t len = PyList_Size(ret); - for (Py_ssize_t i = 0; i < len; i++) { + for (Py_ssize_t i = 0; i < len; i++) + { PyObject *py_str = PyObject_Str(PyList_GetItem(ret, i)); - if (!py_str) { + if (!py_str) + { Py_DECREF(ret); return; } - char *str_ret = PyUnicode_AsUTF8(py_str); + const char *str_ret = UEPyUnicode_AsUTF8(py_str); FString ret_fstring = FString(UTF8_TO_TCHAR(str_ret)); @@ -549,7 +637,7 @@ void UPythonComponent::CallPythonComponentMethodStringArray(FString method_name, } Py_DECREF(ret); - } +} UPythonComponent::~UPythonComponent() diff --git a/Source/UnrealEnginePython/Private/PythonDelegate.cpp b/Source/UnrealEnginePython/Private/PythonDelegate.cpp index 35955e817..e7e4c6699 100644 --- a/Source/UnrealEnginePython/Private/PythonDelegate.cpp +++ b/Source/UnrealEnginePython/Private/PythonDelegate.cpp @@ -1,5 +1,7 @@ -#include "UnrealEnginePythonPrivatePCH.h" + #include "PythonDelegate.h" +#include "UEPyModule.h" +#include "UEPyCallable.h" UPythonDelegate::UPythonDelegate() { @@ -39,7 +41,7 @@ void UPythonDelegate::ProcessEvent(UFunction *function, void *Parms) for (; PArgs && argn < signature->NumParms && ((PArgs->PropertyFlags & (CPF_Parm | CPF_ReturnParm)) == CPF_Parm); ++PArgs) { UProperty *prop = *PArgs; - PyObject *arg = ue_py_convert_property(prop, (uint8 *)Parms); + PyObject *arg = ue_py_convert_property(prop, (uint8 *)Parms, 0); if (!arg) { unreal_engine_py_log_error(); @@ -100,6 +102,12 @@ void UPythonDelegate::PyInputAxisHandler(float value) Py_DECREF(ret); } +bool UPythonDelegate::UsesPyCallable(PyObject *other) +{ + ue_PyCallable *other_callable = (ue_PyCallable*)other; + ue_PyCallable *this_callable = (ue_PyCallable*)py_callable; + return other_callable->u_function == this_callable->u_function && other_callable->u_target == this_callable->u_target; +} UPythonDelegate::~UPythonDelegate() { @@ -109,4 +117,4 @@ UPythonDelegate::~UPythonDelegate() #if defined(UEPY_MEMORY_DEBUG) UE_LOG(LogPython, Warning, TEXT("PythonDelegate %p callable XDECREF'ed"), this); #endif -} \ No newline at end of file +} diff --git a/Source/UnrealEnginePython/Private/PythonFunction.cpp b/Source/UnrealEnginePython/Private/PythonFunction.cpp index f63aeb8b9..efeb5b059 100644 --- a/Source/UnrealEnginePython/Private/PythonFunction.cpp +++ b/Source/UnrealEnginePython/Private/PythonFunction.cpp @@ -1,6 +1,6 @@ -#include "UnrealEnginePythonPrivatePCH.h" -#include "PythonFunction.h" +#include "PythonFunction.h" +#include "UEPyModule.h" void UPythonFunction::SetPyCallable(PyObject *callable) @@ -19,13 +19,17 @@ void UPythonFunction::CallPythonCallable(FFrame& Stack, RESULT_DECL) FScopePythonGIL gil; +#if ENGINE_MINOR_VERSION <= 18 + UObject *Context = Stack.Object; +#endif + UPythonFunction *function = static_cast(Stack.CurrentNativeFunction); bool on_error = false; bool is_static = function->HasAnyFunctionFlags(FUNC_Static); // count the number of arguments - Py_ssize_t argn = (Stack.Object && !is_static) ? 1 : 0; + Py_ssize_t argn = (Context && !is_static) ? 1 : 0; TFieldIterator IArgs(function); for (; IArgs && ((IArgs->PropertyFlags & (CPF_Parm | CPF_ReturnParm)) == CPF_Parm); ++IArgs) { argn++; @@ -34,29 +38,29 @@ void UPythonFunction::CallPythonCallable(FFrame& Stack, RESULT_DECL) UE_LOG(LogPython, Warning, TEXT("Initializing %d parameters"), argn); #endif PyObject *py_args = PyTuple_New(argn); + argn = 0; - if (Stack.Object && !is_static) { - PyObject *py_obj = (PyObject *)ue_get_python_uobject(Stack.Object); + if (Context && !is_static) { + PyObject *py_obj = (PyObject *)ue_get_python_uobject(Context); if (!py_obj) { unreal_engine_py_log_error(); on_error = true; } else { Py_INCREF(py_obj); - PyTuple_SetItem(py_args, 0, py_obj); + PyTuple_SetItem(py_args, argn++, py_obj); } } uint8 *frame = Stack.Locals; - argn = (Stack.Object && !is_static) ? 1 : 0; // is it a blueprint call ? if (*Stack.Code == EX_EndFunctionParms) { for (UProperty *prop = (UProperty *)function->Children; prop; prop = (UProperty *)prop->Next) { if (prop->PropertyFlags & CPF_ReturnParm) continue; if (!on_error) { - PyObject *arg = ue_py_convert_property(prop, (uint8 *)Stack.Locals); + PyObject *arg = ue_py_convert_property(prop, (uint8 *)Stack.Locals, 0); if (!arg) { unreal_engine_py_log_error(); on_error = true; @@ -76,7 +80,7 @@ void UPythonFunction::CallPythonCallable(FFrame& Stack, RESULT_DECL) if (prop->PropertyFlags & CPF_ReturnParm) continue; if (!on_error) { - PyObject *arg = ue_py_convert_property(prop, frame); + PyObject *arg = ue_py_convert_property(prop, frame, 0); if (!arg) { unreal_engine_py_log_error(); on_error = true; @@ -108,7 +112,7 @@ void UPythonFunction::CallPythonCallable(FFrame& Stack, RESULT_DECL) #if defined(UEPY_MEMORY_DEBUG) UE_LOG(LogPython, Warning, TEXT("FOUND RETURN VALUE")); #endif - if (ue_py_convert_pyobject(ret, return_property, frame)) { + if (ue_py_convert_pyobject(ret, return_property, frame, 0)) { // copy value to stack result value FMemory::Memcpy(RESULT_PARAM, frame + function->ReturnValueOffset, return_property->ArrayDim * return_property->ElementSize); } @@ -121,9 +125,10 @@ void UPythonFunction::CallPythonCallable(FFrame& Stack, RESULT_DECL) UPythonFunction::~UPythonFunction() { + FScopePythonGIL gil; Py_XDECREF(py_callable); FUnrealEnginePythonHouseKeeper::Get()->UnregisterPyUObject(this); #if defined(UEPY_MEMORY_DEBUG) UE_LOG(LogPython, Warning, TEXT("PythonFunction callable %p XDECREF'ed"), this); #endif -} \ No newline at end of file +} diff --git a/Source/UnrealEnginePython/Private/PythonHouseKeeper.cpp b/Source/UnrealEnginePython/Private/PythonHouseKeeper.cpp new file mode 100644 index 000000000..dc014e386 --- /dev/null +++ b/Source/UnrealEnginePython/Private/PythonHouseKeeper.cpp @@ -0,0 +1,254 @@ + +#include "PythonHouseKeeper.h" + +void FUnrealEnginePythonHouseKeeper::AddReferencedObjects(FReferenceCollector& InCollector) +{ + InCollector.AddReferencedObjects(PythonTrackedObjects); +} + +FUnrealEnginePythonHouseKeeper *FUnrealEnginePythonHouseKeeper::Get() +{ + static FUnrealEnginePythonHouseKeeper *Singleton; + if (!Singleton) + { + Singleton = new FUnrealEnginePythonHouseKeeper(); + // register a new delegate for the GC +#if ENGINE_MINOR_VERSION >= 18 + FCoreUObjectDelegates::GetPostGarbageCollect().AddRaw(Singleton, &FUnrealEnginePythonHouseKeeper::RunGCDelegate); +#else + FCoreUObjectDelegates::PostGarbageCollect.AddRaw(Singleton, &FUnrealEnginePythonHouseKeeper::RunGCDelegate); +#endif + } + return Singleton; +} + +void FUnrealEnginePythonHouseKeeper::RunGCDelegate() +{ + FScopePythonGIL gil; + RunGC(); +} + +int32 FUnrealEnginePythonHouseKeeper::RunGC() +{ + int32 Garbaged = PyUObjectsGC(); + Garbaged += DelegatesGC(); + return Garbaged; +} + +bool FUnrealEnginePythonHouseKeeper::IsValidPyUObject(ue_PyUObject *PyUObject) +{ + if (!PyUObject) + return false; + + UObject *Object = PyUObject->ue_object; + FPythonUOjectTracker *Tracker = UObjectPyMapping.Find(Object); + if (!Tracker) + { + return false; + } + + if (!Tracker->Owner.IsValid()) + return false; + + return true; + +} + +void FUnrealEnginePythonHouseKeeper::TrackUObject(UObject *Object) +{ + FPythonUOjectTracker *Tracker = UObjectPyMapping.Find(Object); + if (!Tracker) + { + return; + } + if (Tracker->bPythonOwned) + return; + Tracker->bPythonOwned = true; + // when a new ue_PyUObject spawns, it has a reference counting of two + Py_DECREF(Tracker->PyUObject); + Tracker->PyUObject->owned = 1; + PythonTrackedObjects.Add(Object); +} + +void FUnrealEnginePythonHouseKeeper::UntrackUObject(UObject *Object) +{ + PythonTrackedObjects.Remove(Object); +} + +void FUnrealEnginePythonHouseKeeper::RegisterPyUObject(UObject *Object, ue_PyUObject *InPyUObject) +{ + UObjectPyMapping.Add(Object, FPythonUOjectTracker(Object, InPyUObject)); +} + +void FUnrealEnginePythonHouseKeeper::UnregisterPyUObject(UObject *Object) +{ + UObjectPyMapping.Remove(Object); +} + +ue_PyUObject *FUnrealEnginePythonHouseKeeper::GetPyUObject(UObject *Object) +{ + FPythonUOjectTracker *Tracker = UObjectPyMapping.Find(Object); + if (!Tracker) + { + return nullptr; + } + + if (!Tracker->Owner.IsValid(true)) + { +#if defined(UEPY_MEMORY_DEBUG) + UE_LOG(LogPython, Warning, TEXT("DEFREF'ing UObject at %p (refcnt: %d)"), Object, Tracker->PyUObject->ob_base.ob_refcnt); +#endif + if (!Tracker->bPythonOwned) + Py_DECREF((PyObject *)Tracker->PyUObject); + UnregisterPyUObject(Object); + return nullptr; +} + + return Tracker->PyUObject; +} + +uint32 FUnrealEnginePythonHouseKeeper::PyUObjectsGC() +{ + uint32 Garbaged = 0; + TArray BrokenList; + for (auto &UObjectPyItem : UObjectPyMapping) + { + UObject *Object = UObjectPyItem.Key; + FPythonUOjectTracker &Tracker = UObjectPyItem.Value; +#if defined(UEPY_MEMORY_DEBUG) + UE_LOG(LogPython, Warning, TEXT("Checking for UObject at %p"), Object); +#endif + if (!Tracker.Owner.IsValid(true)) + { +#if defined(UEPY_MEMORY_DEBUG) + UE_LOG(LogPython, Warning, TEXT("Removing UObject at %p (refcnt: %d)"), Object, Tracker.PyUObject->ob_base.ob_refcnt); +#endif + BrokenList.Add(Object); + Garbaged++; + } + else + { +#if defined(UEPY_MEMORY_DEBUG) + UE_LOG(LogPython, Error, TEXT("UObject at %p %s is in use"), Object, *Object->GetName()); +#endif +} + } + + for (UObject *Object : BrokenList) + { + FPythonUOjectTracker &Tracker = UObjectPyMapping[Object]; + if (!Tracker.bPythonOwned) + Py_DECREF((PyObject *)Tracker.PyUObject); + UnregisterPyUObject(Object); + } + + return Garbaged; + +} + + +int32 FUnrealEnginePythonHouseKeeper::DelegatesGC() +{ + int32 Garbaged = 0; +#if defined(UEPY_MEMORY_DEBUG) + UE_LOG(LogPython, Display, TEXT("Garbage collecting %d UObject delegates"), PyDelegatesTracker.Num()); +#endif + for (int32 i = PyDelegatesTracker.Num() - 1; i >= 0; --i) + { + FPythonDelegateTracker &Tracker = PyDelegatesTracker[i]; + if (!Tracker.Owner.IsValid(true)) + { + Tracker.Delegate->RemoveFromRoot(); + PyDelegatesTracker.RemoveAt(i); + Garbaged++; + } + + } + +#if defined(UEPY_MEMORY_DEBUG) + UE_LOG(LogPython, Display, TEXT("Garbage collecting %d Slate delegates"), PySlateDelegatesTracker.Num()); +#endif + + for (int32 i = PySlateDelegatesTracker.Num() - 1; i >= 0; --i) + { + FPythonSWidgetDelegateTracker &Tracker = PySlateDelegatesTracker[i]; + if (!Tracker.Owner.IsValid()) + { + PySlateDelegatesTracker.RemoveAt(i); + Garbaged++; + } + + } + return Garbaged; + } + +UPythonDelegate *FUnrealEnginePythonHouseKeeper::FindDelegate(UObject *Owner, PyObject *PyCallable) +{ + for (int32 i = PyDelegatesTracker.Num() - 1; i >= 0; --i) + { + FPythonDelegateTracker &Tracker = PyDelegatesTracker[i]; + if (Tracker.Owner.Get() == Owner && Tracker.Delegate->UsesPyCallable(PyCallable)) + return Tracker.Delegate; + } + return nullptr; +} + +UPythonDelegate *FUnrealEnginePythonHouseKeeper::NewDelegate(UObject *Owner, PyObject *PyCallable, UFunction *Signature) +{ + UPythonDelegate *Delegate = NewObject(); + + Delegate->AddToRoot(); + Delegate->SetPyCallable(PyCallable); + Delegate->SetSignature(Signature); + + FPythonDelegateTracker Tracker(Delegate, Owner); + PyDelegatesTracker.Add(Tracker); + + return Delegate; +} + +TSharedRef FUnrealEnginePythonHouseKeeper::NewSlateDelegate(TSharedRef Owner, PyObject *PyCallable) +{ + TSharedRef Delegate = MakeShareable(new FPythonSlateDelegate()); + Delegate->SetPyCallable(PyCallable); + + FPythonSWidgetDelegateTracker Tracker(Delegate, Owner); + PySlateDelegatesTracker.Add(Tracker); + + return Delegate; +} + +TSharedRef FUnrealEnginePythonHouseKeeper::NewDeferredSlateDelegate(PyObject *PyCallable) +{ + TSharedRef Delegate = MakeShareable(new FPythonSlateDelegate()); + Delegate->SetPyCallable(PyCallable); + + return Delegate; +} + +TSharedRef FUnrealEnginePythonHouseKeeper::NewPythonSmartDelegate(PyObject *PyCallable) +{ + TSharedRef Delegate = MakeShareable(new FPythonSmartDelegate()); + Delegate->SetPyCallable(PyCallable); + + PyStaticSmartDelegatesTracker.Add(Delegate); + + return Delegate; +} + +void FUnrealEnginePythonHouseKeeper::TrackDeferredSlateDelegate(TSharedRef Delegate, TSharedRef Owner) +{ + FPythonSWidgetDelegateTracker Tracker(Delegate, Owner); + PySlateDelegatesTracker.Add(Tracker); +} + +TSharedRef FUnrealEnginePythonHouseKeeper::NewStaticSlateDelegate(PyObject *PyCallable) +{ + TSharedRef Delegate = MakeShareable(new FPythonSlateDelegate()); + Delegate->SetPyCallable(PyCallable); + + PyStaticSlateDelegatesTracker.Add(Delegate); + + return Delegate; +} + diff --git a/Source/UnrealEnginePython/Private/PythonScript.cpp b/Source/UnrealEnginePython/Private/PythonScript.cpp index 84f4e2fbd..1ce9d653f 100644 --- a/Source/UnrealEnginePython/Private/PythonScript.cpp +++ b/Source/UnrealEnginePython/Private/PythonScript.cpp @@ -1,27 +1,30 @@ -#include "UnrealEnginePythonPrivatePCH.h" + #include "PythonScript.h" -static void callback(void *arg) { +#include "UEPyModule.h" + + +static void callback(void *arg) +{ UPythonScript *self = (UPythonScript *)arg; self->CallSpecificFunctionWithArgs(); } -void UPythonScript::Run() { +void UPythonScript::Run() +{ FUnrealEnginePythonModule &PythonModule = FModuleManager::GetModuleChecked("UnrealEnginePython"); PythonModule.RunFile(TCHAR_TO_UTF8(*ScriptPath)); - if (!FunctionToCall.IsEmpty()) { + if (!FunctionToCall.IsEmpty()) + { CallSpecificFunctionWithArgs(); } } -void UPythonScript::RunSandboxed() { - FUnrealEnginePythonModule &PythonModule = FModuleManager::GetModuleChecked("UnrealEnginePython"); - PythonModule.RunFileSandboxed(TCHAR_TO_UTF8(*ScriptPath), callback, this); -} - -void UPythonScript::CallSpecificFunctionWithArgs() { +void UPythonScript::CallSpecificFunctionWithArgs() +{ PyObject *function_to_call = PyDict_GetItemString(PyEval_GetGlobals(), TCHAR_TO_UTF8(*FunctionToCall)); - if (!function_to_call) { + if (!function_to_call) + { UE_LOG(LogPython, Error, TEXT("unable to find function %s"), *FunctionToCall); return; } @@ -32,16 +35,19 @@ void UPythonScript::CallSpecificFunctionWithArgs() { if (n > 0) args = PyTuple_New(n); - for (int i = 0; i < n; i++) { + for (int i = 0; i < n; i++) + { PyTuple_SetItem(args, i, PyUnicode_FromString(TCHAR_TO_UTF8(*FunctionArgs[i]))); } PyObject *ret = PyObject_Call(function_to_call, args, nullptr); Py_DECREF(args); - if (!ret) { + if (!ret) + { unreal_engine_py_log_error(); } - else { + else + { Py_DECREF(ret); } } \ No newline at end of file diff --git a/Source/UnrealEnginePython/Private/PythonSmartDelegate.cpp b/Source/UnrealEnginePython/Private/PythonSmartDelegate.cpp index 62e72dcaf..e4cf60fff 100644 --- a/Source/UnrealEnginePython/Private/PythonSmartDelegate.cpp +++ b/Source/UnrealEnginePython/Private/PythonSmartDelegate.cpp @@ -1,6 +1,12 @@ -#include "UnrealEnginePythonPrivatePCH.h" + #include "PythonSmartDelegate.h" +#include "UEPyModule.h" + +#if WITH_EDITOR +#include "Slate/UEPySWindow.h" +#endif + FPythonSmartDelegate::FPythonSmartDelegate() { py_callable = nullptr; @@ -57,6 +63,19 @@ void FPythonSmartDelegate::PyFOnAssetPostImport(UFactory *factory, UObject *u_ob } Py_DECREF(ret); +} + +void FPythonSmartDelegate::PyFOnMainFrameCreationFinished(TSharedPtr InRootWindow, bool bIsNewProjectWindow) +{ + FScopePythonGIL gil; + PyObject *ret = PyObject_CallFunction(py_callable, (char *)"NO", py_ue_new_swidget(InRootWindow.ToSharedRef(), &ue_PySWindowType), bIsNewProjectWindow ? Py_True : Py_False); + if (!ret) + { + unreal_engine_py_log_error(); + return; + } + Py_DECREF(ret); + } #endif diff --git a/Source/UnrealEnginePython/Private/Slate/UEPyFCharacterEvent.cpp b/Source/UnrealEnginePython/Private/Slate/UEPyFCharacterEvent.cpp index b56af1690..0fc8f37bf 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPyFCharacterEvent.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPyFCharacterEvent.cpp @@ -1,7 +1,9 @@ -#include "UnrealEnginePythonPrivatePCH.h" + #include "UEPyFCharacterEvent.h" +#include "UEPyFModifierKeysState.h" + static PyObject *py_ue_fcharacter_event_get_character(ue_PyFCharacterEvent *self, PyObject * args) { TCHAR c = self->character_event.GetCharacter(); diff --git a/Source/UnrealEnginePython/Private/Slate/UEPyFCharacterEvent.h b/Source/UnrealEnginePython/Private/Slate/UEPyFCharacterEvent.h index 7070e0ee5..f5806960a 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPyFCharacterEvent.h +++ b/Source/UnrealEnginePython/Private/Slate/UEPyFCharacterEvent.h @@ -1,12 +1,11 @@ #pragma once -#include "UnrealEnginePython.h" - #include "UEPyFInputEvent.h" extern PyTypeObject ue_PyFInputEventType; -typedef struct { +typedef struct +{ /* Type-specific fields go here. */ ue_PyFInputEvent f_input; FCharacterEvent character_event; diff --git a/Source/UnrealEnginePython/Private/Slate/UEPyFGeometry.cpp b/Source/UnrealEnginePython/Private/Slate/UEPyFGeometry.cpp index 503bc028f..c50928d1c 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPyFGeometry.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPyFGeometry.cpp @@ -1,5 +1,3 @@ -#include "UnrealEnginePythonPrivatePCH.h" - #include "UEPyFGeometry.h" static PyObject *py_ue_fgeometry_get_local_size(ue_PyFGeometry *self, PyObject * args) diff --git a/Source/UnrealEnginePython/Private/Slate/UEPyFGeometry.h b/Source/UnrealEnginePython/Private/Slate/UEPyFGeometry.h index 4ffeb0518..f983f1007 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPyFGeometry.h +++ b/Source/UnrealEnginePython/Private/Slate/UEPyFGeometry.h @@ -1,13 +1,14 @@ #pragma once -#include "UnrealEnginePython.h" +#include "UEPyModule.h" #include "Runtime/SlateCore/Public/Layout/Geometry.h" -typedef struct { +typedef struct +{ PyObject_HEAD - /* Type-specific fields go here. */ - FGeometry geometry; + /* Type-specific fields go here. */ + FGeometry geometry; } ue_PyFGeometry; void ue_python_init_fgeometry(PyObject *); diff --git a/Source/UnrealEnginePython/Private/Slate/UEPyFInputEvent.cpp b/Source/UnrealEnginePython/Private/Slate/UEPyFInputEvent.cpp index 0c0e88096..dae734a10 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPyFInputEvent.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPyFInputEvent.cpp @@ -1,28 +1,31 @@ -#include "UnrealEnginePythonPrivatePCH.h" - #include "UEPyFInputEvent.h" -static PyObject *py_ue_finput_event_to_text(ue_PyFInputEvent *self, PyObject * args) { +static PyObject *py_ue_finput_event_to_text(ue_PyFInputEvent *self, PyObject * args) +{ return PyUnicode_FromString(TCHAR_TO_UTF8(*self->input.ToText().ToString())); } -static PyObject *py_ue_finput_event_get_user_index(ue_PyFInputEvent *self, PyObject * args) { +static PyObject *py_ue_finput_event_get_user_index(ue_PyFInputEvent *self, PyObject * args) +{ return PyLong_FromUnsignedLong(self->input.GetUserIndex()); } -static PyObject *py_ue_finput_event_is_alt_down(ue_PyFInputEvent *self, PyObject * args) { +static PyObject *py_ue_finput_event_is_alt_down(ue_PyFInputEvent *self, PyObject * args) +{ if (self->input.IsAltDown()) Py_RETURN_TRUE; Py_RETURN_FALSE; } -static PyObject *py_ue_finput_event_is_command_down(ue_PyFInputEvent *self, PyObject * args) { +static PyObject *py_ue_finput_event_is_command_down(ue_PyFInputEvent *self, PyObject * args) +{ if (self->input.IsCommandDown()) Py_RETURN_TRUE; Py_RETURN_FALSE; } -static PyObject *py_ue_finput_event_is_control_down(ue_PyFInputEvent *self, PyObject * args) { +static PyObject *py_ue_finput_event_is_control_down(ue_PyFInputEvent *self, PyObject * args) +{ if (self->input.IsControlDown()) Py_RETURN_TRUE; Py_RETURN_FALSE; @@ -74,7 +77,8 @@ PyTypeObject ue_PyFInputEventType = { ue_PyFInputEvent_methods, /* tp_methods */ }; -void ue_python_init_finput_event(PyObject *ue_module) { +void ue_python_init_finput_event(PyObject *ue_module) +{ ue_PyFInputEventType.tp_new = PyType_GenericNew; if (PyType_Ready(&ue_PyFInputEventType) < 0) @@ -84,7 +88,8 @@ void ue_python_init_finput_event(PyObject *ue_module) { PyModule_AddObject(ue_module, "FInputEvent", (PyObject *)&ue_PyFInputEventType); } -PyObject *py_ue_new_finput_event(FInputEvent input) { +PyObject *py_ue_new_finput_event(FInputEvent input) +{ ue_PyFInputEvent *ret = (ue_PyFInputEvent *)PyObject_New(ue_PyFInputEvent, &ue_PyFInputEventType); new(&ret->input) FInputEvent(input); return (PyObject *)ret; diff --git a/Source/UnrealEnginePython/Private/Slate/UEPyFInputEvent.h b/Source/UnrealEnginePython/Private/Slate/UEPyFInputEvent.h index eab8515b7..3541a5381 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPyFInputEvent.h +++ b/Source/UnrealEnginePython/Private/Slate/UEPyFInputEvent.h @@ -1,6 +1,6 @@ #pragma once -#include "UnrealEnginePython.h" +#include "UEPyModule.h" #include "Runtime/SlateCore/Public/Input/Events.h" diff --git a/Source/UnrealEnginePython/Private/Slate/UEPyFKeyEvent.cpp b/Source/UnrealEnginePython/Private/Slate/UEPyFKeyEvent.cpp index 0d90a7d98..836b9357d 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPyFKeyEvent.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPyFKeyEvent.cpp @@ -1,13 +1,13 @@ -#include "UnrealEnginePythonPrivatePCH.h" - #include "UEPyFKeyEvent.h" -static PyObject *py_ue_fkey_event_get_key(ue_PyFKeyEvent *self, PyObject * args) { +static PyObject *py_ue_fkey_event_get_key(ue_PyFKeyEvent *self, PyObject * args) +{ FKey key = self->key_event.GetKey(); - return py_ue_new_uscriptstruct(FKey::StaticStruct(), (uint8*)&key); + return py_ue_new_owned_uscriptstruct(FKey::StaticStruct(), (uint8*)&key); } -static PyObject *py_ue_fkey_event_get_key_name(ue_PyFKeyEvent *self, PyObject * args) { +static PyObject *py_ue_fkey_event_get_key_name(ue_PyFKeyEvent *self, PyObject * args) +{ FKey key = self->key_event.GetKey(); return PyUnicode_FromString(TCHAR_TO_UTF8(*key.ToString())); } @@ -78,7 +78,8 @@ static int ue_py_fkey_event_init(ue_PyFKeyEvent *self, PyObject *args, PyObject } -void ue_python_init_fkey_event(PyObject *ue_module) { +void ue_python_init_fkey_event(PyObject *ue_module) +{ ue_PyFKeyEventType.tp_base = &ue_PyFInputEventType; ue_PyFKeyEventType.tp_init = (initproc)ue_py_fkey_event_init; @@ -90,7 +91,8 @@ void ue_python_init_fkey_event(PyObject *ue_module) { PyModule_AddObject(ue_module, "FKeyEvent", (PyObject *)&ue_PyFKeyEventType); } -PyObject *py_ue_new_fkey_event(FKeyEvent key_event) { +PyObject *py_ue_new_fkey_event(FKeyEvent key_event) +{ ue_PyFKeyEvent *ret = (ue_PyFKeyEvent *)PyObject_New(ue_PyFKeyEvent, &ue_PyFKeyEventType); new(&ret->key_event) FKeyEvent(key_event); new(&ret->f_input.input) FInputEvent(key_event); diff --git a/Source/UnrealEnginePython/Private/Slate/UEPyFMenuBuilder.cpp b/Source/UnrealEnginePython/Private/Slate/UEPyFMenuBuilder.cpp index 1b128f24f..3e0b978ed 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPyFMenuBuilder.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPyFMenuBuilder.cpp @@ -1,52 +1,48 @@ -#include "UnrealEnginePythonPrivatePCH.h" - #include "UEPyFMenuBuilder.h" -#include "Runtime/Slate/Public/Framework/Commands/UIAction.h" -#if WITH_EDITOR -#include "Developer/AssetTools/Public/AssetToolsModule.h" -#include "Developer/AssetTools/Public/IAssetTools.h" -#endif +#include "Wrappers/UEPyESlateEnums.h" -static PyObject *py_ue_fmenu_builder_begin_section(ue_PyFMenuBuilder *self, PyObject * args) +static PyObject* py_ue_fmenu_builder_begin_section(ue_PyFMenuBuilder* self, PyObject* args) { - char *name; - char *text; + char* name; + char* text; if (!PyArg_ParseTuple(args, "ss:begin_section", &name, &text)) return nullptr; self->menu_builder.BeginSection(name, FText::FromString(UTF8_TO_TCHAR(text))); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } -static PyObject *py_ue_fmenu_builder_end_section(ue_PyFMenuBuilder *self, PyObject * args) +static PyObject* py_ue_fmenu_builder_end_section(ue_PyFMenuBuilder* self, PyObject* args) { self->menu_builder.EndSection(); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } -static PyObject *py_ue_fmenu_builder_make_widget(ue_PyFMenuBuilder *self, PyObject * args) +static PyObject* py_ue_fmenu_builder_make_widget(ue_PyFMenuBuilder* self, PyObject* args) { - ue_PySWidget *ret = (ue_PySWidget *)PyObject_New(ue_PySWidget, &ue_PySWidgetType); - new (&ret->s_widget) TSharedRef(self->menu_builder.MakeWidget()); - return (PyObject *)ret; + ue_PySWidget* ret = (ue_PySWidget*)PyObject_New(ue_PySWidget, &ue_PySWidgetType); + new (&ret->Widget) TSharedRef(self->menu_builder.MakeWidget()); + return (PyObject*)ret; } -static PyObject *py_ue_fmenu_builder_add_menu_entry(ue_PyFMenuBuilder *self, PyObject * args) +static PyObject* py_ue_fmenu_builder_add_menu_entry(ue_PyFMenuBuilder* self, PyObject* args) { - char *label; - char *tooltip; - PyObject *py_callable; - PyObject *py_obj = nullptr; - PyObject *py_uiaction_obj = nullptr; - if (!PyArg_ParseTuple(args, "ssO|OO:add_menu_entry", &label, &tooltip, &py_callable, &py_obj, &py_uiaction_obj)) + char* label; + char* tooltip; + PyObject* py_callable; + PyObject* py_obj = nullptr; +#if ENGINE_MINOR_VERSION >= 23 + int ui_action_type = (int)EUserInterfaceActionType::Button; +#else + int ui_action_type = EUserInterfaceActionType::Button; +#endif + if (!PyArg_ParseTuple(args, "ssO|Oi:add_menu_entry", &label, &tooltip, &py_callable, &py_obj, &ui_action_type)) return nullptr; - if (!PyCalllable_Check_Extended(py_callable)) + if (!PyCallable_Check(py_callable)) { return PyErr_Format(PyExc_Exception, "argument is not callable"); } @@ -65,16 +61,45 @@ static PyObject *py_ue_fmenu_builder_add_menu_entry(ue_PyFMenuBuilder *self, PyO handler.BindSP(py_delegate, &FPythonSlateDelegate::SimpleExecuteAction); } - ue_PyESlateEnums *py_uiaction_enum = py_uiaction_obj ? py_ue_is_eslate_enums(py_uiaction_obj) : nullptr; self->menu_builder.AddMenuEntry(FText::FromString(UTF8_TO_TCHAR(label)), FText::FromString(UTF8_TO_TCHAR(tooltip)), FSlateIcon(), FUIAction(handler), NAME_None, - py_uiaction_enum ? (EUserInterfaceActionType::Type)(py_uiaction_enum->val) : EUserInterfaceActionType::Button); +#if ENGINE_MINOR_VERSION >= 23 + (EUserInterfaceActionType)ui_action_type); +#else + (EUserInterfaceActionType::Type)ui_action_type); +#endif + + Py_RETURN_NONE; +} + +static PyObject* py_ue_fmenu_builder_add_sub_menu(ue_PyFMenuBuilder* self, PyObject* args) +{ + char* label; + char* tooltip; + PyObject* py_callable; + PyObject* py_bool = nullptr; + if (!PyArg_ParseTuple(args, "ssO|O:add_sub_menu", &label, &tooltip, &py_callable, &py_bool)) + return nullptr; + + if (!PyCallable_Check(py_callable)) + { + return PyErr_Format(PyExc_Exception, "argument is not callable"); + } + + + TSharedRef py_delegate = FUnrealEnginePythonHouseKeeper::Get()->NewStaticSlateDelegate(py_callable); + + FNewMenuDelegate menu_delegate; + menu_delegate.BindSP(py_delegate, &FPythonSlateDelegate::SubMenuPyBuilder); + + + self->menu_builder.AddSubMenu(FText::FromString(UTF8_TO_TCHAR(label)), FText::FromString(UTF8_TO_TCHAR(tooltip)), menu_delegate, (py_bool && PyObject_IsTrue(py_bool)) ? true : false); Py_RETURN_NONE; } -static PyObject *py_ue_fmenu_builder_add_menu_separator(ue_PyFMenuBuilder *self, PyObject * args) +static PyObject* py_ue_fmenu_builder_add_menu_separator(ue_PyFMenuBuilder* self, PyObject* args) { - char *name = nullptr; + char* name = nullptr; if (!PyArg_ParseTuple(args, "|s:add_menu_separator", &name)) return nullptr; @@ -86,14 +111,13 @@ static PyObject *py_ue_fmenu_builder_add_menu_separator(ue_PyFMenuBuilder *self, self->menu_builder.AddMenuSeparator(f_name); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } #if WITH_EDITOR -static PyObject *py_ue_fmenu_builder_add_asset_actions(ue_PyFMenuBuilder *self, PyObject * args) +static PyObject* py_ue_fmenu_builder_add_asset_actions(ue_PyFMenuBuilder* self, PyObject* args) { - PyObject *py_assets; + PyObject* py_assets; if (!PyArg_ParseTuple(args, "O:add_asset_actions", &py_assets)) return nullptr; @@ -104,10 +128,10 @@ static PyObject *py_ue_fmenu_builder_add_asset_actions(ue_PyFMenuBuilder *self, return PyErr_Format(PyExc_Exception, "argument is not iterable"); } - TArray u_objects; - while (PyObject *item = PyIter_Next(py_assets)) + TArray u_objects; + while (PyObject * item = PyIter_Next(py_assets)) { - UObject *u_object = ue_py_check_type(item); + UObject* u_object = ue_py_check_type(item); if (u_object) { u_objects.Add(u_object); @@ -126,7 +150,7 @@ static PyObject *py_ue_fmenu_builder_add_asset_actions(ue_PyFMenuBuilder *self, } #endif -static PyObject *py_ue_fmenu_builder_add_search_widget(ue_PyFMenuBuilder *self, PyObject * args) +static PyObject* py_ue_fmenu_builder_add_search_widget(ue_PyFMenuBuilder* self, PyObject* args) { self->menu_builder.AddSearchWidget(); @@ -140,6 +164,7 @@ static PyMethodDef ue_PyFMenuBuilder_methods[] = { { "add_menu_entry", (PyCFunction)py_ue_fmenu_builder_add_menu_entry, METH_VARARGS, "" }, { "add_menu_separator", (PyCFunction)py_ue_fmenu_builder_add_menu_separator, METH_VARARGS, "" }, { "add_search_widget", (PyCFunction)py_ue_fmenu_builder_add_search_widget, METH_VARARGS, "" }, + { "add_sub_menu", (PyCFunction)py_ue_fmenu_builder_add_sub_menu, METH_VARARGS, "" }, #if WITH_EDITOR { "add_asset_actions", (PyCFunction)py_ue_fmenu_builder_add_asset_actions, METH_VARARGS, "" }, #endif @@ -147,13 +172,13 @@ static PyMethodDef ue_PyFMenuBuilder_methods[] = { }; -static PyObject *ue_PyFMenuBuilder_str(ue_PyFMenuBuilder *self) +static PyObject* ue_PyFMenuBuilder_str(ue_PyFMenuBuilder* self) { return PyUnicode_FromFormat("", &self->menu_builder); } -static void ue_py_fmenu_builder_dealloc(ue_PyFMenuBuilder *self) +static void ue_py_fmenu_builder_dealloc(ue_PyFMenuBuilder* self) { #if PY_MAJOR_VERSION < 3 self->ob_type->tp_free((PyObject*)self); @@ -193,14 +218,14 @@ static PyTypeObject ue_PyFMenuBuilderType = { ue_PyFMenuBuilder_methods, /* tp_methods */ }; -static int ue_py_fmenu_builder_init(ue_PyFMenuBuilder *self, PyObject *args, PyObject *kwargs) +static int ue_py_fmenu_builder_init(ue_PyFMenuBuilder* self, PyObject* args, PyObject* kwargs) { new(&self->menu_builder) FMenuBuilder(true, nullptr); return 0; } -void ue_python_init_fmenu_builder(PyObject *ue_module) +void ue_python_init_fmenu_builder(PyObject* ue_module) { ue_PyFMenuBuilderType.tp_new = PyType_GenericNew; @@ -210,12 +235,12 @@ void ue_python_init_fmenu_builder(PyObject *ue_module) return; Py_INCREF(&ue_PyFMenuBuilderType); - PyModule_AddObject(ue_module, "FMenuBuilder", (PyObject *)&ue_PyFMenuBuilderType); + PyModule_AddObject(ue_module, "FMenuBuilder", (PyObject*)& ue_PyFMenuBuilderType); } -PyObject *py_ue_new_fmenu_builder(FMenuBuilder menu_builder) +PyObject* py_ue_new_fmenu_builder(FMenuBuilder menu_builder) { - ue_PyFMenuBuilder *ret = (ue_PyFMenuBuilder *)PyObject_New(ue_PyFMenuBuilder, &ue_PyFMenuBuilderType); + ue_PyFMenuBuilder* ret = (ue_PyFMenuBuilder*)PyObject_New(ue_PyFMenuBuilder, &ue_PyFMenuBuilderType); new(&ret->menu_builder) FMenuBuilder(menu_builder); - return (PyObject *)ret; + return (PyObject*)ret; } diff --git a/Source/UnrealEnginePython/Private/Slate/UEPyFMenuBuilder.h b/Source/UnrealEnginePython/Private/Slate/UEPyFMenuBuilder.h index 4b091e4f7..de5056209 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPyFMenuBuilder.h +++ b/Source/UnrealEnginePython/Private/Slate/UEPyFMenuBuilder.h @@ -1,13 +1,20 @@ #pragma once -#include "UnrealEnginePython.h" +#include "UEPySlate.h" + +#include "Runtime/Slate/Public/Framework/Commands/UIAction.h" +#if WITH_EDITOR +#include "Developer/AssetTools/Public/AssetToolsModule.h" +#include "Developer/AssetTools/Public/IAssetTools.h" +#endif #include "Runtime/Slate/Public/Framework/MultiBox/MultiBoxBuilder.h" -typedef struct { +typedef struct +{ PyObject_HEAD - /* Type-specific fields go here. */ - FMenuBuilder menu_builder; + /* Type-specific fields go here. */ + FMenuBuilder menu_builder; } ue_PyFMenuBuilder; void ue_python_init_fmenu_builder(PyObject *); diff --git a/Source/UnrealEnginePython/Private/Slate/UEPyFModifierKeysState.cpp b/Source/UnrealEnginePython/Private/Slate/UEPyFModifierKeysState.cpp index fa998a860..6c4779a61 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPyFModifierKeysState.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPyFModifierKeysState.cpp @@ -1,5 +1,3 @@ -#include "UnrealEnginePythonPrivatePCH.h" - #include "UEPyFModifierKeysState.h" static PyObject *py_ue_fmodifier_keys_state_are_caps_locked(ue_PyFModifierKeysState *self, PyObject * args) diff --git a/Source/UnrealEnginePython/Private/Slate/UEPyFModifierKeysState.h b/Source/UnrealEnginePython/Private/Slate/UEPyFModifierKeysState.h index 97b5190da..663f1007b 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPyFModifierKeysState.h +++ b/Source/UnrealEnginePython/Private/Slate/UEPyFModifierKeysState.h @@ -2,11 +2,17 @@ #include "UnrealEnginePython.h" +#if ENGINE_MINOR_VERSION <= 17 +#include "Runtime/Core/Public/GenericPlatform/GenericApplication.h" +#else +#include "Runtime/ApplicationCore/Public/GenericPlatform/GenericApplication.h" +#endif + typedef struct { PyObject_HEAD - /* Type-specific fields go here. */ - FModifierKeysState modifier; + /* Type-specific fields go here. */ + FModifierKeysState modifier; } ue_PyFModifierKeysState; void ue_python_init_fmodifier_keys_state(PyObject *); diff --git a/Source/UnrealEnginePython/Private/Slate/UEPyFPaintContext.cpp b/Source/UnrealEnginePython/Private/Slate/UEPyFPaintContext.cpp index dc72b112b..367ca07ce 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPyFPaintContext.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPyFPaintContext.cpp @@ -1,7 +1,7 @@ -#include "UnrealEnginePythonPrivatePCH.h" - #include "UEPyFPaintContext.h" +#include "UEPyFGeometry.h" + static FSlateBrush global_simple_brush; static PyObject *py_ue_fpaint_context_draw_line(ue_PyFPaintContext *self, PyObject * args) diff --git a/Source/UnrealEnginePython/Private/Slate/UEPyFPaintContext.h b/Source/UnrealEnginePython/Private/Slate/UEPyFPaintContext.h index 1d50e7dfd..cb2af2acd 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPyFPaintContext.h +++ b/Source/UnrealEnginePython/Private/Slate/UEPyFPaintContext.h @@ -1,13 +1,14 @@ #pragma once -#include "UnrealEnginePython.h" +#include "UEPyModule.h" #include "Runtime/UMG/Public/Blueprint/UserWidget.h" -typedef struct { +typedef struct +{ PyObject_HEAD - /* Type-specific fields go here. */ - FPaintContext paint_context; + /* Type-specific fields go here. */ + FPaintContext paint_context; } ue_PyFPaintContext; void ue_python_init_fpaint_context(PyObject *); diff --git a/Source/UnrealEnginePython/Private/Slate/UEPyFPointerEvent.cpp b/Source/UnrealEnginePython/Private/Slate/UEPyFPointerEvent.cpp index 0a13b1e51..2e557954c 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPyFPointerEvent.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPyFPointerEvent.cpp @@ -1,11 +1,11 @@ -#include "UnrealEnginePythonPrivatePCH.h" - #include "UEPyFPointerEvent.h" +#include "UEPyFModifierKeysState.h" + static PyObject *py_ue_fpointer_event_get_effecting_button(ue_PyFPointerEvent *self, PyObject * args) { FKey key = self->pointer.GetEffectingButton(); - return py_ue_new_uscriptstruct(FKey::StaticStruct(), (uint8*)&key); + return py_ue_new_owned_uscriptstruct(FKey::StaticStruct(), (uint8*)&key); } static PyObject *py_ue_fpointer_event_get_effecting_button_name(ue_PyFPointerEvent *self, PyObject * args) diff --git a/Source/UnrealEnginePython/Private/Slate/UEPyFPointerEvent.h b/Source/UnrealEnginePython/Private/Slate/UEPyFPointerEvent.h index e66ad673f..91aca2a59 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPyFPointerEvent.h +++ b/Source/UnrealEnginePython/Private/Slate/UEPyFPointerEvent.h @@ -1,12 +1,11 @@ #pragma once -#include "UnrealEnginePython.h" - #include "UEPyFInputEvent.h" extern PyTypeObject ue_PyFInputEventType; -typedef struct { +typedef struct +{ /* Type-specific fields go here. */ ue_PyFInputEvent f_input; FPointerEvent pointer; diff --git a/Source/UnrealEnginePython/Private/Slate/UEPyFSlateIcon.cpp b/Source/UnrealEnginePython/Private/Slate/UEPyFSlateIcon.cpp index c0618e126..72b8d5ca0 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPyFSlateIcon.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPyFSlateIcon.cpp @@ -1,15 +1,13 @@ -#include "UnrealEnginePythonPrivatePCH.h" #include "UEPyFSlateIcon.h" static PyObject *py_ue_fslate_icon_get_icon(ue_PyFSlateIcon *self, PyObject * args) { - PyObject *ret = py_ue_new_uscriptstruct(FSlateBrush::StaticStruct(), (uint8*)self->icon.GetIcon()); - return ret; + return py_ue_new_owned_uscriptstruct(FSlateBrush::StaticStruct(), (uint8*)self->icon.GetIcon()); } static PyMethodDef ue_PyFSlateIcon_methods[] = { - { "get_icon", (PyCFunction)py_ue_fslate_icon_get_icon, METH_VARARGS, "" }, + { "get_icon", (PyCFunction)py_ue_fslate_icon_get_icon, METH_VARARGS, "" }, { NULL } /* Sentinel */ }; @@ -50,27 +48,33 @@ static PyTypeObject ue_PyFSlateIconType = { ue_PyFSlateIcon_methods, /* tp_methods */ }; -static int ue_py_fslate_icon_init(ue_PyFSlateIcon *self, PyObject *args, PyObject *kwargs) { +static int ue_py_fslate_icon_init(ue_PyFSlateIcon *self, PyObject *args, PyObject *kwargs) +{ char *style_set = nullptr; char *style = nullptr; - if (!PyArg_ParseTuple(args, "|ss", &style_set, &style)) { + if (!PyArg_ParseTuple(args, "|ss", &style_set, &style)) + { return -1; } - if (style_set) { - if (!style) { + if (style_set) + { + if (!style) + { PyErr_SetString(PyExc_ValueError, "you have not specified as style name"); return -1; } new(&self->icon) FSlateIcon(FName(style_set), FName(style)); } - else { - new(&self->icon) FSlateIcon(); + else + { + new(&self->icon) FSlateIcon(); } return 0; } -void ue_python_init_fslate_icon(PyObject *ue_module) { +void ue_python_init_fslate_icon(PyObject *ue_module) +{ ue_PyFSlateIconType.tp_new = PyType_GenericNew; ue_PyFSlateIconType.tp_init = (initproc)ue_py_fslate_icon_init; @@ -84,13 +88,14 @@ void ue_python_init_fslate_icon(PyObject *ue_module) { ue_PyFSlateIcon *py_ue_new_fslate_icon(const FSlateIcon slate_icon) { - ue_PyFSlateIcon *ret = (ue_PyFSlateIcon *)PyObject_New(ue_PyFSlateIcon, &ue_PyFSlateIconType); - ret->icon = slate_icon; - return ret; + ue_PyFSlateIcon *ret = (ue_PyFSlateIcon *)PyObject_New(ue_PyFSlateIcon, &ue_PyFSlateIconType); + ret->icon = slate_icon; + return ret; } -ue_PyFSlateIcon *py_ue_is_fslate_icon(PyObject *obj) { - if (!PyObject_IsInstance(obj, (PyObject *)&ue_PyFSlateIconType)) - return nullptr; - return (ue_PyFSlateIcon *)obj; +ue_PyFSlateIcon *py_ue_is_fslate_icon(PyObject *obj) +{ + if (!PyObject_IsInstance(obj, (PyObject *)&ue_PyFSlateIconType)) + return nullptr; + return (ue_PyFSlateIcon *)obj; } diff --git a/Source/UnrealEnginePython/Private/Slate/UEPyFSlateIcon.h b/Source/UnrealEnginePython/Private/Slate/UEPyFSlateIcon.h index b32b07af5..9df78f927 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPyFSlateIcon.h +++ b/Source/UnrealEnginePython/Private/Slate/UEPyFSlateIcon.h @@ -1,13 +1,14 @@ #pragma once -#include "UnrealEnginePython.h" +#include "UEPyModule.h" #include "Runtime/SlateCore/Public/Textures/SlateIcon.h" -typedef struct { +typedef struct +{ PyObject_HEAD - /* Type-specific fields go here. */ - FSlateIcon icon; + /* Type-specific fields go here. */ + FSlateIcon icon; } ue_PyFSlateIcon; void ue_python_init_fslate_icon(PyObject *); diff --git a/Source/UnrealEnginePython/Private/Slate/UEPyFSlateStyleSet.cpp b/Source/UnrealEnginePython/Private/Slate/UEPyFSlateStyleSet.cpp index 7f5e7e45e..5b9b40eb3 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPyFSlateStyleSet.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPyFSlateStyleSet.cpp @@ -1,8 +1,9 @@ -#include "UnrealEnginePythonPrivatePCH.h" #include "UEPyFSlateStyleSet.h" -#include "SlateTypes.h" -#include "Map.h" +#include "Runtime/SlateCore/Public/Styling/SlateTypes.h" +#include "Runtime/SlateCore/Public/Styling/SlateStyleRegistry.h" +#include "Runtime/SlateCore/Public/Sound/SlateSound.h" +#include "Runtime/Core/Public/Containers/Map.h" static PyObject *py_ue_fslate_style_set_set_content_root(ue_PyFSlateStyleSet *self, PyObject * args) { @@ -12,8 +13,7 @@ static PyObject *py_ue_fslate_style_set_set_content_root(ue_PyFSlateStyleSet *se self->style_set->SetContentRoot(path); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject *py_ue_fslate_style_set_register(ue_PyFSlateStyleSet *self, PyObject * args) @@ -89,123 +89,124 @@ static PyObject *py_ue_fslate_style_set_set(ue_PyFSlateStyleSet *self, PyObject return PyErr_Format(PyExc_ValueError, "unsupported value type"); } -namespace { - template - PyObject* pyGetWidgetStyle(FSlateStyleSet& InStyle, FName PropertyName) - { - const WidgetStyleType styleWidgetStyle = InStyle.GetWidgetStyle(PropertyName); - return py_ue_new_uscriptstruct(WidgetStyleType::StaticStruct(), (uint8*)&styleWidgetStyle); - } +namespace +{ + template + PyObject* pyGetWidgetStyle(FSlateStyleSet& InStyle, FName PropertyName) + { + const WidgetStyleType styleWidgetStyle = InStyle.GetWidgetStyle(PropertyName); + return py_ue_new_owned_uscriptstruct(WidgetStyleType::StaticStruct(), (uint8*)&styleWidgetStyle); + } } static PyObject *py_ue_fslate_style_set_get(ue_PyFSlateStyleSet *self, PyObject * args) { - if (!(self && self->style_set)) - return PyErr_Format(PyExc_Exception, "fstyleset is in invalid state"); + if (!(self && self->style_set)) + return PyErr_Format(PyExc_Exception, "fstyleset is in invalid state"); - char *name = nullptr; - PyObject *py_type = nullptr; + char *name = nullptr; + PyObject *py_type = nullptr; if (!PyArg_ParseTuple(args, "sO:get", &name, &py_type)) return NULL; - PyObject *ret = nullptr; + PyObject *ret = nullptr; if (ue_py_check_struct(py_type)) { - const FSlateSound& styleSound = self->style_set->GetSound(FName(name)); - ret = py_ue_new_uscriptstruct(FSlateSound::StaticStruct(), (uint8*)&styleSound); + const FSlateSound& styleSound = self->style_set->GetSound(FName(name)); + ret = py_ue_new_owned_uscriptstruct(FSlateSound::StaticStruct(), (uint8*)&styleSound); } else if (ue_py_check_struct(py_type)) { - if (const FSlateBrush* styleBrush = self->style_set->GetBrush(FName(name))) - { - ret = py_ue_new_uscriptstruct(FSlateBrush::StaticStruct(), (uint8*)styleBrush); - } + if (const FSlateBrush* styleBrush = self->style_set->GetBrush(FName(name))) + { + ret = py_ue_new_owned_uscriptstruct(FSlateBrush::StaticStruct(), (uint8*)styleBrush); + } } else if (ue_py_check_struct(py_type)) { - const FSlateColor styleSlateColor = self->style_set->GetSlateColor(FName(name)); - ret = py_ue_new_uscriptstruct(FSlateColor::StaticStruct(), (uint8*)&styleSlateColor); + const FSlateColor styleSlateColor = self->style_set->GetSlateColor(FName(name)); + ret = py_ue_new_owned_uscriptstruct(FSlateColor::StaticStruct(), (uint8*)&styleSlateColor); } - else if (ue_py_check_struct(py_type)) + else if (ue_py_check_struct(py_type)) { - const FSlateFontInfo styleFontInfo = self->style_set->GetFontStyle(FName(name)); - ret = py_ue_new_uscriptstruct(FSlateFontInfo::StaticStruct(), (uint8*)&styleFontInfo); + const FSlateFontInfo styleFontInfo = self->style_set->GetFontStyle(FName(name)); + ret = py_ue_new_owned_uscriptstruct(FSlateFontInfo::StaticStruct(), (uint8*)&styleFontInfo); } - else if (ue_py_check_childstruct(py_type)) - { + else if (ue_py_check_childstruct(py_type)) + { - typedef TFunction WStyleGetter; - typedef TPair WStylePair; + typedef TFunction WStyleGetter; + typedef TPair WStylePair; #if ENGINE_MINOR_VERSION > 15 - static const WStylePair validWidgetStyleUStructList[] = { - WStylePair{ FTextBlockStyle::StaticStruct() , WStyleGetter([](FSlateStyleSet& InStyle, FName InName) { return pyGetWidgetStyle (InStyle, InName); }) }, - WStylePair{ FButtonStyle::StaticStruct() , WStyleGetter([](FSlateStyleSet& InStyle, FName InName) { return pyGetWidgetStyle (InStyle, InName); }) }, - WStylePair{ FComboButtonStyle::StaticStruct() , WStyleGetter([](FSlateStyleSet& InStyle, FName InName) { return pyGetWidgetStyle (InStyle, InName); }) }, - WStylePair{ FComboBoxStyle::StaticStruct() , WStyleGetter([](FSlateStyleSet& InStyle, FName InName) { return pyGetWidgetStyle (InStyle, InName); }) }, - WStylePair{ FHyperlinkStyle::StaticStruct() , WStyleGetter([](FSlateStyleSet& InStyle, FName InName) { return pyGetWidgetStyle (InStyle, InName); }) }, - WStylePair{ FEditableTextStyle::StaticStruct() , WStyleGetter([](FSlateStyleSet& InStyle, FName InName) { return pyGetWidgetStyle (InStyle, InName); }) }, - WStylePair{ FScrollBarStyle::StaticStruct() , WStyleGetter([](FSlateStyleSet& InStyle, FName InName) { return pyGetWidgetStyle (InStyle, InName); }) }, - WStylePair{ FEditableTextBoxStyle::StaticStruct() , WStyleGetter([](FSlateStyleSet& InStyle, FName InName) { return pyGetWidgetStyle (InStyle, InName); }) }, - WStylePair{ FInlineEditableTextBlockStyle::StaticStruct(), WStyleGetter([](FSlateStyleSet& InStyle, FName InName) { return pyGetWidgetStyle(InStyle, InName); }) }, - WStylePair{ FProgressBarStyle::StaticStruct() , WStyleGetter([](FSlateStyleSet& InStyle, FName InName) { return pyGetWidgetStyle (InStyle, InName); }) }, - WStylePair{ FExpandableAreaStyle::StaticStruct() , WStyleGetter([](FSlateStyleSet& InStyle, FName InName) { return pyGetWidgetStyle (InStyle, InName); }) }, - WStylePair{ FSearchBoxStyle::StaticStruct() , WStyleGetter([](FSlateStyleSet& InStyle, FName InName) { return pyGetWidgetStyle (InStyle, InName); }) }, - WStylePair{ FSliderStyle::StaticStruct() , WStyleGetter([](FSlateStyleSet& InStyle, FName InName) { return pyGetWidgetStyle (InStyle, InName); }) }, - WStylePair{ FVolumeControlStyle::StaticStruct() , WStyleGetter([](FSlateStyleSet& InStyle, FName InName) { return pyGetWidgetStyle (InStyle, InName); }) }, - WStylePair{ FInlineTextImageStyle::StaticStruct() , WStyleGetter([](FSlateStyleSet& InStyle, FName InName) { return pyGetWidgetStyle (InStyle, InName); }) }, - WStylePair{ FSpinBoxStyle::StaticStruct() , WStyleGetter([](FSlateStyleSet& InStyle, FName InName) { return pyGetWidgetStyle (InStyle, InName); }) }, - WStylePair{ FSplitterStyle::StaticStruct() , WStyleGetter([](FSlateStyleSet& InStyle, FName InName) { return pyGetWidgetStyle (InStyle, InName); }) }, - WStylePair{ FTableRowStyle::StaticStruct() , WStyleGetter([](FSlateStyleSet& InStyle, FName InName) { return pyGetWidgetStyle (InStyle, InName); }) }, - WStylePair{ FTableColumnHeaderStyle::StaticStruct() , WStyleGetter([](FSlateStyleSet& InStyle, FName InName) { return pyGetWidgetStyle (InStyle, InName); }) }, - WStylePair{ FHeaderRowStyle::StaticStruct() , WStyleGetter([](FSlateStyleSet& InStyle, FName InName) { return pyGetWidgetStyle (InStyle, InName); }) }, - WStylePair{ FDockTabStyle::StaticStruct() , WStyleGetter([](FSlateStyleSet& InStyle, FName InName) { return pyGetWidgetStyle (InStyle, InName); }) }, - WStylePair{ FScrollBoxStyle::StaticStruct() , WStyleGetter([](FSlateStyleSet& InStyle, FName InName) { return pyGetWidgetStyle (InStyle, InName); }) }, - WStylePair{ FScrollBorderStyle::StaticStruct() , WStyleGetter([](FSlateStyleSet& InStyle, FName InName) { return pyGetWidgetStyle (InStyle, InName); }) }, - WStylePair{ FWindowStyle::StaticStruct() , WStyleGetter([](FSlateStyleSet& InStyle, FName InName) { return pyGetWidgetStyle (InStyle, InName); }) }, - }; - - - for(WStylePair widgetStyleUStruct : validWidgetStyleUStructList) - { - if (do_ue_py_check_struct(py_type, widgetStyleUStruct.Key)) - { - ret = widgetStyleUStruct.Value(*self->style_set, FName(name)); - break; - } - } + static const WStylePair validWidgetStyleUStructList[] = { + WStylePair{ FTextBlockStyle::StaticStruct() , WStyleGetter([](FSlateStyleSet& InStyle, FName InName) { return pyGetWidgetStyle(InStyle, InName); }) }, + WStylePair{ FButtonStyle::StaticStruct() , WStyleGetter([](FSlateStyleSet& InStyle, FName InName) { return pyGetWidgetStyle(InStyle, InName); }) }, + WStylePair{ FComboButtonStyle::StaticStruct() , WStyleGetter([](FSlateStyleSet& InStyle, FName InName) { return pyGetWidgetStyle(InStyle, InName); }) }, + WStylePair{ FComboBoxStyle::StaticStruct() , WStyleGetter([](FSlateStyleSet& InStyle, FName InName) { return pyGetWidgetStyle(InStyle, InName); }) }, + WStylePair{ FHyperlinkStyle::StaticStruct() , WStyleGetter([](FSlateStyleSet& InStyle, FName InName) { return pyGetWidgetStyle(InStyle, InName); }) }, + WStylePair{ FEditableTextStyle::StaticStruct() , WStyleGetter([](FSlateStyleSet& InStyle, FName InName) { return pyGetWidgetStyle(InStyle, InName); }) }, + WStylePair{ FScrollBarStyle::StaticStruct() , WStyleGetter([](FSlateStyleSet& InStyle, FName InName) { return pyGetWidgetStyle(InStyle, InName); }) }, + WStylePair{ FEditableTextBoxStyle::StaticStruct() , WStyleGetter([](FSlateStyleSet& InStyle, FName InName) { return pyGetWidgetStyle(InStyle, InName); }) }, + WStylePair{ FInlineEditableTextBlockStyle::StaticStruct(), WStyleGetter([](FSlateStyleSet& InStyle, FName InName) { return pyGetWidgetStyle(InStyle, InName); }) }, + WStylePair{ FProgressBarStyle::StaticStruct() , WStyleGetter([](FSlateStyleSet& InStyle, FName InName) { return pyGetWidgetStyle(InStyle, InName); }) }, + WStylePair{ FExpandableAreaStyle::StaticStruct() , WStyleGetter([](FSlateStyleSet& InStyle, FName InName) { return pyGetWidgetStyle(InStyle, InName); }) }, + WStylePair{ FSearchBoxStyle::StaticStruct() , WStyleGetter([](FSlateStyleSet& InStyle, FName InName) { return pyGetWidgetStyle(InStyle, InName); }) }, + WStylePair{ FSliderStyle::StaticStruct() , WStyleGetter([](FSlateStyleSet& InStyle, FName InName) { return pyGetWidgetStyle(InStyle, InName); }) }, + WStylePair{ FVolumeControlStyle::StaticStruct() , WStyleGetter([](FSlateStyleSet& InStyle, FName InName) { return pyGetWidgetStyle(InStyle, InName); }) }, + WStylePair{ FInlineTextImageStyle::StaticStruct() , WStyleGetter([](FSlateStyleSet& InStyle, FName InName) { return pyGetWidgetStyle(InStyle, InName); }) }, + WStylePair{ FSpinBoxStyle::StaticStruct() , WStyleGetter([](FSlateStyleSet& InStyle, FName InName) { return pyGetWidgetStyle(InStyle, InName); }) }, + WStylePair{ FSplitterStyle::StaticStruct() , WStyleGetter([](FSlateStyleSet& InStyle, FName InName) { return pyGetWidgetStyle(InStyle, InName); }) }, + WStylePair{ FTableRowStyle::StaticStruct() , WStyleGetter([](FSlateStyleSet& InStyle, FName InName) { return pyGetWidgetStyle(InStyle, InName); }) }, + WStylePair{ FTableColumnHeaderStyle::StaticStruct() , WStyleGetter([](FSlateStyleSet& InStyle, FName InName) { return pyGetWidgetStyle(InStyle, InName); }) }, + WStylePair{ FHeaderRowStyle::StaticStruct() , WStyleGetter([](FSlateStyleSet& InStyle, FName InName) { return pyGetWidgetStyle(InStyle, InName); }) }, + WStylePair{ FDockTabStyle::StaticStruct() , WStyleGetter([](FSlateStyleSet& InStyle, FName InName) { return pyGetWidgetStyle(InStyle, InName); }) }, + WStylePair{ FScrollBoxStyle::StaticStruct() , WStyleGetter([](FSlateStyleSet& InStyle, FName InName) { return pyGetWidgetStyle(InStyle, InName); }) }, + WStylePair{ FScrollBorderStyle::StaticStruct() , WStyleGetter([](FSlateStyleSet& InStyle, FName InName) { return pyGetWidgetStyle(InStyle, InName); }) }, + WStylePair{ FWindowStyle::StaticStruct() , WStyleGetter([](FSlateStyleSet& InStyle, FName InName) { return pyGetWidgetStyle(InStyle, InName); }) }, + }; + + + for (WStylePair widgetStyleUStruct : validWidgetStyleUStructList) + { + if (do_ue_py_check_struct(py_type, widgetStyleUStruct.Key)) + { + ret = widgetStyleUStruct.Value(*self->style_set, FName(name)); + break; + } + } #endif - - if (!ret) - { - return PyErr_Format(PyExc_ValueError, "Unsupported FSlateWidgetStyle type. Add it manually."); - } - } - else if (py_ue_is_flinearcolor(py_type)) + + if (!ret) + { + return PyErr_Format(PyExc_ValueError, "Unsupported FSlateWidgetStyle type. Add it manually."); + } + } + else if (py_ue_is_flinearcolor(py_type)) + { + ret = py_ue_new_flinearcolor(self->style_set->GetColor(FName(name))); + } + else if (PyNumber_Check(py_type)) { - ret = py_ue_new_flinearcolor(self->style_set->GetColor(FName(name))); + ret = PyFloat_FromDouble(self->style_set->GetFloat(FName(name))); } - else if (PyNumber_Check(py_type)) + else { - ret = PyFloat_FromDouble(self->style_set->GetFloat(FName(name))); + return PyErr_Format(PyExc_ValueError, "unsupported value type"); } - else - { - return PyErr_Format(PyExc_ValueError, "unsupported value type"); - } - if (!ret) - return PyErr_Format(PyExc_Exception, "Retrieved style object is in invalid state"); + if (!ret) + return PyErr_Format(PyExc_Exception, "Retrieved style object is in invalid state"); - return ret; + return ret; } static PyMethodDef ue_PyFSlateStyleSet_methods[] = { { "set_content_root", (PyCFunction)py_ue_fslate_style_set_set_content_root, METH_VARARGS, "" }, { "set", (PyCFunction)py_ue_fslate_style_set_set, METH_VARARGS, "" }, - { "get", (PyCFunction)py_ue_fslate_style_set_get, METH_VARARGS, "" }, + { "get", (PyCFunction)py_ue_fslate_style_set_get, METH_VARARGS, "" }, { "register", (PyCFunction)py_ue_fslate_style_set_register, METH_VARARGS, "" }, { NULL } /* Sentinel */ }; @@ -255,16 +256,16 @@ static int ue_py_fslate_style_set_init(ue_PyFSlateStyleSet *self, PyObject *args { return -1; } - //TODO: roberto: ikrimae- I think this leaks? How is FSlateIcon destroyed ever? + //TODO: roberto: ikrimae- I think this leaks? How is FSlateIcon destroyed ever? self->style_set = new FSlateStyleSet(name); return 0; } ue_PyFSlateStyleSet* py_ue_new_fslate_style_set(FSlateStyleSet* styleSet) { - ue_PyFSlateStyleSet *ret = (ue_PyFSlateStyleSet *)PyObject_New(ue_PyFSlateStyleSet, &ue_PyFSlateStyleSetType); - ret->style_set = styleSet; - return ret; + ue_PyFSlateStyleSet *ret = (ue_PyFSlateStyleSet *)PyObject_New(ue_PyFSlateStyleSet, &ue_PyFSlateStyleSetType); + ret->style_set = styleSet; + return ret; } void ue_python_init_fslate_style_set(PyObject *ue_module) diff --git a/Source/UnrealEnginePython/Private/Slate/UEPyFSlateStyleSet.h b/Source/UnrealEnginePython/Private/Slate/UEPyFSlateStyleSet.h index 58ffe57fd..feb3abaa5 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPyFSlateStyleSet.h +++ b/Source/UnrealEnginePython/Private/Slate/UEPyFSlateStyleSet.h @@ -1,11 +1,14 @@ #pragma once -#include "UnrealEnginePython.h" +#include "UEPySlate.h" +#include "Wrappers/UEPyFColor.h" +#include "Wrappers/UEPyFLinearColor.h" -typedef struct { +typedef struct +{ PyObject_HEAD - /* Type-specific fields go here. */ - FSlateStyleSet *style_set; + /* Type-specific fields go here. */ + FSlateStyleSet *style_set; } ue_PyFSlateStyleSet; ue_PyFSlateStyleSet* py_ue_new_fslate_style_set(FSlateStyleSet* styleSet); diff --git a/Source/UnrealEnginePython/Private/Slate/UEPyFTabManager.cpp b/Source/UnrealEnginePython/Private/Slate/UEPyFTabManager.cpp index 4949239de..6afa81fca 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPyFTabManager.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPyFTabManager.cpp @@ -1,5 +1,3 @@ -#include "UnrealEnginePythonPrivatePCH.h" - #include "UEPyFTabManager.h" @@ -46,7 +44,8 @@ static PyTypeObject ue_PyFTabManagerType = { }; -void ue_python_init_ftab_manager(PyObject *ue_module) { +void ue_python_init_ftab_manager(PyObject *ue_module) +{ ue_PyFTabManagerType.tp_new = PyType_GenericNew; if (PyType_Ready(&ue_PyFTabManagerType) < 0) @@ -56,7 +55,8 @@ void ue_python_init_ftab_manager(PyObject *ue_module) { PyModule_AddObject(ue_module, "FTabManager", (PyObject *)&ue_PyFTabManagerType); } -PyObject *py_ue_new_ftab_manager(TSharedRef tab_manager) { +PyObject *py_ue_new_ftab_manager(TSharedRef tab_manager) +{ ue_PyFTabManager *ret = (ue_PyFTabManager *)PyObject_New(ue_PyFTabManager, &ue_PyFTabManagerType); new(&ret->tab_manager) TSharedRef(tab_manager); return (PyObject *)ret; diff --git a/Source/UnrealEnginePython/Private/Slate/UEPyFTabManager.h b/Source/UnrealEnginePython/Private/Slate/UEPyFTabManager.h index 66890ebe4..5221910de 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPyFTabManager.h +++ b/Source/UnrealEnginePython/Private/Slate/UEPyFTabManager.h @@ -1,13 +1,14 @@ #pragma once -#include "UnrealEnginePython.h" +#include "UEPyModule.h" #include "Runtime/Slate/Public/Framework/Docking/TabManager.h" -typedef struct { +typedef struct +{ PyObject_HEAD - /* Type-specific fields go here. */ - TSharedRef tab_manager; + /* Type-specific fields go here. */ + TSharedRef tab_manager; } ue_PyFTabManager; PyObject *py_ue_new_ftab_manager(TSharedRef); diff --git a/Source/UnrealEnginePython/Private/Slate/UEPyFTabSpawnerEntry.cpp b/Source/UnrealEnginePython/Private/Slate/UEPyFTabSpawnerEntry.cpp index 71022af3f..bcf3d7438 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPyFTabSpawnerEntry.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPyFTabSpawnerEntry.cpp @@ -1,9 +1,8 @@ -#include "UnrealEnginePythonPrivatePCH.h" - #include "UEPyFTabSpawnerEntry.h" -static PyObject *py_ue_ftab_spawner_entry_set_display_name(ue_PyFTabSpawnerEntry *self, PyObject * args) { +static PyObject *py_ue_ftab_spawner_entry_set_display_name(ue_PyFTabSpawnerEntry *self, PyObject * args) +{ char *name; if (!PyArg_ParseTuple(args, "s:set_display_name", &name)) return NULL; @@ -14,7 +13,8 @@ static PyObject *py_ue_ftab_spawner_entry_set_display_name(ue_PyFTabSpawnerEntry return (PyObject *)self; } -static PyObject *py_ue_ftab_spawner_entry_set_tooltip_text(ue_PyFTabSpawnerEntry *self, PyObject * args) { +static PyObject *py_ue_ftab_spawner_entry_set_tooltip_text(ue_PyFTabSpawnerEntry *self, PyObject * args) +{ char *tooltip; if (!PyArg_ParseTuple(args, "s:set_tooltip_text", &tooltip)) return NULL; @@ -36,8 +36,8 @@ static PyMethodDef ue_PyFTabSpawnerEntry_methods[] = { static PyObject *ue_PyFTabSpawnerEntry_str(ue_PyFTabSpawnerEntry *self) { - return PyUnicode_FromFormat("", - PyUnicode_FromString(TCHAR_TO_UTF8(*self->spawner_entry->GetDisplayName().ToString()))); + return PyUnicode_FromFormat("", + TCHAR_TO_UTF8(*self->spawner_entry->GetDisplayName().ToString())); } static PyTypeObject ue_PyFTabSpawnerEntryType = { @@ -72,7 +72,8 @@ static PyTypeObject ue_PyFTabSpawnerEntryType = { }; -void ue_python_init_ftab_spawner_entry(PyObject *ue_module) { +void ue_python_init_ftab_spawner_entry(PyObject *ue_module) +{ ue_PyFTabSpawnerEntryType.tp_new = PyType_GenericNew; if (PyType_Ready(&ue_PyFTabSpawnerEntryType) < 0) @@ -82,7 +83,8 @@ void ue_python_init_ftab_spawner_entry(PyObject *ue_module) { PyModule_AddObject(ue_module, "FTabSpawnerEntry", (PyObject *)&ue_PyFTabSpawnerEntryType); } -PyObject *py_ue_new_ftab_spawner_entry(FTabSpawnerEntry *spawner_entry) { +PyObject *py_ue_new_ftab_spawner_entry(FTabSpawnerEntry *spawner_entry) +{ ue_PyFTabSpawnerEntry *ret = (ue_PyFTabSpawnerEntry *)PyObject_New(ue_PyFTabSpawnerEntry, &ue_PyFTabSpawnerEntryType); ret->spawner_entry = spawner_entry; return (PyObject *)ret; diff --git a/Source/UnrealEnginePython/Private/Slate/UEPyFToolBarBuilder.cpp b/Source/UnrealEnginePython/Private/Slate/UEPyFToolBarBuilder.cpp index 8a5fe212f..18c52faf4 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPyFToolBarBuilder.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPyFToolBarBuilder.cpp @@ -1,7 +1,6 @@ -#include "UnrealEnginePythonPrivatePCH.h" - #include "UEPyFToolBarBuilder.h" +#include "UEPyFSlateIcon.h" #include "Runtime/Slate/Public/Framework/Commands/UIAction.h" static PyObject *py_ue_ftool_bar_builder_begin_section(ue_PyFToolBarBuilder *self, PyObject * args) @@ -12,16 +11,14 @@ static PyObject *py_ue_ftool_bar_builder_begin_section(ue_PyFToolBarBuilder *sel self->tool_bar_builder.BeginSection(FName(name)); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject *py_ue_ftool_bar_builder_end_section(ue_PyFToolBarBuilder *self, PyObject * args) { self->tool_bar_builder.EndSection(); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject *py_ue_ftool_bar_builder_add_tool_bar_button(ue_PyFToolBarBuilder *self, PyObject * args) @@ -41,7 +38,7 @@ static PyObject *py_ue_ftool_bar_builder_add_tool_bar_button(ue_PyFToolBarBuilde return PyErr_Format(PyExc_Exception, "argument is not a FSlateIcon"); } - if (!PyCalllable_Check_Extended(py_callable)) + if (!PyCallable_Check(py_callable)) { return PyErr_Format(PyExc_Exception, "argument is not callable"); } @@ -61,8 +58,7 @@ static PyObject *py_ue_ftool_bar_builder_add_tool_bar_button(ue_PyFToolBarBuilde self->tool_bar_builder.AddToolBarButton(FUIAction(handler), FName(hook), FText::FromString(UTF8_TO_TCHAR(label)), FText::FromString(UTF8_TO_TCHAR(tooltip)), py_slate_icon->icon); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject *py_ue_ftool_bar_builder_add_separator(ue_PyFToolBarBuilder *self, PyObject * args) @@ -79,8 +75,7 @@ static PyObject *py_ue_ftool_bar_builder_add_separator(ue_PyFToolBarBuilder *sel self->tool_bar_builder.AddSeparator(f_name); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } @@ -88,24 +83,19 @@ static PyObject *py_ue_ftool_bar_builder_begin_block_group(ue_PyFToolBarBuilder { self->tool_bar_builder.BeginBlockGroup(); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject *py_ue_ftool_bar_builder_end_block_group(ue_PyFToolBarBuilder *self, PyObject * args) { self->tool_bar_builder.EndBlockGroup(); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject *py_ue_ftool_bar_builder_make_widget(ue_PyFToolBarBuilder *self, PyObject * args) { - ue_PySWidget *ret = (ue_PySWidget *)PyObject_New(ue_PySWidget, &ue_PySWidgetType); - ue_py_setup_swidget(ret); - ret->s_widget = self->tool_bar_builder.MakeWidget(); - return (PyObject *)ret; + return (PyObject *)py_ue_new_swidget(self->tool_bar_builder.MakeWidget(), &ue_PySWidgetType); } static PyMethodDef ue_PyFToolBarBuilder_methods[] = { diff --git a/Source/UnrealEnginePython/Private/Slate/UEPyFToolBarBuilder.h b/Source/UnrealEnginePython/Private/Slate/UEPyFToolBarBuilder.h index 992798517..56f8870a6 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPyFToolBarBuilder.h +++ b/Source/UnrealEnginePython/Private/Slate/UEPyFToolBarBuilder.h @@ -1,13 +1,14 @@ #pragma once -#include "UnrealEnginePython.h" +#include "UEPySlate.h" #include "Runtime/Slate/Public/Framework/MultiBox/MultiBoxBuilder.h" -typedef struct { +typedef struct +{ PyObject_HEAD - /* Type-specific fields go here. */ - FToolBarBuilder tool_bar_builder; + /* Type-specific fields go here. */ + FToolBarBuilder tool_bar_builder; } ue_PyFToolBarBuilder; void ue_python_init_ftool_bar_builder(PyObject *); diff --git a/Source/UnrealEnginePython/Private/Slate/UEPyIDetailsView.cpp b/Source/UnrealEnginePython/Private/Slate/UEPyIDetailsView.cpp index 3fb5f2c1c..32e8a1f09 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPyIDetailsView.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPyIDetailsView.cpp @@ -1,47 +1,47 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPyIDetailsView.h" #if WITH_EDITOR #include "Editor/PropertyEditor/Public/IDetailsView.h" -#include "UEPyIDetailsView.h" -#define sw_idetails_view StaticCastSharedRef(self->s_compound_widget.s_widget.s_widget) static PyObject *py_ue_idetails_view_set_object(ue_PyIDetailsView *self, PyObject * args, PyObject *kwargs) { - PyObject *py_in_obj = nullptr; - PyObject *py_force_refresh = nullptr; + ue_py_slate_cast(IDetailsView); + + PyObject *py_in_obj = nullptr; + PyObject *py_force_refresh = nullptr; - char *kwlist[] = { - (char *)"uobject", - (char *)"force_refresh", - nullptr - }; + char *kwlist[] = { + (char *)"uobject", + (char *)"force_refresh", + nullptr + }; - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|O:set_object", kwlist, &py_in_obj, &py_force_refresh)) - { - return nullptr; - } + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|O:set_object", kwlist, &py_in_obj, &py_force_refresh)) + { + return nullptr; + } - UObject *u_object = ue_py_check_type(py_in_obj); - if (!u_object) - { - return PyErr_Format(PyExc_Exception, "argument is not a UObject"); - } + UObject *u_object = ue_py_check_type(py_in_obj); + if (!u_object) + { + return PyErr_Format(PyExc_Exception, "argument is not a UObject"); + } - const bool bForceRefresh = py_force_refresh && PyObject_IsTrue(py_force_refresh); + const bool bForceRefresh = py_force_refresh && PyObject_IsTrue(py_force_refresh); - sw_idetails_view->SetObject(u_object, bForceRefresh); + py_IDetailsView->SetObject(u_object, bForceRefresh); - Py_RETURN_NONE; + Py_RETURN_NONE; } static PyMethodDef ue_PyIDetailsView_methods[] = { #pragma warning(suppress: 4191) - { "set_object", (PyCFunction)py_ue_idetails_view_set_object, METH_VARARGS | METH_KEYWORDS, "" }, + { "set_object", (PyCFunction)py_ue_idetails_view_set_object, METH_VARARGS | METH_KEYWORDS, "" }, { NULL } /* Sentinel */ }; @@ -73,24 +73,24 @@ PyTypeObject ue_PyIDetailsViewType = { 0, /* tp_weaklistoffset */ 0, /* tp_iter */ 0, /* tp_iternext */ - ue_PyIDetailsView_methods, /* tp_methods */ + ue_PyIDetailsView_methods, /* tp_methods */ }; void ue_python_init_idetails_view(PyObject *ue_module) { - ue_PyIDetailsViewType.tp_base = &ue_PySCompoundWidgetType; + ue_PyIDetailsViewType.tp_base = &ue_PySCompoundWidgetType; - if (PyType_Ready(&ue_PyIDetailsViewType) < 0) - return; + if (PyType_Ready(&ue_PyIDetailsViewType) < 0) + return; - Py_INCREF(&ue_PyIDetailsViewType); - PyModule_AddObject(ue_module, "IDetailsView", (PyObject *)&ue_PyIDetailsViewType); + Py_INCREF(&ue_PyIDetailsViewType); + PyModule_AddObject(ue_module, "IDetailsView", (PyObject *)&ue_PyIDetailsViewType); } ue_PyIDetailsView *py_ue_is_idetails_view(PyObject *obj) { - if (!PyObject_IsInstance(obj, (PyObject *)&ue_PyIDetailsViewType)) - return nullptr; - return (ue_PyIDetailsView *)obj; + if (!PyObject_IsInstance(obj, (PyObject *)&ue_PyIDetailsViewType)) + return nullptr; + return (ue_PyIDetailsView *)obj; } #endif \ No newline at end of file diff --git a/Source/UnrealEnginePython/Private/Slate/UEPyIStructureDetailsView.cpp b/Source/UnrealEnginePython/Private/Slate/UEPyIStructureDetailsView.cpp index dea026a94..be76f8f1b 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPyIStructureDetailsView.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPyIStructureDetailsView.cpp @@ -1,12 +1,12 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPyIStructureDetailsView.h" #if WITH_EDITOR -#include "UEPyIStructureDetailsView.h" -#include "IStructureDetailsView.h" -//#define sw_idetails_view StaticCastSharedRef(self->s_compound_widget.s_widget.s_widget) +#include "Editor/PropertyEditor/Public/PropertyEditorModule.h" +#include "UEPySWidget.h" +#include "Editor/PropertyEditor/Public/IDetailsView.h" static PyObject *ue_PyIStructureDetailsView_str(ue_PyIStructureDetailsView *self) @@ -52,7 +52,7 @@ static PyObject *py_ue_istructure_details_view_set_structure_data(ue_PyIStructur Py_XDECREF(self->ue_py_struct); self->ue_py_struct = ue_py_struct; Py_INCREF(self->ue_py_struct); - TSharedPtr struct_scope = MakeShared(ue_py_struct->u_struct, ue_py_struct->data); + TSharedPtr struct_scope = MakeShared(ue_py_struct->u_struct, ue_py_struct->u_struct_ptr); FPropertyEditorModule& PropertyEditorModule = FModuleManager::GetModuleChecked("PropertyEditor"); self->istructure_details_view->SetStructureData(struct_scope); @@ -60,7 +60,7 @@ static PyObject *py_ue_istructure_details_view_set_structure_data(ue_PyIStructur if (py_force_refresh && PyObject_IsTrue(py_force_refresh)) { self->istructure_details_view->GetDetailsView()->ForceRefresh(); - } +} #endif Py_RETURN_NONE; @@ -68,10 +68,6 @@ static PyObject *py_ue_istructure_details_view_set_structure_data(ue_PyIStructur static PyObject *py_ue_istructure_details_view_get_widget(ue_PyIStructureDetailsView *self, PyObject * args) { - if (!self->istructure_details_view.IsValid()) - { - return PyErr_Format(PyExc_Exception, "IStructureDetailsView is not valid"); - } TSharedPtr ret_widget = self->istructure_details_view->GetWidget(); if (!ret_widget.IsValid()) @@ -192,9 +188,9 @@ static int ue_py_istructure_details_view_init(ue_PyIStructureDetailsView *self, self->ue_py_struct = ue_py_struct; Py_INCREF(self->ue_py_struct); - TSharedPtr struct_scope = MakeShared(ue_py_struct->u_struct, ue_py_struct->data); + TSharedPtr struct_scope = MakeShared(ue_py_struct->u_struct, ue_py_struct->u_struct_ptr); FPropertyEditorModule& PropertyEditorModule = FModuleManager::GetModuleChecked("PropertyEditor"); - self->istructure_details_view = PropertyEditorModule.CreateStructureDetailView(view_args, struct_view_args, struct_scope); + new(&self->istructure_details_view) TSharedRef(PropertyEditorModule.CreateStructureDetailView(view_args, struct_view_args, struct_scope)); return 0; } diff --git a/Source/UnrealEnginePython/Private/Slate/UEPyIStructureDetailsView.h b/Source/UnrealEnginePython/Private/Slate/UEPyIStructureDetailsView.h index 54db231bf..c7f80939c 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPyIStructureDetailsView.h +++ b/Source/UnrealEnginePython/Private/Slate/UEPyIStructureDetailsView.h @@ -1,13 +1,18 @@ #pragma once -#include "UnrealEnginePython.h" +#include "UEPyModule.h" + #if WITH_EDITOR -typedef struct { + +#include "IStructureDetailsView.h" + +typedef struct +{ PyObject_HEAD - /* Type-specific fields go here. */ - TSharedPtr istructure_details_view; - ue_PyUScriptStruct *ue_py_struct; + /* Type-specific fields go here. */ + TSharedRef istructure_details_view; + ue_PyUScriptStruct *ue_py_struct; } ue_PyIStructureDetailsView; void ue_python_init_istructure_details_view(PyObject *); diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySAssetDropTarget.cpp b/Source/UnrealEnginePython/Private/Slate/UEPySAssetDropTarget.cpp index a3cc0df61..ce0cf7712 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySAssetDropTarget.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPySAssetDropTarget.cpp @@ -1,9 +1,6 @@ -#if WITH_EDITOR -#include "UnrealEnginePythonPrivatePCH.h" - #include "UEPySAssetDropTarget.h" -#define sw_asset_drop_target StaticCastSharedRef(self->s_drop_target.s_compound_widget.s_widget.s_widget) +#if WITH_EDITOR static PyMethodDef ue_PySAssetDropTarget_methods[] = { @@ -41,14 +38,16 @@ PyTypeObject ue_PySAssetDropTargetType = { ue_PySAssetDropTarget_methods, /* tp_methods */ }; -static int ue_py_sasset_drop_target_init(ue_PySAssetDropTarget *self, PyObject *args, PyObject *kwargs) { +static int ue_py_sasset_drop_target_init(ue_PySAssetDropTarget *self, PyObject *args, PyObject *kwargs) +{ ue_py_slate_setup_farguments(SAssetDropTarget); - ue_py_snew(SAssetDropTarget, s_drop_target.s_compound_widget.s_widget); + ue_py_snew(SAssetDropTarget); return 0; } -void ue_python_init_sasset_drop_target(PyObject *ue_module) { +void ue_python_init_sasset_drop_target(PyObject *ue_module) +{ ue_PySAssetDropTargetType.tp_init = (initproc)ue_py_sasset_drop_target_init; diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySAssetDropTarget.h b/Source/UnrealEnginePython/Private/Slate/UEPySAssetDropTarget.h index 83b4fd83c..134b69549 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySAssetDropTarget.h +++ b/Source/UnrealEnginePython/Private/Slate/UEPySAssetDropTarget.h @@ -1,10 +1,9 @@ #pragma once -#include "UnrealEnginePython.h" - - #include "UEPySDropTarget.h" +#if WITH_EDITOR + #include "Editor/EditorWidgets/Public/SAssetDropTarget.h" extern PyTypeObject ue_PySAssetDropTargetType; @@ -15,3 +14,4 @@ typedef struct { } ue_PySAssetDropTarget; void ue_python_init_sasset_drop_target(PyObject *); +#endif diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySBorder.cpp b/Source/UnrealEnginePython/Private/Slate/UEPySBorder.cpp index 198307ed5..b2a8e4d0f 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySBorder.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPySBorder.cpp @@ -1,49 +1,42 @@ -#include "UnrealEnginePythonPrivatePCH.h" - #include "UEPySBorder.h" -#define sw_border StaticCastSharedRef(self->s_compound_widget.s_widget.s_widget) - static PyObject *py_ue_sborder_clear_content(ue_PySBorder *self, PyObject * args) { - - sw_border->ClearContent(); + ue_py_slate_cast(SBorder); + py_SBorder->ClearContent(); Py_RETURN_NONE; } static PyObject *py_ue_sborder_set_content(ue_PySBorder *self, PyObject * args) { + ue_py_slate_cast(SBorder); + PyObject *py_content; if (!PyArg_ParseTuple(args, "O:set_content", &py_content)) { - return NULL; - } - - ue_PySWidget *py_swidget = py_ue_is_swidget(py_content); - if (!py_swidget) - { - return PyErr_Format(PyExc_Exception, "argument is not a SWidget"); + return nullptr; } + TSharedPtr child = py_ue_is_swidget(py_content); + if (!child.IsValid()) + return nullptr; - Py_INCREF(py_swidget); - + py_SBorder->SetContent(child.ToSharedRef()); - sw_border->SetContent(py_swidget->s_widget->AsShared()); - - Py_INCREF(self); - return (PyObject *)self; + Py_RETURN_SLATE_SELF; } static PyObject *py_ue_sborder_set_padding(ue_PySBorder *self, PyObject * args) { + ue_py_slate_cast(SBorder); + PyObject *py_padding; if (!PyArg_ParseTuple(args, "O:set_padding", &py_padding)) { - return NULL; + return nullptr; } FMargin *margin = ue_py_check_struct(py_padding); @@ -59,42 +52,42 @@ static PyObject *py_ue_sborder_set_padding(ue_PySBorder *self, PyObject * args) Py_DECREF(py_float); } - sw_border->SetPadding(*margin); + py_SBorder->SetPadding(*margin); - Py_INCREF(self); - return (PyObject *)self; + Py_RETURN_SLATE_SELF; } static PyObject *py_ue_sborder_set_h_align(ue_PySBorder *self, PyObject * args) { + ue_py_slate_cast(SBorder); int align; if (!PyArg_ParseTuple(args, "i:set_h_align", &align)) { - return NULL; + return nullptr; } - sw_border->SetHAlign((EHorizontalAlignment)align); + py_SBorder->SetHAlign((EHorizontalAlignment)align); - Py_INCREF(self); - return (PyObject *)self; + Py_RETURN_SLATE_SELF; } static PyObject *py_ue_sborder_set_v_align(ue_PySBorder *self, PyObject * args) { + ue_py_slate_cast(SBorder); int align; if (!PyArg_ParseTuple(args, "i:set_v_align", &align)) { - return NULL; + return nullptr; } - sw_border->SetVAlign((EVerticalAlignment)align); + py_SBorder->SetVAlign((EVerticalAlignment)align); - Py_INCREF(self); - return (PyObject *)self; + Py_RETURN_SLATE_SELF; } static PyObject *py_ue_sborder_set_border_image(ue_PySBorder *self, PyObject * args) { + ue_py_slate_cast(SBorder); PyObject *py_brush; if (!PyArg_ParseTuple(args, "O:set_border_image", &py_brush)) { @@ -105,10 +98,9 @@ static PyObject *py_ue_sborder_set_border_image(ue_PySBorder *self, PyObject * a if (!brush) return PyErr_Format(PyExc_Exception, "argument is not a FSlateBrush"); - sw_border->SetBorderImage(brush); + py_SBorder->SetBorderImage(brush); - Py_INCREF(self); - return (PyObject *)self; + Py_RETURN_SLATE_SELF; } static PyMethodDef ue_PySBorder_methods[] = { @@ -161,11 +153,11 @@ static int ue_py_sborder_init(ue_PySBorder *self, PyObject *args, PyObject *kwar ue_py_slate_farguments_optional_struct_ptr("border_image", BorderImage, FSlateBrush); ue_py_slate_farguments_optional_enum("h_align", HAlign, EHorizontalAlignment); ue_py_slate_farguments_optional_enum("v_align", VAlign, EVerticalAlignment); - ue_py_slate_farguments_struct("padding", Padding, FMargin); + ue_py_slate_farguments_padding("padding", Padding); ue_py_slate_farguments_struct("foreground_color", ForegroundColor, FSlateColor); ue_py_slate_farguments_fvector2d("content_scale", ContentScale); ue_py_slate_farguments_fvector2d("desired_size_scale", DesiredSizeScale); - ue_py_snew(SBorder, s_compound_widget.s_widget); + ue_py_snew(SBorder); return 0; } diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySBox.cpp b/Source/UnrealEnginePython/Private/Slate/UEPySBox.cpp index a64b6946d..1aa250e0e 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySBox.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPySBox.cpp @@ -1,35 +1,61 @@ -#include "UnrealEnginePythonPrivatePCH.h" #include "UEPySBox.h" - -#define sw_box StaticCastSharedRef(self->s_panel.s_widget.s_widget) - static PyObject *py_ue_sbox_set_content(ue_PySBox *self, PyObject * args) { + ue_py_slate_cast(SBox); PyObject *py_content; if (!PyArg_ParseTuple(args, "O:set_content", &py_content)) { return NULL; } - ue_PySWidget *py_swidget = py_ue_is_swidget(py_content); - if (!py_swidget) + TSharedPtr child = py_ue_is_swidget(py_content); + if (!child.IsValid()) + return nullptr; + + py_SBox->SetContent(child.ToSharedRef()); + + Py_RETURN_SLATE_SELF; +} + +static PyObject *py_ue_sbox_set_height_override(ue_PySBox *self, PyObject * args) +{ + ue_py_slate_cast(SBox); + + float height_override = 0; + if (!PyArg_ParseTuple(args, "f:set_height_override", &height_override)) { - return PyErr_Format(PyExc_Exception, "argument is not a SWidget"); + return NULL; } - Py_INCREF(py_swidget); + if (height_override != 0) + py_SBox->SetHeightOverride(height_override); + + Py_RETURN_NONE; +} + +static PyObject *py_ue_sbox_set_width_override(ue_PySBox *self, PyObject * args) +{ + ue_py_slate_cast(SBox); + + float width_override = 0; + if (!PyArg_ParseTuple(args, "f:set_width_override", &width_override)) + { + return NULL; + } - sw_box->SetContent(py_swidget->s_widget->AsShared()); + if (width_override != 0) + py_SBox->SetWidthOverride(width_override); - Py_INCREF(self); - return (PyObject *)self; + Py_RETURN_NONE; } static PyMethodDef ue_PySBox_methods[] = { { "set_content", (PyCFunction)py_ue_sbox_set_content, METH_VARARGS, "" }, + { "set_height_override", (PyCFunction)py_ue_sbox_set_height_override, METH_VARARGS, "" }, + { "set_width_override", (PyCFunction)py_ue_sbox_set_width_override, METH_VARARGS, "" }, { NULL } /* Sentinel */ }; @@ -73,6 +99,7 @@ static int ue_py_sbox_init(ue_PySBox *self, PyObject *args, PyObject *kwargs) ue_py_slate_farguments_optional_enum("v_align", VAlign, EVerticalAlignment); ue_py_slate_farguments_struct("padding", Padding, FMargin); ue_py_slate_farguments_optional_foptional_size("height_override", HeightOverride); + ue_py_slate_farguments_optional_foptional_size("width_override", WidthOverride); #if ENGINE_MINOR_VERSION > 12 ue_py_slate_farguments_optional_foptional_size("max_aspect_ratio", MaxAspectRatio); #endif @@ -81,7 +108,7 @@ static int ue_py_sbox_init(ue_PySBox *self, PyObject *args, PyObject *kwargs) ue_py_slate_farguments_optional_foptional_size("min_desired_height", MinDesiredHeight); ue_py_slate_farguments_optional_foptional_size("min_desired_width", MinDesiredWidth); - ue_py_snew(SBox, s_panel.s_widget); + ue_py_snew(SBox); return 0; } diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySBoxPanel.cpp b/Source/UnrealEnginePython/Private/Slate/UEPySBoxPanel.cpp index bd055e94f..688fe7a70 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySBoxPanel.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPySBoxPanel.cpp @@ -1,15 +1,12 @@ -#include "UnrealEnginePythonPrivatePCH.h" - #include "UEPySBoxPanel.h" -#define sw_box_panel StaticCastSharedRef(self->s_panel.s_widget.s_widget) - -static PyObject *py_ue_sbox_panel_clear_children(ue_PySGridPanel *self, PyObject * args) +static PyObject *py_ue_sbox_panel_clear_children(ue_PySBoxPanel *self, PyObject * args) { + ue_py_slate_cast(SBoxPanel); - sw_box_panel->ClearChildren(); + py_SBoxPanel->ClearChildren(); Py_RETURN_NONE; } diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySButton.cpp b/Source/UnrealEnginePython/Private/Slate/UEPySButton.cpp index f99bf5e9f..3f7561e96 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySButton.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPySButton.cpp @@ -1,46 +1,42 @@ -#include "UnrealEnginePythonPrivatePCH.h" #include "UEPySButton.h" -#define sw_button StaticCastSharedRef(self->s_border.s_compound_widget.s_widget.s_widget) - static PyObject *py_ue_sbutton_is_pressed(ue_PySButton *self, PyObject * args) { + ue_py_slate_cast(SButton); - if (sw_button->IsPressed()) + if (py_SButton->IsPressed()) { - Py_INCREF(Py_True); - return Py_True; + Py_RETURN_TRUE; } - Py_INCREF(Py_False); - return Py_False; + Py_RETURN_FALSE; } static PyObject *py_ue_sbutton_bind_on_clicked(ue_PySButton *self, PyObject * args) { + ue_py_slate_cast(SButton); PyObject *py_callable; if (!PyArg_ParseTuple(args, "O:bind_on_clicked", &py_callable)) { - return NULL; + return nullptr; } - if (!PyCalllable_Check_Extended(py_callable)) + if (!PyCallable_Check(py_callable)) { return PyErr_Format(PyExc_Exception, "argument is not callable"); } FOnClicked handler; - TSharedRefpy_delegate = FUnrealEnginePythonHouseKeeper::Get()->NewSlateDelegate(self->s_border.s_compound_widget.s_widget.s_widget, py_callable); + TSharedRefpy_delegate = FUnrealEnginePythonHouseKeeper::Get()->NewSlateDelegate(self->s_border.s_compound_widget.s_widget.Widget, py_callable); py_delegate->SetPyCallable(py_callable); handler.BindSP(py_delegate, &FPythonSlateDelegate::OnClicked); - sw_button->SetOnClicked(handler); + py_SButton->SetOnClicked(handler); - Py_INCREF(self); - return (PyObject *)self; + Py_RETURN_SLATE_SELF; } static PyMethodDef ue_PySButton_methods[] = { @@ -109,7 +105,7 @@ static int ue_py_sbutton_init(ue_PySButton *self, PyObject *args, PyObject *kwar ue_py_slate_farguments_optional_enum("touch_method", TouchMethod, EButtonTouchMethod::Type); ue_py_slate_farguments_optional_enum("v_align", VAlign, EVerticalAlignment); - ue_py_snew(SButton, s_border.s_compound_widget.s_widget); + ue_py_snew(SButton); return 0; } diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySButton.h b/Source/UnrealEnginePython/Private/Slate/UEPySButton.h index 0cf39561d..5f09791f0 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySButton.h +++ b/Source/UnrealEnginePython/Private/Slate/UEPySButton.h @@ -1,8 +1,5 @@ #pragma once -#include "UnrealEnginePython.h" - - #include "UEPySBorder.h" #include "Runtime/Slate/Public/Widgets/Input/SButton.h" diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySCanvas.cpp b/Source/UnrealEnginePython/Private/Slate/UEPySCanvas.cpp index 056de71d7..e8e241cd8 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySCanvas.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPySCanvas.cpp @@ -1,20 +1,19 @@ -#include "UnrealEnginePythonPrivatePCH.h" #include "UEPySCanvas.h" -#define sw_canvas StaticCastSharedRef(self->s_panel.s_widget.s_widget) - static PyObject *py_ue_scanvas_clear_children(ue_PySCanvas *self, PyObject * args) { - sw_canvas->ClearChildren(); + ue_py_slate_cast(SCanvas); + py_SCanvas->ClearChildren(); Py_RETURN_NONE; } static PyObject *py_ue_scanvas_add_slot(ue_PySCanvas *self, PyObject * args, PyObject *kwargs) { + ue_py_slate_cast(SCanvas); PyObject *py_content; int h_align = 0; int v_align = 0; @@ -39,16 +38,12 @@ static PyObject *py_ue_scanvas_add_slot(ue_PySCanvas *self, PyObject * args, PyO return NULL; } - ue_PySWidget *py_swidget = py_ue_is_swidget(py_content); - if (!py_swidget) - { - return PyErr_Format(PyExc_Exception, "argument is not a SWidget"); - } - - Py_INCREF(py_swidget); + TSharedPtr child = py_ue_is_swidget(py_content); + if (!child.IsValid()) + return nullptr; - SCanvas::FSlot &fslot = sw_canvas->AddSlot(); - fslot.AttachWidget(py_swidget->s_widget->AsShared()); + SCanvas::FSlot &fslot = py_SCanvas->AddSlot(); + fslot.AttachWidget(child.ToSharedRef()); fslot.HAlign((EHorizontalAlignment)h_align); fslot.VAlign((EVerticalAlignment)v_align); @@ -90,8 +85,7 @@ static PyObject *py_ue_scanvas_add_slot(ue_PySCanvas *self, PyObject * args, PyO } } - Py_INCREF(self); - return (PyObject *)self; + Py_RETURN_SLATE_SELF; } static PyMethodDef ue_PySCanvas_methods[] = { @@ -134,7 +128,7 @@ PyTypeObject ue_PySCanvasType = { static int ue_py_scanvas_init(ue_PySCanvas *self, PyObject *args, PyObject *kwargs) { - ue_py_snew_simple(SCanvas, s_panel.s_widget); + ue_py_snew_simple(SCanvas); return 0; } diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySCheckBox.cpp b/Source/UnrealEnginePython/Private/Slate/UEPySCheckBox.cpp index 4aa458a8e..509ebd66f 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySCheckBox.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPySCheckBox.cpp @@ -1,22 +1,60 @@ +#include "UEPySCheckBox.h" -#include "UnrealEnginePythonPrivatePCH.h" -#include "UEPySCheckBox.h" +static PyObject *py_ue_scheck_box_is_checked(ue_PySCheckBox *self, PyObject * args) +{ + ue_py_slate_cast(SCheckBox); + if (py_SCheckBox->IsChecked()) + { + Py_RETURN_TRUE; + } + + Py_RETURN_FALSE; +} +static PyObject *py_ue_scheck_box_set_is_checked(ue_PySCheckBox *self, PyObject * args) +{ + ue_py_slate_cast(SCheckBox); + PyObject * py_bool; + if (!PyArg_ParseTuple(args, "O:set_is_checked", &py_bool)) + { + return NULL; + } -#define sw_check_box StaticCastSharedRef(self->s_compound_widget.s_widget.s_widget) + ECheckBoxState CheckedState = PyObject_IsTrue(py_bool) ? ECheckBoxState::Checked : ECheckBoxState::Unchecked; -static PyObject *py_ue_scheck_box_is_checked(ue_PySCheckBox *self, PyObject * args) { + py_SCheckBox->SetIsChecked(TAttribute(CheckedState)); - if (sw_check_box->IsChecked()) { - Py_RETURN_TRUE; + Py_RETURN_NONE; + +} + +static PyObject *py_ue_scheck_box_set_content(ue_PySCheckBox *self, PyObject * args) +{ + ue_py_slate_cast(SCheckBox); + PyObject * py_content; + if (!PyArg_ParseTuple(args, "O:set_content", &py_content)) + { + return NULL; } - - Py_RETURN_FALSE; + + TSharedPtr child = py_ue_is_swidget(py_content); + if (!child.IsValid()) + { + return nullptr; + } + + + + py_SCheckBox->SetContent(child.ToSharedRef()); + + Py_RETURN_SLATE_SELF; } static PyMethodDef ue_PySCheckBox_methods[] = { { "is_checked", (PyCFunction)py_ue_scheck_box_is_checked, METH_VARARGS, "" }, + { "set_content", (PyCFunction)py_ue_scheck_box_set_content, METH_VARARGS, "" }, + { "set_is_checked", (PyCFunction)py_ue_scheck_box_set_is_checked, METH_VARARGS, "" }, { NULL } /* Sentinel */ }; @@ -51,21 +89,40 @@ PyTypeObject ue_PySCheckBoxType = { ue_PySCheckBox_methods, /* tp_methods */ }; -static int ue_py_scheck_box_init(ue_PySCheckBox *self, PyObject *args, PyObject *kwargs) { - +static int ue_py_scheck_box_init(ue_PySCheckBox *self, PyObject *args, PyObject *kwargs) +{ + ue_py_slate_setup_farguments(SCheckBox); ue_py_slate_farguments_struct("border_background_color", BorderBackgroundColor, FSlateColor); ue_py_slate_farguments_struct("foreground_color", ForegroundColor, FSlateColor); ue_py_slate_farguments_enum("is_checked", IsChecked, ECheckBoxState); ue_py_slate_farguments_event("on_check_state_changed", OnCheckStateChanged, FOnCheckStateChanged, CheckBoxChanged); - - ue_py_snew(SCheckBox, s_compound_widget.s_widget); + ue_py_slate_farguments_optional_struct_ptr("style", Style, FCheckBoxStyle); + ue_py_slate_farguments_optional_enum("type", Type, ESlateCheckBoxType::Type); + ue_py_slate_farguments_event("on_check_state_changed", OnCheckStateChanged, FOnCheckStateChanged, CheckBoxChanged); + ue_py_slate_farguments_enum("is_checked", IsChecked, ECheckBoxState); + ue_py_slate_farguments_optional_enum("h_align", HAlign, EHorizontalAlignment); + ue_py_slate_farguments_struct("padding", Padding, FMargin); + ue_py_slate_farguments_enum("click_method", ClickMethod, EButtonClickMethod::Type); + ue_py_slate_farguments_optional_bool("is_focusable", IsFocusable); + ue_py_slate_farguments_optional_struct_ptr("unchecked_image", UncheckedImage, FSlateBrush); + ue_py_slate_farguments_optional_struct_ptr("unchecked_hoveredimage", UncheckedHoveredImage, FSlateBrush); + ue_py_slate_farguments_optional_struct_ptr("unchecked_pressedimage", UncheckedPressedImage, FSlateBrush); + ue_py_slate_farguments_optional_struct_ptr("checked_image", CheckedImage, FSlateBrush); + ue_py_slate_farguments_optional_struct_ptr("checked_hoveredimage", CheckedHoveredImage, FSlateBrush); + ue_py_slate_farguments_optional_struct_ptr("checked_pressedimage", CheckedPressedImage, FSlateBrush); + ue_py_slate_farguments_optional_struct_ptr("undetermined_image", UndeterminedImage, FSlateBrush); + ue_py_slate_farguments_optional_struct_ptr("undetermined_hoveredimage", UndeterminedHoveredImage, FSlateBrush); + ue_py_slate_farguments_optional_struct_ptr("undetermined_pressedimage", UndeterminedPressedImage, FSlateBrush); + ue_py_snew(SCheckBox); return 0; } -void ue_python_init_scheck_box(PyObject *ue_module) { +void ue_python_init_scheck_box(PyObject *ue_module) +{ ue_PySCheckBoxType.tp_init = (initproc)ue_py_scheck_box_init; + ue_PySCheckBoxType.tp_call = (ternaryfunc)py_ue_scheck_box_set_content; ue_PySCheckBoxType.tp_base = &ue_PySCompoundWidgetType; diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySColorBlock.cpp b/Source/UnrealEnginePython/Private/Slate/UEPySColorBlock.cpp index 6a98b951f..a34792e1a 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySColorBlock.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPySColorBlock.cpp @@ -1,10 +1,6 @@ -#include "UnrealEnginePythonPrivatePCH.h" - #include "UEPySColorBlock.h" -#define sw_color_block StaticCastSharedRef(self->s_leaf_widget.s_widget.s_widget) - static PyMethodDef ue_PySColorBlock_methods[] = { { NULL } /* Sentinel */ }; @@ -40,7 +36,8 @@ PyTypeObject ue_PySColorBlockType = { ue_PySColorBlock_methods, /* tp_methods */ }; -static int ue_py_scolor_block_init(ue_PySColorBlock *self, PyObject *args, PyObject *kwargs) { +static int ue_py_scolor_block_init(ue_PySColorBlock *self, PyObject *args, PyObject *kwargs) +{ ue_py_slate_setup_farguments(SColorBlock); ue_py_slate_farguments_flinear_color("color", Color); @@ -51,11 +48,12 @@ static int ue_py_scolor_block_init(ue_PySColorBlock *self, PyObject *args, PyObj ue_py_slate_farguments_fvector2d("size", Size); ue_py_slate_farguments_bool("use_srgb", UseSRGB); - ue_py_snew(SColorBlock, s_leaf_widget.s_widget); + ue_py_snew(SColorBlock); return 0; } -void ue_python_init_scolor_block(PyObject *ue_module) { +void ue_python_init_scolor_block(PyObject *ue_module) +{ ue_PySColorBlockType.tp_init = (initproc)ue_py_scolor_block_init; diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySColorBlock.h b/Source/UnrealEnginePython/Private/Slate/UEPySColorBlock.h index 9bc920583..3a7235073 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySColorBlock.h +++ b/Source/UnrealEnginePython/Private/Slate/UEPySColorBlock.h @@ -1,8 +1,5 @@ #pragma once -#include "UnrealEnginePython.h" - - #include "UEPySLeafWidget.h" #include "Runtime/Slate/Public/Widgets/Colors/SColorBlock.h" diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySCompoundWidget.cpp b/Source/UnrealEnginePython/Private/Slate/UEPySCompoundWidget.cpp index 7e95d9787..9e0556199 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySCompoundWidget.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPySCompoundWidget.cpp @@ -1,14 +1,11 @@ - -#include "UnrealEnginePythonPrivatePCH.h" - #include "UEPySCompoundWidget.h" -#define sw_compound_widget StaticCastSharedRef(self->s_widget.s_widget) static PyObject *py_ue_scompound_widget_get_color_and_opacity(ue_PySCompoundWidget *self, PyObject * args) { + ue_py_slate_cast(SCompoundWidget); - FLinearColor color = sw_compound_widget->GetColorAndOpacity(); + FLinearColor color = py_SCompoundWidget->GetColorAndOpacity(); return py_ue_new_flinearcolor(color); } @@ -16,11 +13,13 @@ static PyObject *py_ue_scompound_widget_get_color_and_opacity(ue_PySCompoundWidg static PyObject *py_ue_scompound_widget_set_color_and_opacity(ue_PySCompoundWidget *self, PyObject * args) { + ue_py_slate_cast(SCompoundWidget); + PyObject *py_color; if (!PyArg_ParseTuple(args, "O:set_color_and_opacity", &py_color)) { - return NULL; + return nullptr; } ue_PyFLinearColor *py_linear_color = py_ue_is_flinearcolor(py_color); @@ -29,10 +28,9 @@ static PyObject *py_ue_scompound_widget_set_color_and_opacity(ue_PySCompoundWidg return PyErr_Format(PyExc_Exception, "argument is not a FLinearColor"); } - sw_compound_widget->SetColorAndOpacity(py_linear_color->color); + py_SCompoundWidget->SetColorAndOpacity(py_linear_color->color); - Py_INCREF(self); - return (PyObject *)self; + Py_RETURN_SLATE_SELF; } static PyMethodDef ue_PySCompoundWidget_methods[] = { diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySCompoundWidget.h b/Source/UnrealEnginePython/Private/Slate/UEPySCompoundWidget.h index 65adee30a..b73d8ebf1 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySCompoundWidget.h +++ b/Source/UnrealEnginePython/Private/Slate/UEPySCompoundWidget.h @@ -1,14 +1,11 @@ #pragma once - -#include "UnrealEnginePython.h" - - #include "UEPySWidget.h" extern PyTypeObject ue_PySCompoundWidgetType; -typedef struct { +typedef struct +{ ue_PySWidget s_widget; /* Type-specific fields go here. */ } ue_PySCompoundWidget; diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySDirectoryPicker.cpp b/Source/UnrealEnginePython/Private/Slate/UEPySDirectoryPicker.cpp new file mode 100644 index 000000000..bda93bbc3 --- /dev/null +++ b/Source/UnrealEnginePython/Private/Slate/UEPySDirectoryPicker.cpp @@ -0,0 +1,62 @@ +#include "UEPySDirectoryPicker.h" + +#if WITH_EDITOR +#if ENGINE_MINOR_VERSION > 13 + + +static PyObject *py_ue_sdirectory_picker_get_directory(ue_PySDirectoryPicker *self, PyObject * args) +{ + ue_py_slate_cast(SDirectoryPicker); + FString Directory = py_SDirectoryPicker->GetDirectory(); + + return PyUnicode_FromString(TCHAR_TO_UTF8(*Directory)); +} + +static PyObject *py_ue_sdirectory_picker_get_file_path(ue_PySDirectoryPicker *self, PyObject * args) +{ + ue_py_slate_cast(SDirectoryPicker); + FString FilePath = py_SDirectoryPicker->GetFilePath(); + + return PyUnicode_FromString(TCHAR_TO_UTF8(*FilePath)); +} + + +static PyMethodDef ue_PySDirectoryPicker_methods[] = { + { "get_directory", (PyCFunction)py_ue_sdirectory_picker_get_directory, METH_VARARGS, "" }, + { "get_file_path", (PyCFunction)py_ue_sdirectory_picker_get_file_path, METH_VARARGS, "" }, + { NULL } /* Sentinel */ +}; + +DECLARE_UE_PY_SLATE_WIDGET(SDirectoryPicker); + +DECLARE_DELEGATE_OneParam(FOnDirectoryChanged, const FString& /*Directory*/); + +static int ue_py_sdirectory_picker_init(ue_PySDirectoryPicker *self, PyObject *args, PyObject *kwargs) +{ + ue_py_slate_setup_farguments(SDirectoryPicker); + + ue_py_slate_farguments_optional_text("message", Message); + ue_py_slate_farguments_optional_string("directory", Directory); + ue_py_slate_farguments_optional_string("file", File); + ue_py_slate_farguments_bool("is_enabled", IsEnabled); + ue_py_slate_farguments_event("on_directory_changed", OnDirectoryChanged, FOnDirectoryChanged, OnStringChanged); + + ue_py_snew(SDirectoryPicker); + return 0; +} + +void ue_python_init_sdirectory_picker(PyObject *ue_module) +{ + + ue_PySDirectoryPickerType.tp_init = (initproc)ue_py_sdirectory_picker_init; + + ue_PySDirectoryPickerType.tp_base = &ue_PySCompoundWidgetType; + + if (PyType_Ready(&ue_PySDirectoryPickerType) < 0) + return; + + Py_INCREF(&ue_PySDirectoryPickerType); + PyModule_AddObject(ue_module, "SDirectoryPicker", (PyObject *)&ue_PySDirectoryPickerType); +} +#endif +#endif diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySDirectoryPicker.h b/Source/UnrealEnginePython/Private/Slate/UEPySDirectoryPicker.h new file mode 100644 index 000000000..b089e831f --- /dev/null +++ b/Source/UnrealEnginePython/Private/Slate/UEPySDirectoryPicker.h @@ -0,0 +1,20 @@ +#pragma once + +#include "UEPySCompoundWidget.h" + +#if WITH_EDITOR +#if ENGINE_MINOR_VERSION > 13 + +#include "Developer/DesktopWidgets/Public/Widgets/Input/SDirectoryPicker.h" + +extern PyTypeObject ue_PySDirectoryPickerType; + +typedef struct +{ + ue_PySCompoundWidget s_compound_widget; + /* Type-specific fields go here. */ +} ue_PySDirectoryPicker; + +void ue_python_init_sdirectory_picker(PyObject *); +#endif +#endif \ No newline at end of file diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySDockTab.cpp b/Source/UnrealEnginePython/Private/Slate/UEPySDockTab.cpp index a26329821..d8beb88ad 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySDockTab.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPySDockTab.cpp @@ -1,34 +1,34 @@ -#include "UnrealEnginePythonPrivatePCH.h" - - #include "UEPySDockTab.h" -#define sw_dock_tab StaticCastSharedRef(self->s_border.s_compound_widget.s_widget.s_widget) - +#include "UEPyFTabManager.h" -static PyObject *py_ue_sdock_tab_set_label(ue_PySButton *self, PyObject * args) { +static PyObject *py_ue_sdock_tab_set_label(ue_PySDockTab *self, PyObject * args) +{ + ue_py_slate_cast(SDockTab); char *label; - if (!PyArg_ParseTuple(args, "s:set_label", &label)) { - return NULL; + if (!PyArg_ParseTuple(args, "s:set_label", &label)) + { + return nullptr; } - sw_dock_tab->SetLabel(FText::FromString(UTF8_TO_TCHAR(label))); + py_SDockTab->SetLabel(FText::FromString(UTF8_TO_TCHAR(label))); - Py_INCREF(self); - return (PyObject *)self; + Py_RETURN_SLATE_SELF; } -static PyObject *py_ue_sdock_tab_request_close_tab(ue_PySButton *self, PyObject * args) { - - sw_dock_tab->RequestCloseTab(); +static PyObject *py_ue_sdock_tab_request_close_tab(ue_PySDockTab *self, PyObject * args) +{ + ue_py_slate_cast(SDockTab); + py_SDockTab->RequestCloseTab(); Py_RETURN_NONE; } -static PyObject *py_ue_sdock_tab_new_tab_manager(ue_PySButton *self, PyObject * args) { - - TSharedRef tab_manager = FGlobalTabmanager::Get()->NewTabManager(sw_dock_tab); +static PyObject *py_ue_sdock_tab_new_tab_manager(ue_PySDockTab *self, PyObject * args) +{ + ue_py_slate_cast(SDockTab); + TSharedRef tab_manager = FGlobalTabmanager::Get()->NewTabManager(py_SDockTab); return py_ue_new_ftab_manager(tab_manager); } @@ -71,7 +71,8 @@ PyTypeObject ue_PySDockTabType = { ue_PySDockTab_methods, /* tp_methods */ }; -static int ue_py_sdock_tab_init(ue_PySDockTab *self, PyObject *args, PyObject *kwargs) { +static int ue_py_sdock_tab_init(ue_PySDockTab *self, PyObject *args, PyObject *kwargs) +{ ue_py_slate_setup_farguments(SDockTab); ue_py_slate_farguments_struct("content_padding", ContentPadding, FMargin); @@ -81,11 +82,12 @@ static int ue_py_sdock_tab_init(ue_PySDockTab *self, PyObject *args, PyObject *k ue_py_slate_farguments_optional_enum("tab_role", TabRole, ETabRole); - ue_py_snew(SDockTab, s_border.s_compound_widget.s_widget); + ue_py_snew(SDockTab); return 0; } -void ue_python_init_sdock_tab(PyObject *ue_module) { +void ue_python_init_sdock_tab(PyObject *ue_module) +{ ue_PySDockTabType.tp_base = &ue_PySBorderType; ue_PySDockTabType.tp_init = (initproc)ue_py_sdock_tab_init; diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySDockTab.h b/Source/UnrealEnginePython/Private/Slate/UEPySDockTab.h index 42f28f228..f1be66f1b 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySDockTab.h +++ b/Source/UnrealEnginePython/Private/Slate/UEPySDockTab.h @@ -1,15 +1,13 @@ #pragma once -#include "UnrealEnginePython.h" - - #include "UEPySBorder.h" #include "Runtime/Slate/Public/Widgets/Docking/SDockTab.h" extern PyTypeObject ue_PySDockTabType; -typedef struct { +typedef struct +{ ue_PySBorder s_border; /* Type-specific fields go here. */ } ue_PySDockTab; diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySDropTarget.cpp b/Source/UnrealEnginePython/Private/Slate/UEPySDropTarget.cpp index 5d38fd4e6..62710997e 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySDropTarget.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPySDropTarget.cpp @@ -1,7 +1,8 @@ +#include "UEPySDropTarget.h" + #if WITH_EDITOR -#include "UnrealEnginePythonPrivatePCH.h" -#include "UEPySDropTarget.h" + static PyMethodDef ue_PySDropTarget_methods[] = { @@ -39,7 +40,8 @@ PyTypeObject ue_PySDropTargetType = { ue_PySDropTarget_methods, /* tp_methods */ }; -void ue_python_init_sdrop_target(PyObject *ue_module) { +void ue_python_init_sdrop_target(PyObject *ue_module) +{ ue_PySDropTargetType.tp_base = &ue_PySCompoundWidgetType; diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySDropTarget.h b/Source/UnrealEnginePython/Private/Slate/UEPySDropTarget.h index ffa37b87b..620567af6 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySDropTarget.h +++ b/Source/UnrealEnginePython/Private/Slate/UEPySDropTarget.h @@ -1,10 +1,9 @@ #pragma once -#include "UnrealEnginePython.h" - - #include "UEPySCompoundWidget.h" +#if WITH_EDITOR + #include "Editor/EditorWidgets/Public/SDropTarget.h" extern PyTypeObject ue_PySDropTargetType; @@ -15,3 +14,4 @@ typedef struct { } ue_PySDropTarget; void ue_python_init_sdrop_target(PyObject *); +#endif diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySEditableTextBox.cpp b/Source/UnrealEnginePython/Private/Slate/UEPySEditableTextBox.cpp index 76c0f3ef5..da05e6cf7 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySEditableTextBox.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPySEditableTextBox.cpp @@ -1,52 +1,57 @@ -#include "UnrealEnginePythonPrivatePCH.h" - -#include "UEPySEditableTextBox.h" +#include "UEPySEditableTextBox.h" -#define sw_editable_text_box StaticCastSharedRef(self->s_border.s_compound_widget.s_widget.s_widget) -static PyObject *py_ue_seditable_text_box_select_all_text(ue_PySEditableTextBox *self, PyObject * args) { +static PyObject *py_ue_seditable_text_box_select_all_text(ue_PySEditableTextBox *self, PyObject * args) +{ + ue_py_slate_cast(SEditableTextBox); - sw_editable_text_box->SelectAllText(); + py_SEditableTextBox->SelectAllText(); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } -static PyObject *py_ue_seditable_text_box_clear_selection(ue_PySEditableTextBox *self, PyObject * args) { +static PyObject *py_ue_seditable_text_box_clear_selection(ue_PySEditableTextBox *self, PyObject * args) +{ + ue_py_slate_cast(SEditableTextBox); - sw_editable_text_box->ClearSelection(); + py_SEditableTextBox->ClearSelection(); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } -static PyObject *py_ue_seditable_text_box_get_selected_text(ue_PySEditableTextBox *self, PyObject * args) { +static PyObject *py_ue_seditable_text_box_get_selected_text(ue_PySEditableTextBox *self, PyObject * args) +{ + ue_py_slate_cast(SEditableTextBox); - FText text = sw_editable_text_box->GetSelectedText(); + FText text = py_SEditableTextBox->GetSelectedText(); return PyUnicode_FromString(TCHAR_TO_UTF8(*text.ToString())); } -static PyObject *py_ue_seditable_text_box_get_text(ue_PySEditableTextBox *self, PyObject * args) { +static PyObject *py_ue_seditable_text_box_get_text(ue_PySEditableTextBox *self, PyObject * args) +{ + ue_py_slate_cast(SEditableTextBox); - FText text = sw_editable_text_box->GetText(); + FText text = py_SEditableTextBox->GetText(); return PyUnicode_FromString(TCHAR_TO_UTF8(*text.ToString())); } -static PyObject *py_ue_seditable_text_box_set_text(ue_PySEditableTextBox *self, PyObject * args) { +static PyObject *py_ue_seditable_text_box_set_text(ue_PySEditableTextBox *self, PyObject * args) +{ + ue_py_slate_cast(SEditableTextBox); char *text; - if (!PyArg_ParseTuple(args, "s:set_text", &text)) { - return NULL; + if (!PyArg_ParseTuple(args, "s:set_text", &text)) + { + return nullptr; } - sw_editable_text_box->SetText(FText::FromString(UTF8_TO_TCHAR(text))); + py_SEditableTextBox->SetText(FText::FromString(UTF8_TO_TCHAR(text))); - Py_INCREF(self); - return (PyObject *)self; + Py_RETURN_SLATE_SELF; } static PyMethodDef ue_PySEditableTextBox_methods[] = { @@ -89,7 +94,8 @@ PyTypeObject ue_PySEditableTextBoxType = { ue_PySEditableTextBox_methods, /* tp_methods */ }; -static int ue_py_seditable_text_box_init(ue_PySEditableTextBox *self, PyObject *args, PyObject *kwargs) { +static int ue_py_seditable_text_box_init(ue_PySEditableTextBox *self, PyObject *args, PyObject *kwargs) +{ ue_py_slate_setup_farguments(SEditableTextBox); ue_py_slate_farguments_bool("allow_context_menu", AllowContextMenu); @@ -117,11 +123,12 @@ static int ue_py_seditable_text_box_init(ue_PySEditableTextBox *self, PyObject * ue_py_slate_farguments_optional_enum("text_shaping_method", TextShapingMethod, ETextShapingMethod); ue_py_slate_farguments_enum("virtual_keyboard_type", VirtualKeyboardType, EKeyboardType); - ue_py_snew(SEditableTextBox, s_border.s_compound_widget.s_widget); + ue_py_snew(SEditableTextBox); return 0; } -void ue_python_init_seditable_text_box(PyObject *ue_module) { +void ue_python_init_seditable_text_box(PyObject *ue_module) +{ ue_PySEditableTextBoxType.tp_init = (initproc)ue_py_seditable_text_box_init; diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySEditableTextBox.h b/Source/UnrealEnginePython/Private/Slate/UEPySEditableTextBox.h index 619f3615d..597be25f9 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySEditableTextBox.h +++ b/Source/UnrealEnginePython/Private/Slate/UEPySEditableTextBox.h @@ -1,7 +1,5 @@ #pragma once -#include "UnrealEnginePython.h" - #include "UEPySBorder.h" #include "Runtime/Slate/Public/Widgets/Input/SEditableTextBox.h" diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySEditorViewport.cpp b/Source/UnrealEnginePython/Private/Slate/UEPySEditorViewport.cpp index b7fd4aaf7..376fdbefa 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySEditorViewport.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPySEditorViewport.cpp @@ -1,22 +1,24 @@ + +#include "UEPySEditorViewport.h" + #if WITH_EDITOR -#include "UnrealEnginePythonPrivatePCH.h" -#include "UEPySViewport.h" -#define sw_editor_viewport StaticCastSharedRef(self->s_compound_widget.s_widget.s_widget) +static PyObject *py_ue_seditor_viewport_enable_stereo_rendering(ue_PySEditorViewport *self, PyObject * args) +{ + ue_py_slate_cast(SEditorViewport); -static PyObject *py_ue_seditor_viewport_enable_stereo_rendering(ue_PySEditorViewport *self, PyObject * args) { PyObject *py_bool; - if (!PyArg_ParseTuple(args, "O:enable_stereo_rendering", &py_bool)) { - return NULL; + if (!PyArg_ParseTuple(args, "O:enable_stereo_rendering", &py_bool)) + { + return nullptr; } - sw_editor_viewport->EnableStereoRendering(PyObject_IsTrue(py_bool) ? true : false); + py_SEditorViewport->EnableStereoRendering(PyObject_IsTrue(py_bool) ? true : false); - Py_INCREF(self); - return (PyObject *)self; + Py_RETURN_SLATE_SELF; } static PyMethodDef ue_PySEditorViewport_methods[] = { @@ -55,7 +57,8 @@ PyTypeObject ue_PySEditorViewportType = { ue_PySEditorViewport_methods, /* tp_methods */ }; -void ue_python_init_seditor_viewport(PyObject *ue_module) { +void ue_python_init_seditor_viewport(PyObject *ue_module) +{ ue_PySEditorViewportType.tp_base = &ue_PySCompoundWidgetType; diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySEditorViewport.h b/Source/UnrealEnginePython/Private/Slate/UEPySEditorViewport.h index aafedd8a0..207b14904 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySEditorViewport.h +++ b/Source/UnrealEnginePython/Private/Slate/UEPySEditorViewport.h @@ -1,17 +1,18 @@ #pragma once -#include "UnrealEnginePython.h" - - #include "UEPySCompoundWidget.h" +#if WITH_EDITOR + #include "Editor/UnrealEd/Public/SEditorViewport.h" extern PyTypeObject ue_PySEditorViewportType; -typedef struct { +typedef struct +{ ue_PySCompoundWidget s_compound_widget; /* Type-specific fields go here. */ } ue_PySEditorViewport; void ue_python_init_seditor_viewport(PyObject *); +#endif diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySFilePathPicker.cpp b/Source/UnrealEnginePython/Private/Slate/UEPySFilePathPicker.cpp index 66c131ab0..c35118c96 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySFilePathPicker.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPySFilePathPicker.cpp @@ -1,47 +1,16 @@ -#include "UnrealEnginePythonPrivatePCH.h" #include "UEPySFilePathPicker.h" #if WITH_EDITOR #if ENGINE_MINOR_VERSION > 13 -#define sw_file_path_picker StaticCastSharedRef(self->s_compound_widget.s_widget.s_widget) - static PyMethodDef ue_PySFilePathPicker_methods[] = { { NULL } /* Sentinel */ }; -PyTypeObject ue_PySFilePathPickerType = { - PyVarObject_HEAD_INIT(NULL, 0) - "unreal_engine.SFilePathPicker", /* tp_name */ - sizeof(ue_PySFilePathPicker), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Unreal Engine SFilePathPicker", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ue_PySFilePathPicker_methods, /* tp_methods */ -}; +DECLARE_UE_PY_SLATE_WIDGET(SFilePathPicker); -static int ue_py_sfile_path_picker_init(ue_PySFilePathPicker *self, PyObject *args, PyObject *kwargs) { +static int ue_py_sfile_path_picker_init(ue_PySFilePathPicker *self, PyObject *args, PyObject *kwargs) +{ ue_py_slate_setup_farguments(SFilePathPicker); ue_py_slate_farguments_optional_struct_ptr("browse_button_image", BrowseButtonImage, FSlateBrush); @@ -55,11 +24,12 @@ static int ue_py_sfile_path_picker_init(ue_PySFilePathPicker *self, PyObject *ar ue_py_slate_farguments_bool("is_read_only", IsReadOnly); ue_py_slate_farguments_event("on_path_picked", OnPathPicked, FOnPathPicked, OnStringChanged); - ue_py_snew(SFilePathPicker, s_compound_widget.s_widget); + ue_py_snew(SFilePathPicker); return 0; } -void ue_python_init_sfile_path_picker(PyObject *ue_module) { +void ue_python_init_sfile_path_picker(PyObject *ue_module) +{ ue_PySFilePathPickerType.tp_init = (initproc)ue_py_sfile_path_picker_init; diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySFilePathPicker.h b/Source/UnrealEnginePython/Private/Slate/UEPySFilePathPicker.h index b87bd4ac5..f71c64a77 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySFilePathPicker.h +++ b/Source/UnrealEnginePython/Private/Slate/UEPySFilePathPicker.h @@ -1,7 +1,5 @@ #pragma once -#include "UnrealEnginePython.h" - #include "UEPySCompoundWidget.h" #if WITH_EDITOR @@ -10,7 +8,8 @@ extern PyTypeObject ue_PySFilePathPickerType; -typedef struct { +typedef struct +{ ue_PySCompoundWidget s_compound_widget; /* Type-specific fields go here. */ } ue_PySFilePathPicker; diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySGraphEditor.cpp b/Source/UnrealEnginePython/Private/Slate/UEPySGraphEditor.cpp index ddedcb2de..a5d9ace16 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySGraphEditor.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPySGraphEditor.cpp @@ -1,12 +1,9 @@ -#if WITH_EDITOR -#include "UnrealEnginePythonPrivatePCH.h" #include "UEPySGraphEditor.h" +#if WITH_EDITOR - -#define sw_graph_editor StaticCastSharedRef(self->s_compound_widget.s_widget.s_widget) - +#include "Runtime/Engine/Classes/EdGraph/EdGraph.h" static PyMethodDef ue_PySGraphEditor_methods[] = { { NULL } /* Sentinel */ @@ -43,22 +40,29 @@ PyTypeObject ue_PySGraphEditorType = { ue_PySGraphEditor_methods, /* tp_methods */ }; -static int ue_py_sgraph_editor_init(ue_PySGraphEditor *self, PyObject *args, PyObject *kwargs) { +static int ue_py_sgraph_editor_init(ue_PySGraphEditor *self, PyObject *args, PyObject *kwargs) +{ PyObject *py_graph; - if (!PyArg_ParseTuple(args, "O", &py_graph)) { + if (!PyArg_ParseTuple(args, "O", &py_graph)) + { return -1; } UEdGraph *graph = ue_py_check_type(py_graph); - if (!graph) { + if (!graph) + { PyErr_SetString(PyExc_Exception, "argument is not a EdGraph"); return -1; } - new (&self->s_compound_widget.s_widget.s_widget) TSharedRef(SNew(SGraphEditor).GraphToEdit(graph)); + ue_py_slate_setup_farguments(SGraphEditor); + arguments.GraphToEdit(graph); + ue_py_snew(SGraphEditor); + return 0; } -void ue_python_init_sgraph_editor(PyObject *ue_module) { +void ue_python_init_sgraph_editor(PyObject *ue_module) +{ ue_PySGraphEditorType.tp_init = (initproc)ue_py_sgraph_editor_init; diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySGraphPanel.cpp b/Source/UnrealEnginePython/Private/Slate/UEPySGraphPanel.cpp index 03a611652..349cd1c1b 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySGraphPanel.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPySGraphPanel.cpp @@ -1,138 +1,138 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPySGraphPanel.h" #if WITH_EDITOR #if ENGINE_MINOR_VERSION > 15 -#include "UEPySGraphPanel.h" + #define sw_graph_panel StaticCastSharedRef(self->s_nodePanel.s_panel.s_widget) /* static PyObject *py_ue_sgraph_panel_add_slot(ue_PySGraphPanel* self, PyObject *args, PyObject *kwargs) { - PyObject *py_content; - int z_order = -1; - int h_align = 0; - PyObject *padding = nullptr; - int v_align = 0; - - char *kwlist[] = { (char *)"widget", - (char *)"z_order", - (char *)"h_align", - (char *)"padding", - (char *)"v_align", - nullptr }; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|iiOi:add_slot", kwlist, - &py_content, - &z_order, - &h_align, - &padding, - &v_align)) - { - return nullptr; - } - - ue_PySWidget *py_swidget = py_ue_is_swidget(py_content); - if (!py_swidget) - { - return PyErr_Format(PyExc_Exception, "argument is not a SWidget"); - } - - Py_INCREF(py_swidget); - self->s_nodePanel.s_panel.s_widget.py_swidget_slots.Add(py_swidget); - - sw_graph_panel; - - SOverlay::FOverlaySlot &fslot = sw_graph_panel->//sw_overlay->AddSlot(z_order); - fslot.AttachWidget(py_swidget->s_widget->AsShared()); - fslot.HAlign((EHorizontalAlignment)h_align); - if (padding) - { - if (PyTuple_Check(padding)) - { - FMargin margin; - if (!PyArg_ParseTuple(padding, "f|fff", &margin.Left, &margin.Top, &margin.Right, &margin.Bottom)) - { - return PyErr_Format(PyExc_Exception, "invalid padding value"); - } - fslot.Padding(margin); - } - else if (PyNumber_Check(padding)) - { - PyObject *py_float = PyNumber_Float(padding); - fslot.Padding(PyFloat_AsDouble(py_float)); - Py_DECREF(py_float); - } - else - { - return PyErr_Format(PyExc_Exception, "invalid padding value"); - } - } - fslot.VAlign((EVerticalAlignment)v_align); - - Py_INCREF(self); - return (PyObject *)self; + PyObject *py_content; + int z_order = -1; + int h_align = 0; + PyObject *padding = nullptr; + int v_align = 0; + + char *kwlist[] = { (char *)"widget", + (char *)"z_order", + (char *)"h_align", + (char *)"padding", + (char *)"v_align", + nullptr }; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|iiOi:add_slot", kwlist, + &py_content, + &z_order, + &h_align, + &padding, + &v_align)) + { + return nullptr; + } + + ue_PySWidget *py_swidget = py_ue_is_swidget(py_content); + if (!py_swidget) + { + return PyErr_Format(PyExc_Exception, "argument is not a SWidget"); + } + + Py_INCREF(py_swidget); + self->s_nodePanel.s_panel.s_widget.py_swidget_slots.Add(py_swidget); + + sw_graph_panel; + + SOverlay::FOverlaySlot &fslot = sw_graph_panel->//sw_overlay->AddSlot(z_order); + fslot.AttachWidget(py_swidget->s_widget->AsShared()); + fslot.HAlign((EHorizontalAlignment)h_align); + if (padding) + { + if (PyTuple_Check(padding)) + { + FMargin margin; + if (!PyArg_ParseTuple(padding, "f|fff", &margin.Left, &margin.Top, &margin.Right, &margin.Bottom)) + { + return PyErr_Format(PyExc_Exception, "invalid padding value"); + } + fslot.Padding(margin); + } + else if (PyNumber_Check(padding)) + { + PyObject *py_float = PyNumber_Float(padding); + fslot.Padding(PyFloat_AsDouble(py_float)); + Py_DECREF(py_float); + } + else + { + return PyErr_Format(PyExc_Exception, "invalid padding value"); + } + } + fslot.VAlign((EVerticalAlignment)v_align); + + Py_INCREF(self); + return (PyObject *)self; } */ static PyMethodDef ue_PySGraphPanel_methods[] = { - //{"add_slot", (PyCFunction)py_ue_sgraph_panel_add_slot, METH_VARARGS | METH_KEYWORDS, "" }, - { NULL } /* Sentinel */ + //{"add_slot", (PyCFunction)py_ue_sgraph_panel_add_slot, METH_VARARGS | METH_KEYWORDS, "" }, + { NULL } /* Sentinel */ }; PyTypeObject ue_PySGraphPanelType = { - PyVarObject_HEAD_INIT(NULL, 0) - "unreal_engine.SGraphPanel", /* tp_name */ - sizeof(ue_PySGraphPanel), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Unreal Engine SGraphPanel", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ue_PySGraphPanel_methods, /* tp_methods */ + PyVarObject_HEAD_INIT(NULL, 0) + "unreal_engine.SGraphPanel", /* tp_name */ + sizeof(ue_PySGraphPanel), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Unreal Engine SGraphPanel", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + ue_PySGraphPanel_methods, /* tp_methods */ }; //why do you need to return an integer? static int ue_py_sgraph_panel_init(ue_PySGraphPanel *self, PyObject *args, PyObject *kwargs) { - //so for right now, let's just have this commented out to see if we get any errors - //if says we don't have s_nodePanel - ue_py_snew_simple(SGraphPanel, s_nodePanel.s_panel.s_widget);//s_nodePanel.s_panel); - //ue_py_snew(SGraphPanel, s_nodePanel.s_panel.s_widget); + //so for right now, let's just have this commented out to see if we get any errors + //if says we don't have s_nodePanel + ue_py_snew_simple(SGraphPanel);//s_nodePanel.s_panel); + //ue_py_snew(SGraphPanel, s_nodePanel.s_panel.s_widget); - return 0; + return 0; } -void ue_python_init_sgraph_panel(PyObject *ue_module) +void ue_python_init_sgraph_panel(PyObject *ue_module) { - //ue_PySGraphPanelType.tp_init = (initproc)ue_py_sgraph_panel_init; - //ue_PySGraphPanelType.tp_call = (ternaryfunc)py_ue_sgraph_panel_add_slot; - ue_PySGraphPanelType.tp_base = &ue_PySNodePanelType; + //ue_PySGraphPanelType.tp_init = (initproc)ue_py_sgraph_panel_init; + //ue_PySGraphPanelType.tp_call = (ternaryfunc)py_ue_sgraph_panel_add_slot; + ue_PySGraphPanelType.tp_base = &ue_PySNodePanelType; - if (PyType_Ready(&ue_PySGraphPanelType) < 0) - return; + if (PyType_Ready(&ue_PySGraphPanelType) < 0) + return; - Py_INCREF(&ue_PySGraphPanelType); - PyModule_AddObject(ue_module, "SGraphPanel", (PyObject *)&ue_PySGraphPanelType); + Py_INCREF(&ue_PySGraphPanelType); + PyModule_AddObject(ue_module, "SGraphPanel", (PyObject *)&ue_PySGraphPanelType); } #endif diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySGridPanel.cpp b/Source/UnrealEnginePython/Private/Slate/UEPySGridPanel.cpp index 41c826117..06df26b6a 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySGridPanel.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPySGridPanel.cpp @@ -1,45 +1,53 @@ -#include "UnrealEnginePythonPrivatePCH.h" - #include "UEPySGridPanel.h" -#define sw_grid_panel StaticCastSharedRef(self->s_panel.s_widget.s_widget) - -static PyObject *py_ue_sgrid_panel_clear_children(ue_PySGridPanel *self, PyObject * args) { +static PyObject *py_ue_sgrid_panel_clear_children(ue_PySGridPanel *self, PyObject * args) +{ - sw_grid_panel->ClearChildren(); + ue_py_slate_cast(SGridPanel); + py_SGridPanel->ClearChildren(); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } -static PyObject *py_ue_sgrid_panel_add_slot(ue_PySGridPanel *self, PyObject * args) { +static PyObject *py_ue_sgrid_panel_add_slot(ue_PySGridPanel *self, PyObject * args, PyObject * kwargs) +{ + ue_py_slate_cast(SGridPanel); + PyObject *py_content; - int col; + int column; int row; int layer = 0; - if (!PyArg_ParseTuple(args, "Oii|i:add_slot", &py_content, &col, &row, &layer)) { - return NULL; - } + int foobar = 0; + PyObject *py_nudge = nullptr; - ue_PySWidget *py_swidget = py_ue_is_swidget(py_content); - if (!py_swidget) { - return PyErr_Format(PyExc_Exception, "argument is not a SWidget"); + char *kwlist[] = { (char *)"widget", (char *)"column", (char *)"row", (char *)"layer", (char *)"column_span", (char *)"nudge", (char *)"row_span", nullptr }; + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "Oii|iiOi:add_slot", kwlist, &py_content, &column, &row, &layer, &foobar, &py_nudge, &foobar)) + { + return nullptr; } - // TODO: decrement reference when destroying parent - Py_INCREF(py_swidget); - SGridPanel::FSlot &fslot = sw_grid_panel->AddSlot(col, row, SGridPanel::Layer(layer)); - fslot.AttachWidget(py_swidget->s_widget->AsShared()); + int32 retCode = [&]() { + ue_py_slate_setup_hack_slot_args_grid(SGridPanel, py_SGridPanel, column, row, SGridPanel::Layer(layer)); + ue_py_slate_farguments_optional_int32("column_span", ColumnSpan); + ue_py_slate_farguments_optional_fvector2d("nudge", Nudge); + ue_py_slate_farguments_optional_int32("row_span", RowSpan); + return 0; + }(); + + if (retCode != 0) + { + return PyErr_Format(PyExc_Exception, "could not add GridPanel slot"); + } - Py_INCREF(self); - return (PyObject *)self; + Py_RETURN_SLATE_SELF; } static PyMethodDef ue_PySGridPanel_methods[] = { { "clear_children", (PyCFunction)py_ue_sgrid_panel_clear_children, METH_VARARGS, "" }, - { "add_slot", (PyCFunction)py_ue_sgrid_panel_add_slot, METH_VARARGS, "" }, +#pragma warning(suppress: 4191) + { "add_slot", (PyCFunction)py_ue_sgrid_panel_add_slot, METH_VARARGS | METH_KEYWORDS, "" }, { NULL } /* Sentinel */ }; @@ -74,12 +82,14 @@ PyTypeObject ue_PySGridPanelType = { ue_PySGridPanel_methods, /* tp_methods */ }; -static int ue_py_sgrid_panel_init(ue_PySGridPanel *self, PyObject *args, PyObject *kwargs) { - ue_py_snew_simple(SGridPanel, s_panel.s_widget); +static int ue_py_sgrid_panel_init(ue_PySGridPanel *self, PyObject *args, PyObject *kwargs) +{ + ue_py_snew_simple(SGridPanel); return 0; } -void ue_python_init_sgrid_panel(PyObject *ue_module) { +void ue_python_init_sgrid_panel(PyObject *ue_module) +{ ue_PySGridPanelType.tp_init = (initproc)ue_py_sgrid_panel_init; ue_PySGridPanelType.tp_call = (ternaryfunc)py_ue_sgrid_panel_add_slot; diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySHeaderRow.cpp b/Source/UnrealEnginePython/Private/Slate/UEPySHeaderRow.cpp index d3b01bfd7..6598a6bd9 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySHeaderRow.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPySHeaderRow.cpp @@ -1,68 +1,69 @@ -#include "UnrealEnginePythonPrivatePCH.h" -#include "UEPySHeaderRow.h" -#define sw_header_row StaticCastSharedRef(self->s_border.s_compound_widget.s_widget.s_widget) +#include "UEPySHeaderRow.h" -static PyObject *py_ue_sheader_row_add_column(ue_PySHeaderRow *self, PyObject *args, PyObject *kwargs) +static PyObject *py_ue_sheader_row_add_column(ue_PySHeaderRow *self, PyObject *args, PyObject *kwargs) { - int32 retCode = [&]() { - ue_py_slate_setup_farguments(SHeaderRow::FColumn); + ue_py_slate_cast(SHeaderRow); + - // first of all check for values - PyObject *py_columnid = ue_py_dict_get_item(kwargs, "column_id"); - if (!py_columnid) { - PyErr_SetString(PyExc_TypeError, "you must specify the column_id"); - return -1; - } + int32 retCode = [&]() { + ue_py_slate_setup_farguments(SHeaderRow::FColumn); - ue_py_slate_farguments_optional_string("column_id", ColumnId); + // first of all check for values + PyObject *py_columnid = ue_py_dict_get_item(kwargs, "column_id"); + if (!py_columnid) + { + PyErr_SetString(PyExc_TypeError, "you must specify the column_id"); + return -1; + } - ue_py_slate_farguments_text("default_label", DefaultLabel); - ue_py_slate_farguments_text("default_tooltip", DefaultTooltip); + ue_py_slate_farguments_optional_string("column_id", ColumnId); - ue_py_slate_farguments_optional_enum("h_align_header", HAlignHeader, EHorizontalAlignment); - ue_py_slate_farguments_optional_enum("v_align_header", VAlignHeader, EVerticalAlignment); + ue_py_slate_farguments_text("default_label", DefaultLabel); + ue_py_slate_farguments_text("default_tooltip", DefaultTooltip); - ue_py_slate_farguments_float("fill_width", FillWidth); - ue_py_slate_farguments_optional_float("fixed_width", FixedWidth); - ue_py_slate_farguments_float("manual_width", ManualWidth); + ue_py_slate_farguments_optional_enum("h_align_header", HAlignHeader, EHorizontalAlignment); + ue_py_slate_farguments_optional_enum("v_align_header", VAlignHeader, EVerticalAlignment); - ue_py_slate_farguments_optional_named_slot("header_content", HeaderContent); - ue_py_slate_farguments_optional_struct("header_content_padding", HeaderContentPadding, FMargin); + ue_py_slate_farguments_float("fill_width", FillWidth); + ue_py_slate_farguments_optional_float("fixed_width", FixedWidth); + ue_py_slate_farguments_float("manual_width", ManualWidth); - ue_py_slate_farguments_optional_named_slot("menu_content", MenuContent); + ue_py_slate_farguments_optional_named_slot("header_content", HeaderContent); + ue_py_slate_farguments_optional_struct("header_content_padding", HeaderContentPadding, FMargin); - ue_py_slate_farguments_optional_enum("h_align_cell", HAlignCell, EHorizontalAlignment); - ue_py_slate_farguments_optional_enum("v_align_cell", VAlignCell, EVerticalAlignment); + ue_py_slate_farguments_optional_named_slot("menu_content", MenuContent); - ue_py_slate_farguments_enum("sort_mode", SortMode, EColumnSortMode::Type); - ue_py_slate_farguments_enum("sort_priority", SortPriority, EColumnSortPriority::Type); + ue_py_slate_farguments_optional_enum("h_align_cell", HAlignCell, EHorizontalAlignment); + ue_py_slate_farguments_optional_enum("v_align_cell", VAlignCell, EVerticalAlignment); - ue_py_slate_farguments_event("on_sort", OnSort, FOnSortModeChanged, OnSort); + ue_py_slate_farguments_enum("sort_mode", SortMode, EColumnSortMode::Type); + ue_py_slate_farguments_enum("sort_priority", SortPriority, EColumnSortPriority::Type); - ue_py_slate_farguments_bool("should_generate_widget", ShouldGenerateWidget); + ue_py_slate_farguments_event("on_sort", OnSort, FOnSortModeChanged, OnSort); - //sw_header_row->AddColumn( - // SHeaderRow::Column(FName(UTF8_TO_TCHAR(column_id))) - // .DefaultLabel(FText::FromString(UTF8_TO_TCHAR(default_label))) - // .DefaultTooltip(FText::FromString(UTF8_TO_TCHAR(default_tooltip))) - // .FixedWidth(fixed_width) - // .HAlignCell((EHorizontalAlignment)cell_h_align) - // .VAlignCell((EVerticalAlignment)cell_v_align) - //); + ue_py_slate_farguments_bool("should_generate_widget", ShouldGenerateWidget); - sw_header_row->AddColumn(arguments); - return 0; - }(); + //sw_header_row->AddColumn( + // SHeaderRow::Column(FName(UTF8_TO_TCHAR(column_id))) + // .DefaultLabel(FText::FromString(UTF8_TO_TCHAR(default_label))) + // .DefaultTooltip(FText::FromString(UTF8_TO_TCHAR(default_tooltip))) + // .FixedWidth(fixed_width) + // .HAlignCell((EHorizontalAlignment)cell_h_align) + // .VAlignCell((EVerticalAlignment)cell_v_align) + //); - if (retCode != 0) - { - return PyErr_Format(PyExc_Exception, "could not add column slot"); - } + py_SHeaderRow->AddColumn(arguments); + return 0; + }(); - Py_INCREF(self); - return (PyObject *)self; + if (retCode != 0) + { + return PyErr_Format(PyExc_Exception, "could not add column slot"); + } + + Py_RETURN_SLATE_SELF; } static PyMethodDef ue_PySHeaderRow_methods[] = { @@ -102,15 +103,17 @@ PyTypeObject ue_PySHeaderRowType = { ue_PySHeaderRow_methods, /* tp_methods */ }; -static int ue_py_sheader_row_init(ue_PySHeaderRow *self, PyObject *args, PyObject *kwargs) { - ue_py_snew_simple(SHeaderRow, s_border.s_compound_widget.s_widget); +static int ue_py_sheader_row_init(ue_PySHeaderRow *self, PyObject *args, PyObject *kwargs) +{ + ue_py_snew_simple(SHeaderRow); return 0; } -void ue_python_init_sheader_row(PyObject *ue_module) { +void ue_python_init_sheader_row(PyObject *ue_module) +{ ue_PySHeaderRowType.tp_init = (initproc)ue_py_sheader_row_init; - ue_PySHeaderRowType.tp_call = (ternaryfunc)py_ue_sheader_row_add_column; + ue_PySHeaderRowType.tp_call = (ternaryfunc)py_ue_sheader_row_add_column; ue_PySHeaderRowType.tp_base = &ue_PySBorderType; @@ -123,8 +126,8 @@ void ue_python_init_sheader_row(PyObject *ue_module) { ue_PySHeaderRow * py_ue_is_sheader_row(PyObject *obj) { - if (!PyObject_IsInstance(obj, (PyObject *)&ue_PySHeaderRowType)) - return nullptr; - return (ue_PySHeaderRow *)obj; + if (!PyObject_IsInstance(obj, (PyObject *)&ue_PySHeaderRowType)) + return nullptr; + return (ue_PySHeaderRow *)obj; } diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySHeaderRow.h b/Source/UnrealEnginePython/Private/Slate/UEPySHeaderRow.h index 0a3129456..0a23b16d7 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySHeaderRow.h +++ b/Source/UnrealEnginePython/Private/Slate/UEPySHeaderRow.h @@ -1,7 +1,5 @@ #pragma once -#include "UnrealEnginePython.h" - #include "UEPySBorder.h" #include "Runtime/Slate/Public/Widgets/Views/SHeaderRow.h" diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySHorizontalBox.cpp b/Source/UnrealEnginePython/Private/Slate/UEPySHorizontalBox.cpp index 56a42c4a0..579615ebb 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySHorizontalBox.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPySHorizontalBox.cpp @@ -1,64 +1,34 @@ -#include "UnrealEnginePythonPrivatePCH.h" - #include "UEPySHorizontalBox.h" -#define sw_horizontal_box StaticCastSharedRef(self->s_box_panel.s_panel.s_widget.s_widget) - - static PyObject *py_ue_shorizontal_box_add_slot(ue_PySHorizontalBox *self, PyObject * args, PyObject *kwargs) { - int32 retCode = [&]() { - ue_py_slate_setup_hack_slot_args(SHorizontalBox, sw_horizontal_box); - ue_py_slate_farguments_float("fill_width", FillWidth); - ue_py_slate_farguments_float("max_width", MaxWidth); - ue_py_slate_farguments_optional_enum("h_align", HAlign, EHorizontalAlignment); - ue_py_slate_farguments_optional_enum("v_align", VAlign, EVerticalAlignment); - - //NOTE: Padding slot in slate is weird and manually supports different parameter constructions - if (PyObject *padding = ue_py_dict_get_item(kwargs, "padding")) - { - if (PyTuple_Check(padding)) - { - FMargin margin; - if (!PyArg_ParseTuple(padding, "f|fff", &margin.Left, &margin.Top, &margin.Right, &margin.Bottom)) - { - PyErr_SetString(PyExc_TypeError, "invalid padding value"); - return -1; - } - arguments.Padding(margin); - } - else if (PyNumber_Check(padding)) - { - PyObject *py_float = PyNumber_Float(padding); - arguments.Padding(PyFloat_AsDouble(py_float)); - Py_DECREF(py_float); - } - else - { - ue_py_slate_farguments_struct("padding", Padding, FMargin); - } - } - PyObject *py_auto_width = ue_py_dict_get_item(kwargs, "auto_width"); - if (py_auto_width && PyObject_IsTrue(py_auto_width)) - { arguments.AutoWidth(); } - - return 0; - }(); - - if (retCode != 0) - { - return PyErr_Format(PyExc_Exception, "could not add horizontal slot"); - } - - Py_INCREF(self); - return (PyObject *)self; + ue_py_slate_cast(SHorizontalBox); + + int32 retCode = [&]() { + ue_py_slate_setup_hack_slot_args(SHorizontalBox, py_SHorizontalBox); + ue_py_slate_farguments_float("fill_width", FillWidth); + ue_py_slate_farguments_float("max_width", MaxWidth); + ue_py_slate_farguments_optional_enum("h_align", HAlign, EHorizontalAlignment); + ue_py_slate_farguments_optional_enum("v_align", VAlign, EVerticalAlignment); + ue_py_slate_farguments_call("auto_width", AutoWidth); + ue_py_slate_farguments_padding("padding", Padding); + return 0; + }(); + + if (retCode != 0) + { + return PyErr_Format(PyExc_Exception, "could not add horizontal slot"); + } + + Py_RETURN_SLATE_SELF; } static PyObject *py_ue_shorizontal_box_num_slots(ue_PySHorizontalBox *self, PyObject * args) { - return PyLong_FromLong(sw_horizontal_box->NumSlots()); + ue_py_slate_cast(SHorizontalBox); + return PyLong_FromLong(py_SHorizontalBox->NumSlots()); } static PyMethodDef ue_PySHorizontalBox_methods[] = { @@ -68,43 +38,31 @@ static PyMethodDef ue_PySHorizontalBox_methods[] = { { NULL } /* Sentinel */ }; -PyTypeObject ue_PySHorizontalBoxType = { - PyVarObject_HEAD_INIT(NULL, 0) - "unreal_engine.SHorizontalBox", /* tp_name */ - sizeof(ue_PySHorizontalBox), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Unreal Engine SHorizontalBox", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ue_PySHorizontalBox_methods, /* tp_methods */ -}; +DECLARE_UE_PY_SLATE_WIDGET(SHorizontalBox); static int ue_py_shorizontal_box_init(ue_PySHorizontalBox *self, PyObject *args, PyObject *kwargs) { - ue_py_snew_simple(SHorizontalBox, s_box_panel.s_panel.s_widget); + ue_py_snew_simple(SHorizontalBox); return 0; } +PyNumberMethods ue_PySHorizontalBox_number_methods; + +static PyObject *ue_py_shorizontal_box_add(ue_PySHorizontalBox *self, PyObject *value) +{ + ue_py_slate_cast(SHorizontalBox); + + TSharedPtr Child = py_ue_is_swidget(value); + if (!Child.IsValid()) + { + return nullptr; + } + + SHorizontalBox::FSlot &fslot = py_SHorizontalBox->AddSlot(); + fslot.AttachWidget(Child.ToSharedRef()); + + Py_RETURN_SLATE_SELF; +} void ue_python_init_shorizontal_box(PyObject *ue_module) { @@ -112,6 +70,10 @@ void ue_python_init_shorizontal_box(PyObject *ue_module) ue_PySHorizontalBoxType.tp_init = (initproc)ue_py_shorizontal_box_init; ue_PySHorizontalBoxType.tp_call = (ternaryfunc)py_ue_shorizontal_box_add_slot; + memset(&ue_PySHorizontalBox_number_methods, 0, sizeof(PyNumberMethods)); + ue_PySHorizontalBoxType.tp_as_number = &ue_PySHorizontalBox_number_methods; + ue_PySHorizontalBox_number_methods.nb_add = (binaryfunc)ue_py_shorizontal_box_add; + ue_PySHorizontalBoxType.tp_base = &ue_PySBoxPanelType; if (PyType_Ready(&ue_PySHorizontalBoxType) < 0) diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySImage.cpp b/Source/UnrealEnginePython/Private/Slate/UEPySImage.cpp index 232d6f4af..d94571971 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySImage.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPySImage.cpp @@ -1,14 +1,14 @@ - -#include "UnrealEnginePythonPrivatePCH.h" - #include "UEPySImage.h" -#define sw_image StaticCastSharedRef(self->s_leaf_widget.s_widget.s_widget) +#include "Engine/Texture2D.h" -static PyObject *py_ue_simage_set_brush(ue_PySImage *self, PyObject * args) { +static PyObject *py_ue_simage_set_brush(ue_PySImage *self, PyObject * args) +{ + ue_py_slate_cast(SImage); PyObject *py_brush; - if (!PyArg_ParseTuple(args, "O:set_brush", &py_brush)) { - return NULL; + if (!PyArg_ParseTuple(args, "O:set_brush", &py_brush)) + { + return nullptr; } FSlateBrush *brush = ue_py_check_struct(py_brush); @@ -17,17 +17,19 @@ static PyObject *py_ue_simage_set_brush(ue_PySImage *self, PyObject * args) { self->brush = *brush; - sw_image->SetImage(&self->brush); + py_SImage->SetImage(&self->brush); - Py_INCREF(self); - return (PyObject *)self; + Py_RETURN_SLATE_SELF; } -static PyObject *py_ue_simage_set_texture(ue_PySImage *self, PyObject * args) { +static PyObject *py_ue_simage_set_texture(ue_PySImage *self, PyObject * args) +{ + ue_py_slate_cast(SImage); PyObject *py_texture; PyObject *py_linear_color = nullptr; - if (!PyArg_ParseTuple(args, "O|O:set_texture", &py_texture, &py_linear_color)) { - return NULL; + if (!PyArg_ParseTuple(args, "O|O:set_texture", &py_texture, &py_linear_color)) + { + return nullptr; } UTexture2D *texture = ue_py_check_type(py_texture); @@ -36,9 +38,11 @@ static PyObject *py_ue_simage_set_texture(ue_PySImage *self, PyObject * args) { FLinearColor tint(1, 1, 1, 1); - if (py_linear_color) { + if (py_linear_color) + { ue_PyFLinearColor *py_color = py_ue_is_flinearcolor(py_linear_color); - if (!py_color) { + if (!py_color) + { return PyErr_Format(PyExc_Exception, "argument is not a FLinearColor"); } tint = py_color->color; @@ -53,10 +57,9 @@ static PyObject *py_ue_simage_set_texture(ue_PySImage *self, PyObject * args) { self->brush.TintColor = tint; #endif - sw_image->SetImage(&self->brush); + py_SImage->SetImage(&self->brush); - Py_INCREF(self); - return (PyObject *)self; + Py_RETURN_SLATE_SELF; } static PyMethodDef ue_PySImage_methods[] = { @@ -97,18 +100,20 @@ PyTypeObject ue_PySImageType = { ue_PySImage_methods, /* tp_methods */ }; -static int ue_py_simage_init(ue_PySImage *self, PyObject *args, PyObject *kwargs) { +static int ue_py_simage_init(ue_PySImage *self, PyObject *args, PyObject *kwargs) +{ ue_py_slate_setup_farguments(SImage); ue_py_slate_farguments_struct("color_and_opacity", ColorAndOpacity, FSlateColor); ue_py_slate_farguments_optional_struct_ptr("image", Image, FSlateBrush); ue_py_slate_farguments_event("on_mouse_button_down", OnMouseButtonDown, FPointerEventHandler, OnMouseEvent); - ue_py_snew(SImage, s_leaf_widget.s_widget); + ue_py_snew(SImage); return 0; } -void ue_python_init_simage(PyObject *ue_module) { +void ue_python_init_simage(PyObject *ue_module) +{ ue_PySImageType.tp_init = (initproc)ue_py_simage_init; diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySImage.h b/Source/UnrealEnginePython/Private/Slate/UEPySImage.h index fb608ef55..584e14e50 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySImage.h +++ b/Source/UnrealEnginePython/Private/Slate/UEPySImage.h @@ -5,7 +5,11 @@ #include "UEPySLeafWidget.h" +#if ENGINE_MINOR_VERSION > 21 +#include "Runtime/SlateCore/Public/Widgets/Images/SImage.h" +#else #include "Runtime/Slate/Public/Widgets/Images/SImage.h" +#endif #include "Runtime/SlateCore/Public/Styling/SlateBrush.h" extern PyTypeObject ue_PySImageType; diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySLeafWidget.cpp b/Source/UnrealEnginePython/Private/Slate/UEPySLeafWidget.cpp index 3198c3630..a24a90e74 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySLeafWidget.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPySLeafWidget.cpp @@ -1,5 +1,4 @@ -#include "UnrealEnginePythonPrivatePCH.h" #include "UEPySLeafWidget.h" @@ -38,7 +37,8 @@ PyTypeObject ue_PySLeafWidgetType = { ue_PySLeafWidget_methods, /* tp_methods */ }; -void ue_python_init_sleaf_widget(PyObject *ue_module) { +void ue_python_init_sleaf_widget(PyObject *ue_module) +{ ue_PySLeafWidgetType.tp_base = &ue_PySWidgetType; diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySLeafWidget.h b/Source/UnrealEnginePython/Private/Slate/UEPySLeafWidget.h index 126d6669d..ffa84c904 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySLeafWidget.h +++ b/Source/UnrealEnginePython/Private/Slate/UEPySLeafWidget.h @@ -1,7 +1,5 @@ #pragma once -#include "UnrealEnginePython.h" - #include "UEPySWidget.h" #include "Runtime/SlateCore/Public/Widgets/SLeafWidget.h" diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySLevelViewport.cpp b/Source/UnrealEnginePython/Private/Slate/UEPySLevelViewport.cpp index 981cacce6..fd8cce68b 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySLevelViewport.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPySLevelViewport.cpp @@ -1,66 +1,68 @@ +#include "UEPySLevelViewport.h" + #if WITH_EDITOR -#include "UnrealEnginePythonPrivatePCH.h" -#include "UEPySLevelViewport.h" + + #include "LevelEditor.h" #include "Editor/LevelEditor/Public/ILevelEditor.h" -#define sw_level_viewport StaticCastSharedRef(self->s_editor_viewport.s_compound_widget.s_widget.s_widget) - static PyObject *py_ue_slevel_viewport_get_world(ue_PySLevelViewport *self, PyObject * args) { - Py_RETURN_UOBJECT(sw_level_viewport->GetWorld()); + ue_py_slate_cast(SLevelViewport); + Py_RETURN_UOBJECT(py_SLevelViewport->GetWorld()); } static PyObject *py_ue_slevel_viewport_set_show_bounds(ue_PySLevelViewport *self, PyObject * args) { + ue_py_slate_cast(SLevelViewport); PyObject *py_bool; if (!PyArg_ParseTuple(args, "O:set_show_bounds", &py_bool)) { - return NULL; + return nullptr; } - sw_level_viewport->GetViewportClient()->SetShowBounds(PyObject_IsTrue(py_bool) ? true : false); + py_SLevelViewport->GetViewportClient()->SetShowBounds(PyObject_IsTrue(py_bool) ? true : false); - Py_INCREF(self); - return (PyObject *)self; + Py_RETURN_SLATE_SELF; } static PyObject *py_ue_slevel_viewport_set_show_stats(ue_PySLevelViewport *self, PyObject * args) { + ue_py_slate_cast(SLevelViewport); PyObject *py_bool; if (!PyArg_ParseTuple(args, "O:set_show_stats", &py_bool)) { - return NULL; + return nullptr; } - sw_level_viewport->GetViewportClient()->SetShowStats(PyObject_IsTrue(py_bool) ? true : false); + py_SLevelViewport->GetViewportClient()->SetShowStats(PyObject_IsTrue(py_bool) ? true : false); - Py_INCREF(self); - return (PyObject *)self; + Py_RETURN_SLATE_SELF; } static PyObject *py_ue_slevel_viewport_set_view_mode(ue_PySLevelViewport *self, PyObject * args) { + ue_py_slate_cast(SLevelViewport); int mode; if (!PyArg_ParseTuple(args, "i:set_view_mode", &mode)) { - return NULL; + return nullptr; } - sw_level_viewport->GetViewportClient()->SetViewMode((EViewModeIndex)mode); + py_SLevelViewport->GetViewportClient()->SetViewMode((EViewModeIndex)mode); - Py_INCREF(self); - return (PyObject *)self; + Py_RETURN_SLATE_SELF; } -static PyObject *py_ue_slevel_viewport_set_exposure_settings(ue_PySPythonEditorViewport *self, PyObject * args) +static PyObject *py_ue_slevel_viewport_set_exposure_settings(ue_PySLevelViewport *self, PyObject * args) { + ue_py_slate_cast(SLevelViewport); PyObject *py_settings; if (!PyArg_ParseTuple(args, "O:set_exposure_settings", &py_settings)) { - return NULL; + return nullptr; } FExposureSettings *settings = ue_py_check_struct(py_settings); @@ -69,14 +71,13 @@ static PyObject *py_ue_slevel_viewport_set_exposure_settings(ue_PySPythonEditorV return PyErr_Format(PyExc_Exception, "argument is not a FExposureSettings"); } - sw_level_viewport->GetViewportClient()->ExposureSettings = *settings; + py_SLevelViewport->GetViewportClient()->ExposureSettings = *settings; - Py_INCREF(self); - return (PyObject *)self; + Py_RETURN_SLATE_SELF; } /* -PyObject *py_ue_spython_editor_viewport_simulate(ue_PySPythonEditorViewport *self, PyObject * args) { +PyObject *py_ue_spython_editor_viewport_simulate(ue_PySLevelViewport *self, PyObject * args) { sw_python_editor_viewport->GetViewportClient()->SetIsSimulateInEditorViewport(true); @@ -137,9 +138,10 @@ static int ue_py_slevel_viewport_init(ue_PySLevelViewport *self, PyObject *args, ue_py_slate_farguments_optional_bool("realtime", Realtime); ue_py_slate_farguments_optional_enum("viewport_type", ViewportType, ELevelViewportType); - ue_py_snew(SLevelViewport, s_editor_viewport.s_compound_widget.s_widget); + ue_py_snew(SLevelViewport); + ue_py_slate_cast(SLevelViewport); - EditorModule.GetFirstLevelEditor()->AddStandaloneLevelViewport(sw_level_viewport); + EditorModule.GetFirstLevelEditor()->AddStandaloneLevelViewport(py_SLevelViewport); return 0; } diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySLevelViewport.h b/Source/UnrealEnginePython/Private/Slate/UEPySLevelViewport.h index 29eac85f4..c833c2086 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySLevelViewport.h +++ b/Source/UnrealEnginePython/Private/Slate/UEPySLevelViewport.h @@ -1,10 +1,9 @@ #pragma once -#include "UnrealEnginePython.h" - - #include "UEPySEditorViewport.h" +#if WITH_EDITOR + #include "Editor/LevelEditor/Public/SLevelViewport.h" #include "Editor/LevelEditor/Private/SLevelEditor.h" #include "Editor/UnrealEd/Public/EditorViewportClient.h" @@ -12,9 +11,11 @@ extern PyTypeObject ue_PySLevelViewportType; -typedef struct { +typedef struct +{ ue_PySEditorViewport s_editor_viewport; /* Type-specific fields go here. */ } ue_PySLevelViewport; -void ue_python_init_slevel_viewport(PyObject *); \ No newline at end of file +void ue_python_init_slevel_viewport(PyObject *); +#endif \ No newline at end of file diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySListView.cpp b/Source/UnrealEnginePython/Private/Slate/UEPySListView.cpp index 898ecd580..a8c5190e8 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySListView.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPySListView.cpp @@ -1,10 +1,7 @@ -#include "UnrealEnginePythonPrivatePCH.h" #include "UEPySListView.h" -#define sw_slist_view StaticCastSharedRef>>(self->s_table_view_base.s_compound_widget.s_widget.s_widget) - static PyMethodDef ue_PySListView_methods[] = { { NULL } /* Sentinel */ }; @@ -41,7 +38,8 @@ PyTypeObject ue_PySListViewType = { }; -void ue_python_init_slist_view(PyObject *ue_module) { +void ue_python_init_slist_view(PyObject *ue_module) +{ ue_PySListViewType.tp_base = &ue_PySTableViewBaseType; diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySMultiLineEditableText.cpp b/Source/UnrealEnginePython/Private/Slate/UEPySMultiLineEditableText.cpp index 568d920b2..31c62c6ec 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySMultiLineEditableText.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPySMultiLineEditableText.cpp @@ -1,61 +1,65 @@ -#include "UnrealEnginePythonPrivatePCH.h" -#include "UEPySEditableTextBox.h" +#include "UEPySMultiLineEditableText.h" +static PyObject *py_ue_smulti_line_editable_text_select_all_text(ue_PySMultiLineEditableText *self, PyObject * args) +{ + ue_py_slate_cast(SMultiLineEditableText); -#define sw_multi_line_editable_text StaticCastSharedRef(self->s_widget.s_widget) + py_SMultiLineEditableText->SelectAllText(); -static PyObject *py_ue_smulti_line_editable_text_select_all_text(ue_PySMultiLineEditableText *self, PyObject * args) { - - sw_multi_line_editable_text->SelectAllText(); - - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } -static PyObject *py_ue_smulti_line_editable_text_clear_selection(ue_PySMultiLineEditableText *self, PyObject * args) { +static PyObject *py_ue_smulti_line_editable_text_clear_selection(ue_PySMultiLineEditableText *self, PyObject * args) +{ + ue_py_slate_cast(SMultiLineEditableText); + py_SMultiLineEditableText->ClearSelection(); - sw_multi_line_editable_text->ClearSelection(); - - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } -static PyObject *py_ue_smulti_line_editable_text_get_selected_text(ue_PySMultiLineEditableText *self, PyObject * args) { - +static PyObject *py_ue_smulti_line_editable_text_get_selected_text(ue_PySMultiLineEditableText *self, PyObject * args) +{ + ue_py_slate_cast(SMultiLineEditableText); - FText text = sw_multi_line_editable_text->GetSelectedText(); + FText text = py_SMultiLineEditableText->GetSelectedText(); return PyUnicode_FromString(TCHAR_TO_UTF8(*text.ToString())); } -static PyObject *py_ue_smulti_line_editable_text_get_text(ue_PySMultiLineEditableText *self, PyObject * args) { +static PyObject *py_ue_smulti_line_editable_text_get_text(ue_PySMultiLineEditableText *self, PyObject * args) +{ + ue_py_slate_cast(SMultiLineEditableText); - FText text = sw_multi_line_editable_text->GetText(); + FText text = py_SMultiLineEditableText->GetText(); return PyUnicode_FromString(TCHAR_TO_UTF8(*text.ToString())); } -static PyObject *py_ue_smulti_line_editable_text_get_plain_text(ue_PySMultiLineEditableText *self, PyObject * args) { +static PyObject *py_ue_smulti_line_editable_text_get_plain_text(ue_PySMultiLineEditableText *self, PyObject * args) +{ + ue_py_slate_cast(SMultiLineEditableText); - FText text = sw_multi_line_editable_text->GetPlainText(); + FText text = py_SMultiLineEditableText->GetPlainText(); return PyUnicode_FromString(TCHAR_TO_UTF8(*text.ToString())); } -static PyObject *py_ue_smulti_line_editable_text_set_text(ue_PySMultiLineEditableText *self, PyObject * args) { +static PyObject *py_ue_smulti_line_editable_text_set_text(ue_PySMultiLineEditableText *self, PyObject * args) +{ + ue_py_slate_cast(SMultiLineEditableText); char *text; - if (!PyArg_ParseTuple(args, "s:set_text", &text)) { + if (!PyArg_ParseTuple(args, "s:set_text", &text)) + { return NULL; } - sw_multi_line_editable_text->SetText(FText::FromString(UTF8_TO_TCHAR(text))); + py_SMultiLineEditableText->SetText(FText::FromString(UTF8_TO_TCHAR(text))); - Py_INCREF(self); - return (PyObject *)self; + Py_RETURN_SLATE_SELF; } @@ -100,7 +104,8 @@ PyTypeObject ue_PySMultiLineEditableTextType = { ue_PySMultiLineEditableText_methods, /* tp_methods */ }; -static int ue_py_smulti_line_editable_text_init(ue_PySMultiLineEditableText *self, PyObject *args, PyObject *kwargs) { +static int ue_py_smulti_line_editable_text_init(ue_PySMultiLineEditableText *self, PyObject *args, PyObject *kwargs) +{ ue_py_slate_setup_farguments(SMultiLineEditableText); @@ -111,11 +116,12 @@ static int ue_py_smulti_line_editable_text_init(ue_PySMultiLineEditableText *sel ue_py_slate_farguments_text("text", Text); - ue_py_snew(SMultiLineEditableText, s_widget); + ue_py_snew(SMultiLineEditableText); return 0; } -void ue_python_init_smulti_line_editable_text(PyObject *ue_module) { +void ue_python_init_smulti_line_editable_text(PyObject *ue_module) +{ ue_PySMultiLineEditableTextType.tp_init = (initproc)ue_py_smulti_line_editable_text_init; diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySMultiLineEditableText.h b/Source/UnrealEnginePython/Private/Slate/UEPySMultiLineEditableText.h index 9f339c136..913859b16 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySMultiLineEditableText.h +++ b/Source/UnrealEnginePython/Private/Slate/UEPySMultiLineEditableText.h @@ -1,16 +1,15 @@ #pragma once -#include "UnrealEnginePython.h" - #include "UEPySWidget.h" #include "Runtime/Slate/Public/Widgets/Text/SMultiLineEditableText.h" extern PyTypeObject ue_PySMultiLineEditableTextType; -typedef struct { +typedef struct +{ ue_PySWidget s_widget; /* Type-specific fields go here. */ } ue_PySMultiLineEditableText; -void ue_python_init_smulti_line_editable_text(PyObject *); \ No newline at end of file +void ue_python_init_smulti_line_editable_text(PyObject *); diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySNodePanel.cpp b/Source/UnrealEnginePython/Private/Slate/UEPySNodePanel.cpp index d239341f4..7916b516f 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySNodePanel.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPySNodePanel.cpp @@ -1,57 +1,55 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPySNodePanel.h" #if WITH_EDITOR -#include "UEPySNodePanel.h" -#define sw_node_panel StaticCastSharedRef(self->s_panel.s_widget) static PyMethodDef ue_PySNodePanel_methods[] = { - { NULL } /* Sentinel */ + { NULL } /* Sentinel */ }; PyTypeObject ue_PySNodePanelType = { - PyVarObject_HEAD_INIT(NULL, 0) - "unreal_engine.SNodePanel", /* tp_name */ - sizeof(ue_PySNodePanel), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Unreal Engine SNode Panel", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ue_PySNodePanel_methods, /* tp_methods */ + PyVarObject_HEAD_INIT(NULL, 0) + "unreal_engine.SNodePanel", /* tp_name */ + sizeof(ue_PySNodePanel), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + "Unreal Engine SNode Panel", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + ue_PySNodePanel_methods, /* tp_methods */ }; void ue_python_init_snode_panel(PyObject *ue_module) { - ue_PySNodePanelType.tp_base = &ue_PySPanelType; + ue_PySNodePanelType.tp_base = &ue_PySPanelType; - if (PyType_Ready(&ue_PySNodePanelType) < 0) - return; + if (PyType_Ready(&ue_PySNodePanelType) < 0) + return; - Py_INCREF(&ue_PySNodePanelType); - PyModule_AddObject(ue_module, "SNodePanel", (PyObject *)&ue_PySNodePanelType); + Py_INCREF(&ue_PySNodePanelType); + PyModule_AddObject(ue_module, "SNodePanel", (PyObject *)&ue_PySNodePanelType); } #endif \ No newline at end of file diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySNumericEntryBox.cpp b/Source/UnrealEnginePython/Private/Slate/UEPySNumericEntryBox.cpp index a073b7b98..5f4df21bc 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySNumericEntryBox.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPySNumericEntryBox.cpp @@ -1,12 +1,8 @@ -#include "UnrealEnginePythonPrivatePCH.h" #include "UEPySNumericEntryBox.h" -#define sw_float_numeric_entry_box StaticCastSharedRef>(self->s_compound_widget.s_widget.s_widget) - - static PyMethodDef ue_PySNumericEntryBox_methods[] = { { NULL } /* Sentinel */ }; @@ -42,70 +38,72 @@ PyTypeObject ue_PySNumericEntryBoxType = { ue_PySNumericEntryBox_methods, /* tp_methods */ }; -static int ue_py_snumeric_entry_box_init(ue_PySNumericEntryBox *self, PyObject *args, PyObject *kwargs) { - - PyObject *py_numeric_type = ue_py_dict_get_item(kwargs, "numeric_type"); - if (py_numeric_type && PyLong_Check(py_numeric_type)) - { - ue_py_slate_setup_farguments(SNumericEntryBox); - - ue_py_slate_farguments_optional_bool("allow_spin", AllowSpin); - ue_py_slate_farguments_optional_struct("border_background_color", BorderBackgroundColor, FSlateColor); - ue_py_slate_farguments_optional_struct("border_foreground_color", BorderForegroundColor, FSlateColor); - ue_py_slate_farguments_int("delta", Delta); - ue_py_slate_farguments_optional_struct_ptr("editable_text_box_style", EditableTextBoxStyle, FEditableTextBoxStyle); - ue_py_slate_farguments_struct("font", Font, FSlateFontInfo); - ue_py_slate_farguments_optional_struct("label_padding", LabelPadding, FMargin); - ue_py_slate_farguments_optional_enum("label_v_align", LabelVAlign, EVerticalAlignment); - ue_py_slate_farguments_tint("max_slider_value", MaxSliderValue); - ue_py_slate_farguments_tint("max_value", MaxValue); - ue_py_slate_farguments_float("min_desired_value_width", MinDesiredValueWidth); - ue_py_slate_farguments_tint("min_slider_value", MinSliderValue); - ue_py_slate_farguments_tint("min_value", MinValue); - ue_py_slate_farguments_struct("override_text_margin", OverrideTextMargin, FMargin); - ue_py_slate_farguments_float("slider_exponent", SliderExponent); - ue_py_slate_farguments_optional_text("undetermined_string", UndeterminedString); - ue_py_slate_farguments_tint("value", Value); - ue_py_slate_farguments_event("on_begin_slider_movement", OnBeginSliderMovement, FSimpleDelegate, SimpleExecuteAction); - ue_py_slate_farguments_event("on_end_slider_movement", OnEndSliderMovement, FOnInt32ValueChanged, OnInt32Changed); - ue_py_slate_farguments_event("on_value_changed", OnValueChanged, FOnInt32ValueChanged, OnInt32Changed); - ue_py_slate_farguments_event("on_value_committed", OnValueCommitted, FOnInt32ValueCommitted, OnInt32Committed); - - ue_py_snew(SNumericEntryBox, s_compound_widget.s_widget); - } - else - { - ue_py_slate_setup_farguments(SNumericEntryBox); - - ue_py_slate_farguments_optional_bool("allow_spin", AllowSpin); - ue_py_slate_farguments_optional_struct("border_background_color", BorderBackgroundColor, FSlateColor); - ue_py_slate_farguments_optional_struct("border_foreground_color", BorderForegroundColor, FSlateColor); - ue_py_slate_farguments_float("delta", Delta); - ue_py_slate_farguments_optional_struct_ptr("editable_text_box_style", EditableTextBoxStyle, FEditableTextBoxStyle); - ue_py_slate_farguments_struct("font", Font, FSlateFontInfo); - ue_py_slate_farguments_optional_struct("label_padding", LabelPadding, FMargin); - ue_py_slate_farguments_optional_enum("label_v_align", LabelVAlign, EVerticalAlignment); - ue_py_slate_farguments_tfloat("max_slider_value", MaxSliderValue); - ue_py_slate_farguments_tfloat("max_value", MaxValue); - ue_py_slate_farguments_float("min_desired_value_width", MinDesiredValueWidth); - ue_py_slate_farguments_tfloat("min_slider_value", MinSliderValue); - ue_py_slate_farguments_tfloat("min_value", MinValue); - ue_py_slate_farguments_struct("override_text_margin", OverrideTextMargin, FMargin); - ue_py_slate_farguments_float("slider_exponent", SliderExponent); - ue_py_slate_farguments_optional_text("undetermined_string", UndeterminedString); - ue_py_slate_farguments_tfloat("value", Value); - ue_py_slate_farguments_event("on_begin_slider_movement", OnBeginSliderMovement, FSimpleDelegate, SimpleExecuteAction); - ue_py_slate_farguments_event("on_end_slider_movement", OnEndSliderMovement, FOnFloatValueChanged, OnFloatChanged); - ue_py_slate_farguments_event("on_value_changed", OnValueChanged, FOnFloatValueChanged, OnFloatChanged); - ue_py_slate_farguments_event("on_value_committed", OnValueCommitted, FOnFloatValueCommitted, OnFloatCommitted); - - ue_py_snew(SNumericEntryBox, s_compound_widget.s_widget); - } +static int ue_py_snumeric_entry_box_init(ue_PySNumericEntryBox *self, PyObject *args, PyObject *kwargs) +{ + + PyObject *py_numeric_type = ue_py_dict_get_item(kwargs, "numeric_type"); + if (py_numeric_type && PyLong_Check(py_numeric_type)) + { + ue_py_slate_setup_farguments(SNumericEntryBox); + + ue_py_slate_farguments_optional_bool("allow_spin", AllowSpin); + ue_py_slate_farguments_optional_struct("border_background_color", BorderBackgroundColor, FSlateColor); + ue_py_slate_farguments_optional_struct("border_foreground_color", BorderForegroundColor, FSlateColor); + ue_py_slate_farguments_int("delta", Delta); + ue_py_slate_farguments_optional_struct_ptr("editable_text_box_style", EditableTextBoxStyle, FEditableTextBoxStyle); + ue_py_slate_farguments_struct("font", Font, FSlateFontInfo); + ue_py_slate_farguments_optional_struct("label_padding", LabelPadding, FMargin); + ue_py_slate_farguments_optional_enum("label_v_align", LabelVAlign, EVerticalAlignment); + ue_py_slate_farguments_tint("max_slider_value", MaxSliderValue); + ue_py_slate_farguments_tint("max_value", MaxValue); + ue_py_slate_farguments_float("min_desired_value_width", MinDesiredValueWidth); + ue_py_slate_farguments_tint("min_slider_value", MinSliderValue); + ue_py_slate_farguments_tint("min_value", MinValue); + ue_py_slate_farguments_struct("override_text_margin", OverrideTextMargin, FMargin); + ue_py_slate_farguments_float("slider_exponent", SliderExponent); + ue_py_slate_farguments_optional_text("undetermined_string", UndeterminedString); + ue_py_slate_farguments_tint("value", Value); + ue_py_slate_farguments_event("on_begin_slider_movement", OnBeginSliderMovement, FSimpleDelegate, SimpleExecuteAction); + ue_py_slate_farguments_event("on_end_slider_movement", OnEndSliderMovement, FOnInt32ValueChanged, OnInt32Changed); + ue_py_slate_farguments_event("on_value_changed", OnValueChanged, FOnInt32ValueChanged, OnInt32Changed); + ue_py_slate_farguments_event("on_value_committed", OnValueCommitted, FOnInt32ValueCommitted, OnInt32Committed); + + ue_py_snew(SNumericEntryBox); + } + else + { + ue_py_slate_setup_farguments(SNumericEntryBox); + + ue_py_slate_farguments_optional_bool("allow_spin", AllowSpin); + ue_py_slate_farguments_optional_struct("border_background_color", BorderBackgroundColor, FSlateColor); + ue_py_slate_farguments_optional_struct("border_foreground_color", BorderForegroundColor, FSlateColor); + ue_py_slate_farguments_float("delta", Delta); + ue_py_slate_farguments_optional_struct_ptr("editable_text_box_style", EditableTextBoxStyle, FEditableTextBoxStyle); + ue_py_slate_farguments_struct("font", Font, FSlateFontInfo); + ue_py_slate_farguments_optional_struct("label_padding", LabelPadding, FMargin); + ue_py_slate_farguments_optional_enum("label_v_align", LabelVAlign, EVerticalAlignment); + ue_py_slate_farguments_tfloat("max_slider_value", MaxSliderValue); + ue_py_slate_farguments_tfloat("max_value", MaxValue); + ue_py_slate_farguments_float("min_desired_value_width", MinDesiredValueWidth); + ue_py_slate_farguments_tfloat("min_slider_value", MinSliderValue); + ue_py_slate_farguments_tfloat("min_value", MinValue); + ue_py_slate_farguments_struct("override_text_margin", OverrideTextMargin, FMargin); + ue_py_slate_farguments_float("slider_exponent", SliderExponent); + ue_py_slate_farguments_optional_text("undetermined_string", UndeterminedString); + ue_py_slate_farguments_tfloat("value", Value); + ue_py_slate_farguments_event("on_begin_slider_movement", OnBeginSliderMovement, FSimpleDelegate, SimpleExecuteAction); + ue_py_slate_farguments_event("on_end_slider_movement", OnEndSliderMovement, FOnFloatValueChanged, OnFloatChanged); + ue_py_slate_farguments_event("on_value_changed", OnValueChanged, FOnFloatValueChanged, OnFloatChanged); + ue_py_slate_farguments_event("on_value_committed", OnValueCommitted, FOnFloatValueCommitted, OnFloatCommitted); + + ue_py_snew(SNumericEntryBox); + } return 0; } -void ue_python_init_snumeric_entry_box(PyObject *ue_module) { +void ue_python_init_snumeric_entry_box(PyObject *ue_module) +{ ue_PySNumericEntryBoxType.tp_init = (initproc)ue_py_snumeric_entry_box_init; diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySNumericEntryBox.h b/Source/UnrealEnginePython/Private/Slate/UEPySNumericEntryBox.h index 6fa9e7c09..8ef90337b 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySNumericEntryBox.h +++ b/Source/UnrealEnginePython/Private/Slate/UEPySNumericEntryBox.h @@ -1,14 +1,14 @@ #pragma once -#include "UnrealEnginePython.h" #include "UEPySCompoundWidget.h" -#include "Runtime/Slate/Public/SlateFwd.h" +#include "Runtime/Slate/Public/Widgets/Input/SNumericEntryBox.h" extern PyTypeObject ue_PySNumericEntryBoxType; -typedef struct { +typedef struct +{ ue_PySCompoundWidget s_compound_widget; /* Type-specific fields go here. */ } ue_PySNumericEntryBox; diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySObjectPropertyEntryBox.cpp b/Source/UnrealEnginePython/Private/Slate/UEPySObjectPropertyEntryBox.cpp index c8684fcac..d398f4caf 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySObjectPropertyEntryBox.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPySObjectPropertyEntryBox.cpp @@ -1,47 +1,16 @@ -#if WITH_EDITOR -#include "UnrealEnginePythonPrivatePCH.h" - #include "UEPySObjectPropertyEntryBox.h" -#define sw_object_property_entry_box StaticCastSharedRef(self->s_compound_widget.s_widget.s_widget) +#if WITH_EDITOR static PyMethodDef ue_PySObjectPropertyEntryBox_methods[] = { { NULL } /* Sentinel */ }; -PyTypeObject ue_PySObjectPropertyEntryBoxType = { - PyVarObject_HEAD_INIT(NULL, 0) - "unreal_engine.SObjectPropertyEntryBox", /* tp_name */ - sizeof(ue_PySObjectPropertyEntryBox), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Unreal Engine SObjectPropertyEntryBox", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ue_PySObjectPropertyEntryBox_methods, /* tp_methods */ -}; +DECLARE_UE_PY_SLATE_WIDGET(SObjectPropertyEntryBox); -static int ue_py_sobject_property_entry_box_init(ue_PySObjectPropertyEntryBox *self, PyObject *args, PyObject *kwargs) { +static int ue_py_sobject_property_entry_box_init(ue_PySObjectPropertyEntryBox *self, PyObject *args, PyObject *kwargs) +{ ue_py_slate_setup_farguments(SObjectPropertyEntryBox); ue_py_slate_farguments_optional_bool("allow_clear", AllowClear); @@ -57,11 +26,12 @@ static int ue_py_sobject_property_entry_box_init(ue_PySObjectPropertyEntryBox *s ue_py_slate_farguments_event("on_object_changed", OnObjectChanged, FOnSetObject, OnAssetChanged); ue_py_slate_farguments_event("on_should_filter_asset", OnShouldFilterAsset, FOnShouldFilterAsset, OnShouldFilterAsset); - ue_py_snew(SObjectPropertyEntryBox, s_compound_widget.s_widget); + ue_py_snew(SObjectPropertyEntryBox); return 0; } -void ue_python_init_sobject_property_entry_box(PyObject *ue_module) { +void ue_python_init_sobject_property_entry_box(PyObject *ue_module) +{ ue_PySObjectPropertyEntryBoxType.tp_init = (initproc)ue_py_sobject_property_entry_box_init; diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySObjectPropertyEntryBox.h b/Source/UnrealEnginePython/Private/Slate/UEPySObjectPropertyEntryBox.h index f9335f75d..d96de803b 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySObjectPropertyEntryBox.h +++ b/Source/UnrealEnginePython/Private/Slate/UEPySObjectPropertyEntryBox.h @@ -1,17 +1,18 @@ #pragma once -#include "UnrealEnginePython.h" - - #include "UEPySCompoundWidget.h" +#if WITH_EDITOR + #include "Editor/PropertyEditor/Public/PropertyCustomizationHelpers.h" extern PyTypeObject ue_PySObjectPropertyEntryBoxType; -typedef struct { +typedef struct +{ ue_PySCompoundWidget s_compound_widget; /* Type-specific fields go here. */ } ue_PySObjectPropertyEntryBox; void ue_python_init_sobject_property_entry_box(PyObject *); +#endif diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySOverlay.cpp b/Source/UnrealEnginePython/Private/Slate/UEPySOverlay.cpp index fadef42f4..3652785b3 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySOverlay.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPySOverlay.cpp @@ -1,13 +1,11 @@ -#include "UnrealEnginePythonPrivatePCH.h" -#include "UEPySBox.h" - - -#define sw_overlay StaticCastSharedRef(self->s_panel.s_widget.s_widget) +#include "UEPySOverlay.h" static PyObject *py_ue_soverlay_add_slot(ue_PySOverlay *self, PyObject * args, PyObject *kwargs) { + ue_py_slate_cast(SOverlay); + PyObject *py_content; int z_order = -1; int h_align = 0; @@ -31,16 +29,12 @@ static PyObject *py_ue_soverlay_add_slot(ue_PySOverlay *self, PyObject * args, P return nullptr; } - ue_PySWidget *py_swidget = py_ue_is_swidget(py_content); - if (!py_swidget) - { - return PyErr_Format(PyExc_Exception, "argument is not a SWidget"); - } - - Py_INCREF(py_swidget); + TSharedPtr Child = py_ue_is_swidget(py_content); + if (!Child.IsValid()) + return nullptr; - SOverlay::FOverlaySlot &fslot = sw_overlay->AddSlot(z_order); - fslot.AttachWidget(py_swidget->s_widget->AsShared()); + SOverlay::FOverlaySlot &fslot = py_SOverlay->AddSlot(z_order); + fslot.AttachWidget(Child.ToSharedRef()); fslot.HAlign((EHorizontalAlignment)h_align); if (padding) { @@ -66,13 +60,13 @@ static PyObject *py_ue_soverlay_add_slot(ue_PySOverlay *self, PyObject * args, P } fslot.VAlign((EVerticalAlignment)v_align); - Py_INCREF(self); - return (PyObject *)self; + Py_RETURN_SLATE_SELF; } static PyObject *py_ue_soverlay_get_num_widgets(ue_PySOverlay *self, PyObject * args) { - return PyLong_FromLong(sw_overlay->GetNumWidgets()); + ue_py_slate_cast(SOverlay); + return PyLong_FromLong(py_SOverlay->GetNumWidgets()); } static PyMethodDef ue_PySOverlay_methods[] = { @@ -113,11 +107,9 @@ PyTypeObject ue_PySOverlayType = { ue_PySOverlay_methods, /* tp_methods */ }; -static int ue_py_soverlay_init(ue_PySBox *self, PyObject *args, PyObject *kwargs) +static int ue_py_soverlay_init(ue_PySOverlay *self, PyObject *args, PyObject *kwargs) { - - ue_py_snew_simple(SOverlay, s_panel.s_widget); - + ue_py_snew_simple(SOverlay); return 0; } diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySPanel.cpp b/Source/UnrealEnginePython/Private/Slate/UEPySPanel.cpp index 3a1a86af9..8ac16e1e8 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySPanel.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPySPanel.cpp @@ -1,5 +1,4 @@ -#include "UnrealEnginePythonPrivatePCH.h" #include "UEPySPanel.h" diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySPanel.h b/Source/UnrealEnginePython/Private/Slate/UEPySPanel.h index 0c12eee66..40a121073 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySPanel.h +++ b/Source/UnrealEnginePython/Private/Slate/UEPySPanel.h @@ -1,9 +1,5 @@ #pragma once - -#include "UnrealEnginePython.h" - - #include "UEPySWidget.h" extern PyTypeObject ue_PySPanelType; diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySProgressBar.cpp b/Source/UnrealEnginePython/Private/Slate/UEPySProgressBar.cpp index eb47a2faf..a0c1a98e8 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySProgressBar.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPySProgressBar.cpp @@ -1,19 +1,16 @@ - -#include "UnrealEnginePythonPrivatePCH.h" - #include "UEPySProgressBar.h" -#define sw_progress_bar StaticCastSharedRef(self->s_leaf_widget.s_widget.s_widget) - -static PyObject *py_ue_sprogress_bar_set_percent(ue_PySProgressBar *self, PyObject *args) { +static PyObject *py_ue_sprogress_bar_set_percent(ue_PySProgressBar *self, PyObject *args) +{ + ue_py_slate_cast(SProgressBar); float percent; - if (!PyArg_ParseTuple(args, "f", &percent)) { + if (!PyArg_ParseTuple(args, "f", &percent)) + { return nullptr; } - sw_progress_bar->SetPercent(percent); + py_SProgressBar->SetPercent(percent); - Py_INCREF(self); - return (PyObject *)self; + Py_RETURN_SLATE_SELF; } static PyMethodDef ue_PySProgressBar_methods[] = { @@ -52,7 +49,8 @@ PyTypeObject ue_PySProgressBarType = { ue_PySProgressBar_methods, /* tp_methods */ }; -static int ue_py_sprogress_bar_init(ue_PySProgressBar *self, PyObject *args, PyObject *kwargs) { +static int ue_py_sprogress_bar_init(ue_PySProgressBar *self, PyObject *args, PyObject *kwargs) +{ ue_py_slate_setup_farguments(SProgressBar); ue_py_slate_farguments_optional_struct_ptr("background_image", BackgroundImage, FSlateBrush); @@ -65,11 +63,12 @@ static int ue_py_sprogress_bar_init(ue_PySProgressBar *self, PyObject *args, PyO ue_py_slate_farguments_optional_float("refresh_rate", RefreshRate); ue_py_slate_farguments_optional_struct_ptr("style", Style, FProgressBarStyle); - ue_py_snew(SProgressBar, s_leaf_widget.s_widget); + ue_py_snew(SProgressBar); return 0; } -void ue_python_init_sprogress_bar(PyObject *ue_module) { +void ue_python_init_sprogress_bar(PyObject *ue_module) +{ ue_PySProgressBarType.tp_init = (initproc)ue_py_sprogress_bar_init; diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySPythonComboBox.cpp b/Source/UnrealEnginePython/Private/Slate/UEPySPythonComboBox.cpp index 83dedef20..1babd8d3a 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySPythonComboBox.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPySPythonComboBox.cpp @@ -1,45 +1,49 @@ -#include "UnrealEnginePythonPrivatePCH.h" #include "UEPySPythonComboBox.h" -#define sw_python_combo_box StaticCastSharedRef(self->s_panel.s_widget.s_widget) - -static PyObject *py_ue_spython_combo_box_clear_selection(ue_PySPythonComboBox *self, PyObject * args) { - sw_python_combo_box->ClearSelection(); - Py_INCREF(self); - return (PyObject *)self; +static PyObject *py_ue_spython_combo_box_clear_selection(ue_PySPythonComboBox *self, PyObject * args) +{ + ue_py_slate_cast(SPythonComboBox); + py_SPythonComboBox->ClearSelection(); + Py_RETURN_SLATE_SELF; } -static PyObject *py_ue_spython_combo_box_get_selected_item(ue_PySPythonComboBox *self, PyObject * args) { - - TSharedPtr ptr_item = sw_python_combo_box->GetSelectedItem(); +static PyObject *py_ue_spython_combo_box_get_selected_item(ue_PySPythonComboBox *self, PyObject * args) +{ + ue_py_slate_cast(SPythonComboBox); + TSharedPtr ptr_item = py_SPythonComboBox->GetSelectedItem(); if (!ptr_item.IsValid()) return PyErr_Format(PyExc_Exception, "invalid shared pointer to python item"); - Py_INCREF(ptr_item.Get()->py_object); - return ptr_item.Get()->py_object; + Py_INCREF(ptr_item->py_object); + return ptr_item->py_object; } -static PyObject *py_ue_spython_combo_box_set_selected_item(ue_PySPythonComboBox *self, PyObject * args) { +static PyObject *py_ue_spython_combo_box_set_selected_item(ue_PySPythonComboBox *self, PyObject * args) +{ + ue_py_slate_cast(SPythonComboBox); + PyObject *py_item; - if (!PyArg_ParseTuple(args, "O", &py_item)) { + if (!PyArg_ParseTuple(args, "O", &py_item)) + { return nullptr; } - for (TSharedPtr item : *(sw_python_combo_box->PythonOptionsSource)) { + for (TSharedPtr item : *(py_SPythonComboBox->PythonOptionsSource)) + { // just for being safe if (!item.IsValid()) continue; - if (py_item == item.Get()->py_object) { - sw_python_combo_box->SetSelectedItem(item); + if (py_item == item->py_object) + { + py_SPythonComboBox->SetSelectedItem(item); break; } } - Py_INCREF(self); - return (PyObject *)self; + Py_RETURN_SLATE_SELF; } static PyMethodDef ue_PySPythonComboBox_methods[] = { @@ -80,24 +84,28 @@ PyTypeObject ue_PySPythonComboBoxType = { ue_PySPythonComboBox_methods, /* tp_methods */ }; -static int ue_py_spython_combo_box_init(ue_PySPythonComboBox *self, PyObject *args, PyObject *kwargs) { +static int ue_py_spython_combo_box_init(ue_PySPythonComboBox *self, PyObject *args, PyObject *kwargs) +{ ue_py_slate_setup_farguments(SPythonComboBox); // first of all check for values PyObject *values = ue_py_dict_get_item(kwargs, "options_source"); - if (!values) { + if (!values) + { PyErr_SetString(PyExc_Exception, "you must specify the combo box items"); return -1; } values = PyObject_GetIter(values); - if (!values) { + if (!values) + { PyErr_SetString(PyExc_Exception, "values field is not an iterable"); return -1; } TArray> *items = new TArray>(); - while (PyObject *item = PyIter_Next(values)) { + while (PyObject *item = PyIter_Next(values)) + { Py_INCREF(item); items->Add(TSharedPtr(new FPythonItem(item))); } @@ -105,17 +113,17 @@ static int ue_py_spython_combo_box_init(ue_PySPythonComboBox *self, PyObject *ar arguments.OptionsSource(items); - ue_PySWidget *s_widget_content = nullptr; + TSharedPtr child = nullptr; PyObject *content = ue_py_dict_get_item(kwargs, "content"); - if (content) { - s_widget_content = py_ue_is_swidget(content); - if (!s_widget_content) { - PyErr_SetString(PyExc_Exception, "content is not a SWidget"); + if (content) + { + child = py_ue_is_swidget(content); + if (!child.IsValid()) + { return -1; } - Py_INCREF(s_widget_content); - arguments.Content()[s_widget_content->s_widget]; + arguments.Content()[child.ToSharedRef()]; } ue_py_slate_farguments_optional_struct_ptr("button_style", ButtonStyle, FButtonStyle); @@ -136,15 +144,18 @@ static int ue_py_spython_combo_box_init(ue_PySPythonComboBox *self, PyObject *ar ue_py_slate_farguments_event("on_selection_changed", OnSelectionChanged, TSlateDelegates>::FOnSelectionChanged, OnSelectionChanged); - ue_py_snew(SPythonComboBox, s_panel.s_widget); + ue_py_snew(SPythonComboBox); + + ue_py_slate_cast(SPythonComboBox); // keep track of the list, so we can delete on destruction - sw_python_combo_box->PythonOptionsSource = items; + py_SPythonComboBox->PythonOptionsSource = items; return 0; } -void ue_python_init_spython_combo_box(PyObject *ue_module) { +void ue_python_init_spython_combo_box(PyObject *ue_module) +{ ue_PySPythonComboBoxType.tp_base = &ue_PySPanelType; ue_PySPythonComboBoxType.tp_init = (initproc)ue_py_spython_combo_box_init; diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySPythonEditorViewport.cpp b/Source/UnrealEnginePython/Private/Slate/UEPySPythonEditorViewport.cpp index 7874cf9d5..b9c19952c 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySPythonEditorViewport.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPySPythonEditorViewport.cpp @@ -1,19 +1,26 @@ -#if WITH_EDITOR -#include "UnrealEnginePythonPrivatePCH.h" #include "UEPySPythonEditorViewport.h" +#if WITH_EDITOR - -#define sw_python_editor_viewport StaticCastSharedRef(self->s_editor_viewport.s_compound_widget.s_widget.s_widget) +#include "Components/DirectionalLightComponent.h" +#include "Wrappers/UEPyFEditorViewportClient.h" static PyObject *py_ue_spython_editor_viewport_get_world(ue_PySPythonEditorViewport *self, PyObject * args) { - Py_RETURN_UOBJECT(sw_python_editor_viewport->GetPythonWorld()); + ue_py_slate_cast(SPythonEditorViewport); + Py_RETURN_UOBJECT(py_SPythonEditorViewport->GetPythonWorld()); +} + +static PyObject *py_ue_spython_editor_viewport_get_editor_viewport_client(ue_PySPythonEditorViewport *self, PyObject * args) +{ + ue_py_slate_cast(SPythonEditorViewport); + return py_ue_new_feditor_viewport_client(py_SPythonEditorViewport->GetViewportClient().ToSharedRef()); } static PyObject *py_ue_spython_editor_viewport_set_show_bounds(ue_PySPythonEditorViewport *self, PyObject * args) { + ue_py_slate_cast(SPythonEditorViewport); PyObject *py_bool; if (!PyArg_ParseTuple(args, "O:set_show_bounds", &py_bool)) { @@ -21,14 +28,14 @@ static PyObject *py_ue_spython_editor_viewport_set_show_bounds(ue_PySPythonEdito } - sw_python_editor_viewport->GetViewportClient()->SetShowBounds(PyObject_IsTrue(py_bool) ? true : false); + py_SPythonEditorViewport->GetViewportClient()->SetShowBounds(PyObject_IsTrue(py_bool) ? true : false); - Py_INCREF(self); - return (PyObject *)self; + Py_RETURN_SLATE_SELF; } static PyObject *py_ue_spython_editor_viewport_set_show_stats(ue_PySPythonEditorViewport *self, PyObject * args) { + ue_py_slate_cast(SPythonEditorViewport); PyObject *py_bool; if (!PyArg_ParseTuple(args, "O:set_show_stats", &py_bool)) { @@ -36,33 +43,33 @@ static PyObject *py_ue_spython_editor_viewport_set_show_stats(ue_PySPythonEditor } - sw_python_editor_viewport->GetViewportClient()->SetShowStats(PyObject_IsTrue(py_bool) ? true : false); + py_SPythonEditorViewport->GetViewportClient()->SetShowStats(PyObject_IsTrue(py_bool) ? true : false); - Py_INCREF(self); - return (PyObject *)self; + Py_RETURN_SLATE_SELF; } static PyObject *py_ue_spython_editor_viewport_set_view_mode(ue_PySPythonEditorViewport *self, PyObject * args) { + ue_py_slate_cast(SPythonEditorViewport); int mode; if (!PyArg_ParseTuple(args, "i:set_view_mode", &mode)) { - return NULL; + return nullptr; } - sw_python_editor_viewport->GetViewportClient()->SetViewMode((EViewModeIndex)mode); + py_SPythonEditorViewport->GetViewportClient()->SetViewMode((EViewModeIndex)mode); - Py_INCREF(self); - return (PyObject *)self; + Py_RETURN_SLATE_SELF; } static PyObject *py_ue_spython_editor_viewport_set_exposure_settings(ue_PySPythonEditorViewport *self, PyObject * args) { + ue_py_slate_cast(SPythonEditorViewport); PyObject *py_settings; if (!PyArg_ParseTuple(args, "O:set_exposure_settings", &py_settings)) { - return NULL; + return nullptr; } FExposureSettings *settings = ue_py_check_struct(py_settings); @@ -72,14 +79,14 @@ static PyObject *py_ue_spython_editor_viewport_set_exposure_settings(ue_PySPytho } - sw_python_editor_viewport->GetViewportClient()->ExposureSettings = *settings; + py_SPythonEditorViewport->GetViewportClient()->ExposureSettings = *settings; - Py_INCREF(self); - return (PyObject *)self; + Py_RETURN_SLATE_SELF; } static PyObject *py_ue_spython_editor_viewport_set_view_location(ue_PySPythonEditorViewport *self, PyObject * args) { + ue_py_slate_cast(SPythonEditorViewport); float x = 0, y = 0, z = 0; FVector vec; @@ -104,14 +111,14 @@ static PyObject *py_ue_spython_editor_viewport_set_view_location(ue_PySPythonEdi vec.Z = z; } - sw_python_editor_viewport->GetViewportClient()->SetViewLocation(vec); + py_SPythonEditorViewport->GetViewportClient()->SetViewLocation(vec); - Py_INCREF(self); - return (PyObject *)self; + Py_RETURN_SLATE_SELF; } static PyObject *py_ue_spython_editor_viewport_set_view_rotation(ue_PySPythonEditorViewport *self, PyObject * args) { + ue_py_slate_cast(SPythonEditorViewport); float roll = 0, pitch = 0, yaw = 0; FRotator rot; @@ -136,27 +143,28 @@ static PyObject *py_ue_spython_editor_viewport_set_view_rotation(ue_PySPythonEdi rot.Yaw = yaw; } - sw_python_editor_viewport->GetViewportClient()->SetViewRotation(rot); + py_SPythonEditorViewport->GetViewportClient()->SetViewRotation(rot); - Py_INCREF(self); - return (PyObject *)self; + Py_RETURN_SLATE_SELF; } static PyObject *py_ue_spython_editor_viewport_simulate(ue_PySPythonEditorViewport *self, PyObject * args) { + ue_py_slate_cast(SPythonEditorViewport); PyObject *py_bool; if (!PyArg_ParseTuple(args, "O:simulate", &py_bool)) { return NULL; } - sw_python_editor_viewport->Simulate(PyObject_IsTrue(py_bool) != 0); + py_SPythonEditorViewport->Simulate(PyObject_IsTrue(py_bool) != 0); Py_RETURN_NONE; } static PyObject *py_ue_spython_editor_viewport_set_light_color(ue_PySPythonEditorViewport *self, PyObject * args) { + ue_py_slate_cast(SPythonEditorViewport); PyObject *py_obj; if (!PyArg_ParseTuple(args, "O", &py_obj)) @@ -166,14 +174,14 @@ static PyObject *py_ue_spython_editor_viewport_set_light_color(ue_PySPythonEdito if (!py_fcolor) return PyErr_Format(PyExc_Exception, "argument is not a FColor"); - sw_python_editor_viewport->GetPreviewScene()->SetLightColor(py_fcolor->color); + py_SPythonEditorViewport->GetPreviewScene()->SetLightColor(py_fcolor->color); - Py_INCREF(self); - return (PyObject *)self; + Py_RETURN_SLATE_SELF; } static PyObject *py_ue_spython_editor_viewport_set_light_direction(ue_PySPythonEditorViewport *self, PyObject * args) { + ue_py_slate_cast(SPythonEditorViewport); float roll = 0, pitch = 0, yaw = 0; FRotator rot; @@ -198,42 +206,41 @@ static PyObject *py_ue_spython_editor_viewport_set_light_direction(ue_PySPythonE rot.Yaw = yaw; } - sw_python_editor_viewport->GetPreviewScene()->SetLightDirection(rot); + py_SPythonEditorViewport->GetPreviewScene()->SetLightDirection(rot); - Py_INCREF(self); - return (PyObject *)self; + Py_RETURN_SLATE_SELF; } static PyObject *py_ue_spython_editor_viewport_set_sky_brightness(ue_PySPythonEditorViewport *self, PyObject * args) { + ue_py_slate_cast(SPythonEditorViewport); float brightness; if (!PyArg_ParseTuple(args, "f", &brightness)) return nullptr; - sw_python_editor_viewport->GetPreviewScene()->SetSkyBrightness(brightness); + py_SPythonEditorViewport->GetPreviewScene()->SetSkyBrightness(brightness); - Py_INCREF(self); - return (PyObject *)self; + Py_RETURN_SLATE_SELF; } static PyObject *py_ue_spython_editor_viewport_set_light_brightness(ue_PySPythonEditorViewport *self, PyObject * args) { + ue_py_slate_cast(SPythonEditorViewport); float brightness; if (!PyArg_ParseTuple(args, "f", &brightness)) return nullptr; - sw_python_editor_viewport->GetPreviewScene()->SetLightBrightness(brightness); + py_SPythonEditorViewport->GetPreviewScene()->SetLightBrightness(brightness); - Py_INCREF(self); - return (PyObject *)self; + Py_RETURN_SLATE_SELF; } static PyObject *py_ue_spython_editor_viewport_get_light(ue_PySPythonEditorViewport *self, PyObject * args) { - - UDirectionalLightComponent *light = sw_python_editor_viewport->GetPreviewScene()->DirectionalLight; + ue_py_slate_cast(SPythonEditorViewport); + UDirectionalLightComponent *light = py_SPythonEditorViewport->GetPreviewScene()->DirectionalLight; Py_RETURN_UOBJECT(light); } @@ -241,6 +248,7 @@ static PyObject *py_ue_spython_editor_viewport_get_light(ue_PySPythonEditorViewp static PyMethodDef ue_PySPythonEditorViewport_methods[] = { { "simulate", (PyCFunction)py_ue_spython_editor_viewport_simulate, METH_VARARGS, "" }, { "get_world", (PyCFunction)py_ue_spython_editor_viewport_get_world, METH_VARARGS, "" }, + { "get_editor_viewport_client", (PyCFunction)py_ue_spython_editor_viewport_get_editor_viewport_client, METH_VARARGS, "" }, { "set_show_bounds", (PyCFunction)py_ue_spython_editor_viewport_set_show_bounds, METH_VARARGS, "" }, { "set_show_stats", (PyCFunction)py_ue_spython_editor_viewport_set_show_stats, METH_VARARGS, "" }, { "set_view_mode", (PyCFunction)py_ue_spython_editor_viewport_set_view_mode, METH_VARARGS, "" }, @@ -441,7 +449,7 @@ PyTypeObject ue_PySPythonEditorViewportType = { static int ue_py_spython_editor_viewport_init(ue_PySPythonEditorViewport *self, PyObject *args, PyObject *kwargs) { - ue_py_snew_simple(SPythonEditorViewport, s_editor_viewport.s_compound_widget.s_widget); + ue_py_snew_simple(SPythonEditorViewport); return 0; } diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySPythonEditorViewport.h b/Source/UnrealEnginePython/Private/Slate/UEPySPythonEditorViewport.h index 11f7bd320..f38cadff9 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySPythonEditorViewport.h +++ b/Source/UnrealEnginePython/Private/Slate/UEPySPythonEditorViewport.h @@ -1,48 +1,57 @@ #pragma once -#include "UnrealEnginePython.h" - - #include "UEPySEditorViewport.h" +#if WITH_EDITOR + #include "Editor/UnrealEd/Public/SEditorViewport.h" #include "Editor/UnrealEd/Public/EditorViewportClient.h" #include "Runtime/Engine/Public/PreviewScene.h" #include "Editor/UnrealEd/Public/SCommonEditorViewportToolbarBase.h" #include "Editor/UnrealEd/Public/STransformViewportToolbar.h" +#include "EngineUtils.h" + extern PyTypeObject ue_PySEditorViewportType; -typedef struct { +typedef struct +{ ue_PySEditorViewport s_editor_viewport; /* Type-specific fields go here. */ } ue_PySPythonEditorViewport; void ue_python_init_spython_editor_viewport(PyObject *); -class SPythonEditorViewport : public SEditorViewport, public ICommonEditorViewportToolbarInfoProvider { +class SPythonEditorViewport : public SEditorViewport, public ICommonEditorViewportToolbarInfoProvider +{ public: - UWorld *GetPythonWorld(); + UWorld * GetPythonWorld(); virtual void Tick(const FGeometry& AllottedGeometry, const double InCurrentTime, const float InDeltaTime); - void Simulate(bool start) { - if (start) { - if (!bSimulate) { + void Simulate(bool start) + { + if (start) + { + if (!bSimulate) + { bSimulate = true; GetWorld()->BeginPlay(); } } - else { + else + { bSimulate = false; } } - FPreviewScene * GetPreviewScene() { + FPreviewScene * GetPreviewScene() + { return PreviewScene; } - TSharedPtr GetSceneViewport() { + TSharedPtr GetSceneViewport() + { return SceneViewport; } @@ -58,3 +67,5 @@ class SPythonEditorViewport : public SEditorViewport, public ICommonEditorViewpo bool bSimulate; }; + +#endif \ No newline at end of file diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySPythonListView.cpp b/Source/UnrealEnginePython/Private/Slate/UEPySPythonListView.cpp index e8eb44747..79f9fed20 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySPythonListView.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPySPythonListView.cpp @@ -1,117 +1,120 @@ -#include "UnrealEnginePythonPrivatePCH.h" - - #include "UEPySPythonListView.h" +#include "UEPySHeaderRow.h" + void SPythonListView::SetHeaderRow(TSharedPtr InHeaderRowWidget) { - HeaderRow = InHeaderRowWidget; + HeaderRow = InHeaderRowWidget; } -#define sw_python_list_view StaticCastSharedRef(self->s_list_view.s_table_view_base.s_compound_widget.s_widget.s_widget) - -static PyObject *py_ue_spython_list_view_get_selected_items(ue_PySPythonListView *self, PyObject * args) { +static PyObject *py_ue_spython_list_view_get_selected_items(ue_PySPythonListView *self, PyObject * args) +{ + ue_py_slate_cast(SPythonListView); PyObject *py_list = PyList_New(0); - TArray> items = sw_python_list_view->GetSelectedItems(); + TArray> items = py_SPythonListView->GetSelectedItems(); - for (auto item : items) { + for (auto item : items) + { PyList_Append(py_list, item->py_object); } return py_list; } -static PyObject *py_ue_spython_list_view_clear_selection(ue_PySPythonListView *self, PyObject * args) +static PyObject *py_ue_spython_list_view_clear_selection(ue_PySPythonListView *self, PyObject * args) { - sw_python_list_view->ClearSelection(); + ue_py_slate_cast(SPythonListView); + py_SPythonListView->ClearSelection(); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } -static PyObject *py_ue_spython_list_view_get_num_items_selected(ue_PySPythonListView *self, PyObject * args) { - return PyLong_FromLong(sw_python_list_view->GetNumItemsSelected()); +static PyObject *py_ue_spython_list_view_get_num_items_selected(ue_PySPythonListView *self, PyObject * args) +{ + ue_py_slate_cast(SPythonListView); + return PyLong_FromLong(py_SPythonListView->GetNumItemsSelected()); } static PyObject *py_ue_spython_list_view_set_header_row(ue_PySPythonListView *self, PyObject * args) { - PyObject *py_content; + ue_py_slate_cast(SPythonListView); + PyObject *py_content; if (!PyArg_ParseTuple(args, "O:set_header_row", &py_content)) { - return NULL; + return nullptr; } - ue_PySHeaderRow *py_sheader_row = py_ue_is_sheader_row(py_content); - if (!py_sheader_row) - { - return PyErr_Format(PyExc_Exception, "argument is not a SHeaderRow"); - } + TSharedPtr HeaderRow = py_ue_is_swidget(py_content); + if (!HeaderRow.IsValid()) + { + return nullptr; + } - Py_INCREF(py_sheader_row); - sw_python_list_view->SetHeaderRow(StaticCastSharedRef(py_sheader_row->s_border.s_compound_widget.s_widget.s_widget->AsShared())); + py_SPythonListView->SetHeaderRow(HeaderRow); - Py_INCREF(self); - return (PyObject *)self; + Py_RETURN_SLATE_SELF; } static PyObject *py_spython_list_view_update_item_source_list(ue_PySPythonListView *self, PyObject * args) { - PyObject *values; - if (!PyArg_ParseTuple(args, "O:update_item_source_list", &values)) - { - return NULL; - } - - values = PyObject_GetIter(values); - if (!values) { - return PyErr_Format(PyExc_Exception, "argument is not an iterable"); - } - - //NOTE: ikrimae: Increment first so we don't decrement and destroy python objects that - //we're passing in e.g. if you pass the same item source array into update_items(). - //Might not be necessary but I'm not too familiar with python's GC - TArray> tempNewArray; - while (PyObject *item = PyIter_Next(values)) { - Py_INCREF(item); - tempNewArray.Add(TSharedPtr(new FPythonItem(item))); - } - - for (TSharedPtr& item : self->item_source_list) - { - Py_XDECREF(item->py_object); - } - self->item_source_list.Empty(); - - Move>>(self->item_source_list, tempNewArray); - Py_RETURN_NONE; + PyObject *values; + if (!PyArg_ParseTuple(args, "O:update_item_source_list", &values)) + { + return NULL; + } + + values = PyObject_GetIter(values); + if (!values) + { + return PyErr_Format(PyExc_Exception, "argument is not an iterable"); + } + + //NOTE: ikrimae: Increment first so we don't decrement and destroy python objects that + //we're passing in e.g. if you pass the same item source array into update_items(). + //Might not be necessary but I'm not too familiar with python's GC + TArray> tempNewArray; + while (PyObject *item = PyIter_Next(values)) + { + Py_INCREF(item); + tempNewArray.Add(TSharedPtr(new FPythonItem(item))); + } + + for (TSharedPtr& item : self->item_source_list) + { + Py_XDECREF(item->py_object); + } + self->item_source_list.Empty(); + + Move>>(self->item_source_list, tempNewArray); + Py_RETURN_NONE; } static PyMethodDef ue_PySPythonListView_methods[] = { { "get_selected_items", (PyCFunction)py_ue_spython_list_view_get_selected_items, METH_VARARGS, "" }, { "get_num_items_selected", (PyCFunction)py_ue_spython_list_view_get_num_items_selected, METH_VARARGS, "" }, { "clear_selection", (PyCFunction)py_ue_spython_list_view_clear_selection, METH_VARARGS, "" }, - { "set_header_row", (PyCFunction)py_ue_spython_list_view_set_header_row, METH_VARARGS, "" }, - { "update_item_source_list", (PyCFunction)py_spython_list_view_update_item_source_list, METH_VARARGS, "" }, + { "set_header_row", (PyCFunction)py_ue_spython_list_view_set_header_row, METH_VARARGS, "" }, + { "update_item_source_list", (PyCFunction)py_spython_list_view_update_item_source_list, METH_VARARGS, "" }, { NULL } /* Sentinel */ }; static void ue_PySPythonListView_dealloc(ue_PySPythonListView *self) { #if defined(UEPY_MEMORY_DEBUG) - UE_LOG(LogPython, Warning, TEXT("Destroying ue_PySPythonListView %p"), self); + UE_LOG(LogPython, Warning, TEXT("Destroying ue_PySPythonListView %p"), self); #endif - for (TSharedPtr& item : self->item_source_list) - { - Py_XDECREF(item->py_object); - } - self->item_source_list.Empty(); + for (TSharedPtr& item : self->item_source_list) + { + Py_XDECREF(item->py_object); + } + self->item_source_list.Empty(); - Py_TYPE(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject *)self); } PyTypeObject ue_PySPythonListViewType = { @@ -119,7 +122,7 @@ PyTypeObject ue_PySPythonListViewType = { "unreal_engine.SPythonListView", /* tp_name */ sizeof(ue_PySPythonListView), /* tp_basicsize */ 0, /* tp_itemsize */ - (destructor)ue_PySPythonListView_dealloc, /* tp_dealloc */ + (destructor)ue_PySPythonListView_dealloc, /* tp_dealloc */ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ @@ -145,44 +148,49 @@ PyTypeObject ue_PySPythonListViewType = { ue_PySPythonListView_methods, /* tp_methods */ }; -static int ue_py_spython_list_view_init(ue_PySPythonListView *self, PyObject *args, PyObject *kwargs) { +static int ue_py_spython_list_view_init(ue_PySPythonListView *self, PyObject *args, PyObject *kwargs) +{ ue_py_slate_setup_farguments(SPythonListView); - // first of all check for values - PyObject *values = ue_py_dict_get_item(kwargs, "list_items_source"); - if (!values) { - PyErr_SetString(PyExc_Exception, "you must specify list items"); - return -1; - } - - values = PyObject_GetIter(values); - if (!values) { - Py_DECREF(values); - return -1; - } - - new(&self->item_source_list) TArray>(); - while (PyObject *item = PyIter_Next(values)) { - Py_INCREF(item); - self->item_source_list.Add(TSharedPtr(new FPythonItem(item))); - } - arguments.ListItemsSource(&self->item_source_list); - - { - PyObject *value = ue_py_dict_get_item(kwargs, "header_row"); - if (value) { - if (ue_PySHeaderRow *_py_swidget = py_ue_is_sheader_row(value)) { - - Py_INCREF(_py_swidget); - arguments.HeaderRow(StaticCastSharedRef(((ue_PySWidget *)_py_swidget)->s_widget)); - } - else { - PyErr_SetString(PyExc_TypeError, "unsupported type for attribute " "header_row"); - return -1; - } - } - } + // first of all check for values + PyObject *values = ue_py_dict_get_item(kwargs, "list_items_source"); + if (!values) + { + PyErr_SetString(PyExc_Exception, "you must specify list items"); + return -1; + } + + values = PyObject_GetIter(values); + if (!values) + { + Py_DECREF(values); + return -1; + } + + new(&self->item_source_list) TArray>(); + while (PyObject *item = PyIter_Next(values)) + { + Py_INCREF(item); + self->item_source_list.Add(TSharedPtr(new FPythonItem(item))); + } + arguments.ListItemsSource(&self->item_source_list); + + { + PyObject *value = ue_py_dict_get_item(kwargs, "header_row"); + if (value) + { + if (ue_PySHeaderRow *_py_swidget = py_ue_is_sheader_row(value)) + { + arguments.HeaderRow(StaticCastSharedRef(((ue_PySWidget *)_py_swidget)->Widget)); + } + else + { + PyErr_SetString(PyExc_TypeError, "unsupported type for attribute " "header_row"); + return -1; + } + } + } ue_py_slate_farguments_optional_enum("allow_overscroll", AllowOverscroll, EAllowOverscroll); ue_py_slate_farguments_optional_bool("clear_selection_on_click", ClearSelectionOnClick); @@ -198,11 +206,12 @@ static int ue_py_spython_list_view_init(ue_PySPythonListView *self, PyObject *ar ue_py_slate_farguments_optional_float("wheel_scroll_multiplier", WheelScrollMultiplier); #endif - ue_py_snew(SPythonListView, s_list_view.s_table_view_base.s_compound_widget.s_widget); + ue_py_snew(SPythonListView); return 0; } -void ue_python_init_spython_list_view(PyObject *ue_module) { +void ue_python_init_spython_list_view(PyObject *ue_module) +{ ue_PySPythonListViewType.tp_init = (initproc)ue_py_spython_list_view_init; diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySPythonListView.h b/Source/UnrealEnginePython/Private/Slate/UEPySPythonListView.h index 8e981336a..482a4e23e 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySPythonListView.h +++ b/Source/UnrealEnginePython/Private/Slate/UEPySPythonListView.h @@ -1,24 +1,25 @@ #pragma once -#include "UnrealEnginePython.h" - #include "UEPySListView.h" extern PyTypeObject ue_PySPythonListViewType; -class SPythonListView : public SListView> { +class SPythonListView : public SListView> +{ public: - ~SPythonListView() { + ~SPythonListView() + { delete(ItemsSource); } - void SetHeaderRow(TSharedPtr InHeaderRowWidget); + void SetHeaderRow(TSharedPtr InHeaderRowWidget); }; -typedef struct { +typedef struct +{ ue_PySListView s_list_view; /* Type-specific fields go here. */ - TArray> item_source_list; + TArray> item_source_list; } ue_PySPythonListView; void ue_python_init_spython_list_view(PyObject *); diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySPythonMultiColumnTableRow.cpp b/Source/UnrealEnginePython/Private/Slate/UEPySPythonMultiColumnTableRow.cpp index a4d8b3d2a..4f40f1106 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySPythonMultiColumnTableRow.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPySPythonMultiColumnTableRow.cpp @@ -1,10 +1,8 @@ -#include "UnrealEnginePythonPrivatePCH.h" #include "UEPySPythonMultiColumnTableRow.h" - -#define sw_python_multicolumn_table_row StaticCastSharedRef(self->s_compound_widget.s_widget.s_widget) +#include "UEPySTableViewBase.h" static PyMethodDef ue_PySPythonMultiColumnTableRow_methods[] = { { NULL } /* Sentinel */ @@ -41,38 +39,40 @@ PyTypeObject ue_PySPythonMultiColumnTableRowType = { ue_PySPythonMultiColumnTableRow_methods, /* tp_methods */ }; -static int ue_py_spython_multicolumn_table_row_init(ue_PySPythonMultiColumnTableRow *self, PyObject *args, PyObject *kwargs) { +static int ue_py_spython_multicolumn_table_row_init(ue_PySPythonMultiColumnTableRow *self, PyObject *args, PyObject *kwargs) +{ - PyObject *py_object = nullptr; - if (!PyArg_ParseTuple(args, "O", &py_object)) - { - return -1; - } + PyObject *py_object = nullptr; + if (!PyArg_ParseTuple(args, "O", &py_object)) + { + return -1; + } - ue_PySTableViewBase* py_owner_table_view_base = py_ue_is_stable_view_base(py_object); - if (!py_owner_table_view_base) { - PyErr_SetString(PyExc_Exception, "Argument is not a STableViewBase"); - return -1; - } + ue_PySTableViewBase* py_owner_table_view_base = py_ue_is_stable_view_base(py_object); + if (!py_owner_table_view_base) + { + PyErr_SetString(PyExc_Exception, "Argument is not a STableViewBase"); + return -1; + } - Py_INCREF(py_owner_table_view_base); - ue_py_snew_simple_with_req_args( - SPythonMultiColumnTableRow, s_compound_widget.s_widget, - StaticCastSharedRef(py_owner_table_view_base->s_compound_widget.s_widget.s_widget), - (PyObject *)self); + Py_INCREF(py_owner_table_view_base); + ue_py_snew_simple_with_req_args( + SPythonMultiColumnTableRow, + StaticCastSharedRef(py_owner_table_view_base->s_compound_widget.s_widget.Widget), + (PyObject *)self); return 0; } void ue_python_init_spython_multicolumn_table_row(PyObject *ue_module) { - ue_PySPythonMultiColumnTableRowType.tp_base = &ue_PySCompoundWidgetType; - ue_PySPythonMultiColumnTableRowType.tp_init = (initproc)ue_py_spython_multicolumn_table_row_init; + ue_PySPythonMultiColumnTableRowType.tp_base = &ue_PySCompoundWidgetType; + ue_PySPythonMultiColumnTableRowType.tp_init = (initproc)ue_py_spython_multicolumn_table_row_init; - if (PyType_Ready(&ue_PySPythonMultiColumnTableRowType) < 0) - return; + if (PyType_Ready(&ue_PySPythonMultiColumnTableRowType) < 0) + return; - Py_INCREF(&ue_PySPythonMultiColumnTableRowType); - PyModule_AddObject(ue_module, "SPythonMultiColumnTableRow", (PyObject *)&ue_PySPythonMultiColumnTableRowType); + Py_INCREF(&ue_PySPythonMultiColumnTableRowType); + PyModule_AddObject(ue_module, "SPythonMultiColumnTableRow", (PyObject *)&ue_PySPythonMultiColumnTableRowType); } ue_PySPythonMultiColumnTableRow *py_ue_is_spython_multicolumn_table_row(PyObject *obj) diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySPythonMultiColumnTableRow.h b/Source/UnrealEnginePython/Private/Slate/UEPySPythonMultiColumnTableRow.h index 21ccda269..7bc6b1af1 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySPythonMultiColumnTableRow.h +++ b/Source/UnrealEnginePython/Private/Slate/UEPySPythonMultiColumnTableRow.h @@ -1,108 +1,106 @@ #pragma once -#include "UnrealEnginePython.h" - #include "UEPySCompoundWidget.h" -#include "UEPyFGeometry.h" -#include "UEPyFPaintContext.h" -#include "UEPyFCharacterEvent.h" -#include "UEPyFKeyEvent.h" -#include "UEPyFPointerEvent.h" +#include "UnrealEnginePython.h" +#include "Runtime/Slate/Public/Widgets/Views/STableRow.h" +#include "Runtime/Slate/Public/Widgets/Views/STableViewBase.h" +#include "Runtime/Slate/Public/Widgets/Views/SListView.h" extern PyTypeObject ue_PySCompoundWidgetType; extern PyTypeObject ue_PySTableViewBaseType; -class SPythonMultiColumnTableRow : public SMultiColumnTableRow> { +class SPythonMultiColumnTableRow : public SMultiColumnTableRow> +{ public: - SLATE_BEGIN_ARGS(SPythonMultiColumnTableRow) { } - SLATE_END_ARGS(); - - void Construct(const FArguments& InArgs, const TSharedRef& InOwnerTableView, PyObject *in_py_self) - { - SetPyObject(in_py_self); - SMultiColumnTableRow>::Construct(FSuperRowType::FArguments(), InOwnerTableView); - } - - TSharedRef GenerateWidgetForColumn(const FName& ColumnName) - { - FScopePythonGIL gil; - - if (!PyObject_HasAttrString(self, (char *)"generate_widget_for_column")) - return SNullWidget::NullWidget; - - PyObject *py_callable_generate_widget_for_column = PyObject_GetAttrString(self, (char *)"generate_widget_for_column"); - if (!PyCalllable_Check_Extended(py_callable_generate_widget_for_column)) - { - UE_LOG(LogPython, Error, TEXT("generate_widget_for_column is not a callable")); - return SNullWidget::NullWidget; - } - - PyObject *ret = PyObject_CallFunction(py_callable_generate_widget_for_column, (char *)"s", TCHAR_TO_UTF8(*ColumnName.ToString())); - if (!ret) - { - unreal_engine_py_log_error(); - return SNullWidget::NullWidget; - } - - ue_PySWidget *s_widget = py_ue_is_swidget(ret); - if (!s_widget) - { - Py_DECREF(ret); - UE_LOG(LogPython, Error, TEXT("returned value is not a SWidget")); - return SNullWidget::NullWidget; - } - - TSharedRef value = s_widget->s_widget; - Py_DECREF(ret); - return value; - } - - - FReply OnMouseButtonDoubleClick(const FGeometry& InMyGeometry, const FPointerEvent& InMouseEvent) - { - FScopePythonGIL gil; - - if (PyObject_HasAttrString(self, (char *)"on_mouse_button_double_click")) - { - PyObject *py_callable_on_mouse_button_double_click = PyObject_GetAttrString(self, (char *)"on_mouse_button_double_click"); - if (!PyCalllable_Check_Extended(py_callable_on_mouse_button_double_click)) - { - UE_LOG(LogPython, Error, TEXT("on_mouse_button_double_click is not a callable")); - return FReply::Unhandled(); - } - - PyObject *ret = PyObject_CallFunction(py_callable_on_mouse_button_double_click, (char *)"OO", py_ue_new_fgeometry(InMyGeometry), py_ue_new_fpointer_event(InMouseEvent)); - if (!ret) - { - unreal_engine_py_log_error(); - return FReply::Unhandled(); - } - - if (ret == Py_False) - { - Py_DECREF(ret); - return FReply::Unhandled(); - } - Py_DECREF(ret); - return FReply::Handled(); - } - else - { - return SPythonMultiColumnTableRow::OnMouseButtonDoubleClick(InMyGeometry, InMouseEvent); - } - } - - void SetPyObject(PyObject *py_obj) - { - self = py_obj; - } + SLATE_BEGIN_ARGS(SPythonMultiColumnTableRow) {} + SLATE_END_ARGS(); + + void Construct(const FArguments& InArgs, const TSharedRef& InOwnerTableView, PyObject *in_py_self) + { + SetPyObject(in_py_self); + SMultiColumnTableRow>::Construct(FSuperRowType::FArguments(), InOwnerTableView); + } + + TSharedRef GenerateWidgetForColumn(const FName& ColumnName) + { + FScopePythonGIL gil; + + if (!PyObject_HasAttrString(self, (char *)"generate_widget_for_column")) + return SNullWidget::NullWidget; + + PyObject *py_callable_generate_widget_for_column = PyObject_GetAttrString(self, (char *)"generate_widget_for_column"); + if (!PyCallable_Check(py_callable_generate_widget_for_column)) + { + UE_LOG(LogPython, Error, TEXT("generate_widget_for_column is not a callable")); + return SNullWidget::NullWidget; + } + + PyObject *ret = PyObject_CallFunction(py_callable_generate_widget_for_column, (char *)"s", TCHAR_TO_UTF8(*ColumnName.ToString())); + if (!ret) + { + unreal_engine_py_log_error(); + return SNullWidget::NullWidget; + } + + TSharedPtr Widget = py_ue_is_swidget(ret); + if (!Widget.IsValid()) + { + Py_DECREF(ret); + UE_LOG(LogPython, Error, TEXT("returned value is not a SWidget")); + return SNullWidget::NullWidget; + } + + Py_DECREF(ret); + return Widget.ToSharedRef(); + } + + + FReply OnMouseButtonDoubleClick(const FGeometry& InMyGeometry, const FPointerEvent& InMouseEvent) + { + FScopePythonGIL gil; + + if (PyObject_HasAttrString(self, (char *)"on_mouse_button_double_click")) + { + PyObject *py_callable_on_mouse_button_double_click = PyObject_GetAttrString(self, (char *)"on_mouse_button_double_click"); + if (!PyCallable_Check(py_callable_on_mouse_button_double_click)) + { + UE_LOG(LogPython, Error, TEXT("on_mouse_button_double_click is not a callable")); + return FReply::Unhandled(); + } + + PyObject *ret = PyObject_CallFunction(py_callable_on_mouse_button_double_click, (char *)"NN", py_ue_new_fgeometry(InMyGeometry), py_ue_new_fpointer_event(InMouseEvent)); + if (!ret) + { + unreal_engine_py_log_error(); + return FReply::Unhandled(); + } + + if (ret == Py_False) + { + Py_DECREF(ret); + return FReply::Unhandled(); + } + Py_DECREF(ret); + return FReply::Handled(); + } + else + { + return SPythonMultiColumnTableRow::OnMouseButtonDoubleClick(InMyGeometry, InMouseEvent); + } + } + + void SetPyObject(PyObject *py_obj) + { + self = py_obj; + } private: - PyObject *self = nullptr; + PyObject * self = nullptr; - TSharedPtr RowPythonObject; + TSharedPtr RowPythonObject; }; -typedef struct { - ue_PySCompoundWidget s_compound_widget; +typedef struct +{ + ue_PySCompoundWidget s_compound_widget; /* Type-specific fields go here. */ } ue_PySPythonMultiColumnTableRow; diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySPythonShelf.cpp b/Source/UnrealEnginePython/Private/Slate/UEPySPythonShelf.cpp index 267af55c3..0e7940bc6 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySPythonShelf.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPySPythonShelf.cpp @@ -1,9 +1,9 @@ +#include "UEPySPythonShelf.h" #if WITH_EDITOR -#include "UnrealEnginePythonPrivatePCH.h" #if ENGINE_MINOR_VERSION > 14 -#include "UEPySPythonShelf.h" + #include "Editor/ContentBrowser/Public/ContentBrowserModule.h" @@ -91,25 +91,25 @@ static int ue_py_spython_shelf_init(ue_PySPythonShelf *self, PyObject *args, PyO } } - if (py_callable_double_clicked && !PyCalllable_Check_Extended(py_callable_double_clicked)) + if (py_callable_double_clicked && !PyCallable_Check(py_callable_double_clicked)) { PyErr_SetString(PyExc_Exception, "argument is not callable"); return -1; } - if (py_callable_get_context_menu && !PyCalllable_Check_Extended(py_callable_get_context_menu)) + if (py_callable_get_context_menu && !PyCallable_Check(py_callable_get_context_menu)) { PyErr_SetString(PyExc_Exception, "argument is not callable"); return -1; } - if (py_callable_asset_selected && !PyCalllable_Check_Extended(py_callable_asset_selected)) + if (py_callable_asset_selected && !PyCallable_Check(py_callable_asset_selected)) { PyErr_SetString(PyExc_Exception, "argument is not callable"); return -1; } - FContentBrowserModule& module = FModuleManager::Get().LoadModuleChecked(TEXT("ContentBrowser")); + FContentBrowserModule& Module = FModuleManager::Get().LoadModuleChecked(TEXT("ContentBrowser")); FAssetPickerConfig asset_picker_config; asset_picker_config.InitialAssetViewType = EAssetViewType::Tile; @@ -121,9 +121,9 @@ static int ue_py_spython_shelf_init(ue_PySPythonShelf *self, PyObject *args, PyO { while (PyObject *item = PyIter_Next(py_classes_iterable)) { - if (PyUnicode_Check(item)) + if (PyUnicodeOrString_Check(item)) { - FName class_name = FName(UTF8_TO_TCHAR(PyUnicode_AsUTF8(item))); + FName class_name = FName(UTF8_TO_TCHAR(UEPyUnicode_AsUTF8(item))); asset_picker_config.Filter.ClassNames.Add(class_name); } } @@ -134,9 +134,9 @@ static int ue_py_spython_shelf_init(ue_PySPythonShelf *self, PyObject *args, PyO { while (PyObject *item = PyIter_Next(py_collections_iterable)) { - if (PyUnicode_Check(item)) + if (PyUnicodeOrString_Check(item)) { - FName collection_name = FName(UTF8_TO_TCHAR(PyUnicode_AsUTF8(item))); + FName collection_name = FName(UTF8_TO_TCHAR(UEPyUnicode_AsUTF8(item))); asset_picker_config.Collections.Add(FCollectionNameType(collection_name, ECollectionShareType::CST_Local)); } } @@ -173,8 +173,8 @@ static int ue_py_spython_shelf_init(ue_PySPythonShelf *self, PyObject *args, PyO asset_picker_config.OnAssetSelected = handler; } - new(&self->s_compound_widget.s_widget.s_widget) TSharedRef(module.Get().CreateAssetPicker(asset_picker_config)); - ue_py_register_swidget((SWidget *)&self->s_compound_widget.s_widget.s_widget.Get(), (ue_PySWidget *)self); + new(&self->s_compound_widget.s_widget.Widget) TSharedRef(Module.Get().CreateAssetPicker(asset_picker_config)); + return 0; } diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySPythonTreeView.cpp b/Source/UnrealEnginePython/Private/Slate/UEPySPythonTreeView.cpp index 17d9909e0..5815ca2c5 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySPythonTreeView.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPySPythonTreeView.cpp @@ -1,22 +1,20 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPySPythonTreeView.h" #include "Runtime/Slate/Public/Widgets/Views/STreeView.h" -#include "UEPySPythonTreeView.h" - -#define sw_python_tree_view StaticCastSharedRef(self->s_tree_view.s_list_view.s_table_view_base.s_compound_widget.s_widget.s_widget) static PyObject *py_ue_spython_tree_view_set_item_expansion(ue_PySPythonTreeView *self, PyObject * args) { + ue_py_slate_cast(SPythonTreeView); PyObject *py_item; PyObject *py_bool; if (!PyArg_ParseTuple(args, "OO:set_item_expansion", &py_item, &py_bool)) { return nullptr; } - sw_python_tree_view->SetPythonItemExpansion(py_item, PyObject_IsTrue(py_bool) ? true : false); + py_SPythonTreeView->SetPythonItemExpansion(py_item, PyObject_IsTrue(py_bool) ? true : false); Py_RETURN_NONE; } @@ -109,7 +107,7 @@ static int ue_py_spython_tree_view_init(ue_PySPythonTreeView *self, PyObject *ar #endif ue_py_slate_farguments_event("on_get_children", OnGetChildren, TSlateDelegates>::FOnGetChildren, GetChildren); - ue_py_snew(SPythonTreeView, s_tree_view.s_list_view.s_table_view_base.s_compound_widget.s_widget); + ue_py_snew(SPythonTreeView); return 0; } diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySPythonWidget.cpp b/Source/UnrealEnginePython/Private/Slate/UEPySPythonWidget.cpp index 4369af222..840e38cdd 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySPythonWidget.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPySPythonWidget.cpp @@ -1,12 +1,9 @@ -#include "UnrealEnginePythonPrivatePCH.h" - #include "UEPySPythonWidget.h" -#define sw_python_widget StaticCastSharedRef(self->s_compound_widget.s_widget.s_widget) - static PyObject *py_ue_spython_widget_set_active(ue_PySPythonWidget *self, PyObject *args) { + ue_py_slate_cast(SPythonWidget); PyObject *py_bool = nullptr; if (!PyArg_ParseTuple(args, "|O:set_active", &py_bool)) { @@ -26,45 +23,42 @@ static PyObject *py_ue_spython_widget_set_active(ue_PySPythonWidget *self, PyObj } } - sw_python_widget->SetActive(bActive); - Py_INCREF(self); - return (PyObject *)self; + py_SPythonWidget->SetActive(bActive); + Py_RETURN_SLATE_SELF; } static PyObject *py_ue_spython_widget_set_content(ue_PySPythonWidget *self, PyObject *args) { - PyObject *py_content; - if (!PyArg_ParseTuple(args, "O:set_content", &py_content)) - { - return NULL; - } - - ue_PySWidget *py_swidget = py_ue_is_swidget(py_content); - if (!py_swidget) - { - return PyErr_Format(PyExc_Exception, "argument is not a SWidget"); - } + ue_py_slate_cast(SPythonWidget); + PyObject *py_content; + if (!PyArg_ParseTuple(args, "O:set_content", &py_content)) + { + return NULL; + } - Py_INCREF(py_swidget); + TSharedPtr Content = py_ue_is_swidget(py_content); + if (!Content.IsValid()) + { + return nullptr; + } - sw_python_widget->SetContent(py_swidget->s_widget->AsShared()); + py_SPythonWidget->SetContent(Content.ToSharedRef()); - Py_INCREF(self); - return (PyObject *)self; + Py_RETURN_SLATE_SELF; } static PyObject *py_ue_spython_widget_clear_content(ue_PySPythonWidget *self, PyObject *args) { - sw_python_widget->ClearContent(); + ue_py_slate_cast(SPythonWidget); + py_SPythonWidget->ClearContent(); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyMethodDef ue_PySPythonWidget_methods[] = { { "set_active", (PyCFunction)py_ue_spython_widget_set_active, METH_VARARGS | METH_KEYWORDS, "" }, - { "set_content", (PyCFunction)py_ue_spython_widget_set_content, METH_VARARGS, "" }, - { "clear_content", (PyCFunction)py_ue_spython_widget_clear_content, METH_VARARGS, "" }, + { "set_content", (PyCFunction)py_ue_spython_widget_set_content, METH_VARARGS, "" }, + { "clear_content", (PyCFunction)py_ue_spython_widget_clear_content, METH_VARARGS, "" }, { NULL } /* Sentinel */ }; @@ -101,8 +95,9 @@ PyTypeObject ue_PySPythonWidgetType = { static int ue_py_spython_widget_init(ue_PySPythonWidget *self, PyObject *args, PyObject *kwargs) { - ue_py_snew_simple(SPythonWidget, s_compound_widget.s_widget); - sw_python_widget->SetPyObject((PyObject *)self); + ue_py_snew_simple(SPythonWidget); + ue_py_slate_cast(SPythonWidget); + py_SPythonWidget->SetPyObject((PyObject *)self); return 0; } diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySPythonWidget.h b/Source/UnrealEnginePython/Private/Slate/UEPySPythonWidget.h index 698cea267..5a6a7c11d 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySPythonWidget.h +++ b/Source/UnrealEnginePython/Private/Slate/UEPySPythonWidget.h @@ -1,13 +1,9 @@ #pragma once -#include "UnrealEnginePython.h" - #include "UEPySCompoundWidget.h" -#include "UEPyFGeometry.h" -#include "UEPyFPaintContext.h" -#include "UEPyFCharacterEvent.h" -#include "UEPyFKeyEvent.h" -#include "UEPyFPointerEvent.h" + +#include "Runtime/UMG/Public/Blueprint/UserWidget.h" + extern PyTypeObject ue_PySPythonWidgetType; @@ -37,13 +33,13 @@ class SPythonWidget : public SCompoundWidget return FReply::Unhandled(); PyObject *py_callable_on_key_char = PyObject_GetAttrString(self, (char *)"on_key_char"); - if (!PyCalllable_Check_Extended(py_callable_on_key_char)) + if (!PyCallable_Check(py_callable_on_key_char)) { UE_LOG(LogPython, Error, TEXT("on_key_char is not a callable")); return FReply::Unhandled(); } - PyObject *ret = PyObject_CallFunction(py_callable_on_key_char, (char *)"OO", py_ue_new_fgeometry(MyGeometry), py_ue_new_fcharacter_event(InCharacterEvent)); + PyObject *ret = PyObject_CallFunction(py_callable_on_key_char, (char *)"NN", py_ue_new_fgeometry(MyGeometry), py_ue_new_fcharacter_event(InCharacterEvent)); if (!ret) { unreal_engine_py_log_error(); @@ -67,13 +63,13 @@ class SPythonWidget : public SCompoundWidget return FReply::Unhandled(); PyObject *py_callable_on_key_down = PyObject_GetAttrString(self, (char *)"on_key_down"); - if (!PyCalllable_Check_Extended(py_callable_on_key_down)) + if (!PyCallable_Check(py_callable_on_key_down)) { UE_LOG(LogPython, Error, TEXT("on_key_down is not a callable")); return FReply::Unhandled(); } - PyObject *ret = PyObject_CallFunction(py_callable_on_key_down, (char *)"OO", py_ue_new_fgeometry(MyGeometry), py_ue_new_fkey_event(InKeyEvent)); + PyObject *ret = PyObject_CallFunction(py_callable_on_key_down, (char *)"NN", py_ue_new_fgeometry(MyGeometry), py_ue_new_fkey_event(InKeyEvent)); if (!ret) { unreal_engine_py_log_error(); @@ -97,13 +93,13 @@ class SPythonWidget : public SCompoundWidget return FReply::Unhandled(); PyObject *py_callable_on_mouse_move = PyObject_GetAttrString(self, (char *)"on_mouse_move"); - if (!PyCalllable_Check_Extended(py_callable_on_mouse_move)) + if (!PyCallable_Check(py_callable_on_mouse_move)) { UE_LOG(LogPython, Error, TEXT("on_mouse_move is not a callable")); return FReply::Unhandled(); } - PyObject *ret = PyObject_CallFunction(py_callable_on_mouse_move, (char *)"OO", py_ue_new_fgeometry(MyGeometry), py_ue_new_fpointer_event(MyEvent)); + PyObject *ret = PyObject_CallFunction(py_callable_on_mouse_move, (char *)"NN", py_ue_new_fgeometry(MyGeometry), py_ue_new_fpointer_event(MyEvent)); if (!ret) { unreal_engine_py_log_error(); @@ -127,13 +123,13 @@ class SPythonWidget : public SCompoundWidget return FReply::Unhandled(); PyObject *py_callable_on_mouse_wheel = PyObject_GetAttrString(self, (char *)"on_mouse_wheel"); - if (!PyCalllable_Check_Extended(py_callable_on_mouse_wheel)) + if (!PyCallable_Check(py_callable_on_mouse_wheel)) { UE_LOG(LogPython, Error, TEXT("on_mouse_wheel is not a callable")); return FReply::Unhandled(); } - PyObject *ret = PyObject_CallFunction(py_callable_on_mouse_wheel, (char *)"OO", py_ue_new_fgeometry(MyGeometry), py_ue_new_fpointer_event(MyEvent)); + PyObject *ret = PyObject_CallFunction(py_callable_on_mouse_wheel, (char *)"NN", py_ue_new_fgeometry(MyGeometry), py_ue_new_fpointer_event(MyEvent)); if (!ret) { unreal_engine_py_log_error(); @@ -157,13 +153,13 @@ class SPythonWidget : public SCompoundWidget return FReply::Unhandled(); PyObject *py_callable_on_mouse_button_down = PyObject_GetAttrString(self, (char *)"on_mouse_button_down"); - if (!PyCalllable_Check_Extended(py_callable_on_mouse_button_down)) + if (!PyCallable_Check(py_callable_on_mouse_button_down)) { UE_LOG(LogPython, Error, TEXT("on_mouse_button_down is not a callable")); return FReply::Unhandled(); } - PyObject *ret = PyObject_CallFunction(py_callable_on_mouse_button_down, (char *)"OO", py_ue_new_fgeometry(MyGeometry), py_ue_new_fpointer_event(MyEvent)); + PyObject *ret = PyObject_CallFunction(py_callable_on_mouse_button_down, (char *)"NN", py_ue_new_fgeometry(MyGeometry), py_ue_new_fpointer_event(MyEvent)); if (!ret) { unreal_engine_py_log_error(); @@ -187,13 +183,13 @@ class SPythonWidget : public SCompoundWidget return FReply::Unhandled(); PyObject *py_callable_on_mouse_button_up = PyObject_GetAttrString(self, (char *)"on_mouse_button_up"); - if (!PyCalllable_Check_Extended(py_callable_on_mouse_button_up)) + if (!PyCallable_Check(py_callable_on_mouse_button_up)) { UE_LOG(LogPython, Error, TEXT("on_mouse_button_up is not a callable")); return FReply::Unhandled(); } - PyObject *ret = PyObject_CallFunction(py_callable_on_mouse_button_up, (char *)"OO", py_ue_new_fgeometry(MyGeometry), py_ue_new_fpointer_event(MyEvent)); + PyObject *ret = PyObject_CallFunction(py_callable_on_mouse_button_up, (char *)"NN", py_ue_new_fgeometry(MyGeometry), py_ue_new_fpointer_event(MyEvent)); if (!ret) { unreal_engine_py_log_error(); @@ -218,7 +214,7 @@ class SPythonWidget : public SCompoundWidget const FWidgetStyle & InWidgetStyle, bool bParentEnabled) const override { - int32 MaxLayer = SCompoundWidget::OnPaint(Args, AllottedGeometry, MyClippingRect, OutDrawElements, LayerId, InWidgetStyle, bParentEnabled); + int32 MaxLayer = SCompoundWidget::OnPaint(Args, AllottedGeometry, MyClippingRect, OutDrawElements, LayerId, InWidgetStyle, bParentEnabled); FScopePythonGIL gil; @@ -226,7 +222,7 @@ class SPythonWidget : public SCompoundWidget return MaxLayer; PyObject *py_callable_paint = PyObject_GetAttrString(self, (char *)"paint"); - if (!PyCalllable_Check_Extended(py_callable_paint)) + if (!PyCallable_Check(py_callable_paint)) { UE_LOG(LogPython, Error, TEXT("paint is not a callable")); return MaxLayer; @@ -234,7 +230,7 @@ class SPythonWidget : public SCompoundWidget FPaintContext context(AllottedGeometry, MyClippingRect, OutDrawElements, LayerId, InWidgetStyle, bParentEnabled); - PyObject *ret = PyObject_CallFunction(py_callable_paint, (char *)"O", py_ue_new_fpaint_context(context)); + PyObject *ret = PyObject_CallFunction(py_callable_paint, (char *)"N", py_ue_new_fpaint_context(context)); if (!ret) { unreal_engine_py_log_error(); @@ -257,13 +253,13 @@ class SPythonWidget : public SCompoundWidget return; PyObject *py_callable_tick = PyObject_GetAttrString(self, (char *)"tick"); - if (!PyCalllable_Check_Extended(py_callable_tick)) + if (!PyCallable_Check(py_callable_tick)) { UE_LOG(LogPython, Error, TEXT("tick is not a callable")); return; } - PyObject *ret = PyObject_CallFunction(py_callable_tick, (char *)"Off", py_ue_new_fgeometry(AllottedGeometry), InCurrentTime, InDeltaTime); + PyObject *ret = PyObject_CallFunction(py_callable_tick, (char *)"Nff", py_ue_new_fgeometry(AllottedGeometry), InCurrentTime, InDeltaTime); if (!ret) { unreal_engine_py_log_error(); @@ -275,8 +271,8 @@ class SPythonWidget : public SCompoundWidget void SetPyObject(PyObject *py_obj) { - Py_XDECREF(self); - Py_INCREF(py_obj); + Py_XDECREF(self); + Py_INCREF(py_obj); self = py_obj; } @@ -292,21 +288,21 @@ class SPythonWidget : public SCompoundWidget } } - void SetContent(TSharedRef InContent) - { - ChildSlot - [ - InContent - ]; - } + void SetContent(TSharedRef InContent) + { + ChildSlot + [ + InContent + ]; + } - void ClearContent() - { - ChildSlot.DetachWidget(); - } + void ClearContent() + { + ChildSlot.DetachWidget(); + } protected: - PyObject *self; + PyObject * self; TWeakPtr ActiveTimerHandle; diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySRotatorInputBox.cpp b/Source/UnrealEnginePython/Private/Slate/UEPySRotatorInputBox.cpp index 2c1f16293..cb3095dde 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySRotatorInputBox.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPySRotatorInputBox.cpp @@ -1,8 +1,6 @@ -#include "UnrealEnginePythonPrivatePCH.h" -#include "UEPySRotatorInputBox.h" -#define sw_rotator_input_box StaticCastSharedRef(self->s_compound_widget.s_widget.s_widget) +#include "UEPySRotatorInputBox.h" static PyMethodDef ue_PySRotatorInputBox_methods[] = { @@ -40,7 +38,8 @@ PyTypeObject ue_PySRotatorInputBoxType = { ue_PySRotatorInputBox_methods, /* tp_methods */ }; -static int ue_py_srotator_input_box_init(ue_PySRotatorInputBox *self, PyObject *args, PyObject *kwargs) { +static int ue_py_srotator_input_box_init(ue_PySRotatorInputBox *self, PyObject *args, PyObject *kwargs) +{ ue_py_slate_setup_farguments(SRotatorInputBox); ue_py_slate_farguments_optional_bool("allow_responsive_layout", AllowResponsiveLayout); @@ -57,11 +56,12 @@ static int ue_py_srotator_input_box_init(ue_PySRotatorInputBox *self, PyObject * ue_py_slate_farguments_tfloat("pitch", Pitch); ue_py_slate_farguments_tfloat("yaw", Yaw); - ue_py_snew(SRotatorInputBox, s_compound_widget.s_widget); + ue_py_snew(SRotatorInputBox); return 0; } -void ue_python_init_srotator_input_box(PyObject *ue_module) { +void ue_python_init_srotator_input_box(PyObject *ue_module) +{ ue_PySRotatorInputBoxType.tp_init = (initproc)ue_py_srotator_input_box_init; diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySScrollBox.cpp b/Source/UnrealEnginePython/Private/Slate/UEPySScrollBox.cpp index 0684c89c0..d365d2e4e 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySScrollBox.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPySScrollBox.cpp @@ -1,50 +1,30 @@ -#include "UnrealEnginePythonPrivatePCH.h" - #include "UEPySScrollBox.h" -#define sw_scroll_box StaticCastSharedRef(self->s_compound_widget.s_widget.s_widget) - static PyObject *py_ue_sscroll_box_add_slot(ue_PySScrollBox *self, PyObject * args, PyObject *kwargs) { - PyObject *py_content; - int h_align = 0; - int v_align = 0; - - char *kwlist[] = { (char *)"widget", - (char *)"h_align", - (char *)"v_align", - nullptr }; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|ii:add_slot", kwlist, - &py_content, - &h_align, - &v_align)) - { - return NULL; - } + ue_py_slate_cast(SScrollBox); - ue_PySWidget *py_swidget = py_ue_is_swidget(py_content); - if (!py_swidget) + int32 retCode = [&]() { + ue_py_slate_setup_hack_slot_args(SScrollBox, py_SScrollBox); + ue_py_slate_farguments_optional_enum("h_align", HAlign, EHorizontalAlignment); + ue_py_slate_farguments_optional_enum("v_align", VAlign, EVerticalAlignment); + return 0; + }(); + + if (retCode != 0) { - return PyErr_Format(PyExc_Exception, "argument is not a SWidget"); + return PyErr_Format(PyExc_Exception, "could not add vertical slot"); } - Py_INCREF(py_swidget); - - SScrollBox::FSlot &fslot = sw_scroll_box->AddSlot(); - fslot.AttachWidget(py_swidget->s_widget->AsShared()); - fslot.HAlign((EHorizontalAlignment)h_align); - fslot.VAlign((EVerticalAlignment)v_align); - - Py_INCREF(self); - return (PyObject *)self; + Py_RETURN_SLATE_SELF; } static PyObject *py_ue_sscroll_box_clear_children(ue_PySScrollBox *self, PyObject * args) { - sw_scroll_box->ClearChildren(); + ue_py_slate_cast(SScrollBox); + py_SScrollBox->ClearChildren(); Py_RETURN_NONE; } @@ -59,7 +39,7 @@ static PyMethodDef ue_PySScrollBox_methods[] = { PyTypeObject ue_PySScrollBoxType = { PyVarObject_HEAD_INIT(NULL, 0) "unreal_engine.SScrollBox", /* tp_name */ - sizeof(ue_PySNumericEntryBox), /* tp_basicsize */ + sizeof(ue_PySScrollBox), /* tp_basicsize */ 0, /* tp_itemsize */ 0, /* tp_dealloc */ 0, /* tp_print */ @@ -100,7 +80,7 @@ static int ue_py_sscroll_box_init(ue_PySScrollBox *self, PyObject *args, PyObjec ue_py_slate_farguments_optional_fvector2d("scroll_bar_thickness", ScrollBarThickness); ue_py_slate_farguments_optional_struct_ptr("style", Style, FScrollBoxStyle); - ue_py_snew(SScrollBox, s_compound_widget.s_widget); + ue_py_snew(SScrollBox); return 0; } diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySSlider.cpp b/Source/UnrealEnginePython/Private/Slate/UEPySSlider.cpp index aa7d41770..b6c15883f 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySSlider.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPySSlider.cpp @@ -1,25 +1,24 @@ -#include "UnrealEnginePythonPrivatePCH.h" - #include "UEPySSlider.h" - -#define sw_slider StaticCastSharedRef(self->s_leaf_widget.s_widget.s_widget) - -static PyObject *py_ue_sslider_set_value(ue_PySSlider *self, PyObject * args) { +static PyObject *py_ue_sslider_set_value(ue_PySSlider *self, PyObject * args) +{ + ue_py_slate_cast(SSlider); float value; - if (!PyArg_ParseTuple(args, "f:set_value", &value)) { - return NULL; + if (!PyArg_ParseTuple(args, "f:set_value", &value)) + { + return nullptr; } - sw_slider->SetValue(value); + py_SSlider->SetValue(value); - Py_INCREF(self); - return (PyObject *)self; + Py_RETURN_SLATE_SELF; } -static PyObject *py_ue_sslider_get_value(ue_PySSlider *self, PyObject * args) { - return PyFloat_FromDouble(sw_slider->GetValue()); +static PyObject *py_ue_sslider_get_value(ue_PySSlider *self, PyObject * args) +{ + ue_py_slate_cast(SSlider); + return PyFloat_FromDouble(py_SSlider->GetValue()); } static PyMethodDef ue_PySSlider_methods[] = { @@ -59,8 +58,9 @@ PyTypeObject ue_PySSliderType = { ue_PySSlider_methods, /* tp_methods */ }; -static int ue_py_sslider_init(ue_PySSlider *self, PyObject *args, PyObject *kwargs) { - +static int ue_py_sslider_init(ue_PySSlider *self, PyObject *args, PyObject *kwargs) +{ + ue_py_slate_setup_farguments(SSlider); ue_py_slate_farguments_bool("indent_handle", IndentHandle); @@ -78,11 +78,12 @@ static int ue_py_sslider_init(ue_PySSlider *self, PyObject *args, PyObject *kwar ue_py_slate_farguments_optional_struct_ptr("style", Style, FSliderStyle); ue_py_slate_farguments_float("value", Value); - ue_py_snew(SSlider, s_leaf_widget.s_widget); + ue_py_snew(SSlider); return 0; } -void ue_python_init_sslider(PyObject *ue_module) { +void ue_python_init_sslider(PyObject *ue_module) +{ ue_PySSliderType.tp_init = (initproc)ue_py_sslider_init; ue_PySSliderType.tp_base = &ue_PySLeafWidgetType; diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySSlider.h b/Source/UnrealEnginePython/Private/Slate/UEPySSlider.h index 964996eec..4526af97f 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySSlider.h +++ b/Source/UnrealEnginePython/Private/Slate/UEPySSlider.h @@ -1,15 +1,13 @@ #pragma once -#include "UnrealEnginePython.h" - - #include "UEPySLeafWidget.h" #include "Runtime/Slate/Public/Widgets/Input/SSlider.h" extern PyTypeObject ue_PySSliderType; -typedef struct { +typedef struct +{ ue_PySLeafWidget s_leaf_widget; /* Type-specific fields go here. */ } ue_PySSlider; diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySSpacer.cpp b/Source/UnrealEnginePython/Private/Slate/UEPySSpacer.cpp index 70637e7ad..8b29aac82 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySSpacer.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPySSpacer.cpp @@ -1,10 +1,5 @@ - -#include "UnrealEnginePythonPrivatePCH.h" - #include "UEPySSpacer.h" -#define sw_spacer StaticCastSharedRef(self->s_leaf_widget.s_widget.s_widget) - static PyMethodDef ue_PySSpacer_methods[] = { { NULL } /* Sentinel */ }; @@ -46,7 +41,7 @@ static int ue_py_sspacer_init(ue_PySSpacer *self, PyObject *args, PyObject *kwar ue_py_slate_farguments_fvector2d("size", Size); - ue_py_snew(SSpacer, s_leaf_widget.s_widget); + ue_py_snew(SSpacer); return 0; } diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySSpacer.h b/Source/UnrealEnginePython/Private/Slate/UEPySSpacer.h index b1891980c..d799b052e 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySSpacer.h +++ b/Source/UnrealEnginePython/Private/Slate/UEPySSpacer.h @@ -1,6 +1,6 @@ #pragma once -#include "UnrealEnginePython.h" +#include "UEPyModule.h" #include "UEPySLeafWidget.h" diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySSplitter.cpp b/Source/UnrealEnginePython/Private/Slate/UEPySSplitter.cpp index d4f5e783a..cbce68dfe 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySSplitter.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPySSplitter.cpp @@ -1,12 +1,8 @@ - -#include "UnrealEnginePythonPrivatePCH.h" - #include "UEPySSplitter.h" -#define sw_splitter StaticCastSharedRef(self->s_panel.s_widget.s_widget) - static PyObject *py_ue_ssplitter_add_slot(ue_PySSplitter *self, PyObject * args, PyObject *kwargs) { + ue_py_slate_cast(SSplitter); PyObject *py_content; int index = -1; float size_value = -1; @@ -23,15 +19,13 @@ static PyObject *py_ue_ssplitter_add_slot(ue_PySSplitter *self, PyObject * args, return nullptr; } - ue_PySWidget *py_swidget = py_ue_is_swidget(py_content); - if (!py_swidget) + TSharedPtr Child = py_ue_is_swidget(py_content); + if (!Child.IsValid()) { - return PyErr_Format(PyExc_Exception, "argument is not a SWidget"); + return nullptr; } - Py_INCREF(py_swidget); - - SSplitter::FSlot &fslot = sw_splitter->AddSlot(index); + SSplitter::FSlot &fslot = py_SSplitter->AddSlot(index); if (size_value > -1) { fslot.SizeValue = size_value; @@ -40,10 +34,9 @@ static PyObject *py_ue_ssplitter_add_slot(ue_PySSplitter *self, PyObject * args, { fslot.SizingRule = (SSplitter::ESizeRule)sizing_rule; } - fslot.AttachWidget(py_swidget->s_widget->AsShared()); + fslot.AttachWidget(Child.ToSharedRef()); - Py_INCREF(self); - return (PyObject *)self; + Py_RETURN_SLATE_SELF; } static PyMethodDef ue_PySSplitter_methods[] = { @@ -94,7 +87,7 @@ static int ue_py_ssplitter_init(ue_PySSplitter *self, PyObject *args, PyObject * ue_py_slate_farguments_optional_enum("resize_mode", ResizeMode, ESplitterResizeMode::Type); ue_py_slate_farguments_optional_struct_ptr("style", Style, FSplitterStyle); - ue_py_snew(SSplitter, s_panel.s_widget); + ue_py_snew(SSplitter); return 0; } diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySSplitter.h b/Source/UnrealEnginePython/Private/Slate/UEPySSplitter.h index 266e7cd2e..a91bca7e2 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySSplitter.h +++ b/Source/UnrealEnginePython/Private/Slate/UEPySSplitter.h @@ -1,14 +1,13 @@ #pragma once -#include "UnrealEnginePython.h" - #include "UEPySPanel.h" #include "Runtime/Slate/Public/Widgets/Layout/SSplitter.h" extern PyTypeObject ue_PySSplitterType; -typedef struct { +typedef struct +{ ue_PySPanel s_panel; /* Type-specific fields go here. */ } ue_PySSplitter; diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySTableViewBase.cpp b/Source/UnrealEnginePython/Private/Slate/UEPySTableViewBase.cpp index 8165fea28..4ea887d13 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySTableViewBase.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPySTableViewBase.cpp @@ -1,51 +1,49 @@ -#include "UnrealEnginePythonPrivatePCH.h" #include "UEPySTableViewBase.h" -#define sw_table_view_base StaticCastSharedRef(self->s_compound_widget.s_widget.s_widget) - static PyObject *py_ue_stable_view_base_set_item_height(ue_PySTableViewBase *self, PyObject * args) { + ue_py_slate_cast(STableViewBase); float size; if (!PyArg_ParseTuple(args, "f:set_item_height", &size)) { - return NULL; + return nullptr; } - sw_table_view_base->SetItemHeight(size); + py_STableViewBase->SetItemHeight(size); - Py_INCREF(self); - return (PyObject *)self; + Py_RETURN_SLATE_SELF; } static PyObject *py_ue_stable_view_base_set_item_width(ue_PySTableViewBase *self, PyObject * args) { + ue_py_slate_cast(STableViewBase); float size; if (!PyArg_ParseTuple(args, "f:set_item_width", &size)) { - return NULL; + return nullptr; } - sw_table_view_base->SetItemWidth(size); + py_STableViewBase->SetItemWidth(size); - Py_INCREF(self); - return (PyObject *)self; + Py_RETURN_SLATE_SELF; } static PyObject *py_ue_stable_view_base_request_list_refresh(ue_PySTableViewBase *self, PyObject * args) { - sw_table_view_base->RequestListRefresh(); + ue_py_slate_cast(STableViewBase); + py_STableViewBase->RequestListRefresh(); - Py_RETURN_NONE; + Py_RETURN_NONE; } static PyMethodDef ue_PySTableViewBase_methods[] = { { "set_item_height", (PyCFunction)py_ue_stable_view_base_set_item_height, METH_VARARGS, "" }, { "set_item_width", (PyCFunction)py_ue_stable_view_base_set_item_width, METH_VARARGS, "" }, - { "request_list_refresh", (PyCFunction)py_ue_stable_view_base_request_list_refresh, METH_VARARGS, "" }, + { "request_list_refresh", (PyCFunction)py_ue_stable_view_base_request_list_refresh, METH_VARARGS, "" }, { NULL } /* Sentinel */ }; @@ -94,7 +92,7 @@ void ue_python_init_stable_view_base(PyObject *ue_module) ue_PySTableViewBase * py_ue_is_stable_view_base(PyObject *obj) { - if (!PyObject_IsInstance(obj, (PyObject *)&ue_PySTableViewBaseType)) - return nullptr; - return (ue_PySTableViewBase *)obj; + if (!PyObject_IsInstance(obj, (PyObject *)&ue_PySTableViewBaseType)) + return nullptr; + return (ue_PySTableViewBase *)obj; } diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySTextBlock.cpp b/Source/UnrealEnginePython/Private/Slate/UEPySTextBlock.cpp index 1b43e0885..92df02d50 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySTextBlock.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPySTextBlock.cpp @@ -1,45 +1,48 @@ -#include "UnrealEnginePythonPrivatePCH.h" - #include "UEPySTextBlock.h" -#define sw_text_block StaticCastSharedRef(self->s_leaf_widget.s_widget.s_widget) - -static PyObject *py_ue_stext_block_set_text(ue_PySTextBlock *self, PyObject * args) { +static PyObject *py_ue_stext_block_set_text(ue_PySTextBlock *self, PyObject * args) +{ + ue_py_slate_cast(STextBlock); char *text; - if (!PyArg_ParseTuple(args, "s:set_text", &text)) { - return NULL; + if (!PyArg_ParseTuple(args, "s:set_text", &text)) + { + return nullptr; } - sw_text_block->SetText(FString(UTF8_TO_TCHAR(text))); + py_STextBlock->SetText(FString(UTF8_TO_TCHAR(text))); - Py_INCREF(self); - return (PyObject *)self; + Py_RETURN_SLATE_SELF; } -static PyObject *py_ue_stext_block_set_color_and_opacity(ue_PySTextBlock *self, PyObject * args) { +static PyObject *py_ue_stext_block_set_color_and_opacity(ue_PySTextBlock *self, PyObject * args) +{ + + ue_py_slate_cast(STextBlock); PyObject *py_color; - if (!PyArg_ParseTuple(args, "O:set_color_and_opacity", &py_color)) { - return NULL; + if (!PyArg_ParseTuple(args, "O:set_color_and_opacity", &py_color)) + { + return nullptr; } ue_PyFLinearColor *py_linear_color = py_ue_is_flinearcolor(py_color); - if (!py_linear_color) { + if (!py_linear_color) + { return PyErr_Format(PyExc_Exception, "argument is not a FLinearColor"); } - sw_text_block->SetColorAndOpacity(py_linear_color->color); + py_STextBlock->SetColorAndOpacity(py_linear_color->color); - Py_INCREF(self); - return (PyObject *)self; + Py_RETURN_SLATE_SELF; } -static PyObject *py_ue_stext_block_get_text(ue_PySTextBlock *self, PyObject * args) { - - return PyUnicode_FromString(TCHAR_TO_UTF8(*sw_text_block->GetText().ToString())); +static PyObject *py_ue_stext_block_get_text(ue_PySTextBlock *self, PyObject * args) +{ + ue_py_slate_cast(STextBlock); + return PyUnicode_FromString(TCHAR_TO_UTF8(*py_STextBlock->GetText().ToString())); } @@ -50,39 +53,11 @@ static PyMethodDef ue_PySTextBlock_methods[] = { { NULL } /* Sentinel */ }; -PyTypeObject ue_PySTextBlockType = { - PyVarObject_HEAD_INIT(NULL, 0) - "unreal_engine.STextBlock", /* tp_name */ - sizeof(ue_PySTextBlock), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Unreal Engine STextBlock", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ue_PySTextBlock_methods, /* tp_methods */ -}; +DECLARE_UE_PY_SLATE_WIDGET(STextBlock); + +static int ue_py_stext_block_init(ue_PySTextBlock *self, PyObject *args, PyObject *kwargs) +{ -static int ue_py_stext_block_init(ue_PySTextBlock *self, PyObject *args, PyObject *kwargs) { - ue_py_slate_setup_farguments(STextBlock); ue_py_slate_farguments_bool("autowrap_text", AutoWrapText); @@ -95,7 +70,11 @@ static int ue_py_stext_block_init(ue_PySTextBlock *self, PyObject *args, PyObjec ue_py_slate_farguments_float("line_height_percentage", LineHeightPercentage); ue_py_slate_farguments_struct("margin", Margin, FMargin); ue_py_slate_farguments_float("min_desired_width", MinDesiredWidth); +#if ENGINE_MINOR_VERSION >= 23 + ue_py_slate_farguments_event("on_double_clicked", OnDoubleClicked, FPointerEventHandler, OnMouseEvent); +#else ue_py_slate_farguments_event("on_double_clicked", OnDoubleClicked, FOnClicked, OnClicked); +#endif ue_py_slate_farguments_flinear_color("shadow_color_and_opacity", ShadowColorAndOpacity); ue_py_slate_farguments_fvector2d("shadow_offset", ShadowOffset); ue_py_slate_farguments_text("text", Text); @@ -105,11 +84,12 @@ static int ue_py_stext_block_init(ue_PySTextBlock *self, PyObject *args, PyObjec ue_py_slate_farguments_enum("wrapping_policy", WrappingPolicy, ETextWrappingPolicy); ue_py_slate_farguments_float("wrap_text_at", WrapTextAt); - ue_py_snew(STextBlock, s_leaf_widget.s_widget); + ue_py_snew(STextBlock); return 0; } -void ue_python_init_stext_block(PyObject *ue_module) { +void ue_python_init_stext_block(PyObject *ue_module) +{ ue_PySTextBlockType.tp_init = (initproc)ue_py_stext_block_init; ue_PySTextBlockType.tp_base = &ue_PySLeafWidgetType; diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySTextBlock.h b/Source/UnrealEnginePython/Private/Slate/UEPySTextBlock.h index f4f2e8355..03f71a178 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySTextBlock.h +++ b/Source/UnrealEnginePython/Private/Slate/UEPySTextBlock.h @@ -1,15 +1,13 @@ #pragma once -#include "UnrealEnginePython.h" - - #include "UEPySLeafWidget.h" #include "Runtime/Slate/Public/Widgets/Text/STextBlock.h" extern PyTypeObject ue_PySTextBlockType; -typedef struct { +typedef struct +{ ue_PySLeafWidget s_leaf_widget; /* Type-specific fields go here. */ } ue_PySTextBlock; diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySTreeView.cpp b/Source/UnrealEnginePython/Private/Slate/UEPySTreeView.cpp index bec4f3b17..baf459796 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySTreeView.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPySTreeView.cpp @@ -1,19 +1,17 @@ -#include "UnrealEnginePythonPrivatePCH.h" - #include "UEPySTreeView.h" -#define sw_tree_view StaticCastSharedRef>>(self->s_list_view.s_table_view_base.s_compound_widget.s_widget.s_widget) - static PyObject *py_ue_stree_view_request_tree_refresh(ue_PySTreeView *self, PyObject * args) { - sw_tree_view->RequestTreeRefresh(); + ue_py_slate_cast_named(STreeView>, py_STreeView); + py_STreeView->RequestTreeRefresh(); Py_RETURN_NONE; } static PyObject *py_ue_stree_view_clear_expanded_items(ue_PySTreeView *self, PyObject * args) { - sw_tree_view->ClearExpandedItems(); + ue_py_slate_cast_named(STreeView>, py_STreeView); + py_STreeView->ClearExpandedItems(); Py_RETURN_NONE; } diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySVectorInputBox.cpp b/Source/UnrealEnginePython/Private/Slate/UEPySVectorInputBox.cpp index f5c950e0a..3902a7f7e 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySVectorInputBox.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPySVectorInputBox.cpp @@ -1,9 +1,6 @@ -#include "UnrealEnginePythonPrivatePCH.h" #include "UEPySVectorInputBox.h" -#define sw_vector_input_box StaticCastSharedRef(self->s_compound_widget.s_widget.s_widget) - static PyMethodDef ue_PySVectorInputBox_methods[] = { { NULL } /* Sentinel */ @@ -40,11 +37,12 @@ PyTypeObject ue_PySVectorInputBoxType = { ue_PySVectorInputBox_methods, /* tp_methods */ }; -static int ue_py_svector_input_box_init(ue_PySVectorInputBox *self, PyObject *args, PyObject *kwargs) { +static int ue_py_svector_input_box_init(ue_PySVectorInputBox *self, PyObject *args, PyObject *kwargs) +{ ue_py_slate_setup_farguments(SVectorInputBox); #if ENGINE_MINOR_VERSION > 15 - ue_py_slate_farguments_optional_bool("allow_spin", AllowSpin); + ue_py_slate_farguments_optional_bool("allow_spin", AllowSpin); #endif ue_py_slate_farguments_optional_bool("allow_responsive_layout", AllowResponsiveLayout); ue_py_slate_farguments_optional_bool("color_axis_labels", bColorAxisLabels); @@ -59,11 +57,12 @@ static int ue_py_svector_input_box_init(ue_PySVectorInputBox *self, PyObject *ar ue_py_slate_farguments_tfloat("y", Y); ue_py_slate_farguments_tfloat("z", Z); - ue_py_snew(SVectorInputBox, s_compound_widget.s_widget); + ue_py_snew(SVectorInputBox); return 0; } -void ue_python_init_svector_input_box(PyObject *ue_module) { +void ue_python_init_svector_input_box(PyObject *ue_module) +{ ue_PySVectorInputBoxType.tp_init = (initproc)ue_py_svector_input_box_init; diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySVectorInputBox.h b/Source/UnrealEnginePython/Private/Slate/UEPySVectorInputBox.h index 02b23e73f..b46d090db 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySVectorInputBox.h +++ b/Source/UnrealEnginePython/Private/Slate/UEPySVectorInputBox.h @@ -1,15 +1,13 @@ #pragma once -#include "UnrealEnginePython.h" - - #include "UEPySCompoundWidget.h" #include "Runtime/Slate/Public/Widgets/Input/SVectorInputBox.h" extern PyTypeObject ue_PySVectorInputBoxType; -typedef struct { +typedef struct +{ ue_PySCompoundWidget s_compound_widget; /* Type-specific fields go here. */ } ue_PySVectorInputBox; diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySVerticalBox.cpp b/Source/UnrealEnginePython/Private/Slate/UEPySVerticalBox.cpp index dd1a48896..b5063de25 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySVerticalBox.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPySVerticalBox.cpp @@ -1,86 +1,34 @@ -#include "UnrealEnginePythonPrivatePCH.h" - #include "UEPySVerticalBox.h" -#define sw_vertical_box StaticCastSharedRef(self->s_box_panel.s_panel.s_widget.s_widget) - -static PyObject *py_ue_svertical_box_add_slot(ue_PySVerticalBox *self, PyObject * args, PyObject *kwargs) { - PyObject *py_content; - int h_align = 0; - float max_height = 0; - PyObject *padding = nullptr; - int v_align = 0; - float fill_height = 0; - PyObject *py_auto_height = nullptr; - - char *kwlist[] = { (char *)"widget", - (char *)"h_align", - (char *)"max_height", - (char *)"padding", - (char *)"v_align", - (char *)"fill_height", - (char *)"auto_height", - nullptr }; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|ifOifO:add_slot", kwlist, - &py_content, - &h_align, - &max_height, - &padding, - &v_align, - &fill_height, - &py_auto_height)) { - return NULL; - } +static PyObject *py_ue_svertical_box_add_slot(ue_PySVerticalBox *self, PyObject * args, PyObject *kwargs) +{ + ue_py_slate_cast(SVerticalBox); - ue_PySWidget *py_swidget = py_ue_is_swidget(py_content); - if (!py_swidget) { - return PyErr_Format(PyExc_Exception, "argument is not a SWidget"); - } - - Py_INCREF(py_swidget); - - SVerticalBox::FSlot &fslot = sw_vertical_box->AddSlot(); - fslot.AttachWidget(py_swidget->s_widget->AsShared()); - fslot.HAlign((EHorizontalAlignment)h_align); - if (max_height != 0) - fslot.MaxHeight(max_height); - if (fill_height) - fslot.FillHeight(fill_height); - if (padding) + int32 retCode = [&]() { + ue_py_slate_setup_hack_slot_args(SVerticalBox, py_SVerticalBox); + ue_py_slate_farguments_float("fill_height", FillHeight); + ue_py_slate_farguments_float("max_height", MaxHeight); + ue_py_slate_farguments_optional_enum("h_align", HAlign, EHorizontalAlignment); + ue_py_slate_farguments_optional_enum("v_align", VAlign, EVerticalAlignment); + ue_py_slate_farguments_call("auto_height", AutoHeight); + ue_py_slate_farguments_padding("padding", Padding); + return 0; + }(); + + if (retCode != 0) { - if (PyTuple_Check(padding)) - { - FMargin margin; - if (!PyArg_ParseTuple(padding, "f|fff", &margin.Left, &margin.Top, &margin.Right, &margin.Bottom)) - { - return PyErr_Format(PyExc_Exception, "invalid padding value"); - } - fslot.Padding(margin); - } - else if (PyNumber_Check(padding)) - { - PyObject *py_float = PyNumber_Float(padding); - fslot.Padding(PyFloat_AsDouble(py_float)); - Py_DECREF(py_float); - } - else - { - return PyErr_Format(PyExc_Exception, "invalid padding value"); - } + return PyErr_Format(PyExc_Exception, "could not add vertical slot"); } - fslot.VAlign((EVerticalAlignment)v_align); - if (py_auto_height && PyObject_IsTrue(py_auto_height)) - fslot.AutoHeight(); - Py_INCREF(self); - return (PyObject *)self; + Py_RETURN_SLATE_SELF; } -static PyObject *py_ue_svertical_box_num_slots(ue_PySHorizontalBox *self, PyObject * args) { - return PyLong_FromLong(sw_vertical_box->NumSlots()); +static PyObject *py_ue_svertical_box_num_slots(ue_PySVerticalBox *self, PyObject * args) +{ + ue_py_slate_cast(SVerticalBox); + return PyLong_FromLong(py_SVerticalBox->NumSlots()); } static PyMethodDef ue_PySVerticalBox_methods[] = { @@ -90,50 +38,40 @@ static PyMethodDef ue_PySVerticalBox_methods[] = { { NULL } /* Sentinel */ }; -PyTypeObject ue_PySVerticalBoxType = { - PyVarObject_HEAD_INIT(NULL, 0) - "unreal_engine.SVerticalBox", /* tp_name */ - sizeof(ue_PySVerticalBox), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Unreal Engine SVerticalBox", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ue_PySVerticalBox_methods, /* tp_methods */ -}; - -static int ue_py_svertical_box_init(ue_PySHorizontalBox *self, PyObject *args, PyObject *kwargs) { - - ue_py_slate_setup_farguments(SVerticalBox); +DECLARE_UE_PY_SLATE_WIDGET(SVerticalBox); - ue_py_snew(SVerticalBox, s_box_panel.s_panel.s_widget); +static int ue_py_svertical_box_init(ue_PySVerticalBox *self, PyObject *args, PyObject *kwargs) +{ + ue_py_snew_simple(SVerticalBox); return 0; } +PyNumberMethods ue_PySVerticalBox_number_methods; + +static PyObject *ue_py_svertical_box_add(ue_PySVerticalBox *self, PyObject *value) +{ + ue_py_slate_cast(SVerticalBox); + + TSharedPtr Child = py_ue_is_swidget(value); + if (!Child.IsValid()) + { + return nullptr; + } + + SVerticalBox::FSlot &fslot = py_SVerticalBox->AddSlot(); + fslot.AttachWidget(Child.ToSharedRef()); + + Py_RETURN_SLATE_SELF; +} -void ue_python_init_svertical_box(PyObject *ue_module) { +void ue_python_init_svertical_box(PyObject *ue_module) +{ ue_PySVerticalBoxType.tp_init = (initproc)ue_py_svertical_box_init; ue_PySVerticalBoxType.tp_call = (ternaryfunc)py_ue_svertical_box_add_slot; + memset(&ue_PySVerticalBox_number_methods, 0, sizeof(PyNumberMethods)); + ue_PySVerticalBoxType.tp_as_number = &ue_PySVerticalBox_number_methods; + ue_PySVerticalBox_number_methods.nb_add = (binaryfunc)ue_py_svertical_box_add; ue_PySVerticalBoxType.tp_base = &ue_PySBoxPanelType; diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySVerticalBox.h b/Source/UnrealEnginePython/Private/Slate/UEPySVerticalBox.h index a11ad3f46..3f7af270f 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySVerticalBox.h +++ b/Source/UnrealEnginePython/Private/Slate/UEPySVerticalBox.h @@ -1,15 +1,13 @@ #pragma once -#include "UnrealEnginePython.h" - - #include "UEPySBoxPanel.h" #include "Runtime/SlateCore/Public/Widgets/SBoxPanel.h" extern PyTypeObject ue_PySVerticalBoxType; -typedef struct { +typedef struct +{ ue_PySBoxPanel s_box_panel; /* Type-specific fields go here. */ } ue_PySVerticalBox; diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySViewport.cpp b/Source/UnrealEnginePython/Private/Slate/UEPySViewport.cpp index 51a5e4ee1..3862b0700 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySViewport.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPySViewport.cpp @@ -1,20 +1,20 @@ -#include "UnrealEnginePythonPrivatePCH.h" #include "UEPySViewport.h" -#define sw_viewport StaticCastSharedRef(self->s_compound_widget.s_widget.s_widget) -static PyObject *py_ue_sviewport_enable_stereo_rendering(ue_PySViewport *self, PyObject * args) { +static PyObject *py_ue_sviewport_enable_stereo_rendering(ue_PySViewport *self, PyObject * args) +{ + ue_py_slate_cast(SViewport); PyObject *py_bool; - if (!PyArg_ParseTuple(args, "O:enable_stereo_rendering", &py_bool)) { + if (!PyArg_ParseTuple(args, "O:enable_stereo_rendering", &py_bool)) + { return NULL; } - sw_viewport->EnableStereoRendering(PyObject_IsTrue(py_bool) ? true : false); + py_SViewport->EnableStereoRendering(PyObject_IsTrue(py_bool) ? true : false); - Py_INCREF(self); - return (PyObject *)self; + Py_RETURN_SLATE_SELF; } static PyMethodDef ue_PySViewport_methods[] = { @@ -53,12 +53,14 @@ PyTypeObject ue_PySViewportType = { ue_PySViewport_methods, /* tp_methods */ }; -static int ue_py_sviewport_init(ue_PySViewport *self, PyObject *args, PyObject *kwargs) { - ue_py_snew_simple(SViewport, s_compound_widget.s_widget); +static int ue_py_sviewport_init(ue_PySViewport *self, PyObject *args, PyObject *kwargs) +{ + ue_py_snew_simple(SViewport); return 0; } -void ue_python_init_sviewport(PyObject *ue_module) { +void ue_python_init_sviewport(PyObject *ue_module) +{ ue_PySViewportType.tp_init = (initproc)ue_py_sviewport_init; diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySViewport.h b/Source/UnrealEnginePython/Private/Slate/UEPySViewport.h index e038dd97f..3c1750ba5 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySViewport.h +++ b/Source/UnrealEnginePython/Private/Slate/UEPySViewport.h @@ -1,7 +1,5 @@ #pragma once -#include "UnrealEnginePython.h" - #include "UEPySCompoundWidget.h" #include "Runtime/Slate/Public/Widgets/SViewport.h" diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySWidget.cpp b/Source/UnrealEnginePython/Private/Slate/UEPySWidget.cpp index 8b2b40421..1104338d8 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySWidget.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPySWidget.cpp @@ -1,22 +1,23 @@ -#include "UnrealEnginePythonPrivatePCH.h" #include "UEPySWidget.h" +#include "Runtime/Slate/Public/Framework/Application/SlateApplication.h" + static PyObject *ue_PySWidget_str(ue_PySWidget *self) { #if PY_MAJOR_VERSION >= 3 return PyUnicode_FromFormat("", - TCHAR_TO_UTF8(*self->s_widget->GetTypeAsString()), &self->s_widget.Get(), self->s_widget.GetSharedReferenceCount(), self->ob_base.ob_refcnt); + TCHAR_TO_UTF8(*self->Widget->GetTypeAsString()), &self->Widget.Get(), self->Widget.GetSharedReferenceCount(), self->ob_base.ob_refcnt); #else return PyUnicode_FromFormat("", - TCHAR_TO_UTF8(*self->s_widget->GetTypeAsString()), &self->s_widget.Get(), self->s_widget.GetSharedReferenceCount()); + TCHAR_TO_UTF8(*self->Widget->GetTypeAsString()), &self->Widget.Get(), self->Widget.GetSharedReferenceCount()); #endif } static PyObject *py_ue_swidget_get_children(ue_PySWidget *self, PyObject * args) { - FChildren *children = self->s_widget->GetChildren(); + FChildren *children = self->Widget->GetChildren(); PyObject *py_list = PyList_New(0); for (int32 i = 0; i < children->Num(); i++) { @@ -65,10 +66,9 @@ static PyObject *py_ue_swidget_set_visibility(ue_PySWidget *self, PyObject * arg break; } - self->s_widget->SetVisibility(visibility); + self->Widget->SetVisibility(visibility); - Py_INCREF(self); - return (PyObject *)self; + Py_RETURN_SLATE_SELF; } static PyObject *py_ue_swidget_set_tooltip_text(ue_PySWidget *self, PyObject * args) @@ -79,10 +79,9 @@ static PyObject *py_ue_swidget_set_tooltip_text(ue_PySWidget *self, PyObject * a return NULL; } - self->s_widget->SetToolTipText(FText::FromString(UTF8_TO_TCHAR(text))); + self->Widget->SetToolTipText(FText::FromString(UTF8_TO_TCHAR(text))); - Py_INCREF(self); - return (PyObject *)self; + Py_RETURN_SLATE_SELF; } static PyObject *py_ue_swidget_set_cursor(ue_PySWidget *self, PyObject * args) @@ -93,7 +92,7 @@ static PyObject *py_ue_swidget_set_cursor(ue_PySWidget *self, PyObject * args) return NULL; } - self->s_widget->SetCursor((EMouseCursor::Type)cursor); + self->Widget->SetCursor((EMouseCursor::Type)cursor); Py_INCREF(self); return (PyObject *)self; @@ -107,10 +106,9 @@ static PyObject *py_ue_swidget_set_enabled(ue_PySWidget *self, PyObject * args) return NULL; } - self->s_widget->SetEnabled(PyObject_IsTrue(py_bool) ? true : false); + self->Widget->SetEnabled(PyObject_IsTrue(py_bool) ? true : false); - Py_INCREF(self); - return (PyObject *)self; + Py_RETURN_SLATE_SELF; } #if ENGINE_MINOR_VERSION > 12 @@ -122,19 +120,18 @@ static PyObject *py_ue_swidget_bind_on_mouse_button_down(ue_PySWidget *self, PyO return NULL; } - if (!PyCalllable_Check_Extended(py_callable)) + if (!PyCallable_Check(py_callable)) { return PyErr_Format(PyExc_Exception, "argument is not callable"); } FPointerEventHandler handler; - TSharedRef py_delegate = FUnrealEnginePythonHouseKeeper::Get()->NewSlateDelegate(self->s_widget, py_callable); + TSharedRef py_delegate = FUnrealEnginePythonHouseKeeper::Get()->NewSlateDelegate(self->Widget, py_callable); handler.BindSP(py_delegate, &FPythonSlateDelegate::OnMouseEvent); - self->s_widget->SetOnMouseButtonDown(handler); + self->Widget->SetOnMouseButtonDown(handler); - Py_INCREF(self); - return (PyObject *)self; + Py_RETURN_SLATE_SELF; } static PyObject *py_ue_swidget_bind_on_mouse_button_up(ue_PySWidget *self, PyObject * args) @@ -145,19 +142,18 @@ static PyObject *py_ue_swidget_bind_on_mouse_button_up(ue_PySWidget *self, PyObj return nullptr; } - if (!PyCalllable_Check_Extended(py_callable)) + if (!PyCallable_Check(py_callable)) { return PyErr_Format(PyExc_Exception, "argument is not callable"); } FPointerEventHandler handler; - TSharedRef py_delegate = FUnrealEnginePythonHouseKeeper::Get()->NewSlateDelegate(self->s_widget, py_callable); + TSharedRef py_delegate = FUnrealEnginePythonHouseKeeper::Get()->NewSlateDelegate(self->Widget, py_callable); handler.BindSP(py_delegate, &FPythonSlateDelegate::OnMouseEvent); - self->s_widget->SetOnMouseButtonUp(handler); + self->Widget->SetOnMouseButtonUp(handler); - Py_INCREF(self); - return (PyObject *)self; + Py_RETURN_SLATE_SELF; } static PyObject *py_ue_swidget_bind_on_mouse_double_click(ue_PySWidget *self, PyObject * args) @@ -168,19 +164,18 @@ static PyObject *py_ue_swidget_bind_on_mouse_double_click(ue_PySWidget *self, Py return NULL; } - if (!PyCalllable_Check_Extended(py_callable)) + if (!PyCallable_Check(py_callable)) { return PyErr_Format(PyExc_Exception, "argument is not callable"); } FPointerEventHandler handler; - TSharedRef py_delegate = FUnrealEnginePythonHouseKeeper::Get()->NewSlateDelegate(self->s_widget, py_callable); + TSharedRef py_delegate = FUnrealEnginePythonHouseKeeper::Get()->NewSlateDelegate(self->Widget, py_callable); handler.BindSP(py_delegate, &FPythonSlateDelegate::OnMouseEvent); - self->s_widget->SetOnMouseDoubleClick(handler); + self->Widget->SetOnMouseDoubleClick(handler); - Py_INCREF(self); - return (PyObject *)self; + Py_RETURN_SLATE_SELF; } static PyObject *py_ue_swidget_bind_on_mouse_move(ue_PySWidget *self, PyObject * args) @@ -191,19 +186,18 @@ static PyObject *py_ue_swidget_bind_on_mouse_move(ue_PySWidget *self, PyObject * return NULL; } - if (!PyCalllable_Check_Extended(py_callable)) + if (!PyCallable_Check(py_callable)) { return PyErr_Format(PyExc_Exception, "argument is not callable"); } FPointerEventHandler handler; - TSharedRef py_delegate = FUnrealEnginePythonHouseKeeper::Get()->NewSlateDelegate(self->s_widget, py_callable); + TSharedRef py_delegate = FUnrealEnginePythonHouseKeeper::Get()->NewSlateDelegate(self->Widget, py_callable); handler.BindSP(py_delegate, &FPythonSlateDelegate::OnMouseEvent); - self->s_widget->SetOnMouseMove(handler); + self->Widget->SetOnMouseMove(handler); - Py_INCREF(self); - return (PyObject *)self; + Py_RETURN_SLATE_SELF; } #endif @@ -211,37 +205,33 @@ static PyObject *py_ue_swidget_bind_on_mouse_move(ue_PySWidget *self, PyObject * static PyObject *py_ue_swidget_has_keyboard_focus(ue_PySWidget *self, PyObject * args) { - if (self->s_widget->HasKeyboardFocus()) + if (self->Widget->HasKeyboardFocus()) { - Py_INCREF(Py_True); - return Py_True; + Py_RETURN_TRUE; } - Py_INCREF(Py_False); - return Py_False; + Py_RETURN_FALSE; } static PyObject *py_ue_swidget_set_keyboard_focus(ue_PySWidget *self, PyObject * args) { - - FSlateApplication::Get().SetKeyboardFocus(self->s_widget, EFocusCause::SetDirectly); - Py_INCREF(self); - return (PyObject *)self; + FSlateApplication::Get().SetKeyboardFocus(self->Widget, EFocusCause::SetDirectly); + Py_RETURN_SLATE_SELF; } static PyObject *py_ue_swidget_get_type(ue_PySWidget *self, PyObject * args) { - return PyUnicode_FromString(TCHAR_TO_UTF8(*(self->s_widget->GetTypeAsString()))); + return PyUnicode_FromString(TCHAR_TO_UTF8(*(self->Widget->GetTypeAsString()))); } static PyObject *py_ue_swidget_get_cached_geometry(ue_PySWidget *self, PyObject * args) { - return py_ue_new_fgeometry(self->s_widget->GetCachedGeometry()); + return py_ue_new_fgeometry(self->Widget->GetCachedGeometry()); } static PyObject *py_ue_swidget_get_shared_reference_count(ue_PySWidget *self, PyObject * args) { - return PyLong_FromLong(self->s_widget.GetSharedReferenceCount()); + return PyLong_FromLong(self->Widget.GetSharedReferenceCount()); } static PyObject *py_ue_swidget_invalidate(ue_PySWidget *self, PyObject * args) @@ -251,7 +241,7 @@ static PyObject *py_ue_swidget_invalidate(ue_PySWidget *self, PyObject * args) { return nullptr; } - self->s_widget->Invalidate((EInvalidateWidget)invalidate_mode); + self->Widget->Invalidate((EInvalidateWidget)invalidate_mode); Py_RETURN_NONE; } @@ -276,7 +266,7 @@ static PyObject *py_ue_swidget_on_mouse_button_down(ue_PySWidget *self, PyObject return PyErr_Format(PyExc_Exception, "argument is not a FPointerEvent"); } - FReply reply = self->s_widget->OnMouseButtonDown(geometry->geometry, pointer->pointer); + FReply reply = self->Widget->OnMouseButtonDown(geometry->geometry, pointer->pointer); if (reply.IsEventHandled()) { @@ -307,7 +297,7 @@ static PyObject *py_ue_swidget_on_mouse_button_up(ue_PySWidget *self, PyObject * return PyErr_Format(PyExc_Exception, "argument is not a FPointerEvent"); } - FReply reply = self->s_widget->OnMouseButtonUp(geometry->geometry, pointer->pointer); + FReply reply = self->Widget->OnMouseButtonUp(geometry->geometry, pointer->pointer); if (reply.IsEventHandled()) { @@ -317,7 +307,52 @@ static PyObject *py_ue_swidget_on_mouse_button_up(ue_PySWidget *self, PyObject * Py_RETURN_FALSE; } + +static PyObject *py_ue_swidget_new_ref(ue_PySWidget *self, PyObject * args) +{ + PyObject *py_widget; + if (!PyArg_ParseTuple(args, "O:new_ref", &py_widget)) + { + return nullptr; + } + + TSharedPtr Widget = py_ue_is_swidget(py_widget); + if (!Widget.IsValid()) + return nullptr; + + return (PyObject *)py_ue_new_swidget(Widget.ToSharedRef(), &ue_PySWidgetType); +} + +static PyObject *py_ue_swidget_assign(ue_PySWidget *self, PyObject * args) +{ + char *global_name; + if (!PyArg_ParseTuple(args, "s:assign", &global_name)) + { + return nullptr; + } + + PyObject *py_globals = PyEval_GetGlobals(); + if (!py_globals) + { + return PyErr_Format(PyExc_Exception, "unable to retrieve globals"); + } + + if (!PyDict_GetItemString(py_globals, global_name)) + { + PyErr_Clear(); + return PyErr_Format(PyExc_Exception, "global \"%s\" not found", global_name); + } + + if (PyDict_SetItemString(py_globals, global_name, (PyObject *)self) < 0) + { + return PyErr_Format(PyExc_Exception, "unable to assign global \"%s\" to SWidget", global_name); + } + + Py_RETURN_SLATE_SELF; +} + static PyMethodDef ue_PySWidget_methods[] = { + { "new_ref", (PyCFunction)py_ue_swidget_new_ref, METH_VARARGS, "" }, { "get_shared_reference_count", (PyCFunction)py_ue_swidget_get_shared_reference_count, METH_VARARGS, "" }, { "get_cached_geometry", (PyCFunction)py_ue_swidget_get_cached_geometry, METH_VARARGS, "" }, { "get_children", (PyCFunction)py_ue_swidget_get_children, METH_VARARGS, "" }, @@ -337,21 +372,25 @@ static PyMethodDef ue_PySWidget_methods[] = { #endif { "on_mouse_button_down", (PyCFunction)py_ue_swidget_on_mouse_button_down, METH_VARARGS, "" }, { "on_mouse_button_up", (PyCFunction)py_ue_swidget_on_mouse_button_up, METH_VARARGS, "" }, + + { "assign", (PyCFunction)py_ue_swidget_assign, METH_VARARGS, "" }, { NULL } /* Sentinel */ }; -static void ue_PySWidgett_dealloc(ue_PySWidget *self) +static void ue_PySWidget_dealloc(ue_PySWidget *self) { #if defined(UEPY_MEMORY_DEBUG) UE_LOG(LogPython, Warning, TEXT("Destroying ue_PySWidget %p mapped to %s %p (slate refcount: %d)"), self, *self->s_widget->GetTypeAsString(), &self->s_widget.Get(), self->s_widget.GetSharedReferenceCount()); #endif - Py_DECREF(self->py_dict); - ue_py_unregister_swidget(&self->s_widget.Get()); + + if (self->weakreflist != nullptr) + PyObject_ClearWeakRefs((PyObject *)self); + // decrement widget reference count // but only if python vm is still fully active (hack to avoid crashes on editor shutdown) if (Py_IsInitialized()) { - self->s_widget = SNullWidget::NullWidget; + self->Widget = SNullWidget::NullWidget; } else { @@ -366,7 +405,7 @@ PyTypeObject ue_PySWidgetType = { "unreal_engine.SWidget", /* tp_name */ sizeof(ue_PySWidget), /* tp_basicsize */ 0, /* tp_itemsize */ - (destructor)ue_PySWidgett_dealloc, /* tp_dealloc */ + (destructor)ue_PySWidget_dealloc, /* tp_dealloc */ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ @@ -400,7 +439,8 @@ ue_PySWidget_new(PyTypeObject *type, PyObject *args, PyObject *kwds) self = (ue_PySWidget *)type->tp_alloc(type, 0); if (self != NULL) { - ue_py_setup_swidget(self); + new(&self->Widget) TSharedRef(SNullWidget::NullWidget); + self->weakreflist = nullptr; } return (PyObject *)self; @@ -409,10 +449,8 @@ ue_PySWidget_new(PyTypeObject *type, PyObject *args, PyObject *kwds) void ue_python_init_swidget(PyObject *ue_module) { ue_PySWidgetType.tp_new = ue_PySWidget_new; - - ue_PySWidgetType.tp_getattro = PyObject_GenericGetAttr; - ue_PySWidgetType.tp_setattro = PyObject_GenericSetAttr; - ue_PySWidgetType.tp_dictoffset = offsetof(ue_PySWidget, py_dict); + // support for weak references, useful for tests + ue_PySWidgetType.tp_weaklistoffset = offsetof(ue_PySWidget, weakreflist); if (PyType_Ready(&ue_PySWidgetType) < 0) return; @@ -421,10 +459,5 @@ void ue_python_init_swidget(PyObject *ue_module) PyModule_AddObject(ue_module, "SWidget", (PyObject *)&ue_PySWidgetType); } -ue_PySWidget *py_ue_is_swidget(PyObject *obj) -{ - if (!PyObject_IsInstance(obj, (PyObject *)&ue_PySWidgetType)) - return nullptr; - return (ue_PySWidget *)obj; -} + diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySWidget.h b/Source/UnrealEnginePython/Private/Slate/UEPySWidget.h index ac3ca3645..bd77a6831 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySWidget.h +++ b/Source/UnrealEnginePython/Private/Slate/UEPySWidget.h @@ -1,22 +1,53 @@ #pragma once -#include "UnrealEnginePython.h" - -extern PyTypeObject ue_PySWidgetType; - -class UPythonSlateDelegate; -typedef struct ue_PySWidget ue_PySWidget; - -struct ue_PySWidget -{ - PyObject_HEAD - /* Type-specific fields go here. */ - - TSharedRef s_widget; - PyObject *py_dict; -}; - -void ue_python_init_swidget(PyObject *); - -ue_PySWidget *py_ue_is_swidget(PyObject *); +#include "UEPySlate.h" + +#include "UEPyFGeometry.h" +#include "UEPyFPaintContext.h" + +#include "UEPyFInputEvent.h" +#include "UEPyFPointerEvent.h" +#include "UEPyFKeyEvent.h" +#include "UEPyFCharacterEvent.h" +#include "UEPyFModifierKeysState.h" + +#define ue_py_slate_cast(T) ue_PySWidget *py_self_swidget = (ue_PySWidget *)self;\ + TSharedRef py_ ## T = StaticCastSharedRef(py_self_swidget->Widget) + +#define ue_py_slate_cast_named(T, name) ue_PySWidget *py_self_swidget = (ue_PySWidget *)self;\ + TSharedRef name = StaticCastSharedRef(py_self_swidget->Widget) + +#define Py_RETURN_SLATE_SELF Py_INCREF(self);\ + return (PyObject *)self + +#define DECLARE_UE_PY_SLATE_WIDGET(WIDGETTYPE) PyTypeObject ue_Py##WIDGETTYPE##Type = {\ +PyVarObject_HEAD_INIT(NULL, 0)\ +"unreal_engine." #WIDGETTYPE, /* tp_name */\ +sizeof(ue_Py##WIDGETTYPE), /* tp_basicsize */\ +0, /* tp_itemsize */\ +0, /* tp_dealloc */\ +0, /* tp_print */\ +0, /* tp_getattr */\ +0, /* tp_setattr */\ +0, /* tp_reserved */\ +0, /* tp_repr */\ +0, /* tp_as_number */\ +0, /* tp_as_sequence */\ +0, /* tp_as_mapping */\ +0, /* tp_hash */\ +0, /* tp_call */\ +0, /* tp_str */\ +0, /* tp_getattro */\ +0, /* tp_setattro */\ +0, /* tp_as_buffer */\ +Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */\ +"Unreal Engine " #WIDGETTYPE, /* tp_doc */\ +0, /* tp_traverse */\ +0, /* tp_clear */\ +0, /* tp_richcompare */\ +0, /* tp_weaklistoffset */\ +0, /* tp_iter */\ +0, /* tp_iternext */\ +ue_Py##WIDGETTYPE##_methods, /* tp_methods */\ +} diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySWindow.cpp b/Source/UnrealEnginePython/Private/Slate/UEPySWindow.cpp index 7d22b4671..41f6615ab 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySWindow.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPySWindow.cpp @@ -1,30 +1,42 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPySWindow.h" #if WITH_EDITOR #include "Editor/MainFrame/Public/Interfaces/IMainFrameModule.h" #endif -#include "UEPySWindow.h" +#if PLATFORM_WINDOWS +#include "Windows/AllowWindowsPlatformTypes.h" +#endif -#define sw_window StaticCastSharedRef(self->s_compound_widget.s_widget.s_widget) +#include "Runtime/Slate/Public/Framework/Application/SlateApplication.h" static PyObject *py_ue_swindow_set_title(ue_PySWindow *self, PyObject * args) { + ue_py_slate_cast(SWindow); char *title; if (!PyArg_ParseTuple(args, "s:set_title", &title)) { - return NULL; + return nullptr; } - sw_window->SetTitle(FText::FromString(UTF8_TO_TCHAR(title))); + py_SWindow->SetTitle(FText::FromString(UTF8_TO_TCHAR(title))); - Py_INCREF(self); - return (PyObject *)self; + Py_RETURN_SLATE_SELF; +} + +static PyObject *py_ue_swindow_get_title(ue_PySWindow *self, PyObject * args) +{ + ue_py_slate_cast(SWindow); + + const char *title = TCHAR_TO_UTF8(*py_SWindow->GetTitle().ToString()); + + return PyUnicode_FromString(title); } static PyObject *py_ue_swindow_resize(ue_PySWindow *self, PyObject * args) { + ue_py_slate_cast(SWindow); int width; int height; if (!PyArg_ParseTuple(args, "ii:resize", &width, &height)) @@ -33,89 +45,126 @@ static PyObject *py_ue_swindow_resize(ue_PySWindow *self, PyObject * args) } - sw_window->Resize(FVector2D(width, height)); + py_SWindow->Resize(FVector2D(width, height)); - Py_INCREF(self); - return (PyObject *)self; + Py_RETURN_SLATE_SELF; } static PyObject *py_ue_swindow_minimize(ue_PySWindow *self, PyObject * args) { - sw_window->Minimize(); + ue_py_slate_cast(SWindow); + py_SWindow->Minimize(); - Py_INCREF(self); - return (PyObject *)self; + Py_RETURN_SLATE_SELF; } static PyObject *py_ue_swindow_set_content(ue_PySWindow *self, PyObject * args) { + ue_py_slate_cast(SWindow); PyObject *py_content; if (!PyArg_ParseTuple(args, "O:set_content", &py_content)) { - return NULL; + return nullptr; } - ue_PySWidget *py_swidget = py_ue_is_swidget(py_content); - if (!py_swidget) + TSharedPtr Content = py_ue_is_swidget(py_content); + if (!Content.IsValid()) { - return PyErr_Format(PyExc_Exception, "argument is not a SWidget"); + return nullptr; } - Py_INCREF(py_swidget); + py_SWindow->SetContent(Content.ToSharedRef()); - sw_window->SetContent(py_swidget->s_widget->AsShared()); - - Py_INCREF(self); - return (PyObject *)self; + Py_RETURN_SLATE_SELF; } static PyObject *py_ue_swindow_set_sizing_rule(ue_PySWindow *self, PyObject * args) { + ue_py_slate_cast(SWindow); int rule; if (!PyArg_ParseTuple(args, "i:set_sizing_rule", &rule)) { - return NULL; + return nullptr; } #if ENGINE_MINOR_VERSION > 15 - sw_window->SetSizingRule((ESizingRule)rule); + py_SWindow->SetSizingRule((ESizingRule)rule); #else - sw_window->SetSizingRule((ESizingRule::Type)rule); + py_SWindow->SetSizingRule((ESizingRule::Type)rule); #endif - Py_INCREF(self); - return (PyObject *)self; + Py_RETURN_SLATE_SELF; } static PyObject *py_ue_swindow_get_handle(ue_PySWindow *self, PyObject * args) { - return PyLong_FromLongLong((long long)sw_window->GetNativeWindow()->GetOSWindowHandle()); + ue_py_slate_cast(SWindow); + return PyLong_FromLongLong((long long)py_SWindow->GetNativeWindow()->GetOSWindowHandle()); +} + +static PyObject *py_ue_swindow_set_as_owner(ue_PySWindow *self, PyObject * args) +{ + ue_py_slate_cast(SWindow); + long long window_ptr; + if (!PyArg_ParseTuple(args, "L:set_as_owner", &window_ptr)) + { + return nullptr; + } + void *whnd = py_SWindow->GetNativeWindow()->GetOSWindowHandle(); +#if PLATFORM_WINDOWS + SetWindowLongPtr((HWND)window_ptr, GWLP_HWNDPARENT, (LONG_PTR)whnd); +#endif + Py_RETURN_NONE; } static PyObject *py_ue_swindow_request_destroy(ue_PySWindow *self, PyObject * args) { + ue_py_slate_cast(SWindow); + py_SWindow->RequestDestroyWindow(); - sw_window->RequestDestroyWindow(); + Py_RETURN_NONE; +} +static PyObject *py_ue_swindow_bring_to_front(ue_PySWindow *self, PyObject * args) +{ + ue_py_slate_cast(SWindow); + + PyObject *py_force = nullptr; + + if (!PyArg_ParseTuple(args, "|O:set_as_owner", &py_force)) + { + return nullptr; + } + + bool bForce = false; + if (py_force && PyObject_IsTrue(py_force)) + bForce = true; + + py_SWindow->BringToFront(bForce); + Py_RETURN_NONE; } #if WITH_EDITOR static PyObject *py_ue_swindow_add_modal(ue_PySWindow *self, PyObject * args) { + ue_py_slate_cast(SWindow); TSharedPtr parent_window; if (FModuleManager::Get().IsModuleLoaded("MainFrame")) { parent_window = FModuleManager::LoadModuleChecked("MainFrame").GetParentWindow(); } - FSlateApplication::Get().AddModalWindow(StaticCastSharedRef(sw_window->AsShared()), parent_window, false); + Py_BEGIN_ALLOW_THREADS; + FSlateApplication::Get().AddModalWindow(StaticCastSharedRef(py_SWindow->AsShared()), parent_window, false); + Py_END_ALLOW_THREADS; Py_RETURN_NONE; } #endif static PyObject *py_ue_swindow_add_child(ue_PySWindow *self, PyObject * args) { + ue_py_slate_cast(SWindow); PyObject *py_obj; if (!PyArg_ParseTuple(args, "O:add_child", &py_obj)) { @@ -129,21 +178,38 @@ static PyObject *py_ue_swindow_add_child(ue_PySWindow *self, PyObject * args) } FSlateApplication::Get().AddWindowAsNativeChild( - StaticCastSharedRef(py_swindow_child->s_compound_widget.s_widget.s_widget), - sw_window); + StaticCastSharedRef(py_swindow_child->s_compound_widget.s_widget.Widget), + py_SWindow); Py_RETURN_NONE; } +static PyObject *py_ue_swindow_get_child_windows(ue_PySWindow *self, PyObject * args) +{ + ue_py_slate_cast(SWindow); + TArray>& ChildWindows = py_SWindow->GetChildWindows(); + PyObject *py_list = PyList_New(0); + for (TSharedRef ChildWindow : ChildWindows) + { + PyList_Append(py_list, (PyObject *)py_ue_new_swindow(ChildWindow)); + } + + return py_list; +} + static PyMethodDef ue_PySWindow_methods[] = { + { "get_child_windows", (PyCFunction)py_ue_swindow_get_child_windows, METH_VARARGS, "" }, { "set_title", (PyCFunction)py_ue_swindow_set_title, METH_VARARGS, "" }, + { "get_title", (PyCFunction)py_ue_swindow_get_title, METH_VARARGS, "" }, { "set_sizing_rule", (PyCFunction)py_ue_swindow_set_sizing_rule, METH_VARARGS, "" }, { "minimize", (PyCFunction)py_ue_swindow_minimize, METH_VARARGS, "" }, { "resize", (PyCFunction)py_ue_swindow_resize, METH_VARARGS, "" }, { "set_client_size", (PyCFunction)py_ue_swindow_resize, METH_VARARGS, "" }, { "set_content", (PyCFunction)py_ue_swindow_set_content, METH_VARARGS, "" }, { "get_handle", (PyCFunction)py_ue_swindow_get_handle, METH_VARARGS, "" }, + { "set_as_owner", (PyCFunction)py_ue_swindow_set_as_owner, METH_VARARGS, "" }, { "request_destroy", (PyCFunction)py_ue_swindow_request_destroy, METH_VARARGS, "" }, + { "bring_to_front", (PyCFunction)py_ue_swindow_bring_to_front, METH_VARARGS, "" }, #if WITH_EDITOR { "add_modal", (PyCFunction)py_ue_swindow_add_modal, METH_VARARGS, "" }, #endif @@ -151,36 +217,8 @@ static PyMethodDef ue_PySWindow_methods[] = { { NULL } /* Sentinel */ }; -PyTypeObject ue_PySWindowType = { - PyVarObject_HEAD_INIT(NULL, 0) - "unreal_engine.SWindow", /* tp_name */ - sizeof(ue_PySWindow), /* tp_basicsize */ - 0, /* tp_itemsize */ - 0, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_reserved */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - 0, /* tp_str */ - 0, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ - "Unreal Engine SWindow", /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - ue_PySWindow_methods, /* tp_methods */ -}; + +DECLARE_UE_PY_SLATE_WIDGET(SWindow); static int ue_py_swindow_init(ue_PySWindow *self, PyObject *args, PyObject *kwargs) { @@ -228,7 +266,9 @@ static int ue_py_swindow_init(ue_PySWindow *self, PyObject *args, PyObject *kwar ue_py_slate_farguments_optional_bool("use_os_window_border", UseOSWindowBorder); ue_py_slate_farguments_optional_struct("user_resize_border", UserResizeBorder, FMargin); - ue_py_snew(SWindow, s_compound_widget.s_widget); + ue_py_snew(SWindow); + + ue_py_slate_cast(SWindow); #if WITH_EDITOR // is it a modal window ? @@ -240,31 +280,53 @@ static int ue_py_swindow_init(ue_PySWindow *self, PyObject *args, PyObject *kwar #endif PyObject *on_closed = ue_py_dict_get_item(kwargs, "on_closed"); - if (on_closed && PyCalllable_Check_Extended(on_closed)) + if (on_closed && PyCallable_Check(on_closed)) { FOnWindowClosed handler; - TSharedRef py_delegate = FUnrealEnginePythonHouseKeeper::Get()->NewSlateDelegate(self->s_compound_widget.s_widget.s_widget, on_closed); + TSharedRef py_delegate = FUnrealEnginePythonHouseKeeper::Get()->NewSlateDelegate(self->s_compound_widget.s_widget.Widget, on_closed); handler.BindSP(py_delegate, &FPythonSlateDelegate::OnWindowClosed); - sw_window->SetOnWindowClosed(handler); + py_SWindow->SetOnWindowClosed(handler); } // is it a child ? PyObject *is_child = ue_py_dict_get_item(kwargs, "child"); if (!(is_child && PyObject_IsTrue(is_child))) { - FSlateApplication::Get().AddWindow(StaticCastSharedRef(sw_window->AsShared()), true); + FSlateApplication::Get().AddWindow(py_SWindow, true); } return 0; } +PyNumberMethods ue_PySWindow_number_methods; + +static PyObject *ue_py_swindow_lshift(ue_PySWindow *self, PyObject *value) +{ + ue_py_slate_cast(SWindow); + + TSharedPtr Content = py_ue_is_swidget(value); + if (!Content.IsValid()) + { + return nullptr; + } + + py_SWindow->SetContent(Content.ToSharedRef()); + + Py_RETURN_SLATE_SELF; +} + + void ue_python_init_swindow(PyObject *ue_module) { ue_PySWindowType.tp_init = (initproc)ue_py_swindow_init; ue_PySWindowType.tp_call = (ternaryfunc)py_ue_swindow_set_content; + memset(&ue_PySWindow_number_methods, 0, sizeof(PyNumberMethods)); + ue_PySWindowType.tp_as_number = &ue_PySWindow_number_methods; + ue_PySWindow_number_methods.nb_lshift = (binaryfunc)ue_py_swindow_lshift; + ue_PySWindowType.tp_base = &ue_PySCompoundWidgetType; if (PyType_Ready(&ue_PySWindowType) < 0) @@ -279,4 +341,13 @@ ue_PySWindow *py_ue_is_swindow(PyObject *obj) if (!PyObject_IsInstance(obj, (PyObject *)&ue_PySWindowType)) return nullptr; return (ue_PySWindow *)obj; +} + +ue_PySWindow *py_ue_new_swindow(TSharedRef s_window) +{ + ue_PySWindow *ret = (ue_PySWindow *)PyObject_New(ue_PySWindow, &ue_PySWindowType); + + new(&ret->s_compound_widget.s_widget.Widget) TSharedRef(s_window); + ret->s_compound_widget.s_widget.weakreflist = nullptr; + return ret; } \ No newline at end of file diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySWindow.h b/Source/UnrealEnginePython/Private/Slate/UEPySWindow.h index 396c860de..b09c3f3b1 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySWindow.h +++ b/Source/UnrealEnginePython/Private/Slate/UEPySWindow.h @@ -1,7 +1,5 @@ #pragma once -#include "UnrealEnginePython.h" - #include "UEPySCompoundWidget.h" #include "Runtime/SlateCore/Public/Widgets/SWindow.h" @@ -15,4 +13,6 @@ typedef struct { void ue_python_init_swindow(PyObject *); -ue_PySWindow *py_ue_is_swindow(PyObject *obj); \ No newline at end of file +ue_PySWindow *py_ue_is_swindow(PyObject *obj); + +ue_PySWindow *py_ue_new_swindow(TSharedRef); \ No newline at end of file diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySlate.cpp b/Source/UnrealEnginePython/Private/Slate/UEPySlate.cpp index 3064f7997..2e705a303 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySlate.cpp +++ b/Source/UnrealEnginePython/Private/Slate/UEPySlate.cpp @@ -1,5 +1,5 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPySlate.h" #if WITH_EDITOR #include "LevelEditor.h" @@ -26,11 +26,96 @@ #include "UEPySlate.h" #include "PyNativeWidgetHost.h" +#include "Wrappers/UEPyFAssetData.h" + +#include "Sound/SoundBase.h" + +#include "UEPySWidget.h" +#include "UEPySCompoundWidget.h" +#include "UEPySWindow.h" +#include "UEPySBorder.h" +#include "UEPySButton.h" +#include "UEPySLeafWidget.h" +#include "UEPySTextBlock.h" +#include "UEPySEditableTextBox.h" +#include "UEPySMultiLineEditableText.h" +#include "UEPySPanel.h" +#include "UEPySGridPanel.h" +#include "UEPySBoxPanel.h" +#include "UEPySHorizontalBox.h" +#include "UEPySVerticalBox.h" +#include "UEPySViewport.h" + + +#include "UEPySImage.h" +#include "UEPySDockTab.h" +#include "UEPySTableViewBase.h" +#include "UEPySListView.h" +#include "UEPySPythonListView.h" +#include "UEPySPythonMultiColumnTableRow.h" +#include "UEPySTreeView.h" +#include "UEPySPythonTreeView.h" +#include "UEPySSplitter.h" +#include "UEPySHeaderRow.h" +#include "UEPySCheckBox.h" +#include "UEPySNumericEntryBox.h" +#include "UEPySCanvas.h" +#include "UEPySSlider.h" +#include "UEPySVectorInputBox.h" +#include "UEPySRotatorInputBox.h" +#include "UEPySPythonComboBox.h" +#include "UEPySScrollBox.h" +#include "UEPySColorBlock.h" +#include "UEPySBox.h" +#include "UEPySProgressBar.h" +#include "UEPySSpacer.h" +#include "UEPySPythonWidget.h" +#include "UEPySOverlay.h" + +#include "UEPyFTabManager.h" +#include "UEPyFTabSpawnerEntry.h" +#include "UEPyFMenuBuilder.h" +#include "UEPyFToolBarBuilder.h" +#include "UEPyFSlateIcon.h" +#include "UEPyFSlateStyleSet.h" + +#include "UEPyFGeometry.h" +#include "UEPyFPaintContext.h" + +#include "UEPyFInputEvent.h" +#include "UEPyFPointerEvent.h" +#include "UEPyFKeyEvent.h" +#include "UEPyFCharacterEvent.h" +#include "UEPyFModifierKeysState.h" +#include "Wrappers/UEPyESlateEnums.h" + +#if WITH_EDITOR +#include "UEPySEditorViewport.h" +#include "UEPySLevelViewport.h" +#include "UEPySPythonEditorViewport.h" +#include "UEPySGraphEditor.h" +#include "UEPySPythonShelf.h" +#include "UEPySFilePathPicker.h" +#include "UEPySDirectoryPicker.h" +#include "UEPySDropTarget.h" +#include "UEPySAssetDropTarget.h" +#include "UEPySObjectPropertyEntryBox.h" +#include "UEPyIDetailsView.h" +#include "UEPyIStructureDetailsView.h" +#include "UEPySNodePanel.h" +#include "UEPySGraphPanel.h" +#endif + +#include "Runtime/Core/Public/Misc/Attribute.h" +#include "Runtime/Slate/Public/Framework/Application/SlateApplication.h" +#include "Runtime/SlateCore/Public/Styling/SlateStyleRegistry.h" +#include "Runtime/Slate/Public/Framework/Commands/Commands.h" + FReply FPythonSlateDelegate::OnMouseEvent(const FGeometry &geometry, const FPointerEvent &pointer_event) { FScopePythonGIL gil; - PyObject *ret = PyObject_CallFunction(py_callable, (char *)"OO", py_ue_new_fgeometry(geometry), py_ue_new_fpointer_event(pointer_event)); + PyObject *ret = PyObject_CallFunction(py_callable, (char *)"NN", py_ue_new_fgeometry(geometry), py_ue_new_fpointer_event(pointer_event)); if (!ret) { unreal_engine_py_log_error(); @@ -50,7 +135,7 @@ FReply FPythonSlateDelegate::OnKeyDown(const FGeometry &geometry, const FKeyEven { FScopePythonGIL gil; - PyObject *ret = PyObject_CallFunction(py_callable, (char *)"OO", py_ue_new_fgeometry(geometry), py_ue_new_fkey_event(key_event)); + PyObject *ret = PyObject_CallFunction(py_callable, (char *)"NN", py_ue_new_fgeometry(geometry), py_ue_new_fkey_event(key_event)); if (!ret) { unreal_engine_py_log_error(); @@ -168,7 +253,7 @@ void FPythonSlateDelegate::OnLinearColorChanged(FLinearColor color) { FScopePythonGIL gil; - PyObject *ret = PyObject_CallFunction(py_callable, (char *)"O", py_ue_new_flinearcolor(color)); + PyObject *ret = PyObject_CallFunction(py_callable, (char *)"N", py_ue_new_flinearcolor(color)); if (!ret) { unreal_engine_py_log_error(); @@ -181,7 +266,7 @@ void FPythonSlateDelegate::OnWindowClosed(const TSharedRef &Window) { FScopePythonGIL gil; - PyObject *ret = PyObject_CallFunction(py_callable, (char *)"O", py_ue_new_swidget(StaticCastSharedRef(Window), &ue_PySWindowType)); + PyObject *ret = PyObject_CallFunction(py_callable, (char *)"N", py_ue_new_swidget(StaticCastSharedRef(Window), &ue_PySWindowType)); if (!ret) { unreal_engine_py_log_error(); @@ -234,7 +319,7 @@ void FPythonSlateDelegate::OnAssetDoubleClicked(const FAssetData& AssetData) { FScopePythonGIL gil; - PyObject *ret = PyObject_CallFunction(py_callable, (char *)"O", py_ue_new_fassetdata(AssetData)); + PyObject *ret = PyObject_CallFunction(py_callable, (char *)"N", py_ue_new_fassetdata(AssetData)); if (!ret) { unreal_engine_py_log_error(); @@ -246,7 +331,7 @@ void FPythonSlateDelegate::OnAssetSelected(const FAssetData& AssetData) { FScopePythonGIL gil; - PyObject *ret = PyObject_CallFunction(py_callable, (char *)"O", py_ue_new_fassetdata(AssetData)); + PyObject *ret = PyObject_CallFunction(py_callable, (char *)"N", py_ue_new_fassetdata(AssetData)); if (!ret) { unreal_engine_py_log_error(); @@ -258,7 +343,7 @@ void FPythonSlateDelegate::OnAssetChanged(const FAssetData& AssetData) { FScopePythonGIL gil; - PyObject *ret = PyObject_CallFunction(py_callable, (char *)"O", py_ue_new_fassetdata(AssetData)); + PyObject *ret = PyObject_CallFunction(py_callable, (char *)"N", py_ue_new_fassetdata(AssetData)); if (!ret) { unreal_engine_py_log_error(); @@ -270,7 +355,7 @@ bool FPythonSlateDelegate::OnShouldFilterAsset(const FAssetData& AssetData) { FScopePythonGIL gil; - PyObject *ret = PyObject_CallFunction(py_callable, (char *)"O", py_ue_new_fassetdata(AssetData)); + PyObject *ret = PyObject_CallFunction(py_callable, (char *)"N", py_ue_new_fassetdata(AssetData)); if (!ret) { unreal_engine_py_log_error(); @@ -299,16 +384,17 @@ TSharedPtr FPythonSlateDelegate::OnGetAssetContextMenu(const TArray Widget = py_ue_is_swidget(ret); + if (!Widget.IsValid()) { Py_DECREF(ret); + PyErr_Clear(); UE_LOG(LogPython, Error, TEXT("returned value is not a SWidget")); return nullptr; } - TSharedPtr value = s_widget->s_widget; + TSharedRef RefWidget = Widget.ToSharedRef(); Py_DECREF(ret); - return value; + return RefWidget; } void FPythonSlateDelegate::MenuPyAssetBuilder(FMenuBuilder &Builder, TArray SelectedAssets) @@ -321,7 +407,7 @@ void FPythonSlateDelegate::MenuPyAssetBuilder(FMenuBuilder &Builder, TArray FPythonSlateDelegate::OnExtendContentBrowserMenu(const TArray& SelectedAssets) { TSharedRef Extender(new FExtender()); @@ -341,6 +428,21 @@ TSharedRef FPythonSlateDelegate::OnExtendContentBrowserMenu(const TAr #endif + +void FPythonSlateDelegate::SubMenuPyBuilder(FMenuBuilder &Builder) +{ + FScopePythonGIL gil; + + PyObject *ret = PyObject_CallFunction(py_callable, (char *)"N", py_ue_new_fmenu_builder(Builder)); + if (!ret) + { + unreal_engine_py_log_error(); + return; + } + Py_DECREF(ret); +} + + TSharedRef FPythonSlateDelegate::OnGenerateWidget(TSharedPtr py_item) { FScopePythonGIL gil; @@ -352,17 +454,17 @@ TSharedRef FPythonSlateDelegate::OnGenerateWidget(TSharedPtr Widget = py_ue_is_swidget(ret); + if (!Widget.IsValid()) { Py_DECREF(ret); UE_LOG(LogPython, Error, TEXT("returned value is not a SWidget")); + PyErr_Clear(); return SNullWidget::NullWidget; } - TSharedRef value = s_widget->s_widget; - - Py_INCREF(ret); - return value; + TSharedRef RefWidget = Widget.ToSharedRef(); + Py_DECREF(ret); + return RefWidget; } TSharedRef FPythonSlateDelegate::OnGetMenuContent() @@ -376,16 +478,17 @@ TSharedRef FPythonSlateDelegate::OnGetMenuContent() return SNullWidget::NullWidget; } - ue_PySWidget *s_widget = py_ue_is_swidget(ret); - if (!s_widget) + TSharedPtr Widget = py_ue_is_swidget(ret); + if (!Widget.IsValid()) { Py_DECREF(ret); + PyErr_Clear(); UE_LOG(LogPython, Error, TEXT("returned value is not a SWidget")); return SNullWidget::NullWidget; } - TSharedRef value = s_widget->s_widget; + TSharedRef RefWidget = Widget.ToSharedRef(); Py_DECREF(ret); - return value; + return RefWidget; } void FPythonSlateDelegate::OnSelectionChanged(TSharedPtr py_item, ESelectInfo::Type select_type) @@ -417,16 +520,17 @@ TSharedPtr FPythonSlateDelegate::OnContextMenuOpening() return nullptr; } - ue_PySWidget *s_widget = py_ue_is_swidget(ret); - if (!s_widget) + TSharedPtr Widget = py_ue_is_swidget(ret); + if (!Widget.IsValid()) { Py_DECREF(ret); + PyErr_Clear(); UE_LOG(LogPython, Error, TEXT("returned value is not a SWidget")); return nullptr; } - TSharedPtr value = s_widget->s_widget; + TSharedRef RefWidget = Widget.ToSharedRef(); Py_DECREF(ret); - return value; + return RefWidget; } void FPythonSlateDelegate::SimpleExecuteAction() @@ -471,7 +575,7 @@ FText FPythonSlateDelegate::GetterFText() const return FText(); } - FText text = FText::FromString(PyUnicode_AsUTF8(str)); + FText text = FText::FromString(UEPyUnicode_AsUTF8(str)); Py_DECREF(str); Py_DECREF(ret); return text; @@ -495,7 +599,7 @@ FString FPythonSlateDelegate::GetterFString() const return FString(); } - FString fstr = UTF8_TO_TCHAR(PyUnicode_AsUTF8(str)); + FString fstr = UTF8_TO_TCHAR(UEPyUnicode_AsUTF8(str)); Py_DECREF(str); Py_DECREF(ret); return fstr; @@ -668,9 +772,9 @@ FLinearColor FPythonSlateDelegate::GetterFLinearColor() const TSharedRef FPythonSlateDelegate::SpawnPythonTab(const FSpawnTabArgs &args) { + FScopePythonGIL gil; TSharedRef dock_tab = SNew(SDockTab).TabRole(ETabRole::NomadTab); - PyObject *py_dock = (PyObject *)ue_py_get_swidget(dock_tab); - PyObject *ret = PyObject_CallFunction(py_callable, (char *)"O", py_dock); + PyObject *ret = PyObject_CallFunction(py_callable, (char *)"N", ue_py_get_swidget(dock_tab)); if (!ret) { unreal_engine_py_log_error(); @@ -695,15 +799,18 @@ TSharedRef FPythonSlateDelegate::GenerateRow(TSharedPtr if (ue_PySPythonMultiColumnTableRow *spython_multicolumn_table_row = py_ue_is_spython_multicolumn_table_row(ret)) { - Py_INCREF(spython_multicolumn_table_row); - TSharedRef value = StaticCastSharedRef(spython_multicolumn_table_row->s_compound_widget.s_widget.s_widget->AsShared()); - return value; + return StaticCastSharedRef(spython_multicolumn_table_row->s_compound_widget.s_widget.Widget->AsShared()); } - else if (ue_PySWidget *s_widget = py_ue_is_swidget(ret)) + + TSharedPtr Widget = py_ue_is_swidget(ret); + Py_DECREF(ret); + if (Widget.IsValid()) { - return SNew(STableRow>, OwnerTable).Content()[s_widget->s_widget]; + return SNew(STableRow>, OwnerTable).Content()[Widget.ToSharedRef()]; } + PyErr_Clear(); + UE_LOG(LogPython, Error, TEXT("python callable did not return a SWidget")); return SNew(STableRow>, OwnerTable); @@ -735,60 +842,28 @@ void FPythonSlateDelegate::GetChildren(TSharedPtr InItem, TArray *py_slate_mapping; - ue_PySWidget *ue_py_get_swidget(TSharedRef s_widget) { ue_PySWidget *ret = nullptr; - auto it = py_slate_mapping->find(&s_widget.Get()); - // not found, it means it is an SWidget not generated from python - if (it == py_slate_mapping->end()) + + if (s_widget->GetType().Compare(FName("SWindow")) == 0) { - if (s_widget->GetType().Compare(FName("SWindow")) == 0) - { - return py_ue_new_swidget(s_widget, &ue_PySWindowType); - } - if (s_widget->GetType().Compare(FName("SDockTab")) == 0) - { - return py_ue_new_swidget(s_widget, &ue_PySDockTabType); - } - else - { - return py_ue_new_swidget(s_widget, &ue_PySWidgetType); - } + return py_ue_new_swidget(s_widget, &ue_PySWindowType); + } + if (s_widget->GetType().Compare(FName("SDockTab")) == 0) + { + return py_ue_new_swidget(s_widget, &ue_PySDockTabType); } else { - ret = it->second; + return py_ue_new_swidget(s_widget, &ue_PySWidgetType); } - Py_INCREF(ret); - return ret; -} -void ue_py_setup_swidget(ue_PySWidget *self) -{ -#if defined(UEPY_MEMORY_DEBUG) - UE_LOG(LogPython, Warning, TEXT("Allocating new %s..."), UTF8_TO_TCHAR(self->ob_base.ob_type->tp_name)); -#endif - self->py_dict = PyDict_New(); - new(&self->s_widget) TSharedRef(SNullWidget::NullWidget); -} - -void ue_py_register_swidget(SWidget *s_widget, ue_PySWidget *py_s_widget) -{ - (*py_slate_mapping)[s_widget] = py_s_widget; -} - -void ue_py_unregister_swidget(SWidget *s_widget) -{ - (*py_slate_mapping).erase(s_widget); } void ue_python_init_slate(PyObject *module) { - py_slate_mapping = new std::map(); - ue_python_init_swidget(module); ue_python_init_scompound_widget(module); ue_python_init_swindow(module); @@ -845,6 +920,7 @@ void ue_python_init_slate(PyObject *module) ue_python_init_spython_shelf(module); #if ENGINE_MINOR_VERSION > 13 ue_python_init_sfile_path_picker(module); + ue_python_init_sdirectory_picker(module); #endif #endif ue_python_init_sdrop_target(module); @@ -944,8 +1020,11 @@ class FPythonSlateCommands : public TCommands virtual void RegisterCommands() override { commands = MakeShareable(new FUICommandList); - +#if ENGINE_MINOR_VERSION >= 23 + MakeUICommand_InternalUseOnly(this, command, nullptr, *name, *name, TCHAR_TO_UTF8(*name), *name, *name, EUserInterfaceActionType::Button, FInputGesture()); +#else UI_COMMAND_Function(this, command, nullptr, *name, *name, TCHAR_TO_UTF8(*name), *name, *name, EUserInterfaceActionType::Button, FInputGesture()); +#endif commands->MapAction(command, FExecuteAction::CreateRaw(this, &FPythonSlateCommands::Callback), FCanExecuteAction()); } @@ -969,7 +1048,7 @@ class FPythonSlateCommands : public TCommands void MenuPyBuilder(FMenuBuilder &Builder) { FScopePythonGIL gil; - PyObject *ret = PyObject_CallFunction(py_callable, (char *)"O", py_ue_new_fmenu_builder(Builder)); + PyObject *ret = PyObject_CallFunction(py_callable, (char *)"N", py_ue_new_fmenu_builder(Builder)); if (!ret) { unreal_engine_py_log_error(); @@ -987,7 +1066,7 @@ class FPythonSlateCommands : public TCommands void ToolBarBuilder(FToolBarBuilder &Builder) { FScopePythonGIL gil; - PyObject *ret = PyObject_CallFunction(py_callable, (char *)"O", py_ue_new_ftool_bar_builder(Builder)); + PyObject *ret = PyObject_CallFunction(py_callable, (char *)"N", py_ue_new_ftool_bar_builder(Builder)); if (!ret) { unreal_engine_py_log_error(); @@ -1131,7 +1210,7 @@ PyObject *py_unreal_engine_create_structure_detail_view(PyObject *self, PyObject { Py_INCREF(ue_py_struct); ret->ue_py_struct = ue_py_struct; - struct_scope = MakeShared(ue_py_struct->u_struct, ue_py_struct->data); + struct_scope = MakeShared(ue_py_struct->u_struct, ue_py_struct->u_struct_ptr); } FPropertyEditorModule& PropertyEditorModule = FModuleManager::GetModuleChecked("PropertyEditor"); @@ -1225,7 +1304,7 @@ PyObject *py_unreal_engine_add_menu_extension(PyObject * self, PyObject * args) if (!menu_extension_interface) return PyErr_Format(PyExc_Exception, "module %s is not supported", module); - if (!PyCalllable_Check_Extended(py_callable)) + if (!PyCallable_Check(py_callable)) return PyErr_Format(PyExc_Exception, "argument is not callable"); TSharedRef *commands = new TSharedRef(new FPythonSlateCommands()); @@ -1258,9 +1337,10 @@ PyObject *py_unreal_engine_add_menu_bar_extension(PyObject * self, PyObject * ar FLevelEditorModule &ExtensibleModule = FModuleManager::LoadModuleChecked("LevelEditor"); - if (!PyCalllable_Check_Extended(py_callable)) + if (!PyCallable_Check(py_callable)) return PyErr_Format(PyExc_Exception, "argument is not callable"); + TSharedRef *commands = new TSharedRef(new FPythonSlateCommands()); commands->Get().Setup(command_name, py_callable); @@ -1272,8 +1352,7 @@ PyObject *py_unreal_engine_add_menu_bar_extension(PyObject * self, PyObject * ar ExtensibleModule.GetMenuExtensibilityManager()->AddExtender(extender); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyObject *py_unreal_engine_add_tool_bar_extension(PyObject * self, PyObject * args) @@ -1291,7 +1370,7 @@ PyObject *py_unreal_engine_add_tool_bar_extension(PyObject * self, PyObject * ar FLevelEditorModule &ExtensibleModule = FModuleManager::LoadModuleChecked("LevelEditor"); - if (!PyCalllable_Check_Extended(py_callable)) + if (!PyCallable_Check(py_callable)) return PyErr_Format(PyExc_Exception, "argument is not callable"); TSharedRef *commands = new TSharedRef(new FPythonSlateCommands()); @@ -1319,7 +1398,7 @@ PyObject *py_unreal_engine_add_asset_view_context_menu_extension(PyObject * self return NULL; } - if (!PyCalllable_Check_Extended(py_callable)) + if (!PyCallable_Check(py_callable)) return PyErr_Format(PyExc_Exception, "argument is not callable"); FContentBrowserModule &ContentBrowser = FModuleManager::LoadModuleChecked("ContentBrowser"); @@ -1340,26 +1419,46 @@ PyObject *py_unreal_engine_register_nomad_tab_spawner(PyObject * self, PyObject char *name; PyObject *py_callable; - if (!PyArg_ParseTuple(args, "sO:register_nomad_tab_spawner", &name, &py_callable)) + PyObject *py_icon = nullptr; + if (!PyArg_ParseTuple(args, "sO|O:register_nomad_tab_spawner", &name, &py_callable, &py_icon)) { return NULL; } - if (!PyCalllable_Check_Extended(py_callable)) + if (!PyCallable_Check(py_callable)) return PyErr_Format(PyExc_Exception, "argument is not callable"); FOnSpawnTab spawn_tab; TSharedRef py_delegate = FUnrealEnginePythonHouseKeeper::Get()->NewStaticSlateDelegate(py_callable); spawn_tab.BindSP(py_delegate, &FPythonSlateDelegate::SpawnPythonTab); - FTabSpawnerEntry *spawner_entry = &FGlobalTabmanager::Get()->RegisterNomadTabSpawner(UTF8_TO_TCHAR(name), spawn_tab) + FName TabName = FName(UTF8_TO_TCHAR(name)); + + // avoid crash if re-registering the same tab + FGlobalTabmanager::Get()->UnregisterNomadTabSpawner(TabName); + + FSlateIcon Icon = FSlateIcon(); + if (py_icon) + { + ue_PyFSlateIcon *slate_icon = py_ue_is_fslate_icon(py_icon); + if (!slate_icon) + { + return PyErr_Format(PyExc_Exception, "argument is not a FSlateIcon"); + } + Icon = slate_icon->icon; + } + + FTabSpawnerEntry *SpawnerEntry = &FGlobalTabmanager::Get()->RegisterNomadTabSpawner(TabName, spawn_tab) + .SetDisplayName(FText::FromString((TabName).ToString())) + .SetTooltipText(FText::FromString((TabName).ToString())) + .SetIcon(Icon) // TODO: more generic way to set the group #if WITH_EDITOR .SetGroup(WorkspaceMenu::GetMenuStructure().GetDeveloperToolsMiscCategory()) #endif ; - PyObject *ret = py_ue_new_ftab_spawner_entry(spawner_entry); + PyObject *ret = py_ue_new_ftab_spawner_entry(SpawnerEntry); Py_INCREF(ret); return ret; } @@ -1423,16 +1522,15 @@ PyObject * py_unreal_engine_create_wrapper_from_pyswidget(PyObject *self, PyObje return NULL; } - ue_PySWidget *py_swidget = py_ue_is_swidget(py_object); - if (!py_swidget) + TSharedPtr Widget = py_ue_is_swidget(py_object); + if (!Widget.IsValid()) { - return PyErr_Format(PyExc_Exception, "argument is not a SWidget"); + return nullptr; } - Py_INCREF(py_swidget); FPythonSWidgetWrapper py_swidget_wrapper; - py_swidget_wrapper.Widget = py_swidget->s_widget; - return py_ue_new_uscriptstruct(FPythonSWidgetWrapper::StaticStruct(), (uint8 *)&py_swidget_wrapper); + py_swidget_wrapper.Widget = Widget; + return py_ue_new_owned_uscriptstruct(FPythonSWidgetWrapper::StaticStruct(), (uint8 *)&py_swidget_wrapper); } PyObject *py_unreal_engine_open_color_picker(PyObject *self, PyObject *args, PyObject *kwargs) @@ -1449,7 +1547,7 @@ PyObject *py_unreal_engine_open_color_picker(PyObject *self, PyObject *args, PyO return nullptr; } - if (!PyCalllable_Check_Extended(py_callable)) + if (!PyCallable_Check(py_callable)) { return PyErr_Format(PyExc_Exception, "on_color_committed must be a callable"); } diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySlate.h b/Source/UnrealEnginePython/Private/Slate/UEPySlate.h index 99a8ffc7b..bda71c376 100644 --- a/Source/UnrealEnginePython/Private/Slate/UEPySlate.h +++ b/Source/UnrealEnginePython/Private/Slate/UEPySlate.h @@ -1,11 +1,8 @@ #pragma once +#include "UEPyModule.h" - -#include "UnrealEnginePython.h" - -#include "SlateBasics.h" -#include "SlateExtras.h" +#include "Runtime/SlateCore/Public/Widgets/DeclarativeSyntaxSupport.h" #if WITH_EDITOR @@ -15,87 +12,37 @@ #include "UnrealEdMisc.h" #endif -#include - - -#include "UEPySWidget.h" -#include "UEPySCompoundWidget.h" -#include "UEPySWindow.h" -#include "UEPySBorder.h" -#include "UEPySButton.h" -#include "UEPySLeafWidget.h" -#include "UEPySTextBlock.h" -#include "UEPySEditableTextBox.h" -#include "UEPySMultiLineEditableText.h" -#include "UEPySPanel.h" -#include "UEPySGridPanel.h" -#include "UEPySBoxPanel.h" -#include "UEPySHorizontalBox.h" -#include "UEPySVerticalBox.h" -#include "UEPySViewport.h" - - -#include "UEPySImage.h" -#include "UEPySDockTab.h" -#include "UEPySTableViewBase.h" -#include "UEPySListView.h" -#include "UEPySPythonListView.h" -#include "UEPySPythonMultiColumnTableRow.h" -#include "UEPySTreeView.h" -#include "UEPySPythonTreeView.h" -#include "UEPySSplitter.h" -#include "UEPySHeaderRow.h" -#include "UEPySCheckBox.h" -#include "UEPySNumericEntryBox.h" -#include "UEPySCanvas.h" -#include "UEPySSlider.h" -#include "UEPySVectorInputBox.h" -#include "UEPySRotatorInputBox.h" -#include "UEPySPythonComboBox.h" -#include "UEPySScrollBox.h" -#include "UEPySColorBlock.h" -#include "UEPySBox.h" -#include "UEPySProgressBar.h" -#include "UEPySSpacer.h" -#include "UEPySPythonWidget.h" -#include "UEPySOverlay.h" - -#include "UEPyFTabManager.h" -#include "UEPyFTabSpawnerEntry.h" -#include "UEPyFMenuBuilder.h" -#include "UEPyFToolBarBuilder.h" -#include "UEPyFSlateIcon.h" -#include "UEPyFSlateStyleSet.h" - -#include "UEPyFGeometry.h" -#include "UEPyFPaintContext.h" - -#include "UEPyFInputEvent.h" -#include "UEPyFPointerEvent.h" -#include "UEPyFKeyEvent.h" -#include "UEPyFCharacterEvent.h" -#include "UEPyFModifierKeysState.h" -#if WITH_EDITOR -#include "UEPySEditorViewport.h" -#include "UEPySLevelViewport.h" -#include "UEPySPythonEditorViewport.h" -#include "UEPySGraphEditor.h" -#include "UEPySPythonShelf.h" -#include "UEPySFilePathPicker.h" -#include "UEPySDropTarget.h" -#include "UEPySAssetDropTarget.h" -#include "UEPySObjectPropertyEntryBox.h" -#include "UEPyIDetailsView.h" -#include "UEPyIStructureDetailsView.h" -#include "UEPySNodePanel.h" -#include "UEPySGraphPanel.h" -#endif -#include "Runtime/Core/Public/Misc/Attribute.h" -#include "Runtime/Slate/Public/Framework/Application/SlateApplication.h" +#include "UEPySlateDelegate.h" +#include "UEPySlatePythonItem.h" + +void ue_python_init_swidget(PyObject *); + +extern PyTypeObject ue_PySWidgetType; + +typedef struct ue_PySWidget ue_PySWidget; + +struct ue_PySWidget +{ + PyObject_HEAD + /* Type-specific fields go here. */ + TSharedRef Widget; + PyObject *weakreflist; +}; + +template +TSharedPtr py_ue_is_swidget(PyObject *py_obj) +{ + if (!PyObject_IsInstance(py_obj, (PyObject *)&ue_PySWidgetType)) + { + PyErr_SetString(PyExc_Exception, "object is not an SWidget"); + return nullptr; + } + return StaticCastSharedRef(((ue_PySWidget *)py_obj)->Widget); +} + -#include "PythonDelegate.h" PyObject *py_unreal_engine_get_editor_window(PyObject *, PyObject *); @@ -125,35 +72,32 @@ PyObject *py_unreal_engine_destroy_color_picker(PyObject *, PyObject *); PyObject *py_unreal_engine_play_sound(PyObject *, PyObject *); -void ue_py_register_swidget(SWidget *, ue_PySWidget *); -void ue_py_unregister_swidget(SWidget *); - -void ue_py_setup_swidget(ue_PySWidget *); - - PyObject *ue_py_dict_get_item(PyObject *, const char *); template ue_PySWidget *py_ue_new_swidget(TSharedRef s_widget, PyTypeObject *py_type) { ue_PySWidget *ret = (ue_PySWidget *)PyObject_New(T, py_type); - ue_py_setup_swidget(ret); - - ret->s_widget = s_widget; - - ue_py_register_swidget(&s_widget.Get(), ret); + new(&ret->Widget) TSharedRef(s_widget); + ret->weakreflist = nullptr; return ret; } -#define ue_py_snew_base(T, field, required, arguments) self->field.s_widget = TSharedRef(MakeTDecl(#T, __FILE__, __LINE__, required) <<= arguments); ue_py_register_swidget((SWidget *)&self->field.s_widget.Get(), (ue_PySWidget *)self) +#define ue_py_snew_base(T, required, arguments) ((ue_PySWidget *)self)->Widget = TSharedRef(MakeTDecl(#T, __FILE__, __LINE__, required) <<= arguments);\ + for(TSharedRef Delegate : DeferredSlateDelegates)\ + {\ + FUnrealEnginePythonHouseKeeper::Get()->TrackDeferredSlateDelegate(Delegate, ((ue_PySWidget *)self)->Widget);\ + } -#define ue_py_snew_simple(T, field) ue_py_snew_base(T, field, RequiredArgs::MakeRequiredArgs(), T::FArguments()) +#define ue_py_snew_simple(T) TArray> DeferredSlateDelegates;\ + ue_py_snew_base(T, RequiredArgs::MakeRequiredArgs(), T::FArguments()) -#define ue_py_snew_simple_with_req_args(T, field, ... ) ue_py_snew_base(T, field, RequiredArgs::MakeRequiredArgs(__VA_ARGS__), T::FArguments()) +#define ue_py_snew_simple_with_req_args(T, ... ) TArray> DeferredSlateDelegates;\ + ue_py_snew_base(T, RequiredArgs::MakeRequiredArgs(__VA_ARGS__), T::FArguments()) -#define ue_py_snew(T, field) ue_py_snew_base(T, field, RequiredArgs::MakeRequiredArgs(), arguments) +#define ue_py_snew(T) ue_py_snew_base(T, RequiredArgs::MakeRequiredArgs(), arguments) -#define ue_py_snew_with_args(T, field, args) ue_py_snew_base(T, field, RequiredArgs::MakeRequiredArgs(args), arguments) +#define ue_py_snew_with_args(T, args) ue_py_snew_base(T, RequiredArgs::MakeRequiredArgs(args), arguments) ue_PySWidget *ue_py_get_swidget(TSharedRef s_widget); @@ -162,11 +106,11 @@ ue_PySWidget *ue_py_get_swidget(TSharedRef s_widget); {\ PyObject *value = ue_py_dict_get_item(kwargs, _param);\ if (value) {\ - if (PyCalllable_Check_Extended(value)) {\ + if (PyCallable_Check(value)) {\ _base handler;\ - ue_PySWidget *py_swidget = (ue_PySWidget *)self;\ - TSharedRef py_delegate = FUnrealEnginePythonHouseKeeper::Get()->NewSlateDelegate(py_swidget->s_widget, value);\ + TSharedRef py_delegate = FUnrealEnginePythonHouseKeeper::Get()->NewDeferredSlateDelegate(value);\ handler.Bind(py_delegate, &FPythonSlateDelegate::_func);\ + DeferredSlateDelegates.Add(py_delegate);\ arguments._attribute(handler);\ } @@ -174,11 +118,11 @@ ue_PySWidget *ue_py_get_swidget(TSharedRef s_widget); {\ PyObject *value = ue_py_dict_get_item(kwargs, _param);\ if (value) {\ - if (PyCalllable_Check_Extended(value)) {\ + if (PyCallable_Check(value)) {\ _base handler;\ - ue_PySWidget *py_swidget = (ue_PySWidget *)self;\ - TSharedRef py_delegate = FUnrealEnginePythonHouseKeeper::Get()->NewSlateDelegate(py_swidget->s_widget, value);\ + TSharedRef py_delegate = FUnrealEnginePythonHouseKeeper::Get()->NewDeferredSlateDelegate(value);\ handler.BindSP(py_delegate, &FPythonSlateDelegate::_func);\ + DeferredSlateDelegates.Add(py_delegate);\ arguments._attribute(handler);\ } @@ -192,15 +136,15 @@ ue_PySWidget *ue_py_get_swidget(TSharedRef s_widget); #define ue_py_slate_up(_type, _func, _param, _attribute) ue_py_slate_base_up(TAttribute<_type>, _func, _param, _attribute) #define ue_py_slate_farguments_text(param, attribute) ue_py_slate_up(FText, GetterFText, param, attribute)\ - else if (PyUnicode_Check(value)) {\ - arguments.attribute(FText::FromString(UTF8_TO_TCHAR(PyUnicode_AsUTF8(value))));\ + else if (PyUnicodeOrString_Check(value)) {\ + arguments.attribute(FText::FromString(UTF8_TO_TCHAR(UEPyUnicode_AsUTF8(value))));\ }\ ue_py_slate_down(param) #define ue_py_slate_farguments_string(param, attribute) ue_py_slate_up(FString, GetterFString, param, attribute)\ - else if (PyUnicode_Check(value)) {\ - arguments.attribute(UTF8_TO_TCHAR(PyUnicode_AsUTF8(value)));\ + else if (PyUnicodeOrString_Check(value)) {\ + arguments.attribute(UTF8_TO_TCHAR(UEPyUnicode_AsUTF8(value)));\ }\ ue_py_slate_down(param) @@ -252,6 +196,16 @@ ue_PySWidget *ue_py_get_swidget(TSharedRef s_widget); }\ ue_py_slate_down(param) + +#define ue_py_slate_farguments_int32(param, attribute) ue_py_slate_up(int32, GetterInt, param, attribute)\ + else if (PyNumber_Check(value)) {\ + PyObject *py_int = PyNumber_Long(value);\ + arguments.attribute((int32)PyLong_AsLong(py_int)); \ + Py_DECREF(py_int);\ + }\ + ue_py_slate_down(param) + + #define ue_py_slate_farguments_tint(param, attribute) ue_py_slate_up(TOptional, GetterIntT>, param, attribute)\ else if (PyNumber_Check(value)) {\ PyObject *py_int = PyNumber_Long(value);\ @@ -368,6 +322,20 @@ ue_PySWidget *ue_py_get_swidget(TSharedRef s_widget); } +#define ue_py_slate_farguments_optional_int32(param, attribute) { PyObject *value = ue_py_dict_get_item(kwargs, param);\ + if (value) {\ + if (PyNumber_Check(value)) {\ + PyObject *py_int = PyNumber_Long(value);\ + arguments.attribute((int32)PyLong_AsLong(py_int)); \ + Py_DECREF(py_int);\ + }\ + else {\ + PyErr_SetString(PyExc_TypeError, "unsupported type for attribute " param); \ + return -1;\ + }\ + }\ +} + #define ue_py_slate_farguments_optional_float(param, attribute) { PyObject *value = ue_py_dict_get_item(kwargs, param);\ if (value) {\ @@ -398,15 +366,15 @@ ue_PySWidget *ue_py_get_swidget(TSharedRef s_widget); } #define ue_py_slate_farguments_optional_string(param, attribute) { PyObject *value = ue_py_dict_get_item(kwargs, param);\ - if (PyUnicode_Check(value)) {\ - arguments.attribute(UTF8_TO_TCHAR(PyUnicode_AsUTF8(value)));\ + if (PyUnicodeOrString_Check(value)) {\ + arguments.attribute(UTF8_TO_TCHAR(UEPyUnicode_AsUTF8(value)));\ }\ } #define ue_py_slate_farguments_optional_text(param, attribute) { PyObject *value = ue_py_dict_get_item(kwargs, param);\ if (value) {\ - if (PyUnicode_Check(value)) {\ - arguments.attribute(FText::FromString(UTF8_TO_TCHAR(PyUnicode_AsUTF8(value))));\ + if (PyUnicodeOrString_Check(value)) {\ + arguments.attribute(FText::FromString(UTF8_TO_TCHAR(UEPyUnicode_AsUTF8(value))));\ }\ else {\ PyErr_SetString(PyExc_TypeError, "unsupported type for attribute " param); \ @@ -417,11 +385,11 @@ ue_PySWidget *ue_py_get_swidget(TSharedRef s_widget); #define ue_py_slate_farguments_optional_named_slot(param, attribute) { PyObject *value = ue_py_dict_get_item(kwargs, param);\ if (value) {\ - if (ue_PySWidget *py_swidget = py_ue_is_swidget(value)) {\ - Py_INCREF(py_swidget);\ + TSharedPtr Child = py_ue_is_swidget(value);\ + if (Child.IsValid()) {\ arguments.attribute()\ [\ - py_swidget->s_widget\ + Child.ToSharedRef()\ ];\ }\ else {\ @@ -442,6 +410,43 @@ ue_PySWidget *ue_py_get_swidget(TSharedRef s_widget); }\ } +#define ue_py_slate_farguments_call(param, attribute) { PyObject *value = ue_py_dict_get_item(kwargs, param);\ + if (value && PyObject_IsTrue(value)) {\ + arguments.attribute();\ + }\ +} + +#define ue_py_slate_farguments_padding(param, attribute) { PyObject *padding = ue_py_dict_get_item(kwargs, param);\ + if (padding)\ + {\ + if (PyTuple_Check(padding))\ + {\ + FMargin margin;\ + if (!PyArg_ParseTuple(padding, "f|fff", &margin.Left, &margin.Top, &margin.Right, &margin.Bottom))\ + {\ + PyErr_SetString(PyExc_TypeError, "invalid padding value");\ + return -1;\ + }\ + arguments.attribute(margin);\ + }\ + else if (PyNumber_Check(padding))\ + {\ + PyObject *py_float = PyNumber_Float(padding); \ + arguments.attribute(PyFloat_AsDouble(py_float)); \ + Py_DECREF(py_float); \ + }\ + else if (FMargin *u_struct = ue_py_check_struct(padding))\ + {\ + arguments.attribute(*u_struct); \ + }\ + else\ + {\ + PyErr_SetString(PyExc_TypeError, "invalid padding value"); \ + return -1; \ + }\ + }\ +} + #define ue_py_slate_farguments_optional_bool(param, attribute) { PyObject *value = ue_py_dict_get_item(kwargs, param);\ if (value) {\ @@ -462,143 +467,34 @@ ue_PySWidget *ue_py_get_swidget(TSharedRef s_widget); #define ue_py_slate_setup_farguments(_type) _type::FArguments arguments;\ - ue_py_slate_farguments_bool("is_enabled", IsEnabled);\ - ue_py_slate_farguments_text("tool_tip_text", ToolTipText);\ - ue_py_slate_farguments_fvector2d("render_transform_pivot", RenderTransformPivot) + TArray> DeferredSlateDelegates;\ + ue_py_slate_farguments_bool("is_enabled", IsEnabled); \ + ue_py_slate_farguments_text("tool_tip_text", ToolTipText); \ + ue_py_slate_farguments_fvector2d("render_transform_pivot", RenderTransformPivot) #define ue_py_slate_farguments_required_slot(param) { PyObject *value = ue_py_dict_get_item(kwargs, param);\ value = value ? value : PyTuple_GetItem(args, 0);\ - if (ue_PySWidget *py_swidget = value ? py_ue_is_swidget(value) : nullptr) {\ - Py_INCREF(py_swidget);\ - ue_PySWidget *self_py_swidget = py_ue_is_swidget((PyObject*)self);\ - arguments.AttachWidget(py_swidget->s_widget->AsShared());\ - }\ - else {\ - PyErr_SetString(PyExc_TypeError, "unsupported type for required slot " param); \ + if (!value) {PyErr_Clear(); PyErr_SetString(PyExc_TypeError, "you need to specify a widget"); return -1;}\ + TSharedPtr Widget = py_ue_is_swidget(value);\ + if (Widget.IsValid())\ + arguments.AttachWidget(Widget.ToSharedRef());\ + else\ + {\ + PyErr_SetString(PyExc_TypeError, "unsupported type for required slot " param);\ return -1;\ }\ } #define ue_py_slate_setup_hack_slot_args(_type, _swidget_ref) _type::FSlot &arguments = _swidget_ref->AddSlot();\ + TArray> DeferredSlateDelegates;\ ue_py_slate_farguments_required_slot("widget"); -void ue_python_init_slate(PyObject *); - -struct FPythonItem -{ - PyObject *py_object = nullptr; - - FPythonItem(PyObject *item) - { - py_object = item; - } -}; - - -class FPythonSlateDelegate : public FPythonSmartDelegate -{ - -public: - FReply OnMouseEvent(const FGeometry &geometry, const FPointerEvent &pointer_event); - FReply OnClicked(); - - FReply OnKeyDown(const FGeometry &geometry, const FKeyEvent &key_event); - void OnTextChanged(const FText &text); - void OnTextCommitted(const FText &text, ETextCommit::Type commit_type); - void OnInt32Changed(int32 value); - void OnInt32Committed(int32 value, ETextCommit::Type commit_type); - void OnFloatChanged(float value); - void OnFloatCommitted(float value, ETextCommit::Type commit_type); - void OnSort(const EColumnSortPriority::Type SortPriority, const FName& ColumnName, const EColumnSortMode::Type NewSortMode); - - void OnLinearColorChanged(FLinearColor color); - - void OnStringChanged(const FString &text); - - TSharedRef SpawnPythonTab(const FSpawnTabArgs& args); - - TSharedRef GenerateRow(TSharedPtr InItem, const TSharedRef& OwnerTable); - void GetChildren(TSharedPtr InItem, TArray>& OutChildren); - -#if WITH_EDITOR - void OnAssetDoubleClicked(const FAssetData& AssetData); - TSharedPtr OnGetAssetContextMenu(const TArray& SelectedAssets); - void OnAssetSelected(const FAssetData& AssetData); - TSharedRef OnExtendContentBrowserMenu(const TArray &SelectedAssets); - void MenuPyAssetBuilder(FMenuBuilder &Builder, TArray SelectedAssets); - void OnAssetChanged(const FAssetData &AssetData); - bool OnShouldFilterAsset(const FAssetData& AssetData); -#endif - - void OnWindowClosed(const TSharedRef &Window); - - TSharedPtr OnContextMenuOpening(); - TSharedRef OnGenerateWidget(TSharedPtr py_item); - TSharedRef OnGetMenuContent(); - void OnSelectionChanged(TSharedPtr py_item, ESelectInfo::Type select_type); - - void SimpleExecuteAction(); - void ExecuteAction(PyObject *py_obj); - - FText GetterFText() const; - FString GetterFString() const; - float GetterFloat() const; - TOptional GetterTFloat() const; - int GetterInt() const; - bool GetterBool() const; - - FVector2D GetterFVector2D() const; - FLinearColor GetterFLinearColor() const; - void CheckBoxChanged(ECheckBoxState state); - - - template T GetterIntT() const - { - FScopePythonGIL gil; - - PyObject *ret = PyObject_CallFunction(py_callable, nullptr); - if (!ret) - { - unreal_engine_py_log_error(); - return (T)0; - } - if (!PyNumber_Check(ret)) - { - PyErr_SetString(PyExc_ValueError, "returned value is not a number"); - Py_DECREF(ret); - return (T)0; - } - - PyObject *py_int = PyNumber_Long(ret); - int n = PyLong_AsLong(py_int); - Py_DECREF(py_int); - Py_DECREF(ret); - return (T)n; - } - - template T GetterStructT() const - { - FScopePythonGIL gil; +#define ue_py_slate_setup_hack_slot_args_grid(_type, _swidget_ref, column, row, layer) _type::FSlot &arguments = _swidget_ref->AddSlot(column, row, layer);\ + TArray> DeferredSlateDelegates;\ + ue_py_slate_farguments_required_slot("widget"); - PyObject *ret = PyObject_CallFunction(py_callable, nullptr); - if (!ret) - { - unreal_engine_py_log_error(); - return T(); - } +void ue_python_init_slate(PyObject *); - T *u_struct = ue_py_check_struct(ret); - if (!u_struct) - { - PyErr_SetString(PyExc_ValueError, "returned value is not a UStruct"); - Py_DECREF(ret); - return T(); - } - T u_struct_copy = *u_struct; - Py_DECREF(ret); - return u_struct_copy; - } -}; diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySlateDelegate.h b/Source/UnrealEnginePython/Private/Slate/UEPySlateDelegate.h new file mode 100644 index 000000000..f74f9fe34 --- /dev/null +++ b/Source/UnrealEnginePython/Private/Slate/UEPySlateDelegate.h @@ -0,0 +1,124 @@ +#pragma once + + +#include "PythonSmartDelegate.h" + +#include "UEPySlatePythonItem.h" +#include "Runtime/Slate/Public/Widgets/Views/SHeaderRow.h" +#include "Runtime/Slate/Public/Widgets/Docking/SDockTab.h" +#include "Runtime/Slate/Public/Widgets/Views/STableRow.h" +#include "Runtime/Slate/Public/Framework/MultiBox/MultiBoxExtender.h" +#include "AssetData.h" + +void unreal_engine_py_log_error(); +template T *ue_py_check_struct(PyObject *); + + +class FPythonSlateDelegate : public FPythonSmartDelegate +{ + +public: + FReply OnMouseEvent(const FGeometry &geometry, const FPointerEvent &pointer_event); + FReply OnClicked(); + + FReply OnKeyDown(const FGeometry &geometry, const FKeyEvent &key_event); + void OnTextChanged(const FText &text); + void OnTextCommitted(const FText &text, ETextCommit::Type commit_type); + void OnInt32Changed(int32 value); + void OnInt32Committed(int32 value, ETextCommit::Type commit_type); + void OnFloatChanged(float value); + void OnFloatCommitted(float value, ETextCommit::Type commit_type); + void OnSort(const EColumnSortPriority::Type SortPriority, const FName& ColumnName, const EColumnSortMode::Type NewSortMode); + + void OnLinearColorChanged(FLinearColor color); + + void OnStringChanged(const FString &text); + + TSharedRef SpawnPythonTab(const FSpawnTabArgs& args); + + TSharedRef GenerateRow(TSharedPtr InItem, const TSharedRef& OwnerTable); + void GetChildren(TSharedPtr InItem, TArray>& OutChildren); + +#if WITH_EDITOR + void OnAssetDoubleClicked(const FAssetData& AssetData); + TSharedPtr OnGetAssetContextMenu(const TArray& SelectedAssets); + void OnAssetSelected(const FAssetData& AssetData); + TSharedRef OnExtendContentBrowserMenu(const TArray &SelectedAssets); + void MenuPyAssetBuilder(FMenuBuilder &Builder, TArray SelectedAssets); + void OnAssetChanged(const FAssetData &AssetData); + bool OnShouldFilterAsset(const FAssetData& AssetData); +#endif + + void OnWindowClosed(const TSharedRef &Window); + void SubMenuPyBuilder(FMenuBuilder &Builder); + + TSharedPtr OnContextMenuOpening(); + TSharedRef OnGenerateWidget(TSharedPtr py_item); + TSharedRef OnGetMenuContent(); + void OnSelectionChanged(TSharedPtr py_item, ESelectInfo::Type select_type); + + void SimpleExecuteAction(); + void ExecuteAction(PyObject *py_obj); + + FText GetterFText() const; + FString GetterFString() const; + float GetterFloat() const; + TOptional GetterTFloat() const; + int GetterInt() const; + bool GetterBool() const; + + FVector2D GetterFVector2D() const; + FLinearColor GetterFLinearColor() const; + void CheckBoxChanged(ECheckBoxState state); + + + template T GetterIntT() const + { + FScopePythonGIL gil; + + PyObject *ret = PyObject_CallFunction(py_callable, nullptr); + if (!ret) + { + unreal_engine_py_log_error(); + return (T)0; + } + if (!PyNumber_Check(ret)) + { + PyErr_SetString(PyExc_ValueError, "returned value is not a number"); + Py_DECREF(ret); + return (T)0; + } + + PyObject *py_int = PyNumber_Long(ret); + int n = PyLong_AsLong(py_int); + Py_DECREF(py_int); + Py_DECREF(ret); + return (T)n; + } + + template T GetterStructT() const + { + FScopePythonGIL gil; + + PyObject *ret = PyObject_CallFunction(py_callable, nullptr); + if (!ret) + { + unreal_engine_py_log_error(); + return T(); + } + + T *u_struct = ue_py_check_struct(ret); + if (!u_struct) + { + PyErr_SetString(PyExc_ValueError, "returned value is not a UStruct"); + Py_DECREF(ret); + return T(); + } + + T u_struct_copy = *u_struct; + Py_DECREF(ret); + return u_struct_copy; + } +}; + + diff --git a/Source/UnrealEnginePython/Private/Slate/UEPySlatePythonItem.h b/Source/UnrealEnginePython/Private/Slate/UEPySlatePythonItem.h new file mode 100644 index 000000000..76bd5e2af --- /dev/null +++ b/Source/UnrealEnginePython/Private/Slate/UEPySlatePythonItem.h @@ -0,0 +1,13 @@ +#pragma once + +#include "UnrealEnginePython.h" + +struct FPythonItem +{ + PyObject *py_object = nullptr; + + FPythonItem(PyObject *item) + { + py_object = item; + } +}; \ No newline at end of file diff --git a/Source/UnrealEnginePython/Private/SlateApplication/UEPyFSlateApplication.cpp b/Source/UnrealEnginePython/Private/SlateApplication/UEPyFSlateApplication.cpp index 21935b116..33982e626 100644 --- a/Source/UnrealEnginePython/Private/SlateApplication/UEPyFSlateApplication.cpp +++ b/Source/UnrealEnginePython/Private/SlateApplication/UEPyFSlateApplication.cpp @@ -1,8 +1,10 @@ -#include "UnrealEnginePythonPrivatePCH.h" - #include "UEPyFSlateApplication.h" +#include "Slate/UEPySWidget.h" +#include "Runtime/Slate/Public/Framework/Application/SlateApplication.h" +#include "Runtime/SlateRHIRenderer/Public/Interfaces/ISlateRHIRendererModule.h" +#include "Slate/UEPySWindow.h" static PyObject *py_ue_get_average_delta_time(PyObject *cls, PyObject * args) { @@ -64,15 +66,13 @@ static PyObject *py_ue_set_all_user_focus(PyObject *cls, PyObject * args) return nullptr; } - ue_PySWidget *py_swidget = py_ue_is_swidget(py_widget); - if (!py_swidget) + TSharedPtr Widget = py_ue_is_swidget(py_widget); + if (!Widget.IsValid()) { - return PyErr_Format(PyExc_Exception, "argument is not a SWidget"); + return nullptr; } - TSharedPtr widget_ptr(py_swidget->s_widget); - - FSlateApplication::Get().SetAllUserFocus(widget_ptr, (EFocusCause)focus_cause); + FSlateApplication::Get().SetAllUserFocus(Widget, (EFocusCause)focus_cause); Py_RETURN_NONE; } @@ -154,7 +154,36 @@ static PyObject *py_ue_process_key_char_event(PyObject *cls, PyObject * args) Py_RETURN_FALSE; } +static PyObject *py_ue_create(PyObject *cls, PyObject * args) +{ +#if ENGINE_MINOR_VERSION > 18 +#if ENGINE_MINOR_VERSION > 20 + FSlateApplication::InitHighDPI(true); +#else + FSlateApplication::InitHighDPI(); +#endif +#endif + FSlateApplication::Create(); + + TSharedRef SlateRenderer = FModuleManager::Get().LoadModuleChecked("SlateRHIRenderer").CreateSlateRHIRenderer(); + FSlateApplication::Get().InitializeRenderer(SlateRenderer); + + Py_RETURN_NONE; +} + + +static PyObject *py_ue_get_active_top_level_window(PyObject *cls, PyObject * args) +{ + + TSharedPtr Window = FSlateApplication::Get().GetActiveTopLevelWindow(); + if (!Window.IsValid()) + return PyErr_Format(PyExc_Exception, "no active TopLevel Window found"); + + return (PyObject *)py_ue_new_swindow(Window.ToSharedRef()); +} + static PyMethodDef ue_PyFSlateApplication_methods[] = { + { "create", (PyCFunction)py_ue_create, METH_VARARGS | METH_CLASS, "" }, { "get_average_delta_time", (PyCFunction)py_ue_get_average_delta_time, METH_VARARGS | METH_CLASS, "" }, { "get_cursor_radius", (PyCFunction)py_ue_get_cursor_radius, METH_VARARGS | METH_CLASS, "" }, { "get_delta_time", (PyCFunction)py_ue_get_delta_time, METH_VARARGS | METH_CLASS, "" }, @@ -167,6 +196,7 @@ static PyMethodDef ue_PyFSlateApplication_methods[] = { { "set_application_scale", (PyCFunction)py_ue_set_application_scale, METH_VARARGS | METH_CLASS, "" }, { "set_all_user_focus", (PyCFunction)py_ue_set_all_user_focus, METH_VARARGS | METH_CLASS, "" }, { "set_cursor_pos", (PyCFunction)py_ue_set_cursor_pos, METH_VARARGS | METH_CLASS, "" }, + { "get_active_top_level_window", (PyCFunction)py_ue_get_active_top_level_window, METH_VARARGS | METH_CLASS, "" }, { NULL } /* Sentinel */ }; diff --git a/Source/UnrealEnginePython/Private/SlateApplication/UEPyFSlateApplication.h b/Source/UnrealEnginePython/Private/SlateApplication/UEPyFSlateApplication.h index 8c9caa4f3..93e77440d 100644 --- a/Source/UnrealEnginePython/Private/SlateApplication/UEPyFSlateApplication.h +++ b/Source/UnrealEnginePython/Private/SlateApplication/UEPyFSlateApplication.h @@ -1,6 +1,6 @@ #pragma once -#include "UnrealEnginePython.h" +#include "UEPyModule.h" typedef struct { diff --git a/Source/UnrealEnginePython/Private/UEPyAssetUserData.cpp b/Source/UnrealEnginePython/Private/UEPyAssetUserData.cpp index 1ca8e7d13..a43657401 100644 --- a/Source/UnrealEnginePython/Private/UEPyAssetUserData.cpp +++ b/Source/UnrealEnginePython/Private/UEPyAssetUserData.cpp @@ -1,4 +1,4 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPyAssetUserData.h" #if WITH_EDITOR @@ -23,7 +23,11 @@ PyObject *py_ue_asset_import_data(ue_PyUObject * self, PyObject * args) PyDict_SetItemString(py_source_file, "absolute_filepath", PyUnicode_FromString(TCHAR_TO_UTF8(*import_data->ResolveImportFilename(import_info->SourceFiles[i].RelativeFilename, NULL)))); PyDict_SetItemString(py_source_file, "relative_filepath", PyUnicode_FromString(TCHAR_TO_UTF8(*import_info->SourceFiles[i].RelativeFilename))); PyDict_SetItemString(py_source_file, "timestamp", PyLong_FromLong(import_info->SourceFiles[i].Timestamp.ToUnixTimestamp())); +#if ENGINE_MINOR_VERSION > 19 + PyDict_SetItemString(py_source_file, "filehash", PyUnicode_FromString(TCHAR_TO_UTF8(*LexToString(import_info->SourceFiles[i].FileHash)))); +#else PyDict_SetItemString(py_source_file, "filehash", PyUnicode_FromString(TCHAR_TO_UTF8(*LexicalConversion::ToString(import_info->SourceFiles[i].FileHash)))); +#endif PyList_SetItem(ret, i, py_source_file); } return ret; @@ -49,9 +53,9 @@ PyObject *py_ue_asset_import_data_set_sources(ue_PyUObject * self, PyObject * ar return PyErr_Format(PyExc_Exception, "UObject does not have asset import data."); } - if (PyUnicode_Check(py_files)) + if (PyUnicodeOrString_Check(py_files)) { - filenames.Add(FString(UTF8_TO_TCHAR(PyUnicode_AsUTF8(py_files)))); + filenames.Add(FString(UTF8_TO_TCHAR(UEPyUnicode_AsUTF8(py_files)))); } else { @@ -63,12 +67,12 @@ PyObject *py_ue_asset_import_data_set_sources(ue_PyUObject * self, PyObject * ar while (PyObject *py_item = PyIter_Next(py_iter)) { - if (!PyUnicode_Check(py_item)) + if (!PyUnicodeOrString_Check(py_item)) { Py_DECREF(py_iter); return PyErr_Format(PyExc_Exception, "argument is not a string or an interable of strings"); } - filenames.Add(FString(UTF8_TO_TCHAR(PyUnicode_AsUTF8(py_item)))); + filenames.Add(FString(UTF8_TO_TCHAR(UEPyUnicode_AsUTF8(py_item)))); } Py_DECREF(py_iter); diff --git a/Source/UnrealEnginePython/Private/UEPyAssetUserData.h b/Source/UnrealEnginePython/Private/UEPyAssetUserData.h index 9506d13c3..aa23fbb1d 100644 --- a/Source/UnrealEnginePython/Private/UEPyAssetUserData.h +++ b/Source/UnrealEnginePython/Private/UEPyAssetUserData.h @@ -2,9 +2,10 @@ -#include "UnrealEnginePython.h" +#include "UEPyModule.h" #if WITH_EDITOR +#include "EditorFramework/AssetImportData.h" PyObject *py_ue_asset_import_data(ue_PyUObject *, PyObject *); PyObject *py_ue_asset_import_data_set_sources(ue_PyUObject *, PyObject *); #endif diff --git a/Source/UnrealEnginePython/Private/UEPyCallable.cpp b/Source/UnrealEnginePython/Private/UEPyCallable.cpp index 719b10e10..08841d239 100644 --- a/Source/UnrealEnginePython/Private/UEPyCallable.cpp +++ b/Source/UnrealEnginePython/Private/UEPyCallable.cpp @@ -1,23 +1,26 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPyCallable.h" // destructor -static void ue_pycallable_dealloc(ue_PyCallable *self) { +static void ue_pycallable_dealloc(ue_PyCallable *self) +{ #if defined(UEPY_MEMORY_DEBUG) UE_LOG(LogPython, Warning, TEXT("Destroying ue_PyCallable %p mapped to UFunction %p"), self, self->u_function); #endif Py_TYPE(self)->tp_free((PyObject *)self); } -static PyObject* ue_pycallable_call(ue_PyCallable *self, PyObject *args, PyObject *kw) { +static PyObject* ue_pycallable_call(ue_PyCallable *self, PyObject *args, PyObject *kw) +{ if (!self->u_function || !self->u_target || !self->u_function->IsValidLowLevel() || !self->u_target->IsValidLowLevel() || self->u_function->IsPendingKillOrUnreachable() || - self->u_target->IsPendingKillOrUnreachable()) { + self->u_target->IsPendingKillOrUnreachable()) + { return PyErr_Format(PyExc_Exception, "UFunction/UObject is in invalid state for python callable"); } - + return py_ue_ufunction_call(self->u_function, self->u_target, args, 0, kw); } @@ -54,7 +57,8 @@ static PyTypeObject ue_PyCallableType = { 0, }; -void ue_python_init_callable(PyObject *ue_module) { +void ue_python_init_callable(PyObject *ue_module) +{ ue_PyCallableType.tp_new = PyType_GenericNew; if (PyType_Ready(&ue_PyCallableType) < 0) @@ -64,14 +68,16 @@ void ue_python_init_callable(PyObject *ue_module) { PyModule_AddObject(ue_module, "Callable", (PyObject *)&ue_PyCallableType); } -PyObject *py_ue_new_callable(UFunction *u_function, UObject *u_target) { +PyObject *py_ue_new_callable(UFunction *u_function, UObject *u_target) +{ ue_PyCallable *ret = (ue_PyCallable *)PyObject_New(ue_PyCallable, &ue_PyCallableType); ret->u_function = u_function; ret->u_target = u_target; return (PyObject *)ret; } -ue_PyCallable *py_ue_is_callable(PyObject *obj) { +ue_PyCallable *py_ue_is_callable(PyObject *obj) +{ if (!PyObject_IsInstance(obj, (PyObject *)&ue_PyCallableType)) return nullptr; return (ue_PyCallable *)obj; diff --git a/Source/UnrealEnginePython/Private/UEPyCallable.h b/Source/UnrealEnginePython/Private/UEPyCallable.h index 3dd77e764..fc6a933a2 100644 --- a/Source/UnrealEnginePython/Private/UEPyCallable.h +++ b/Source/UnrealEnginePython/Private/UEPyCallable.h @@ -2,12 +2,13 @@ -#include "UnrealEnginePython.h" +#include "UEPyModule.h" -typedef struct { +typedef struct +{ PyObject_HEAD - /* Type-specific fields go here. */ - UFunction *u_function; + /* Type-specific fields go here. */ + UFunction *u_function; UObject *u_target; } ue_PyCallable; diff --git a/Source/UnrealEnginePython/Private/UEPyEditor.cpp b/Source/UnrealEnginePython/Private/UEPyEditor.cpp index 50ff5b6d0..1b3df7bca 100644 --- a/Source/UnrealEnginePython/Private/UEPyEditor.cpp +++ b/Source/UnrealEnginePython/Private/UEPyEditor.cpp @@ -1,13 +1,14 @@ +#include "UEPyEditor.h" + #if WITH_EDITOR -#include "UnrealEnginePythonPrivatePCH.h" #include "Developer/AssetTools/Public/AssetToolsModule.h" #include "Editor/UnrealEd/Classes/Factories/Factory.h" #include "Runtime/AssetRegistry/Public/AssetRegistryModule.h" #include "Kismet2/KismetEditorUtilities.h" #include "Editor/ContentBrowser/Public/ContentBrowserModule.h" - +#include "Editor/UnrealEd/Public/PackageTools.h" #include "UnrealEd.h" #include "FbxMeshUtils.h" #include "Kismet2/BlueprintEditorUtils.h" @@ -28,6 +29,29 @@ #include "Developer/Settings/Public/ISettingsModule.h" #include "Engine/Blueprint.h" +#include "Wrappers/UEPyFARFilter.h" +#include "Wrappers/UEPyFVector.h" +#include "Wrappers/UEPyFAssetData.h" +#include "Wrappers/UEPyFEditorViewportClient.h" +#include "Wrappers/UEPyIAssetEditorInstance.h" +#include "Editor/MainFrame/Public/Interfaces/IMainFrameModule.h" + +#include "Runtime/Core/Public/HAL/ThreadHeartBeat.h" +#include "Runtime/Engine/Public/EditorSupportDelegates.h" + +#include "UEPyIPlugin.h" + +PyObject *py_unreal_engine_redraw_all_viewports(PyObject * self, PyObject * args) +{ + FEditorSupportDelegates::RedrawAllViewports.Broadcast(); + Py_RETURN_NONE; +} + +PyObject *py_unreal_engine_update_ui(PyObject * self, PyObject * args) +{ + FEditorSupportDelegates::UpdateUI.Broadcast(); + Py_RETURN_NONE; +} PyObject *py_unreal_engine_editor_play_in_viewport(PyObject * self, PyObject * args) { @@ -64,8 +88,9 @@ PyObject *py_unreal_engine_editor_play_in_viewport(PyObject * self, PyObject * a if (!EditorModule.GetFirstActiveViewport().IsValid()) return PyErr_Format(PyExc_Exception, "no active LevelEditor Viewport"); + Py_BEGIN_ALLOW_THREADS; GEditor->RequestPlaySession(py_vector == nullptr, EditorModule.GetFirstActiveViewport(), true, &v, &r); - + Py_END_ALLOW_THREADS; Py_RETURN_NONE; } @@ -84,8 +109,9 @@ PyObject *py_unreal_engine_request_play_session(PyObject * self, PyObject * args bool bAtPlayerStart = py_at_player_start && PyObject_IsTrue(py_at_player_start); bool bSimulate = py_simulate_in_editor && PyObject_IsTrue(py_simulate_in_editor); + Py_BEGIN_ALLOW_THREADS; GEditor->RequestPlaySession(bAtPlayerStart, nullptr, bSimulate); - + Py_END_ALLOW_THREADS; Py_RETURN_NONE; } @@ -114,8 +140,9 @@ PyObject *py_unreal_engine_console_exec(PyObject * self, PyObject * args) return NULL; } + Py_BEGIN_ALLOW_THREADS; GEditor->Exec(GEditor->GetEditorWorldContext().World(), UTF8_TO_TCHAR(command), *GLog); - + Py_END_ALLOW_THREADS; Py_RETURN_NONE; } @@ -137,8 +164,7 @@ PyObject *py_unreal_engine_allow_actor_script_execution_in_editor(PyObject * sel GAllowActorScriptExecutionInEditor = enable; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } @@ -173,70 +199,51 @@ PyObject *py_unreal_engine_editor_command_build(PyObject * self, PyObject * args if (!GEditor) return PyErr_Format(PyExc_Exception, "no GEditor found"); + Py_BEGIN_ALLOW_THREADS; FLevelEditorActionCallbacks::Build_Execute(); - - Py_INCREF(Py_None); - return Py_None; + Py_END_ALLOW_THREADS; + Py_RETURN_NONE; } PyObject *py_unreal_engine_editor_command_save_current_level(PyObject * self, PyObject * args) { - - if (!GEditor) - return PyErr_Format(PyExc_Exception, "no GEditor found"); - + Py_BEGIN_ALLOW_THREADS; FLevelEditorActionCallbacks::Save(); - - Py_INCREF(Py_None); - return Py_None; + Py_END_ALLOW_THREADS; + Py_RETURN_NONE; } PyObject *py_unreal_engine_editor_command_save_all_levels(PyObject * self, PyObject * args) { - - if (!GEditor) - return PyErr_Format(PyExc_Exception, "no GEditor found"); - + Py_BEGIN_ALLOW_THREADS; FLevelEditorActionCallbacks::SaveAllLevels(); - - Py_INCREF(Py_None); - return Py_None; + Py_END_ALLOW_THREADS; + Py_RETURN_NONE; } PyObject *py_unreal_engine_editor_save_all(PyObject * self, PyObject * args) { - - if (!GEditor) - return PyErr_Format(PyExc_Exception, "no GEditor found"); - + Py_BEGIN_ALLOW_THREADS; FEditorFileUtils::SaveDirtyPackages(false, true, true, false, false, false); - - Py_INCREF(Py_None); - return Py_None; + Py_END_ALLOW_THREADS; + Py_RETURN_NONE; } PyObject *py_unreal_engine_editor_command_build_lighting(PyObject * self, PyObject * args) { - - if (!GEditor) - return PyErr_Format(PyExc_Exception, "no GEditor found"); - + Py_BEGIN_ALLOW_THREADS; FLevelEditorActionCallbacks::BuildLightingOnly_Execute(); - Py_INCREF(Py_None); - return Py_None; + Py_END_ALLOW_THREADS; + Py_RETURN_NONE; } PyObject *py_unreal_engine_editor_deselect_actors(PyObject * self, PyObject * args) { - if (!GEditor) - return PyErr_Format(PyExc_Exception, "no GEditor found"); - GEditor->SelectNone(true, true, false); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyObject *py_unreal_engine_editor_play(PyObject * self, PyObject * args) @@ -269,12 +276,14 @@ PyObject *py_unreal_engine_editor_play(PyObject * self, PyObject * args) r = rotator->rot; } + Py_BEGIN_ALLOW_THREADS; #if ENGINE_MINOR_VERSION >= 17 const FString mobile_device = FString(""); GEditor->RequestPlaySession(&v, &r, false, false, mobile_device); #else GEditor->RequestPlaySession(&v, &r, false, false); #endif + Py_END_ALLOW_THREADS; Py_RETURN_NONE; } @@ -288,23 +297,16 @@ PyObject *py_unreal_engine_editor_select_actor(PyObject * self, PyObject * args) PyObject *obj; if (!PyArg_ParseTuple(args, "O:editor_select_actor", &obj)) { - return NULL; + return nullptr; } - if (!ue_is_pyuobject(obj)) - return PyErr_Format(PyExc_Exception, "invalid uobject"); - - ue_PyUObject *py_actor = (ue_PyUObject *)obj; - - if (!py_actor->ue_object->IsA()) + AActor *actor = ue_py_check_type(obj); + if (!actor) return PyErr_Format(PyExc_Exception, "uobject is not an Actor"); - AActor *actor = (AActor *)py_actor->ue_object; - GEditor->SelectActor(actor, true, true); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyObject *py_unreal_engine_import_asset(PyObject * self, PyObject * args) @@ -320,7 +322,7 @@ PyObject *py_unreal_engine_import_asset(PyObject * self, PyObject * args) PyObject *py_sync = nullptr; if (!PyArg_ParseTuple(args, "Os|OO:import_asset", &assetsObject, &destination, &obj, &py_sync)) { - return NULL; + return nullptr; } FString Result; @@ -356,7 +358,7 @@ PyObject *py_unreal_engine_import_asset(PyObject * self, PyObject * args) } else if (PyUnicodeOrString_Check(obj)) { - char *class_name = PyUnicode_AsUTF8(obj); + const char *class_name = UEPyUnicode_AsUTF8(obj); UClass *u_class = FindObject(ANY_PACKAGE, UTF8_TO_TCHAR(class_name)); if (u_class) { @@ -427,12 +429,15 @@ PyObject *py_unreal_engine_import_asset(PyObject * self, PyObject * args) sync_to_browser = true; } + TArray objects; + + Py_BEGIN_ALLOW_THREADS; FAssetToolsModule& AssetToolsModule = FModuleManager::LoadModuleChecked("AssetTools"); - TArray objects = AssetToolsModule.Get().ImportAssets(files, UTF8_TO_TCHAR(destination), factory, sync_to_browser); + objects = AssetToolsModule.Get().ImportAssets(files, UTF8_TO_TCHAR(destination), factory, sync_to_browser); + Py_END_ALLOW_THREADS; if (objects.Num() == 1) { - UObject *object = objects[0]; Py_RETURN_UOBJECT(object); } @@ -462,14 +467,19 @@ PyObject *py_unreal_engine_import_asset(PyObject * self, PyObject * args) PyObject *py_unreal_engine_editor_tick(PyObject * self, PyObject * args) { float delta_seconds = FApp::GetDeltaTime(); - PyObject *py_bool = nullptr; - if (!PyArg_ParseTuple(args, "|fO:editor_tick", &delta_seconds, &py_bool)) + PyObject *py_idle = nullptr; + if (!PyArg_ParseTuple(args, "|fO:editor_tick", &delta_seconds, &py_idle)) { return NULL; } - GEditor->Tick(delta_seconds, (py_bool && PyObject_IsTrue(py_bool)) ? true : false); + bool bIdle = false; + if (py_idle && PyObject_IsTrue(py_idle)) + bIdle = true; + Py_BEGIN_ALLOW_THREADS; + GEditor->Tick(delta_seconds, bIdle); + Py_END_ALLOW_THREADS; Py_RETURN_NONE; } @@ -484,11 +494,14 @@ PyObject *py_unreal_engine_message_dialog_open(PyObject * self, PyObject * args) if (!PyArg_ParseTuple(args, "is:message_dialog_open", &app_msg_type, &text)) { - return NULL; + return nullptr; } - EAppReturnType::Type ret = FMessageDialog::Open((EAppMsgType::Type) app_msg_type, FText::FromString(UTF8_TO_TCHAR(text))); + EAppReturnType::Type ret; + Py_BEGIN_ALLOW_THREADS; + ret = FMessageDialog::Open((EAppMsgType::Type) app_msg_type, FText::FromString(UTF8_TO_TCHAR(text))); + Py_END_ALLOW_THREADS; return PyLong_FromLong(ret); } @@ -504,6 +517,9 @@ PyObject *py_unreal_engine_create_modal_save_asset_dialog(PyObject * self, PyObj return nullptr; } + FString ret; + + Py_BEGIN_ALLOW_THREADS; FSaveAssetDialogConfig config; config.DialogTitleOverride = FText::FromString(FString(UTF8_TO_TCHAR(title))); config.DefaultPath = FString(UTF8_TO_TCHAR(path)); @@ -511,8 +527,8 @@ PyObject *py_unreal_engine_create_modal_save_asset_dialog(PyObject * self, PyObj config.ExistingAssetPolicy = ESaveAssetDialogExistingAssetPolicy::AllowButWarn; FContentBrowserModule &ContentBrowserModule = FModuleManager::LoadModuleChecked("ContentBrowser"); - FString ret = ContentBrowserModule.Get().CreateModalSaveAssetDialog(config); - + ret = ContentBrowserModule.Get().CreateModalSaveAssetDialog(config); + Py_END_ALLOW_THREADS; if (ret.IsEmpty()) { Py_RETURN_NONE; @@ -540,6 +556,35 @@ PyObject *py_unreal_engine_get_asset(PyObject * self, PyObject * args) Py_RETURN_UOBJECT(asset.GetAsset()); } +PyObject *py_unreal_engine_is_loading_assets(PyObject * self, PyObject * args) +{ + if (!GEditor) + return PyErr_Format(PyExc_Exception, "no GEditor found"); + + FAssetRegistryModule& AssetRegistryModule = FModuleManager::GetModuleChecked("AssetRegistry"); + if (AssetRegistryModule.Get().IsLoadingAssets()) + Py_RETURN_TRUE; + Py_RETURN_FALSE; +} + +PyObject *py_unreal_engine_wait_for_assets(PyObject * self, PyObject * args) +{ + if (!GEditor) + return PyErr_Format(PyExc_Exception, "no GEditor found"); + + FAssetRegistryModule& AssetRegistryModule = FModuleManager::GetModuleChecked("AssetRegistry"); + while (AssetRegistryModule.Get().IsLoadingAssets()) + { + Py_BEGIN_ALLOW_THREADS; + AssetRegistryModule.Get().Tick(-1.0f); + FThreadHeartBeat::Get().HeartBeat(); + FPlatformProcess::SleepNoStats(0.0001f); + Py_END_ALLOW_THREADS; + } + + Py_RETURN_NONE; +} + PyObject *py_unreal_engine_find_asset(PyObject * self, PyObject * args) { char *path; @@ -556,19 +601,49 @@ PyObject *py_unreal_engine_find_asset(PyObject * self, PyObject * args) FAssetData asset = AssetRegistryModule.Get().GetAssetByObjectPath(UTF8_TO_TCHAR(path)); if (!asset.IsValid()) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } Py_RETURN_UOBJECT(asset.GetAsset()); } +PyObject *py_unreal_engine_create_asset(PyObject * self, PyObject * args) +{ + char *asset_name; + char *package_path; + PyObject *py_class; + PyObject *py_factory; + + if (!PyArg_ParseTuple(args, "ssOO:create_asset", &asset_name, &package_path, &py_class, &py_factory)) + { + return nullptr; + } + + if (!GEditor) + return PyErr_Format(PyExc_Exception, "no GEditor found"); + + UClass *uclass = ue_py_check_type(py_class); + if (!uclass) + return PyErr_Format(PyExc_Exception, "argument is not a UClass"); + + UFactory *factory = ue_py_check_type(py_factory); + if (!factory) + return PyErr_Format(PyExc_Exception, "argument is not a UFactory"); + + FAssetToolsModule& AssetToolsModule = FModuleManager::LoadModuleChecked("AssetTools"); + UObject *uobject = AssetToolsModule.Get().CreateAsset(FString(UTF8_TO_TCHAR(asset_name)), FString(UTF8_TO_TCHAR(package_path)), uclass, factory); + if (!uobject) + return PyErr_Format(PyExc_Exception, "unable to create asset"); + Py_RETURN_UOBJECT(uobject); +} + PyObject *py_unreal_engine_get_asset_referencers(PyObject * self, PyObject * args) { char *path; + int depency_type = (int)EAssetRegistryDependencyType::All; - if (!PyArg_ParseTuple(args, "s:get_asset_referencers", &path)) + if (!PyArg_ParseTuple(args, "s|i:get_asset_referencers", &path, &depency_type)) { - return NULL; + return nullptr; } if (!GEditor) @@ -576,7 +651,7 @@ PyObject *py_unreal_engine_get_asset_referencers(PyObject * self, PyObject * arg FAssetRegistryModule& AssetRegistryModule = FModuleManager::GetModuleChecked("AssetRegistry"); TArray referencers; - AssetRegistryModule.Get().GetReferencers(UTF8_TO_TCHAR(path), referencers); + AssetRegistryModule.Get().GetReferencers(UTF8_TO_TCHAR(path), referencers, (EAssetRegistryDependencyType::Type) depency_type); PyObject *referencers_list = PyList_New(0); for (FName name : referencers) @@ -586,11 +661,38 @@ PyObject *py_unreal_engine_get_asset_referencers(PyObject * self, PyObject * arg return referencers_list; } +PyObject *py_unreal_engine_get_asset_identifier_referencers(PyObject * self, PyObject * args) +{ + char *path; + int depency_type = (int)EAssetRegistryDependencyType::All; + + if (!PyArg_ParseTuple(args, "s|i:get_asset_identifier_referencers", &path, &depency_type)) + { + return nullptr; + } + + if (!GEditor) + return PyErr_Format(PyExc_Exception, "no GEditor found"); + + FAssetRegistryModule& AssetRegistryModule = FModuleManager::GetModuleChecked("AssetRegistry"); + TArray referencers; + AssetRegistryModule.Get().GetReferencers(FAssetIdentifier::FromString(UTF8_TO_TCHAR(path)), referencers, (EAssetRegistryDependencyType::Type) depency_type); + + PyObject *referencers_list = PyList_New(0); + for (FAssetIdentifier identifier : referencers) + { + PyList_Append(referencers_list, PyUnicode_FromString(TCHAR_TO_UTF8(*identifier.ToString()))); + } + return referencers_list; +} + + PyObject *py_unreal_engine_get_asset_dependencies(PyObject * self, PyObject * args) { char *path; + int depency_type = (int)EAssetRegistryDependencyType::All; - if (!PyArg_ParseTuple(args, "s:get_asset_dependencies", &path)) + if (!PyArg_ParseTuple(args, "s|i:get_asset_dependencies", &path, &depency_type)) { return NULL; } @@ -600,7 +702,7 @@ PyObject *py_unreal_engine_get_asset_dependencies(PyObject * self, PyObject * ar FAssetRegistryModule& AssetRegistryModule = FModuleManager::GetModuleChecked("AssetRegistry"); TArray dependencies; - AssetRegistryModule.Get().GetDependencies(UTF8_TO_TCHAR(path), dependencies); + AssetRegistryModule.Get().GetDependencies(UTF8_TO_TCHAR(path), dependencies, (EAssetRegistryDependencyType::Type) depency_type); PyObject *dependencies_list = PyList_New(0); for (FName name : dependencies) @@ -623,16 +725,29 @@ PyObject *py_unreal_engine_get_long_package_path(PyObject * self, PyObject * arg return PyUnicode_FromString(TCHAR_TO_UTF8(*(package_path))); } -PyObject *py_unreal_engine_rename_asset(PyObject * self, PyObject * args) +PyObject *py_unreal_engine_get_long_package_asset_name(PyObject * self, PyObject * args) { char *path; - char *package_name; - char *object_name; - if (!PyArg_ParseTuple(args, "sss:rename_asset", &path, &package_name, &object_name)) + if (!PyArg_ParseTuple(args, "s:get_long_package_asset_name", &path)) { return NULL; } + const FString asset_name = FPackageName::GetLongPackageAssetName(UTF8_TO_TCHAR(path)); + + return PyUnicode_FromString(TCHAR_TO_UTF8(*(asset_name))); +} + +PyObject *py_unreal_engine_rename_asset(PyObject * self, PyObject * args) +{ + char *path; + char *destination; + PyObject *py_only_soft = nullptr; + if (!PyArg_ParseTuple(args, "ss|O:rename_asset", &path, &destination, &py_only_soft)) + { + return nullptr; + } + if (!GEditor) return PyErr_Format(PyExc_Exception, "no GEditor found"); @@ -641,21 +756,46 @@ PyObject *py_unreal_engine_rename_asset(PyObject * self, PyObject * args) if (!asset.IsValid()) return PyErr_Format(PyExc_Exception, "unable to find asset %s", path); - UObject *u_object = asset.GetAsset(); - ObjectTools::FPackageGroupName pgn; - pgn.ObjectName = UTF8_TO_TCHAR(object_name); - pgn.GroupName = FString(""); - pgn.PackageName = UTF8_TO_TCHAR(package_name); + FAssetToolsModule& AssetToolsModule = FModuleManager::LoadModuleChecked("AssetTools"); - TSet refused_packages; - FText error_text; - if (!ObjectTools::RenameSingleObject(u_object, pgn, refused_packages, error_text, nullptr, false)) + TArray AssetsAndNames; + FString Destination = FString(UTF8_TO_TCHAR(destination)); + +#if ENGINE_MINOR_VERSION > 17 + FAssetRenameData RenameData; + RenameData.Asset = asset.GetAsset(); + + if (Destination.StartsWith("/")) + { + + RenameData.NewPackagePath = FPackageName::GetLongPackagePath(Destination); + RenameData.NewName = FPackageName::GetShortName(Destination); + } + else + { + RenameData.NewPackagePath = FPackageName::GetLongPackagePath(UTF8_TO_TCHAR(path)); + RenameData.NewName = Destination; + } + + if (py_only_soft && PyObject_IsTrue(py_only_soft)) + { + RenameData.bOnlyFixSoftReferences = true; + } +#else + FAssetRenameData RenameData(TWeakObjectPtr(asset.GetAsset()), FPackageName::GetLongPackagePath(UTF8_TO_TCHAR(path)), Destination.StartsWith("/") ? FPackageName::GetShortName(Destination) : Destination); +#endif + + AssetsAndNames.Add(RenameData); +#if ENGINE_MINOR_VERSION < 19 + AssetToolsModule.Get().RenameAssets(AssetsAndNames); +#else + if (!AssetToolsModule.Get().RenameAssets(AssetsAndNames)) { return PyErr_Format(PyExc_Exception, "unable to rename asset %s", path); } +#endif - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyObject *py_unreal_engine_duplicate_asset(PyObject * self, PyObject * args) @@ -694,6 +834,7 @@ PyObject *py_unreal_engine_duplicate_asset(PyObject * self, PyObject * args) return PyErr_Format(PyExc_Exception, "unable to duplicate asset %s", path); } + FAssetRegistryModule::AssetCreated(new_asset); Py_RETURN_UOBJECT(new_asset); } @@ -733,8 +874,7 @@ PyObject *py_unreal_engine_delete_asset(PyObject * self, PyObject * args) } } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyObject *py_unreal_engine_delete_object(PyObject * self, PyObject * args) @@ -772,8 +912,7 @@ PyObject *py_unreal_engine_delete_object(PyObject * self, PyObject * args) } } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } @@ -825,21 +964,26 @@ PyObject *py_unreal_engine_get_assets_by_filter(PyObject * self, PyObject * args if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O|O:get_assets_by_filter", kw_names, &pyfilter, &py_return_asset_data)) { - return NULL; + return nullptr; } - ue_PyFARFilter *filter = py_ue_is_farfilter(pyfilter); - if (!filter) + ue_PyFARFilter *py_filter = py_ue_is_farfilter(pyfilter); + if (!py_filter) return PyErr_Format(PyExc_Exception, "Arg is not a FARFilter"); - if (!GEditor) - return PyErr_Format(PyExc_Exception, "no GEditor found"); + FARFilter& Filter = py_filter->filter; + + py_ue_sync_farfilter((PyObject *)py_filter); - py_ue_sync_farfilter((PyObject *)filter); TArray assets; + + Py_BEGIN_ALLOW_THREADS; + FAssetRegistryModule& AssetRegistryModule = FModuleManager::GetModuleChecked("AssetRegistry"); AssetRegistryModule.Get().SearchAllAssets(true); - AssetRegistryModule.Get().GetAssets(filter->filter, assets); + AssetRegistryModule.Get().GetAssets(Filter, assets); + + Py_END_ALLOW_THREADS; bool return_asset_data = false; if (py_return_asset_data && PyObject_IsTrue(py_return_asset_data)) @@ -994,25 +1138,66 @@ PyObject *py_unreal_engine_get_selected_assets(PyObject * self, PyObject * args) return assets_list; } +PyObject *py_unreal_engine_get_all_edited_assets(PyObject * self, PyObject * args) +{ + TArray assets = FAssetEditorManager::Get().GetAllEditedAssets(); + PyObject *assets_list = PyList_New(0); + + for (UObject *asset : assets) + { + ue_PyUObject *ret = ue_get_python_uobject(asset); + if (ret) + { + PyList_Append(assets_list, (PyObject *)ret); + } + } + + return assets_list; +} + PyObject *py_unreal_engine_open_editor_for_asset(PyObject * self, PyObject * args) { PyObject *py_obj; if (!PyArg_ParseTuple(args, "O:open_editor_for_asset", &py_obj)) { - return NULL; + return nullptr; } UObject *u_obj = ue_py_check_type(py_obj); if (!u_obj) return PyErr_Format(PyExc_Exception, "argument is not a UObject"); + if (FAssetEditorManager::Get().OpenEditorForAsset(u_obj)) { - Py_INCREF(Py_True); - return Py_True; + Py_RETURN_TRUE; } - Py_INCREF(Py_False); - return Py_False; + Py_RETURN_FALSE; +} + +PyObject *py_unreal_engine_find_editor_for_asset(PyObject * self, PyObject * args) +{ + PyObject *py_obj; + PyObject *py_bool = nullptr; + + if (!PyArg_ParseTuple(args, "O|O:find_editor_for_asset", &py_obj, &py_bool)) + { + return nullptr; + } + + UObject *u_obj = ue_py_check_type(py_obj); + if (!u_obj) + return PyErr_Format(PyExc_Exception, "argument is not a UObject"); + + bool bFocus = false; + if (py_bool && PyObject_IsTrue(py_bool)) + bFocus = true; + + IAssetEditorInstance *instance = FAssetEditorManager::Get().FindEditorForAsset(u_obj, bFocus); + if (!instance) + return PyErr_Format(PyExc_Exception, "no editor found for asset"); + + return py_ue_new_iasset_editor_instance(instance); } PyObject *py_unreal_engine_close_editor_for_asset(PyObject * self, PyObject * args) @@ -1021,7 +1206,7 @@ PyObject *py_unreal_engine_close_editor_for_asset(PyObject * self, PyObject * ar if (!PyArg_ParseTuple(args, "O:close_editor_for_asset", &py_obj)) { - return NULL; + return nullptr; } UObject *u_obj = ue_py_check_type(py_obj); @@ -1029,16 +1214,14 @@ PyObject *py_unreal_engine_close_editor_for_asset(PyObject * self, PyObject * ar return PyErr_Format(PyExc_Exception, "argument is not a UObject"); FAssetEditorManager::Get().CloseAllEditorsForAsset(u_obj); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyObject *py_unreal_engine_close_all_asset_editors(PyObject * self, PyObject * args) { FAssetEditorManager::Get().CloseAllAssetEditors(); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyObject *py_unreal_engine_set_fbx_import_option(PyObject * self, PyObject * args) @@ -1075,21 +1258,17 @@ PyObject *py_unreal_engine_create_blueprint(PyObject * self, PyObject * args) char *name; if (!PyArg_ParseTuple(args, "Os:create_blueprint", &py_parent, &name)) { - return NULL; + return nullptr; } UClass *parent = UObject::StaticClass(); if (py_parent != Py_None) { - if (!ue_is_pyuobject(py_parent)) - { - return PyErr_Format(PyExc_Exception, "argument is not a UObject"); - } - ue_PyUObject *py_obj = (ue_PyUObject *)py_parent; - if (!py_obj->ue_object->IsA()) + UClass *new_parent = ue_py_check_type(py_parent); + if (!new_parent) return PyErr_Format(PyExc_Exception, "uobject is not a UClass"); - parent = (UClass *)py_obj->ue_object; + parent = new_parent; } if (name[0] != '/') @@ -1107,6 +1286,11 @@ PyObject *py_unreal_engine_create_blueprint(PyObject * self, PyObject * args) if (!outer) return PyErr_Format(PyExc_Exception, "unable to create package"); + TArray TopLevelPackages; + TopLevelPackages.Add(outer); + if (!PackageTools::HandleFullyLoadingPackages(TopLevelPackages, FText::FromString("Create a new object"))) + return PyErr_Format(PyExc_Exception, "unable to fully load package"); + if (FindObject(outer, UTF8_TO_TCHAR(bp_name)) != nullptr) return PyErr_Format(PyExc_Exception, "there is already a Blueprint with this name"); @@ -1156,7 +1340,7 @@ PyObject *py_unreal_engine_reload_blueprint(PyObject * self, PyObject * args) PyObject *py_blueprint; if (!PyArg_ParseTuple(args, "O:reload_blueprint", &py_blueprint)) { - return NULL; + return nullptr; } if (!ue_is_pyuobject(py_blueprint)) @@ -1164,14 +1348,17 @@ PyObject *py_unreal_engine_reload_blueprint(PyObject * self, PyObject * args) return PyErr_Format(PyExc_Exception, "argument is not a UObject"); } - ue_PyUObject *py_obj = (ue_PyUObject *)py_blueprint; - if (!py_obj->ue_object->IsA()) + UBlueprint *bp = ue_py_check_type(py_blueprint); + if (!bp) return PyErr_Format(PyExc_Exception, "uobject is not a UBlueprint"); - UBlueprint *bp = (UBlueprint *)py_obj->ue_object; - UBlueprint *reloaded_bp = FKismetEditorUtilities::ReloadBlueprint(bp); + UBlueprint *reloaded_bp = nullptr; + + Py_BEGIN_ALLOW_THREADS + reloaded_bp = FKismetEditorUtilities::ReloadBlueprint(bp); + Py_END_ALLOW_THREADS - Py_RETURN_UOBJECT(reloaded_bp); + Py_RETURN_UOBJECT(reloaded_bp); } PyObject *py_unreal_engine_compile_blueprint(PyObject * self, PyObject * args) @@ -1180,24 +1367,18 @@ PyObject *py_unreal_engine_compile_blueprint(PyObject * self, PyObject * args) PyObject *py_blueprint; if (!PyArg_ParseTuple(args, "O:compile_blueprint", &py_blueprint)) { - return NULL; - } - - if (!ue_is_pyuobject(py_blueprint)) - { - return PyErr_Format(PyExc_Exception, "argument is not a UObject"); + return nullptr; } - ue_PyUObject *py_obj = (ue_PyUObject *)py_blueprint; - if (!py_obj->ue_object->IsA()) + UBlueprint *bp = ue_py_check_type(py_blueprint); + if (!bp) return PyErr_Format(PyExc_Exception, "uobject is not a UBlueprint"); - UBlueprint *bp = (UBlueprint *)py_obj->ue_object; - - FKismetEditorUtilities::CompileBlueprint(bp); - Py_INCREF(Py_None); - return Py_None; + Py_BEGIN_ALLOW_THREADS + FKismetEditorUtilities::CompileBlueprint(bp); + Py_END_ALLOW_THREADS + Py_RETURN_NONE; } PyObject *py_unreal_engine_replace_blueprint(PyObject * self, PyObject * args) @@ -1292,6 +1473,37 @@ PyObject *py_unreal_engine_get_blueprint_components(PyObject * self, PyObject * } +PyObject *py_unreal_engine_remove_component_from_blueprint(PyObject *self, PyObject *args) +{ + PyObject *py_blueprint; + char *name; + char *parentName = nullptr; + + if (!PyArg_ParseTuple(args, "Os|s:remove_component_from_blueprint", &py_blueprint, &name, &parentName)) + { + return NULL; + } + + if (!ue_is_pyuobject(py_blueprint)) + { + return PyErr_Format(PyExc_Exception, "argument is not a UObject"); + } + + ue_PyUObject *py_obj = (ue_PyUObject *)py_blueprint; + if (!py_obj->ue_object->IsA()) + return PyErr_Format(PyExc_Exception, "uobject is not a UBlueprint"); + UBlueprint *bp = (UBlueprint *)py_obj->ue_object; + + bp->Modify(); + USCS_Node *ComponentNode = bp->SimpleConstructionScript->FindSCSNode(UTF8_TO_TCHAR(name)); + if (ComponentNode) + { + bp->SimpleConstructionScript->RemoveNode(ComponentNode); + } + + Py_RETURN_NONE; +} + PyObject *py_unreal_engine_add_component_to_blueprint(PyObject * self, PyObject * args) { @@ -1373,46 +1585,58 @@ PyObject *py_unreal_engine_blueprint_add_member_variable(PyObject * self, PyObje PyObject *py_blueprint; char *name; - char *in_type; + PyObject *py_type; PyObject *py_is_array = nullptr; - if (!PyArg_ParseTuple(args, "Oss|O:blueprint_add_member_variable", &py_blueprint, &name, &in_type, &py_is_array)) + char *default_value = nullptr; + if (!PyArg_ParseTuple(args, "OsO|Os:blueprint_add_member_variable", &py_blueprint, &name, &py_type, &py_is_array, &default_value)) { - return NULL; + return nullptr; } - if (!ue_is_pyuobject(py_blueprint)) - { - return PyErr_Format(PyExc_Exception, "argument is not a UObject"); - } + UBlueprint *bp = ue_py_check_type(py_blueprint); + if (!bp) + return PyErr_Format(PyExc_Exception, "uobject is not a Blueprint"); - ue_PyUObject *py_obj = (ue_PyUObject *)py_blueprint; - if (!py_obj->ue_object->IsA()) - return PyErr_Format(PyExc_Exception, "uobject is not a UBlueprint"); - UBlueprint *bp = (UBlueprint *)py_obj->ue_object; + FEdGraphPinType pin; + + if (PyUnicodeOrString_Check(py_type)) + { + const char *in_type = UEPyUnicode_AsUTF8(py_type); - bool is_array = false; - if (py_is_array && PyObject_IsTrue(py_is_array)) - is_array = true; + bool is_array = false; + if (py_is_array && PyObject_IsTrue(py_is_array)) + is_array = true; #if ENGINE_MINOR_VERSION > 14 - FEdGraphPinType pin; - pin.PinCategory = UTF8_TO_TCHAR(in_type); + pin.PinCategory = UTF8_TO_TCHAR(in_type); #if ENGINE_MINOR_VERSION >= 17 - pin.ContainerType = is_array ? EPinContainerType::Array : EPinContainerType::None; + pin.ContainerType = is_array ? EPinContainerType::Array : EPinContainerType::None; #else - pin.bIsArray = is_array; + pin.bIsArray = is_array; #endif #else - FEdGraphPinType pin(UTF8_TO_TCHAR(in_type), FString(""), nullptr, is_array, false); + FEdGraphPinType pin2(UTF8_TO_TCHAR(in_type), FString(""), nullptr, is_array, false); + pin = pin2; #endif + } + else + { + FEdGraphPinType *pinptr = ue_py_check_struct(py_type); + if (!pinptr) + return PyErr_Format(PyExc_Exception, "argument is not a EdGraphPinType"); + pin = *pinptr; + } + + FString DefaultValue = FString(""); - if (FBlueprintEditorUtils::AddMemberVariable(bp, UTF8_TO_TCHAR(name), pin)) + if (default_value) + DefaultValue = FString(default_value); + + if (FBlueprintEditorUtils::AddMemberVariable(bp, UTF8_TO_TCHAR(name), pin, DefaultValue)) { - Py_INCREF(Py_True); - return Py_True; + Py_RETURN_TRUE; } - Py_INCREF(Py_False); - return Py_False; + Py_RETURN_FALSE; } PyObject *py_unreal_engine_blueprint_set_variable_visibility(PyObject * self, PyObject * args) @@ -1423,18 +1647,12 @@ PyObject *py_unreal_engine_blueprint_set_variable_visibility(PyObject * self, Py PyObject *visibility; if (!PyArg_ParseTuple(args, "OsO:blueprint_set_variable_visibility", &py_blueprint, &name, &visibility)) { - return NULL; - } - - if (!ue_is_pyuobject(py_blueprint)) - { - return PyErr_Format(PyExc_Exception, "argument is not a UObject"); + return nullptr; } - ue_PyUObject *py_obj = (ue_PyUObject *)py_blueprint; - if (!py_obj->ue_object->IsA()) - return PyErr_Format(PyExc_Exception, "uobject is not a UBlueprint"); - UBlueprint *bp = (UBlueprint *)py_obj->ue_object; + UBlueprint *bp = ue_py_check_type(py_blueprint); + if (!bp) + return PyErr_Format(PyExc_Exception, "uobject is not a Blueprint"); bool visible = false; if (PyObject_IsTrue(visibility)) @@ -1444,8 +1662,7 @@ PyObject *py_unreal_engine_blueprint_set_variable_visibility(PyObject * self, Py FBlueprintEditorUtils::SetBlueprintOnlyEditableFlag(bp, FName(UTF8_TO_TCHAR(name)), !visible); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyObject *py_unreal_engine_blueprint_add_new_timeline(PyObject * self, PyObject * args) @@ -1484,18 +1701,12 @@ PyObject *py_unreal_engine_blueprint_add_function(PyObject * self, PyObject * ar char *name; if (!PyArg_ParseTuple(args, "Os:blueprint_add_function", &py_blueprint, &name)) { - return NULL; - } - - if (!ue_is_pyuobject(py_blueprint)) - { - return PyErr_Format(PyExc_Exception, "argument is not a UObject"); + return nullptr; } - ue_PyUObject *py_obj = (ue_PyUObject *)py_blueprint; - if (!py_obj->ue_object->IsA()) - return PyErr_Format(PyExc_Exception, "uobject is not a UBlueprint"); - UBlueprint *bp = (UBlueprint *)py_obj->ue_object; + UBlueprint *bp = ue_py_check_type(py_blueprint); + if (!bp) + return PyErr_Format(PyExc_Exception, "argument is not a UBlueprint"); UEdGraph *graph = FBlueprintEditorUtils::CreateNewGraph(bp, FName(UTF8_TO_TCHAR(name)), UEdGraph::StaticClass(), UEdGraphSchema_K2::StaticClass()); FBlueprintEditorUtils::AddFunctionGraph(bp, graph, true, nullptr); @@ -1698,12 +1909,40 @@ PyObject *py_unreal_engine_editor_on_asset_post_import(PyObject * self, PyObject if (!PyCallable_Check(py_callable)) return PyErr_Format(PyExc_Exception, "object is not a callable"); - TSharedRef py_delegate = MakeShareable(new FPythonSmartDelegate); - py_delegate->SetPyCallable(py_callable); + TSharedRef py_delegate = FUnrealEnginePythonHouseKeeper::Get()->NewPythonSmartDelegate(py_callable); +#if ENGINE_MINOR_VERSION > 21 + GEditor->GetEditorSubsystem()->OnAssetPostImport.AddSP(py_delegate, &FPythonSmartDelegate::PyFOnAssetPostImport); +#else FEditorDelegates::OnAssetPostImport.AddSP(py_delegate, &FPythonSmartDelegate::PyFOnAssetPostImport); +#endif + Py_RETURN_NONE; +} + +PyObject *py_unreal_engine_on_main_frame_creation_finished(PyObject * self, PyObject * args) +{ + PyObject *py_callable; + if (!PyArg_ParseTuple(args, "O:on_main_frame_creation_finished", &py_callable)) + { + return NULL; + } + + if (!PyCallable_Check(py_callable)) + return PyErr_Format(PyExc_Exception, "object is not a callable"); + /* + TSharedRef py_delegate = FUnrealEnginePythonHouseKeeper::Get()->NewPythonSmartDelegate(py_callable); + IMainFrameModule& MainFrameModule = FModuleManager::LoadModuleChecked(TEXT("MainFrame")); + MainFrameModule.OnMainFrameCreationFinished().AddSP(py_delegate, &FPythonSmartDelegate::PyFOnMainFrameCreationFinished); + */ + + FPythonSmartDelegate *py_delegate = new FPythonSmartDelegate(); + py_delegate->SetPyCallable(py_callable); + IMainFrameModule& MainFrameModule = FModuleManager::LoadModuleChecked(TEXT("MainFrame")); + MainFrameModule.OnMainFrameCreationFinished().AddRaw(py_delegate, &FPythonSmartDelegate::PyFOnMainFrameCreationFinished); + Py_RETURN_NONE; } + PyObject *py_unreal_engine_create_material_instance(PyObject * self, PyObject * args) { @@ -1763,33 +2002,66 @@ PyObject *py_ue_factory_create_new(ue_PyUObject *self, PyObject * args) char *name; if (!PyArg_ParseTuple(args, "s:factory_create_new", &name)) { - return NULL; + return nullptr; } - if (!self->ue_object->IsA()) + UFactory *factory = ue_py_check_type(self); + if (!factory) return PyErr_Format(PyExc_Exception, "uobject is not a Factory"); - UPackage *outer = CreatePackage(nullptr, UTF8_TO_TCHAR(name)); + char *obj_name = strrchr(name, '/') + 1; + if (strlen(obj_name) < 1) + { + return PyErr_Format(PyExc_Exception, "invalid object name"); + } + + FString PackageName = PackageTools::SanitizePackageName(FString(UTF8_TO_TCHAR(name))); + + UPackage *outer = CreatePackage(nullptr, *PackageName); if (!outer) return PyErr_Format(PyExc_Exception, "unable to create package"); - UFactory *factory = (UFactory *)self->ue_object; + TArray TopLevelPackages; + TopLevelPackages.Add(outer); + if (!PackageTools::HandleFullyLoadingPackages(TopLevelPackages, FText::FromString("Create a new object"))) + return PyErr_Format(PyExc_Exception, "unable to fully load package"); + UClass *u_class = factory->GetSupportedClass(); - char *obj_name = strrchr(name, '/') + 1; - if (strlen(obj_name) < 1) + // avoid duplicates + if (u_class->IsChildOf()) { - return PyErr_Format(PyExc_Exception, "invalid object name"); + if (FindObject(outer, UTF8_TO_TCHAR(obj_name))) + { + return PyErr_Format(PyExc_Exception, "a blueprint with this name already exists in the package"); + } } - UObject *u_object = factory->FactoryCreateNew(u_class, outer, FName(UTF8_TO_TCHAR(obj_name)), RF_Public | RF_Standalone, nullptr, GWarn); + if (u_class->IsChildOf()) + { + if (FindObject(outer, UTF8_TO_TCHAR(obj_name))) + { + return PyErr_Format(PyExc_Exception, "a structure with this name already exists in the package"); + } + } - if (!u_object) - return PyErr_Format(PyExc_Exception, "unable to create new object from factory"); + UObject *u_object = nullptr; - FAssetRegistryModule::AssetCreated(u_object); - outer->MarkPackageDirty(); + Py_BEGIN_ALLOW_THREADS; + u_object = factory->FactoryCreateNew(u_class, outer, FName(UTF8_TO_TCHAR(obj_name)), RF_Public | RF_Standalone, nullptr, GWarn); + + if (u_object) + { + FAssetRegistryModule::AssetCreated(u_object); + outer->MarkPackageDirty(); + } + + Py_END_ALLOW_THREADS; + if (!u_object) + { + return PyErr_Format(PyExc_Exception, "unable to create new object from factory"); + } Py_RETURN_UOBJECT(u_object); } @@ -1818,14 +2090,20 @@ PyObject *py_ue_factory_import_object(ue_PyUObject *self, PyObject * args) return PyErr_Format(PyExc_Exception, "unable to create package"); bool canceled = false; - UObject *u_object = factory->ImportObject(factory->ResolveSupportedClass(), outer, FName(*object_name), RF_Public | RF_Standalone, UTF8_TO_TCHAR(filename), nullptr, canceled); + UObject *u_object = nullptr; + + Py_BEGIN_ALLOW_THREADS; + u_object = factory->ImportObject(factory->ResolveSupportedClass(), outer, FName(*object_name), RF_Public | RF_Standalone, UTF8_TO_TCHAR(filename), nullptr, canceled); + if (u_object) + { + FAssetRegistryModule::AssetCreated(u_object); + outer->MarkPackageDirty(); + } + Py_END_ALLOW_THREADS; if (!u_object) return PyErr_Format(PyExc_Exception, "unable to create new object from factory"); - FAssetRegistryModule::AssetCreated(u_object); - outer->MarkPackageDirty(); - Py_RETURN_UOBJECT(u_object); } @@ -1846,12 +2124,17 @@ PyObject *py_unreal_engine_add_level_to_world(PyObject *self, PyObject * args) return PyErr_Format(PyExc_Exception, "argument is not a UWorld"); } + if (!FPackageName::DoesPackageExist(UTF8_TO_TCHAR(name), nullptr, nullptr)) + return PyErr_Format(PyExc_Exception, "package does not exist"); + UClass *streaming_mode_class = ULevelStreamingKismet::StaticClass(); if (py_bool && PyObject_IsTrue(py_bool)) { streaming_mode_class = ULevelStreamingAlwaysLoaded::StaticClass(); } + + #if ENGINE_MINOR_VERSION >= 17 ULevelStreaming *level_streaming = EditorLevelUtils::AddLevelToWorld(u_world, UTF8_TO_TCHAR(name), streaming_mode_class); #else @@ -2047,7 +2330,13 @@ PyObject *py_unreal_engine_editor_undo(PyObject * self, PyObject * args) if (!GEditor || !GEditor->Trans) return PyErr_Format(PyExc_Exception, "no GEditor found"); - if (GEditor->Trans->Undo()) + bool bSuccess; + + Py_BEGIN_ALLOW_THREADS; + bSuccess = GEditor->Trans->Undo(); + Py_END_ALLOW_THREADS; + + if (bSuccess) { Py_RETURN_TRUE; } @@ -2061,14 +2350,15 @@ PyObject *py_unreal_engine_editor_redo(PyObject * self, PyObject * args) if (!GEditor || !GEditor->Trans) return PyErr_Format(PyExc_Exception, "no GEditor found"); - if (GEditor->Trans->Redo()) - { - Py_INCREF(Py_True); - return Py_True; - } + bool bSuccess; - Py_INCREF(Py_False); - return Py_False; + Py_BEGIN_ALLOW_THREADS; + bSuccess = GEditor->Trans->Redo(); + Py_END_ALLOW_THREADS; + + if (bSuccess) + Py_RETURN_TRUE; + Py_RETURN_FALSE; } @@ -2185,7 +2475,9 @@ PyObject *py_unreal_engine_play_preview_sound(PyObject * self, PyObject * args) if (!sound) return PyErr_Format(PyExc_Exception, "argument is not a USoundBase"); + Py_BEGIN_ALLOW_THREADS; GEditor->PlayPreviewSound(sound); + Py_END_ALLOW_THREADS; Py_RETURN_NONE; } @@ -2234,12 +2526,14 @@ PyObject * py_unreal_engine_show_viewer(PyObject * self, PyObject * args) char *category_name; char *section_name; - if (!PyArg_ParseTuple(args, "sss:register_settings", &container_name, &category_name, §ion_name)) + if (!PyArg_ParseTuple(args, "sss:show_viewer", &container_name, &category_name, §ion_name)) return nullptr; if (ISettingsModule* SettingsModule = FModuleManager::GetModulePtr("Settings")) { + Py_BEGIN_ALLOW_THREADS; SettingsModule->ShowViewer(container_name, category_name, section_name); + Py_END_ALLOW_THREADS; } else { @@ -2274,7 +2568,11 @@ PyObject *py_unreal_engine_unregister_settings(PyObject * self, PyObject * args) PyObject *py_unreal_engine_all_viewport_clients(PyObject * self, PyObject * args) { +#if ENGINE_MINOR_VERSION > 21 + TArray clients = GEditor->GetAllViewportClients(); +#else TArray clients = GEditor->AllViewportClients; +#endif PyObject *py_list = PyList_New(0); for (FEditorViewportClient *client : clients) { @@ -2320,15 +2618,21 @@ PyObject *py_unreal_engine_editor_sync_browser_to_assets(PyObject * self, PyObje } } + bool bFocus = false; + if (py_focus && PyObject_IsTrue(py_focus)) + bFocus = true; + + Py_BEGIN_ALLOW_THREADS; if (asset_data.Num() > 0) { - ContentBrowserModule.Get().SyncBrowserToAssets(asset_data, false, py_focus && PyObject_IsTrue(py_focus)); + ContentBrowserModule.Get().SyncBrowserToAssets(asset_data, false, bFocus); } if (uobjects.Num() > 0) { - ContentBrowserModule.Get().SyncBrowserToAssets(uobjects, false, py_focus && PyObject_IsTrue(py_focus)); + ContentBrowserModule.Get().SyncBrowserToAssets(uobjects, false, bFocus); } + Py_END_ALLOW_THREADS; Py_DECREF(py_iter); @@ -2370,12 +2674,18 @@ PyObject *py_unreal_engine_export_assets(PyObject * self, PyObject * args) Py_DECREF(py_iter); - FAssetToolsModule& AssetToolsModule = FModuleManager::LoadModuleChecked("AssetTools"); + #if ENGINE_MINOR_VERSION > 16 + Py_BEGIN_ALLOW_THREADS; + FAssetToolsModule& AssetToolsModule = FModuleManager::LoadModuleChecked("AssetTools"); AssetToolsModule.Get().ExportAssets(UObjects, FString(UTF8_TO_TCHAR(filename))); + Py_END_ALLOW_THREADS; +#else + return PyErr_Format(PyExc_Exception, "Asset exporting not supported in this engine version"); #endif Py_RETURN_NONE; } + #endif diff --git a/Source/UnrealEnginePython/Private/UEPyEditor.h b/Source/UnrealEnginePython/Private/UEPyEditor.h index 36e24c6ad..31c8028e1 100644 --- a/Source/UnrealEnginePython/Private/UEPyEditor.h +++ b/Source/UnrealEnginePython/Private/UEPyEditor.h @@ -2,7 +2,7 @@ -#include "UnrealEnginePython.h" +#include "UEPyModule.h" #if WITH_EDITOR @@ -13,7 +13,10 @@ PyObject *py_unreal_engine_editor_deselect_actors(PyObject *, PyObject *); PyObject *py_unreal_engine_editor_select_actor(PyObject *, PyObject *); PyObject *py_unreal_engine_import_asset(PyObject *, PyObject *); PyObject *py_unreal_engine_get_asset(PyObject *, PyObject *); +PyObject *py_unreal_engine_is_loading_assets(PyObject *, PyObject *); +PyObject *py_unreal_engine_wait_for_assets(PyObject *, PyObject *); PyObject *py_unreal_engine_find_asset(PyObject *, PyObject *); +PyObject *py_unreal_engine_create_asset(PyObject *, PyObject *); PyObject *py_unreal_engine_delete_object(PyObject *, PyObject *); PyObject *py_unreal_engine_get_assets(PyObject *, PyObject *); PyObject *py_unreal_engine_get_selected_assets(PyObject *, PyObject *); @@ -21,6 +24,9 @@ PyObject *py_unreal_engine_get_assets_by_class(PyObject *, PyObject *); PyObject *py_unreal_engine_get_assets_by_filter(PyObject *, PyObject *, PyObject *); PyObject *py_unreal_engine_set_fbx_import_option(PyObject *, PyObject *); +PyObject *py_unreal_engine_redraw_all_viewports(PyObject *, PyObject *); +PyObject *py_unreal_engine_update_ui(PyObject *, PyObject *); + PyObject *py_unreal_engine_create_modal_save_asset_dialog(PyObject *, PyObject *); PyObject *py_unreal_engine_console_exec(PyObject *, PyObject * args); @@ -36,6 +42,7 @@ PyObject *py_unreal_engine_duplicate_asset(PyObject *, PyObject *); PyObject *py_unreal_engine_delete_asset(PyObject *, PyObject *); PyObject *py_unreal_engine_get_long_package_path(PyObject *, PyObject *); +PyObject *py_unreal_engine_get_long_package_asset_name(PyObject *, PyObject *); PyObject *py_unreal_engine_create_blueprint(PyObject *, PyObject *); PyObject *py_unreal_engine_compile_blueprint(PyObject *, PyObject *); @@ -45,6 +52,7 @@ PyObject *py_unreal_engine_reload_blueprint(PyObject *, PyObject *); PyObject *py_unreal_engine_replace_blueprint(PyObject *, PyObject *); PyObject *py_unreal_engine_create_blueprint_from_actor(PyObject *, PyObject *); PyObject *py_unreal_engine_add_component_to_blueprint(PyObject *, PyObject *); +PyObject *py_unreal_engine_remove_component_from_blueprint(PyObject *, PyObject *); PyObject *py_unreal_engine_blueprint_add_member_variable(PyObject *, PyObject *); PyObject *py_unreal_engine_blueprint_add_new_timeline(PyObject *, PyObject *); @@ -54,6 +62,7 @@ PyObject *py_unreal_engine_get_blueprint_components(PyObject *, PyObject *); PyObject *py_unreal_engine_editor_play(PyObject *, PyObject *); PyObject *py_unreal_engine_editor_on_asset_post_import(PyObject *, PyObject *); +PyObject *py_unreal_engine_on_main_frame_creation_finished(PyObject *, PyObject *); PyObject *py_unreal_engine_editor_command_build(PyObject *, PyObject *); PyObject *py_unreal_engine_editor_command_build_lighting(PyObject *, PyObject *); @@ -88,9 +97,12 @@ PyObject *py_unreal_engine_create_material_instance(PyObject *, PyObject *); PyObject *py_unreal_engine_allow_actor_script_execution_in_editor(PyObject *, PyObject *); PyObject *py_unreal_engine_get_asset_referencers(PyObject *, PyObject *); +PyObject *py_unreal_engine_get_asset_identifier_referencers(PyObject *, PyObject *); PyObject *py_unreal_engine_get_asset_dependencies(PyObject *, PyObject *); PyObject *py_unreal_engine_open_editor_for_asset(PyObject *, PyObject *); +PyObject *py_unreal_engine_find_editor_for_asset(PyObject *, PyObject *); +PyObject *py_unreal_engine_get_all_edited_assets(PyObject *, PyObject *); PyObject *py_unreal_engine_close_editor_for_asset(PyObject *, PyObject *); PyObject *py_unreal_engine_close_all_asset_editors(PyObject *, PyObject *); diff --git a/Source/UnrealEnginePython/Private/UEPyEngine.cpp b/Source/UnrealEnginePython/Private/UEPyEngine.cpp index e4f5b1b50..40a92d582 100644 --- a/Source/UnrealEnginePython/Private/UEPyEngine.cpp +++ b/Source/UnrealEnginePython/Private/UEPyEngine.cpp @@ -1,6 +1,6 @@ // Copyright 20Tab S.r.l. -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPyEngine.h" #include "Kismet/KismetSystemLibrary.h" #include "Kismet/KismetMathLibrary.h" @@ -9,8 +9,24 @@ #include "Developer/DesktopPlatform/Public/DesktopPlatformModule.h" #if WITH_EDITOR #include "PackageTools.h" +#include "Editor.h" #endif +#include "UnrealEngine.h" +#include "Runtime/Engine/Classes/Engine/GameViewportClient.h" + +#if ENGINE_MINOR_VERSION >= 18 +#include "HAL/PlatformApplicationMisc.h" +#endif + +#include "Runtime/Launch/Public/LaunchEngineLoop.h" + +#if PLATFORM_MAC +#include "Runtime/Core/Public/Mac/CocoaThread.h" +#endif + +#include "Runtime/Slate/Public/Framework/Application/SlateApplication.h" +#include "Runtime/CoreUObject/Public/UObject/UObjectIterator.h" PyObject *py_unreal_engine_log(PyObject * self, PyObject * args) { @@ -23,12 +39,11 @@ PyObject *py_unreal_engine_log(PyObject * self, PyObject * args) PyObject *stringified = PyObject_Str(py_message); if (!stringified) return PyErr_Format(PyExc_Exception, "argument cannot be casted to string"); - char *message = PyUnicode_AsUTF8(stringified); + const char *message = UEPyUnicode_AsUTF8(stringified); UE_LOG(LogPython, Log, TEXT("%s"), UTF8_TO_TCHAR(message)); Py_DECREF(stringified); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyObject *py_unreal_engine_log_warning(PyObject * self, PyObject * args) @@ -42,12 +57,11 @@ PyObject *py_unreal_engine_log_warning(PyObject * self, PyObject * args) PyObject *stringified = PyObject_Str(py_message); if (!stringified) return PyErr_Format(PyExc_Exception, "argument cannot be casted to string"); - char *message = PyUnicode_AsUTF8(stringified); + const char *message = UEPyUnicode_AsUTF8(stringified); UE_LOG(LogPython, Warning, TEXT("%s"), UTF8_TO_TCHAR(message)); Py_DECREF(stringified); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyObject *py_unreal_engine_log_error(PyObject * self, PyObject * args) @@ -61,12 +75,11 @@ PyObject *py_unreal_engine_log_error(PyObject * self, PyObject * args) PyObject *stringified = PyObject_Str(py_message); if (!stringified) return PyErr_Format(PyExc_Exception, "argument cannot be casted to string"); - char *message = PyUnicode_AsUTF8(stringified); + const char *message = UEPyUnicode_AsUTF8(stringified); UE_LOG(LogPython, Error, TEXT("%s"), UTF8_TO_TCHAR(message)); Py_DECREF(stringified); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyObject *py_unreal_engine_add_on_screen_debug_message(PyObject * self, PyObject * args) @@ -88,14 +101,13 @@ PyObject *py_unreal_engine_add_on_screen_debug_message(PyObject * self, PyObject PyObject *stringified = PyObject_Str(py_message); if (!stringified) return PyErr_Format(PyExc_Exception, "argument cannot be casted to string"); - char *message = PyUnicode_AsUTF8(stringified); + const char *message = UEPyUnicode_AsUTF8(stringified); GEngine->AddOnScreenDebugMessage(key, time_to_display, FColor::Green, FString::Printf(TEXT("%s"), UTF8_TO_TCHAR(message))); Py_DECREF(stringified); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyObject *py_unreal_engine_print_string(PyObject * self, PyObject * args) @@ -127,7 +139,7 @@ PyObject *py_unreal_engine_print_string(PyObject * self, PyObject * args) PyObject *stringified = PyObject_Str(py_message); if (!stringified) return PyErr_Format(PyExc_Exception, "argument cannot be casted to string"); - char *message = PyUnicode_AsUTF8(stringified); + const char *message = UEPyUnicode_AsUTF8(stringified); GEngine->AddOnScreenDebugMessage(-1, timeout, color, FString(UTF8_TO_TCHAR(message))); @@ -165,12 +177,20 @@ PyObject *py_unreal_engine_get_up_vector(PyObject * self, PyObject * args) PyObject *py_unreal_engine_get_content_dir(PyObject * self, PyObject * args) { +#if ENGINE_MINOR_VERSION >= 18 + return PyUnicode_FromString(TCHAR_TO_UTF8(*FPaths::ProjectContentDir())); +#else return PyUnicode_FromString(TCHAR_TO_UTF8(*FPaths::GameContentDir())); +#endif } PyObject *py_unreal_engine_get_game_saved_dir(PyObject * self, PyObject * args) { +#if ENGINE_MINOR_VERSION >= 18 + return PyUnicode_FromString(TCHAR_TO_UTF8(*FPaths::ProjectSavedDir())); +#else return PyUnicode_FromString(TCHAR_TO_UTF8(*FPaths::GameSavedDir())); +#endif } PyObject * py_unreal_engine_get_game_user_developer_dir(PyObject *, PyObject *) @@ -297,11 +317,26 @@ PyObject *py_unreal_engine_unload_package(PyObject * self, PyObject * args) FText outErrorMsg; if (!PackageTools::UnloadPackages({ packageToUnload }, outErrorMsg)) { - return PyErr_Format(PyExc_Exception, TCHAR_TO_UTF8(*outErrorMsg.ToString())); + return PyErr_Format(PyExc_Exception, "%s", TCHAR_TO_UTF8(*outErrorMsg.ToString())); } Py_RETURN_NONE; } + +PyObject *py_unreal_engine_get_package_filename(PyObject * self, PyObject * args) +{ + char *name; + if (!PyArg_ParseTuple(args, "s:get_package_filename", &name)) + { + return NULL; + } + + FString Filename; + if (!FPackageName::DoesPackageExist(FString(UTF8_TO_TCHAR(name)), nullptr, &Filename)) + return PyErr_Format(PyExc_Exception, "package does not exist"); + + return PyUnicode_FromString(TCHAR_TO_UTF8(*Filename)); +} #endif PyObject *py_unreal_engine_load_class(PyObject * self, PyObject * args) @@ -432,7 +467,7 @@ PyObject *py_unreal_engine_string_to_guid(PyObject * self, PyObject * args) if (FGuid::Parse(FString(str), guid)) { - return py_ue_new_uscriptstruct(FindObject(ANY_PACKAGE, UTF8_TO_TCHAR((char *)"Guid")), (uint8 *)&guid); + return py_ue_new_owned_uscriptstruct(FindObject(ANY_PACKAGE, UTF8_TO_TCHAR((char *)"Guid")), (uint8 *)&guid); } return PyErr_Format(PyExc_Exception, "unable to build FGuid"); @@ -443,7 +478,7 @@ PyObject *py_unreal_engine_new_guid(PyObject * self, PyObject * args) FGuid guid = FGuid::NewGuid(); - return py_ue_new_uscriptstruct(FindObject(ANY_PACKAGE, UTF8_TO_TCHAR((char *)"Guid")), (uint8 *)&guid); + return py_ue_new_owned_uscriptstruct(FindObject(ANY_PACKAGE, UTF8_TO_TCHAR((char *)"Guid")), (uint8 *)&guid); } PyObject *py_unreal_engine_guid_to_string(PyObject * self, PyObject * args) @@ -463,25 +498,44 @@ PyObject *py_unreal_engine_guid_to_string(PyObject * self, PyObject * args) PyObject *py_unreal_engine_slate_tick(PyObject * self, PyObject * args) { + Py_BEGIN_ALLOW_THREADS; FSlateApplication::Get().PumpMessages(); FSlateApplication::Get().Tick(); + Py_END_ALLOW_THREADS; Py_RETURN_NONE; } PyObject *py_unreal_engine_engine_tick(PyObject * self, PyObject * args) { float delta_seconds = FApp::GetDeltaTime(); - PyObject *py_bool = nullptr; - if (!PyArg_ParseTuple(args, "|fO:engine_tick", &delta_seconds, &py_bool)) + PyObject *py_idle = nullptr; + if (!PyArg_ParseTuple(args, "|fO:engine_tick", &delta_seconds, &py_idle)) { - return NULL; + return nullptr; } - GEngine->Tick(delta_seconds, (py_bool && PyObject_IsTrue(py_bool)) ? true : false); + bool bIdle = false; + if (py_idle && PyObject_IsTrue(py_idle)) + bIdle = true; + + Py_BEGIN_ALLOW_THREADS; + GEngine->Tick(delta_seconds, bIdle); + Py_END_ALLOW_THREADS; Py_RETURN_NONE; } +#if WITH_EDITOR +PyObject *py_unreal_engine_tick_rendering_tickables(PyObject * self, PyObject * args) +{ + Py_BEGIN_ALLOW_THREADS; + TickRenderingTickables(); + Py_END_ALLOW_THREADS; + + Py_RETURN_NONE; +} +#endif + PyObject *py_unreal_engine_get_delta_time(PyObject * self, PyObject * args) { return PyFloat_FromDouble(FApp::GetDeltaTime()); @@ -514,21 +568,13 @@ PyObject *py_unreal_engine_new_object(PyObject * self, PyObject * args) uint64 flags = (uint64)(RF_Public); if (!PyArg_ParseTuple(args, "O|OsK:new_object", &obj, &py_outer, &name, &flags)) { - return NULL; - } - - if (!ue_is_pyuobject(obj)) - { - return PyErr_Format(PyExc_Exception, "argument is not a UObject"); + return nullptr; } - ue_PyUObject *py_obj = (ue_PyUObject *)obj; - - if (!py_obj->ue_object->IsA()) + UClass *obj_class = ue_py_check_type(obj); + if (!obj_class) return PyErr_Format(PyExc_Exception, "uobject is not a UClass"); - UClass *obj_class = (UClass *)py_obj->ue_object; - FName f_name = NAME_None; if (name && strlen(name) > 0) @@ -540,22 +586,21 @@ PyObject *py_unreal_engine_new_object(PyObject * self, PyObject * args) if (py_outer && py_outer != Py_None) { - if (!ue_is_pyuobject(py_outer)) - { + outer = ue_py_check_type(py_outer); + if (!outer) return PyErr_Format(PyExc_Exception, "argument is not a UObject"); - } - - ue_PyUObject *py_outer_obj = (ue_PyUObject *)py_outer; - - outer = py_outer_obj->ue_object; } - UObject *new_object = NewObject(outer, obj_class, f_name, (EObjectFlags)flags); + UObject *new_object = nullptr; + Py_BEGIN_ALLOW_THREADS; + new_object = NewObject(outer, obj_class, f_name, (EObjectFlags)flags); + if (new_object) + new_object->PostLoad(); + Py_END_ALLOW_THREADS; + if (!new_object) return PyErr_Format(PyExc_Exception, "unable to create object"); - new_object->PostLoad(); - Py_RETURN_UOBJECT(new_object); } @@ -563,7 +608,7 @@ PyObject *py_unreal_engine_get_mutable_default(PyObject * self, PyObject * args) { PyObject *obj; - if (!PyArg_ParseTuple(args, "O|Os:new_object", &obj)) + if (!PyArg_ParseTuple(args, "O|Os:get_mutable_default", &obj)) { return NULL; } @@ -679,7 +724,8 @@ PyObject *py_unreal_engine_tobject_iterator(PyObject * self, PyObject * args) PyObject *py_unreal_engine_create_and_dispatch_when_ready(PyObject * self, PyObject * args) { PyObject *py_callable; - if (!PyArg_ParseTuple(args, "O:create_and_dispatch_when_ready", &py_callable)) + int named_thread = (int)ENamedThreads::GameThread; + if (!PyArg_ParseTuple(args, "O|i:create_and_dispatch_when_ready", &py_callable, &named_thread)) { return NULL; } @@ -689,6 +735,7 @@ PyObject *py_unreal_engine_create_and_dispatch_when_ready(PyObject * self, PyObj Py_INCREF(py_callable); + FGraphEventRef task = FFunctionGraphTask::CreateAndDispatchWhenReady([&]() { FScopePythonGIL gil; PyObject *ret = PyObject_CallObject(py_callable, nullptr); @@ -701,16 +748,56 @@ PyObject *py_unreal_engine_create_and_dispatch_when_ready(PyObject * self, PyObj unreal_engine_py_log_error(); } Py_DECREF(py_callable); - }, TStatId(), nullptr, ENamedThreads::GameThread); + }, TStatId(), nullptr, (ENamedThreads::Type)named_thread); + + Py_BEGIN_ALLOW_THREADS; FTaskGraphInterface::Get().WaitUntilTaskCompletes(task); + Py_END_ALLOW_THREADS; // TODO Implement signal triggering in addition to WaitUntilTaskCompletes // FTaskGraphInterface::Get().TriggerEventWhenTaskCompletes - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } + +#if PLATFORM_MAC +PyObject *py_unreal_engine_main_thread_call(PyObject * self, PyObject * args) +{ + PyObject *py_callable; + if (!PyArg_ParseTuple(args, "O|:main_thread_call", &py_callable)) + { + return NULL; + } + + if (!PyCallable_Check(py_callable)) + return PyErr_Format(PyExc_TypeError, "argument is not callable"); + + Py_INCREF(py_callable); + + Py_BEGIN_ALLOW_THREADS; + MainThreadCall(^{ + FScopePythonGIL gil; + PyObject *ret = PyObject_CallObject(py_callable, nullptr); + if (ret) + { + Py_DECREF(ret); + } + else + { + unreal_engine_py_log_error(); + } + Py_DECREF(py_callable); + }); + Py_END_ALLOW_THREADS; + + Py_RETURN_NONE; +} +#endif + + + + PyObject *py_unreal_engine_get_game_viewport_size(PyObject *self, PyObject * args) { @@ -1237,13 +1324,21 @@ PyObject *py_unreal_engine_clipboard_copy(PyObject * self, PyObject * args) return nullptr; } +#if ENGINE_MINOR_VERSION >= 18 + FPlatformApplicationMisc::ClipboardCopy(UTF8_TO_TCHAR(text)); +#else FGenericPlatformMisc::ClipboardCopy(UTF8_TO_TCHAR(text)); +#endif Py_RETURN_NONE; } PyObject *py_unreal_engine_clipboard_paste(PyObject * self, PyObject * args) { FString clipboard; +#if ENGINE_MINOR_VERSION >= 18 + FPlatformApplicationMisc::ClipboardPaste(clipboard); +#else FGenericPlatformMisc::ClipboardPaste(clipboard); +#endif return PyUnicode_FromString(TCHAR_TO_UTF8(*clipboard)); -} \ No newline at end of file +} diff --git a/Source/UnrealEnginePython/Private/UEPyEngine.h b/Source/UnrealEnginePython/Private/UEPyEngine.h index 40e78f182..6a95cbb01 100644 --- a/Source/UnrealEnginePython/Private/UEPyEngine.h +++ b/Source/UnrealEnginePython/Private/UEPyEngine.h @@ -2,7 +2,7 @@ -#include "UnrealEnginePython.h" +#include "UEPyModule.h" PyObject *py_unreal_engine_log(PyObject *, PyObject *); PyObject *py_unreal_engine_log_warning(PyObject *, PyObject *); @@ -37,6 +37,7 @@ PyObject *py_unreal_engine_load_enum(PyObject *, PyObject *); PyObject *py_unreal_engine_load_package(PyObject *, PyObject *); #if WITH_EDITOR PyObject *py_unreal_engine_unload_package(PyObject *, PyObject *); +PyObject *py_unreal_engine_get_package_filename(PyObject *, PyObject *); #endif PyObject *py_unreal_engine_string_to_guid(PyObject *, PyObject *); @@ -47,6 +48,8 @@ PyObject *py_unreal_engine_engine_tick(PyObject *, PyObject *); PyObject *py_unreal_engine_slate_tick(PyObject *, PyObject *); PyObject *py_unreal_engine_get_delta_time(PyObject *, PyObject *); +PyObject *py_unreal_engine_tick_rendering_tickables(PyObject *, PyObject *); + PyObject *py_unreal_engine_all_classes(PyObject *, PyObject *); PyObject *py_unreal_engine_all_worlds(PyObject *, PyObject *); PyObject *py_unreal_engine_tobject_iterator(PyObject *, PyObject *); @@ -93,4 +96,6 @@ PyObject *py_unreal_engine_editor_get_pie_viewport_size(PyObject *, PyObject *); #endif - +#if PLATFORM_MAC +PyObject *py_unreal_engine_main_thread_call(PyObject *, PyObject *); +#endif diff --git a/Source/UnrealEnginePython/Private/UEPyEnumsImporter.cpp b/Source/UnrealEnginePython/Private/UEPyEnumsImporter.cpp index a502e6325..403865174 100644 --- a/Source/UnrealEnginePython/Private/UEPyEnumsImporter.cpp +++ b/Source/UnrealEnginePython/Private/UEPyEnumsImporter.cpp @@ -1,4 +1,4 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPyEnumsImporter.h" static PyObject *ue_PyEnumsImporter_getattro(ue_PyEnumsImporter *self, PyObject *attr_name) { @@ -7,7 +7,7 @@ static PyObject *ue_PyEnumsImporter_getattro(ue_PyEnumsImporter *self, PyObject { if (PyUnicodeOrString_Check(attr_name)) { - char *attr = PyUnicode_AsUTF8(attr_name); + const char *attr = UEPyUnicode_AsUTF8(attr_name); if (attr[0] != '_') { UEnum *u_enum = FindObject(ANY_PACKAGE, UTF8_TO_TCHAR(attr)); diff --git a/Source/UnrealEnginePython/Private/UEPyEnumsImporter.h b/Source/UnrealEnginePython/Private/UEPyEnumsImporter.h index 3e4fddc28..03daf1d99 100644 --- a/Source/UnrealEnginePython/Private/UEPyEnumsImporter.h +++ b/Source/UnrealEnginePython/Private/UEPyEnumsImporter.h @@ -2,11 +2,12 @@ -#include "UnrealEnginePython.h" +#include "UEPyModule.h" -typedef struct { +typedef struct +{ PyObject_HEAD - /* Type-specific fields go here. */ + /* Type-specific fields go here. */ } ue_PyEnumsImporter; PyObject *py_ue_new_enumsimporter(); diff --git a/Source/UnrealEnginePython/Private/UEPyIPlugin.cpp b/Source/UnrealEnginePython/Private/UEPyIPlugin.cpp index bee1b113a..d178b3f83 100644 --- a/Source/UnrealEnginePython/Private/UEPyIPlugin.cpp +++ b/Source/UnrealEnginePython/Private/UEPyIPlugin.cpp @@ -1,8 +1,8 @@ +#include "UEPyIPlugin.h" #if WITH_EDITOR -#include "UnrealEnginePythonPrivatePCH.h" #include "Runtime/Projects/Public/Interfaces/IPluginManager.h" static PyObject *py_ue_iplugin_get_name(ue_PyIPlugin *self, PyObject * args) diff --git a/Source/UnrealEnginePython/Private/UEPyIPlugin.h b/Source/UnrealEnginePython/Private/UEPyIPlugin.h index b822a3bef..2f550eeaf 100644 --- a/Source/UnrealEnginePython/Private/UEPyIPlugin.h +++ b/Source/UnrealEnginePython/Private/UEPyIPlugin.h @@ -1,15 +1,18 @@ #pragma once +#include "UEPyModule.h" + #if WITH_EDITOR -#include "UnrealEnginePython.h" + #include "Runtime/Projects/Public/Interfaces/IPluginManager.h" -typedef struct { +typedef struct +{ PyObject_HEAD - /* Type-specific fields go here. */ - IPlugin *plugin; + /* Type-specific fields go here. */ + IPlugin *plugin; } ue_PyIPlugin; PyObject *py_ue_new_iplugin(IPlugin *); diff --git a/Source/UnrealEnginePython/Private/UEPyModule.cpp b/Source/UnrealEnginePython/Private/UEPyModule.cpp index a356275f4..56954d32e 100644 --- a/Source/UnrealEnginePython/Private/UEPyModule.cpp +++ b/Source/UnrealEnginePython/Private/UEPyModule.cpp @@ -1,4 +1,4 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPyModule.h" #include "UEPyEngine.h" #include "UEPyTimer.h" @@ -36,6 +36,7 @@ #include "UObject/UEPyUserDefinedStruct.h" #include "UObject/UEPyDataTable.h" #include "UObject/UEPyExporter.h" +#include "UObject/UEPyFoliage.h" #include "UEPyAssetUserData.h" @@ -47,12 +48,74 @@ #include "Editor/BlueprintGraph/Public/BlueprintActionDatabase.h" #endif +#include "Wrappers/UEPyESlateEnums.h" + +#include "Wrappers/UEPyFVector.h" +#include "Wrappers/UEPyFVector2D.h" +#include "Wrappers/UEPyFHitResult.h" +#include "Wrappers/UEPyFRotator.h" +#include "Wrappers/UEPyFTransform.h" +#include "Wrappers/UEPyFColor.h" +#include "Wrappers/UEPyFLinearColor.h" +#include "Wrappers/UEPyFSocket.h" +#include "Wrappers/UEPyFQuat.h" + +#include "Wrappers/UEPyFRawAnimSequenceTrack.h" + +#include "Wrappers/UEPyFRandomStream.h" + +#include "Wrappers/UEPyFPythonOutputDevice.h" +#if WITH_EDITOR +#include "Wrappers/UEPyFSoftSkinVertex.h" +#endif +#include "Wrappers/UEPyFMorphTargetDelta.h" +#include "Wrappers/UEPyFObjectThumbnail.h" + +#include "Wrappers/UEPyFViewportClient.h" +#if WITH_EDITOR +#include "Wrappers/UEPyFEditorViewportClient.h" +#include "Wrappers/UEPyIAssetEditorInstance.h" +#endif + +#include "Wrappers/UEPyFFoliageInstance.h" + +#include "UEPyCallable.h" +#include "UEPyUClassesImporter.h" +#include "UEPyEnumsImporter.h" +#include "UEPyUStructsImporter.h" + +#include "UEPyUScriptStruct.h" + +#if WITH_EDITOR +#include "Wrappers/UEPyFSlowTask.h" +#include "Wrappers/UEPyFAssetData.h" +#include "Wrappers/UEPyFARFilter.h" +#include "Wrappers/UEPyFRawMesh.h" +#include "Wrappers/UEPyFStringAssetReference.h" + +#include "UObject/UEPyAnimSequence.h" +#include "Blueprint/UEPyEdGraphPin.h" +#include "UEPyIPlugin.h" +#include "CollectionManager/UEPyICollectionManager.h" +#include "MaterialEditorUtilities/UEPyFMaterialEditorUtilities.h" +#endif + +#include "Wrappers/UEPyFFrameNumber.h" + +#include "Slate/UEPySlate.h" +#include "Http/UEPyIHttp.h" +#include "ConsoleManager/UEPyIConsoleManager.h" +#include "SlateApplication/UEPyFSlateApplication.h" +#include "Voice/UEPyIVoiceCapture.h" -#include "PythonDelegate.h" #include "PythonFunction.h" #include "PythonClass.h" -#include "Slate/UEPySlate.h" +#if ENGINE_MINOR_VERSION >= 15 +#include "Engine/UserDefinedEnum.h" +#endif + +#include "Runtime/Core/Public/UObject/PropertyPortFlags.h" #if ENGINE_MINOR_VERSION < 18 #define USoftObjectProperty UAssetObjectProperty @@ -74,7 +137,7 @@ static PyModuleDef unreal_engine_module = { -1, NULL, }; -static PyObject *init_unreal_engine(void); +static PyObject* init_unreal_engine(void); @@ -85,39 +148,45 @@ void init_unreal_engine_builtin() #endif -static PyObject *py_unreal_engine_py_gc(PyObject * self, PyObject * args) +static PyObject* py_unreal_engine_py_gc(PyObject* self, PyObject* args) { int32 Garbaged = FUnrealEnginePythonHouseKeeper::Get()->RunGC(); return PyLong_FromLong(Garbaged); } -static PyObject *py_unreal_engine_exec(PyObject * self, PyObject * args) +static PyObject* py_unreal_engine_exec(PyObject* self, PyObject* args) { - char *filename = nullptr; + char* filename = nullptr; if (!PyArg_ParseTuple(args, "s:exec", &filename)) { return NULL; } - FUnrealEnginePythonModule &PythonModule = FModuleManager::GetModuleChecked("UnrealEnginePython"); + FUnrealEnginePythonModule& PythonModule = FModuleManager::GetModuleChecked("UnrealEnginePython"); + Py_BEGIN_ALLOW_THREADS; PythonModule.RunFile(filename); - Py_INCREF(Py_None); - return Py_None; + Py_END_ALLOW_THREADS; + Py_RETURN_NONE; } -static PyObject *py_unreal_engine_sandbox_exec(PyObject * self, PyObject * args) + +#if PLATFORM_MAC +static PyObject* py_unreal_engine_exec_in_main_thread(PyObject* self, PyObject* args) { - char *filename = nullptr; - if (!PyArg_ParseTuple(args, "s:sandbox_exec", &filename)) + char* filename = nullptr; + if (!PyArg_ParseTuple(args, "s:exec_in_main_thread", &filename)) { return NULL; } - FUnrealEnginePythonModule &PythonModule = FModuleManager::GetModuleChecked("UnrealEnginePython"); - PythonModule.RunFileSandboxed(filename, nullptr, nullptr); + FUnrealEnginePythonModule& PythonModule = FModuleManager::GetModuleChecked("UnrealEnginePython"); + Py_BEGIN_ALLOW_THREADS; + PythonModule.RunFileInMainThread(filename); + Py_END_ALLOW_THREADS; Py_RETURN_NONE; } +#endif -static PyObject *py_ue_get_py_proxy(ue_PyUObject *self, PyObject * args) +static PyObject* py_ue_get_py_proxy(ue_PyUObject* self, PyObject* args) { ue_py_check(self); @@ -125,10 +194,33 @@ static PyObject *py_ue_get_py_proxy(ue_PyUObject *self, PyObject * args) if (self->py_proxy) { Py_INCREF(self->py_proxy); - UE_LOG(LogPython, Error, TEXT("PROXY %d"), self->py_proxy->ob_refcnt); - return (PyObject *)self->py_proxy; + return (PyObject*)self->py_proxy; + } + + Py_RETURN_NONE; +} + +static PyObject* py_unreal_engine_shutdown(PyObject* self, PyObject* args) +{ + + GIsRequestingExit = true; + + Py_RETURN_NONE; +} + +static PyObject* py_unreal_engine_set_brutal_finalize(PyObject* self, PyObject* args) +{ + + PyObject* py_bool = nullptr; + if (!PyArg_ParseTuple(args, "|O:set_brutal_finalize", &py_bool)) + { + return nullptr; } + bool bBrutalFinalize = !py_bool || PyObject_IsTrue(py_bool); + + FUnrealEnginePythonModule& PythonModule = FModuleManager::GetModuleChecked("UnrealEnginePython"); + PythonModule.BrutalFinalize = bBrutalFinalize; Py_RETURN_NONE; } @@ -137,6 +229,9 @@ static PyMethodDef unreal_engine_methods[] = { { "log_warning", py_unreal_engine_log_warning, METH_VARARGS, "" }, { "log_error", py_unreal_engine_log_error, METH_VARARGS, "" }, + { "shutdown", py_unreal_engine_shutdown, METH_VARARGS, "" }, + { "set_brutal_finalize", py_unreal_engine_set_brutal_finalize, METH_VARARGS, "" }, + { "add_on_screen_debug_message", py_unreal_engine_add_on_screen_debug_message, METH_VARARGS, "" }, { "print_string", py_unreal_engine_print_string, METH_VARARGS, "" }, @@ -156,6 +251,7 @@ static PyMethodDef unreal_engine_methods[] = { { "load_package", py_unreal_engine_load_package, METH_VARARGS, "" }, #if WITH_EDITOR { "unload_package", py_unreal_engine_unload_package, METH_VARARGS, "" }, + { "get_package_filename", py_unreal_engine_get_package_filename, METH_VARARGS, "" }, #endif { "get_forward_vector", py_unreal_engine_get_forward_vector, METH_VARARGS, "" }, { "get_up_vector", py_unreal_engine_get_up_vector, METH_VARARGS, "" }, @@ -209,6 +305,9 @@ static PyMethodDef unreal_engine_methods[] = { { "add_asset_view_context_menu_extension", py_unreal_engine_add_asset_view_context_menu_extension, METH_VARARGS, "" }, + { "redraw_all_viewports", py_unreal_engine_redraw_all_viewports, METH_VARARGS, "" }, + { "update_ui", py_unreal_engine_update_ui, METH_VARARGS, "" }, + #pragma warning(suppress: 4191) { "create_detail_view", (PyCFunction)py_unreal_engine_create_detail_view, METH_VARARGS | METH_KEYWORDS, "" }, #pragma warning(suppress: 4191) @@ -217,6 +316,8 @@ static PyMethodDef unreal_engine_methods[] = { { "create_property_view", (PyCFunction)py_unreal_engine_create_property_view, METH_VARARGS | METH_KEYWORDS, "" }, { "open_editor_for_asset", py_unreal_engine_open_editor_for_asset, METH_VARARGS, "" }, + { "find_editor_for_asset", py_unreal_engine_find_editor_for_asset, METH_VARARGS, "" }, + { "get_all_edited_assets", py_unreal_engine_get_all_edited_assets, METH_VARARGS, "" }, { "close_editor_for_asset", py_unreal_engine_close_editor_for_asset, METH_VARARGS, "" }, { "close_all_asset_editors", py_unreal_engine_close_all_asset_editors, METH_VARARGS, "" }, { "allow_actor_script_execution_in_editor", py_unreal_engine_allow_actor_script_execution_in_editor , METH_VARARGS, "" }, @@ -229,14 +330,19 @@ static PyMethodDef unreal_engine_methods[] = { { "export_assets", py_unreal_engine_export_assets, METH_VARARGS, "" }, { "get_asset", py_unreal_engine_get_asset, METH_VARARGS, "" }, { "find_asset", py_unreal_engine_find_asset, METH_VARARGS, "" }, + { "create_asset", py_unreal_engine_create_asset, METH_VARARGS, "" }, { "delete_object", py_unreal_engine_delete_object, METH_VARARGS, "" }, { "get_assets", py_unreal_engine_get_assets, METH_VARARGS, "" }, { "get_selected_assets", py_unreal_engine_get_selected_assets, METH_VARARGS, "" }, { "get_assets_by_class", py_unreal_engine_get_assets_by_class, METH_VARARGS, "" }, + { "is_loading_assets", py_unreal_engine_is_loading_assets, METH_VARARGS, "" }, + { "wait_for_assets", py_unreal_engine_wait_for_assets, METH_VARARGS, "" }, + { "sync_browser_to_assets", py_unreal_engine_editor_sync_browser_to_assets, METH_VARARGS, "" }, { "get_asset_referencers", py_unreal_engine_get_asset_referencers, METH_VARARGS, "" }, + { "get_asset_identifier_referencers", py_unreal_engine_get_asset_identifier_referencers, METH_VARARGS, "" }, { "get_asset_dependencies", py_unreal_engine_get_asset_dependencies, METH_VARARGS, "" }, { "rename_asset", py_unreal_engine_rename_asset, METH_VARARGS, "" }, @@ -244,6 +350,7 @@ static PyMethodDef unreal_engine_methods[] = { { "delete_asset", py_unreal_engine_delete_asset, METH_VARARGS, "" }, { "get_long_package_path", py_unreal_engine_get_long_package_path, METH_VARARGS, "" }, + { "get_long_package_asset_name", py_unreal_engine_get_long_package_asset_name, METH_VARARGS, "" }, { "editor_command_build", py_unreal_engine_editor_command_build, METH_VARARGS, "" }, { "editor_command_build_lighting", py_unreal_engine_editor_command_build_lighting, METH_VARARGS, "" }, @@ -282,6 +389,7 @@ static PyMethodDef unreal_engine_methods[] = { { "blueprint_get_all_graphs", py_unreal_engine_blueprint_get_all_graphs, METH_VARARGS, "" }, { "blueprint_mark_as_structurally_modified", py_unreal_engine_blueprint_mark_as_structurally_modified, METH_VARARGS, "" }, { "add_component_to_blueprint", py_unreal_engine_add_component_to_blueprint, METH_VARARGS, "" }, + { "remove_component_from_blueprint", py_unreal_engine_remove_component_from_blueprint, METH_VARARGS, "" }, { "get_blueprint_components", py_unreal_engine_get_blueprint_components, METH_VARARGS, "" }, { "create_material_instance", py_unreal_engine_create_material_instance, METH_VARARGS, "" }, { "message_dialog_open", py_unreal_engine_message_dialog_open, METH_VARARGS, "" }, @@ -297,6 +405,7 @@ static PyMethodDef unreal_engine_methods[] = { { "move_actor_to_level", py_unreal_engine_move_actor_to_level, METH_VARARGS, "" }, { "editor_on_asset_post_import", py_unreal_engine_editor_on_asset_post_import, METH_VARARGS, "" }, + { "on_main_frame_creation_finished", py_unreal_engine_on_main_frame_creation_finished, METH_VARARGS, "" }, // transactions @@ -316,7 +425,9 @@ static PyMethodDef unreal_engine_methods[] = { #endif { "engine_tick", py_unreal_engine_engine_tick, METH_VARARGS, "" }, + #if WITH_EDITOR + { "tick_rendering_tickables", py_unreal_engine_tick_rendering_tickables, METH_VARARGS, "" }, { "all_viewport_clients", py_unreal_engine_all_viewport_clients , METH_VARARGS, "" }, #endif { "slate_tick", py_unreal_engine_slate_tick, METH_VARARGS, "" }, @@ -335,6 +446,9 @@ static PyMethodDef unreal_engine_methods[] = { { "create_and_dispatch_when_ready", py_unreal_engine_create_and_dispatch_when_ready, METH_VARARGS, "" }, +#if PLATFORM_MAC + { "main_thread_call", py_unreal_engine_main_thread_call, METH_VARARGS, "" }, +#endif { "add_ticker", py_unreal_engine_add_ticker, METH_VARARGS, "" }, { "remove_ticker", py_unreal_engine_remove_ticker, METH_VARARGS, "" }, @@ -345,8 +459,10 @@ static PyMethodDef unreal_engine_methods[] = { { "exec", py_unreal_engine_exec, METH_VARARGS, "" }, #endif { "py_exec", py_unreal_engine_exec, METH_VARARGS, "" }, - - { "sandbox_exec", py_unreal_engine_sandbox_exec, METH_VARARGS, "" }, +#if PLATFORM_MAC + { "exec_in_main_thread", py_unreal_engine_exec_in_main_thread, METH_VARARGS, "" }, + { "py_exec_in_main_thread", py_unreal_engine_exec_in_main_thread, METH_VARARGS, "" }, +#endif { "get_engine_defined_action_mappings", py_unreal_engine_get_engine_defined_action_mappings, METH_VARARGS, "" }, @@ -387,6 +503,7 @@ static PyMethodDef unreal_engine_methods[] = { { "clipboard_copy", py_unreal_engine_clipboard_copy, METH_VARARGS, "" }, { "clipboard_paste", py_unreal_engine_clipboard_paste, METH_VARARGS, "" }, + #pragma warning(suppress: 4191) { "copy_properties_for_unrelated_objects", (PyCFunction)py_unreal_engine_copy_properties_for_unrelated_objects, METH_VARARGS | METH_KEYWORDS, "" }, @@ -454,6 +571,10 @@ static PyMethodDef ue_PyUObject_methods[] = { { "has_property", (PyCFunction)py_ue_has_property, METH_VARARGS, "" }, { "get_uproperty", (PyCFunction)py_ue_get_uproperty, METH_VARARGS, "" }, { "get_property_struct", (PyCFunction)py_ue_get_property_struct, METH_VARARGS, "" }, + { "get_property_array_dim", (PyCFunction)py_ue_get_property_array_dim, METH_VARARGS, "" }, + { "get_inner", (PyCFunction)py_ue_get_inner, METH_VARARGS, "" }, + { "get_key_prop", (PyCFunction)py_ue_get_key_prop, METH_VARARGS, "" }, + { "get_value_prop", (PyCFunction)py_ue_get_value_prop, METH_VARARGS, "" }, { "functions", (PyCFunction)py_ue_functions, METH_VARARGS, "" }, @@ -487,6 +608,8 @@ static PyMethodDef ue_PyUObject_methods[] = { { "set_name", (PyCFunction)py_ue_set_name, METH_VARARGS, "" }, { "bind_event", (PyCFunction)py_ue_bind_event, METH_VARARGS, "" }, + { "unbind_event", (PyCFunction)py_ue_unbind_event, METH_VARARGS, "" }, + { "delegate_bind_ufunction", (PyCFunction)py_ue_delegate_bind_ufunction, METH_VARARGS, "" }, { "get_py_proxy", (PyCFunction)py_ue_get_py_proxy, METH_VARARGS, "" }, @@ -498,14 +621,30 @@ static PyMethodDef ue_PyUObject_methods[] = { #if WITH_EDITOR { "get_thumbnail", (PyCFunction)py_ue_get_thumbnail, METH_VARARGS, "" }, { "render_thumbnail", (PyCFunction)py_ue_render_thumbnail, METH_VARARGS, "" }, + {"get_metadata_tag", (PyCFunction)py_ue_get_metadata_tag, METH_VARARGS, "" }, + {"set_metadata_tag", (PyCFunction)py_ue_set_metadata_tag, METH_VARARGS, "" }, + { "metadata_tags", (PyCFunction)py_ue_metadata_tags, METH_VARARGS, "" }, + { "has_metadata_tag", (PyCFunction)py_ue_has_metadata_tag, METH_VARARGS, "" }, + {"remove_metadata_tag", (PyCFunction)py_ue_remove_metadata_tag, METH_VARARGS, "" }, + #endif #if WITH_EDITOR { "save_config", (PyCFunction)py_ue_save_config, METH_VARARGS, "" }, { "get_actor_label", (PyCFunction)py_ue_get_actor_label, METH_VARARGS, "" }, { "set_actor_label", (PyCFunction)py_ue_set_actor_label, METH_VARARGS, "" }, + { "set_actor_hidden_in_game", (PyCFunction)py_ue_set_actor_hidden_in_game, METH_VARARGS, "" }, + + { "get_folder_path", (PyCFunction)py_ue_get_folder_path, METH_VARARGS, "" }, + { "set_folder_path", (PyCFunction)py_ue_set_folder_path, METH_VARARGS, "" }, + + { "world_create_folder", (PyCFunction)py_ue_world_create_folder, METH_VARARGS, "" }, + { "world_delete_folder", (PyCFunction)py_ue_world_delete_folder, METH_VARARGS, "" }, + { "world_rename_folder", (PyCFunction)py_ue_world_rename_folder, METH_VARARGS, "" }, + { "world_folders", (PyCFunction)py_ue_world_folders, METH_VARARGS, "" }, { "get_editor_world_counterpart_actor", (PyCFunction)py_ue_get_editor_world_counterpart_actor, METH_VARARGS, "" }, + { "component_type_registry_invalidate_class", (PyCFunction)py_ue_component_type_registry_invalidate_class, METH_VARARGS, "" }, { "find_actor_by_label", (PyCFunction)py_ue_find_actor_by_label, METH_VARARGS, "" }, { "save_package", (PyCFunction)py_ue_save_package, METH_VARARGS, "" }, @@ -522,13 +661,21 @@ static PyMethodDef ue_PyUObject_methods[] = { { "graph_add_node_variable_set", (PyCFunction)py_ue_graph_add_node_variable_set, METH_VARARGS, "" }, { "graph_add_node", (PyCFunction)py_ue_graph_add_node, METH_VARARGS, "" }, + { "graph_add_node_dynamic_cast", (PyCFunction)py_ue_graph_add_node_dynamic_cast, METH_VARARGS, "" }, { "graph_add_node_event", (PyCFunction)py_ue_graph_add_node_event, METH_VARARGS, "" }, { "graph_get_good_place_for_new_node", (PyCFunction)py_ue_graph_get_good_place_for_new_node, METH_VARARGS, "" }, + { "graph_reconstruct_node", (PyCFunction)py_ue_graph_reconstruct_node, METH_VARARGS, "" }, + { "graph_remove_node", (PyCFunction)py_ue_graph_remove_node, METH_VARARGS, "" }, + { "node_pins", (PyCFunction)py_ue_node_pins, METH_VARARGS, "" }, { "node_get_title", (PyCFunction)py_ue_node_get_title, METH_VARARGS, "" }, { "node_find_pin", (PyCFunction)py_ue_node_find_pin, METH_VARARGS, "" }, { "node_create_pin", (PyCFunction)py_ue_node_create_pin, METH_VARARGS, "" }, + { "node_pin_type_changed", (PyCFunction)py_ue_node_pin_type_changed, METH_VARARGS, "" }, + { "node_pin_default_value_changed", (PyCFunction)py_ue_node_pin_default_value_changed, METH_VARARGS, "" }, + + { "node_function_entry_set_pure", (PyCFunction)py_ue_node_function_entry_set_pure, METH_VARARGS, "" }, { "node_allocate_default_pins", (PyCFunction)py_ue_node_allocate_default_pins, METH_VARARGS, "" }, { "node_reconstruct", (PyCFunction)py_ue_node_reconstruct, METH_VARARGS, "" }, @@ -557,6 +704,10 @@ static PyMethodDef ue_PyUObject_methods[] = { { "auto_root", (PyCFunction)py_ue_auto_root, METH_VARARGS, "" }, { "remove_from_root", (PyCFunction)py_ue_remove_from_root, METH_VARARGS, "" }, + { "own", (PyCFunction)py_ue_own, METH_VARARGS, "" }, + { "disown", (PyCFunction)py_ue_disown, METH_VARARGS, "" }, + { "is_owned", (PyCFunction)py_ue_is_owned, METH_VARARGS, "" }, + { "find_function", (PyCFunction)py_ue_find_function, METH_VARARGS, "" }, #pragma warning(suppress: 4191) @@ -584,11 +735,21 @@ static PyMethodDef ue_PyUObject_methods[] = { { "get_blend_parameter", (PyCFunction)py_ue_get_blend_parameter, METH_VARARGS, "" }, { "set_blend_parameter", (PyCFunction)py_ue_set_blend_parameter, METH_VARARGS, "" }, + { "get_bone_transform", (PyCFunction)py_ue_anim_get_bone_transform, METH_VARARGS, "" }, + { "extract_bone_transform", (PyCFunction)py_ue_anim_extract_bone_transform, METH_VARARGS, "" }, + { "extract_root_motion", (PyCFunction)py_ue_anim_extract_root_motion, METH_VARARGS, "" }, + #if WITH_EDITOR #if ENGINE_MINOR_VERSION > 13 { "get_raw_animation_data", (PyCFunction)py_ue_anim_sequence_get_raw_animation_data, METH_VARARGS, "" }, { "get_raw_animation_track", (PyCFunction)py_ue_anim_sequence_get_raw_animation_track, METH_VARARGS, "" }, { "add_new_raw_track", (PyCFunction)py_ue_anim_sequence_add_new_raw_track, METH_VARARGS, "" }, +#if ENGINE_MINOR_VERSION <23 + { "update_compressed_track_map_from_raw", (PyCFunction)py_ue_anim_sequence_update_compressed_track_map_from_raw, METH_VARARGS, "" }, +#endif + { "update_raw_track", (PyCFunction)py_ue_anim_sequence_update_raw_track, METH_VARARGS, "" }, + { "apply_raw_anim_changes", (PyCFunction)py_ue_anim_sequence_apply_raw_anim_changes, METH_VARARGS, "" }, + { "add_key_to_sequence", (PyCFunction)py_ue_anim_add_key_to_sequence, METH_VARARGS, "" }, #endif { "add_anim_composite_section", (PyCFunction)py_ue_add_anim_composite_section, METH_VARARGS, "" }, #endif @@ -598,6 +759,7 @@ static PyMethodDef ue_PyUObject_methods[] = { { "vlog_cylinder", (PyCFunction)py_ue_vlog_cylinder, METH_VARARGS, "" }, // StaticMesh + { "get_static_mesh_bounds", (PyCFunction)py_ue_static_mesh_get_bounds, METH_VARARGS, "" }, #if WITH_EDITOR { "static_mesh_build", (PyCFunction)py_ue_static_mesh_build, METH_VARARGS, "" }, { "static_mesh_create_body_setup", (PyCFunction)py_ue_static_mesh_create_body_setup, METH_VARARGS, "" }, @@ -660,6 +822,8 @@ static PyMethodDef ue_PyUObject_methods[] = { { "class_set_flags", (PyCFunction)py_ue_class_set_flags, METH_VARARGS, "" }, { "get_obj_flags", (PyCFunction)py_ue_get_obj_flags, METH_VARARGS, "" }, { "set_obj_flags", (PyCFunction)py_ue_set_obj_flags, METH_VARARGS, "" }, + { "clear_obj_flags", (PyCFunction)py_ue_clear_obj_flags, METH_VARARGS, "" }, + { "reset_obj_flags", (PyCFunction)py_ue_reset_obj_flags, METH_VARARGS, "" }, #if WITH_EDITOR { "class_get_config_name", (PyCFunction)py_ue_class_get_config_name, METH_VARARGS, "" }, @@ -706,6 +870,7 @@ static PyMethodDef ue_PyUObject_methods[] = { #pragma warning(suppress: 4191) { "actor_spawn", (PyCFunction)py_ue_actor_spawn, METH_VARARGS | METH_KEYWORDS, "" }, { "actor_has_tag", (PyCFunction)py_ue_actor_has_tag, METH_VARARGS, "" }, + { "component_has_tag", (PyCFunction)py_ue_component_has_tag, METH_VARARGS, "" }, { "get_actor_bounds", (PyCFunction)py_ue_get_actor_bounds, METH_VARARGS, "" }, { "line_trace_single_by_channel", (PyCFunction)py_ue_line_trace_single_by_channel, METH_VARARGS, "" }, @@ -723,9 +888,13 @@ static PyMethodDef ue_PyUObject_methods[] = { { "set_current_level", (PyCFunction)py_ue_set_current_level, METH_VARARGS, "" }, #if WITH_EDITOR + { "get_level_script_blueprint", (PyCFunction)py_ue_get_level_script_blueprint, METH_VARARGS, "" }, { "add_foliage_asset", (PyCFunction)py_ue_add_foliage_asset, METH_VARARGS, "" }, + { "get_foliage_instances", (PyCFunction)py_ue_get_foliage_instances, METH_VARARGS, "" }, #endif { "get_instanced_foliage_actor_for_current_level", (PyCFunction)py_ue_get_instanced_foliage_actor_for_current_level, METH_VARARGS, "" }, + { "get_instanced_foliage_actor_for_level", (PyCFunction)py_ue_get_instanced_foliage_actor_for_level, METH_VARARGS, "" }, + { "get_foliage_types", (PyCFunction)py_ue_get_foliage_types, METH_VARARGS, "" }, { "add_actor_component", (PyCFunction)py_ue_add_actor_component, METH_VARARGS, "" }, @@ -733,11 +902,17 @@ static PyMethodDef ue_PyUObject_methods[] = { { "get_actor_root_component", (PyCFunction)py_ue_get_actor_root_component, METH_VARARGS, "" }, { "add_actor_root_component", (PyCFunction)py_ue_add_actor_root_component, METH_VARARGS, "" }, { "get_actor_component_by_type", (PyCFunction)py_ue_get_actor_component_by_type, METH_VARARGS, "" }, + { "get_actor_component_by_class", (PyCFunction)py_ue_get_actor_component_by_type, METH_VARARGS, "" }, { "get_component_by_type", (PyCFunction)py_ue_get_actor_component_by_type, METH_VARARGS, "" }, + { "get_component_by_class", (PyCFunction)py_ue_get_actor_component_by_type, METH_VARARGS, "" }, { "get_component", (PyCFunction)py_ue_get_actor_component, METH_VARARGS, "" }, { "get_actor_component", (PyCFunction)py_ue_get_actor_component, METH_VARARGS, "" }, { "get_actor_components_by_type", (PyCFunction)py_ue_get_actor_components_by_type, METH_VARARGS, "" }, { "get_components_by_type", (PyCFunction)py_ue_get_actor_components_by_type, METH_VARARGS, "" }, + { "get_actor_components_by_class", (PyCFunction)py_ue_get_actor_components_by_type, METH_VARARGS, "" }, + { "get_components_by_class", (PyCFunction)py_ue_get_actor_components_by_type, METH_VARARGS, "" }, + { "get_actor_components_by_tag", (PyCFunction)py_ue_get_actor_components_by_tag, METH_VARARGS, "" }, + { "get_components_by_tag", (PyCFunction)py_ue_get_actor_components_by_tag, METH_VARARGS, "" }, { "add_python_component", (PyCFunction)py_ue_add_python_component, METH_VARARGS, "" }, @@ -756,9 +931,13 @@ static PyMethodDef ue_PyUObject_methods[] = { { "get_game_viewport", (PyCFunction)py_ue_get_game_viewport, METH_VARARGS, "" }, + { "game_viewport_client_set_rendering_flag", (PyCFunction)py_ue_game_viewport_client_set_rendering_flag, METH_VARARGS, "" }, + { "get_world_location_at_distance_along_spline", (PyCFunction)py_ue_get_world_location_at_distance_along_spline, METH_VARARGS, "" }, { "get_spline_length", (PyCFunction)py_ue_get_spline_length, METH_VARARGS, "" }, + { "game_viewport_client_get_window", (PyCFunction)py_ue_game_viewport_client_get_window, METH_VARARGS, "" }, + // Widget { "take_widget", (PyCFunction)py_ue_take_widget, METH_VARARGS, "" }, { "create_widget", (PyCFunction)py_ue_create_widget, METH_VARARGS, "" }, @@ -849,14 +1028,18 @@ static PyMethodDef ue_PyUObject_methods[] = { { "skeleton_add_bone", (PyCFunction)py_ue_skeleton_add_bone, METH_VARARGS, "" }, #endif +#if WITH_EDITOR #if ENGINE_MINOR_VERSION > 12 { "skeletal_mesh_set_soft_vertices", (PyCFunction)py_ue_skeletal_mesh_set_soft_vertices, METH_VARARGS, "" }, { "skeletal_mesh_get_soft_vertices", (PyCFunction)py_ue_skeletal_mesh_get_soft_vertices, METH_VARARGS, "" }, #endif { "skeletal_mesh_get_lod", (PyCFunction)py_ue_skeletal_mesh_get_lod, METH_VARARGS, "" }, + { "skeletal_mesh_get_raw_indices", (PyCFunction)py_ue_skeletal_mesh_get_raw_indices, METH_VARARGS, "" }, +#endif { "skeletal_mesh_set_skeleton", (PyCFunction)py_ue_skeletal_mesh_set_skeleton, METH_VARARGS, "" }, +#if WITH_EDITOR #if ENGINE_MINOR_VERSION > 12 { "skeletal_mesh_get_bone_map", (PyCFunction)py_ue_skeletal_mesh_get_bone_map, METH_VARARGS, "" }, { "skeletal_mesh_set_bone_map", (PyCFunction)py_ue_skeletal_mesh_set_bone_map, METH_VARARGS, "" }, @@ -867,17 +1050,19 @@ static PyMethodDef ue_PyUObject_methods[] = { { "skeletal_mesh_get_required_bones", (PyCFunction)py_ue_skeletal_mesh_get_required_bones, METH_VARARGS, "" }, { "skeletal_mesh_lods_num", (PyCFunction)py_ue_skeletal_mesh_lods_num, METH_VARARGS, "" }, { "skeletal_mesh_sections_num", (PyCFunction)py_ue_skeletal_mesh_sections_num, METH_VARARGS, "" }, -#if WITH_EDITOR + #pragma warning(suppress: 4191) { "skeletal_mesh_build_lod", (PyCFunction)py_ue_skeletal_mesh_build_lod, METH_VARARGS | METH_KEYWORDS, "" }, #endif +#if WITH_EDITOR { "skeletal_mesh_register_morph_target", (PyCFunction)py_ue_skeletal_mesh_register_morph_target, METH_VARARGS, "" }, + { "skeletal_mesh_to_import_vertex_map", (PyCFunction)py_ue_skeletal_mesh_to_import_vertex_map, METH_VARARGS, "" }, { "morph_target_populate_deltas", (PyCFunction)py_ue_morph_target_populate_deltas, METH_VARARGS, "" }, { "morph_target_get_deltas", (PyCFunction)py_ue_morph_target_get_deltas, METH_VARARGS, "" }, - +#endif // Timer { "set_timer", (PyCFunction)py_ue_set_timer, METH_VARARGS, "" }, @@ -886,12 +1071,14 @@ static PyMethodDef ue_PyUObject_methods[] = { { "texture_set_data", (PyCFunction)py_ue_texture_set_data, METH_VARARGS, "" }, { "texture_get_width", (PyCFunction)py_ue_texture_get_width, METH_VARARGS, "" }, { "texture_get_height", (PyCFunction)py_ue_texture_get_height, METH_VARARGS, "" }, + { "texture_has_alpha_channel", (PyCFunction)py_ue_texture_has_alpha_channel, METH_VARARGS, "" }, { "render_target_get_data", (PyCFunction)py_ue_render_target_get_data, METH_VARARGS, "" }, { "render_target_get_data_to_buffer", (PyCFunction)py_ue_render_target_get_data_to_buffer, METH_VARARGS, "" }, { "texture_update_resource", (PyCFunction)py_ue_texture_update_resource, METH_VARARGS, "" }, #if WITH_EDITOR { "texture_get_source_data", (PyCFunction)py_ue_texture_get_source_data, METH_VARARGS, "" }, + { "texture_set_source_data", (PyCFunction)py_ue_texture_set_source_data, METH_VARARGS, "" }, #endif // Sequencer @@ -899,6 +1086,12 @@ static PyMethodDef ue_PyUObject_methods[] = { { "sequencer_possessable_tracks", (PyCFunction)py_ue_sequencer_possessable_tracks, METH_VARARGS, "" }, { "sequencer_get_camera_cut_track", (PyCFunction)py_ue_sequencer_get_camera_cut_track, METH_VARARGS, "" }, #if WITH_EDITOR + { "sequencer_set_playback_range", (PyCFunction)py_ue_sequencer_set_playback_range, METH_VARARGS, "" }, + { "sequencer_set_view_range", (PyCFunction)py_ue_sequencer_set_view_range, METH_VARARGS, "" }, + { "sequencer_set_working_range", (PyCFunction)py_ue_sequencer_set_working_range, METH_VARARGS, "" }, + { "sequencer_set_section_range", (PyCFunction)py_ue_sequencer_set_section_range, METH_VARARGS, "" }, + { "sequencer_get_playback_range", (PyCFunction)py_ue_sequencer_get_playback_range, METH_VARARGS, "" }, + { "sequencer_get_selection_range", (PyCFunction)py_ue_sequencer_get_selection_range, METH_VARARGS, "" }, { "sequencer_folders", (PyCFunction)py_ue_sequencer_folders, METH_VARARGS, "" }, { "sequencer_create_folder", (PyCFunction)py_ue_sequencer_create_folder, METH_VARARGS, "" }, { "sequencer_set_display_name", (PyCFunction)py_ue_sequencer_set_display_name, METH_VARARGS, "" }, @@ -918,6 +1111,8 @@ static PyMethodDef ue_PyUObject_methods[] = { { "sequencer_remove_camera_cut_track", (PyCFunction)py_ue_sequencer_remove_camera_cut_track, METH_VARARGS, "" }, { "sequencer_remove_master_track", (PyCFunction)py_ue_sequencer_remove_master_track, METH_VARARGS, "" }, { "sequencer_remove_track", (PyCFunction)py_ue_sequencer_remove_track, METH_VARARGS, "" }, + { "sequencer_import_fbx_transform", (PyCFunction)py_ue_sequencer_import_fbx_transform, METH_VARARGS, "" }, + #endif { "sequencer_sections", (PyCFunction)py_ue_sequencer_sections, METH_VARARGS, "" }, { "sequencer_track_sections", (PyCFunction)py_ue_sequencer_track_sections, METH_VARARGS, "" }, @@ -933,7 +1128,9 @@ static PyMethodDef ue_PyUObject_methods[] = { // Material { "set_material", (PyCFunction)py_ue_set_material, METH_VARARGS, "" }, + { "set_material_by_name", (PyCFunction)py_ue_set_material_by_name, METH_VARARGS, "" }, { "set_material_scalar_parameter", (PyCFunction)py_ue_set_material_scalar_parameter, METH_VARARGS, "" }, + { "set_material_static_switch_parameter", (PyCFunction)py_ue_set_material_static_switch_parameter, METH_VARARGS, "" }, { "set_material_vector_parameter", (PyCFunction)py_ue_set_material_vector_parameter, METH_VARARGS, "" }, { "set_material_texture_parameter", (PyCFunction)py_ue_set_material_texture_parameter, METH_VARARGS, "" }, { "get_material_scalar_parameter", (PyCFunction)py_ue_get_material_scalar_parameter, METH_VARARGS, "" }, @@ -946,6 +1143,15 @@ static PyMethodDef ue_PyUObject_methods[] = { { "static_mesh_set_collision_for_lod", (PyCFunction)py_ue_static_mesh_set_collision_for_lod, METH_VARARGS, "" }, { "static_mesh_set_shadow_for_lod", (PyCFunction)py_ue_static_mesh_set_shadow_for_lod, METH_VARARGS, "" }, { "get_raw_mesh", (PyCFunction)py_ue_static_mesh_get_raw_mesh, METH_VARARGS, "" }, + + { "static_mesh_generate_kdop10x", (PyCFunction)py_ue_static_mesh_generate_kdop10x, METH_VARARGS, "" }, + { "static_mesh_generate_kdop10y", (PyCFunction)py_ue_static_mesh_generate_kdop10y, METH_VARARGS, "" }, + { "static_mesh_generate_kdop10z", (PyCFunction)py_ue_static_mesh_generate_kdop10z, METH_VARARGS, "" }, + { "static_mesh_generate_kdop18", (PyCFunction)py_ue_static_mesh_generate_kdop18, METH_VARARGS, "" }, + { "static_mesh_generate_kdop26", (PyCFunction)py_ue_static_mesh_generate_kdop26, METH_VARARGS, "" }, + + { "static_mesh_import_lod", (PyCFunction)py_ue_static_mesh_import_lod, METH_VARARGS, "" }, + #endif // Viewport @@ -960,6 +1166,8 @@ static PyMethodDef ue_PyUObject_methods[] = { { "as_dict", (PyCFunction)py_ue_as_dict, METH_VARARGS, "" }, { "get_cdo", (PyCFunction)py_ue_get_cdo, METH_VARARGS, "" }, + { "get_archetype", (PyCFunction)py_ue_get_archetype, METH_VARARGS, "" }, + { "get_archetype_instances", (PyCFunction)py_ue_get_archetype_instances, METH_VARARGS, "" }, { "enum_values", (PyCFunction)py_ue_enum_values, METH_VARARGS, "" }, { "enum_names", (PyCFunction)py_ue_enum_names, METH_VARARGS, "" }, #if ENGINE_MINOR_VERSION >= 15 @@ -975,11 +1183,16 @@ static PyMethodDef ue_PyUObject_methods[] = { // destructor -static void ue_pyobject_dealloc(ue_PyUObject *self) +static void ue_pyobject_dealloc(ue_PyUObject* self) { #if defined(UEPY_MEMORY_DEBUG) UE_LOG(LogPython, Warning, TEXT("Destroying ue_PyUObject %p mapped to UObject %p"), self, self->ue_object); #endif + if (self->owned) + { + FUnrealEnginePythonHouseKeeper::Get()->UntrackUObject(self->ue_object); + } + if (self->auto_rooted && (self->ue_object && self->ue_object->IsValidLowLevel() && self->ue_object->IsRooted())) { self->ue_object->RemoveFromRoot(); @@ -987,38 +1200,38 @@ static void ue_pyobject_dealloc(ue_PyUObject *self) Py_XDECREF(self->py_dict); - Py_TYPE(self)->tp_free((PyObject *)self); + Py_TYPE(self)->tp_free((PyObject*)self); } -static PyObject *ue_PyUObject_getattro(ue_PyUObject *self, PyObject *attr_name) +static PyObject* ue_PyUObject_getattro(ue_PyUObject* self, PyObject* attr_name) { ue_py_check(self); - PyObject *ret = PyObject_GenericGetAttr((PyObject *)self, attr_name); + PyObject* ret = PyObject_GenericGetAttr((PyObject*)self, attr_name); if (!ret) { if (PyUnicodeOrString_Check(attr_name)) { - char *attr = PyUnicode_AsUTF8(attr_name); + const char* attr = UEPyUnicode_AsUTF8(attr_name); // first check for property - UStruct *u_struct = nullptr; + UStruct* u_struct = nullptr; if (self->ue_object->IsA()) { - u_struct = (UStruct *)self->ue_object; + u_struct = (UStruct*)self->ue_object; } else { - u_struct = (UStruct *)self->ue_object->GetClass(); + u_struct = (UStruct*)self->ue_object->GetClass(); } - UProperty *u_property = u_struct->FindPropertyByName(FName(UTF8_TO_TCHAR(attr))); + UProperty* u_property = u_struct->FindPropertyByName(FName(UTF8_TO_TCHAR(attr))); if (u_property) { // swallow previous exception PyErr_Clear(); - return ue_py_convert_property(u_property, (uint8 *)self->ue_object); + return ue_py_convert_property(u_property, (uint8*)self->ue_object, 0); } - UFunction *function = self->ue_object->FindFunction(FName(UTF8_TO_TCHAR(attr))); + UFunction* function = self->ue_object->FindFunction(FName(UTF8_TO_TCHAR(attr))); // retry wth K2_ prefix if (!function) { @@ -1031,8 +1244,8 @@ static PyObject *ue_PyUObject_getattro(ue_PyUObject *self, PyObject *attr_name) { if (self->ue_object->IsA()) { - UClass *u_class = (UClass *)self->ue_object; - UObject *cdo = u_class->GetDefaultObject(); + UClass* u_class = (UClass*)self->ue_object; + UObject* cdo = u_class->GetDefaultObject(); if (cdo) { function = cdo->FindFunction(FName(UTF8_TO_TCHAR(attr))); @@ -1052,7 +1265,7 @@ static PyObject *ue_PyUObject_getattro(ue_PyUObject *self, PyObject *attr_name) #if ENGINE_MINOR_VERSION >= 15 if (self->ue_object->IsA()) { - UUserDefinedEnum *u_enum = (UUserDefinedEnum *)self->ue_object; + UUserDefinedEnum* u_enum = (UUserDefinedEnum*)self->ue_object; PyErr_Clear(); FString attr_as_string = FString(UTF8_TO_TCHAR(attr)); for (auto item : u_enum->DisplayNameMap) @@ -1066,16 +1279,23 @@ static PyObject *ue_PyUObject_getattro(ue_PyUObject *self, PyObject *attr_name) #endif } } + return PyErr_Format(PyExc_Exception, "unknown enum name \"%s\"", attr); } #endif if (self->ue_object->IsA()) { - UEnum *u_enum = (UEnum *)self->ue_object; + UEnum* u_enum = (UEnum*)self->ue_object; PyErr_Clear(); #if ENGINE_MINOR_VERSION > 15 - return PyLong_FromLong(u_enum->GetIndexByName(FName(UTF8_TO_TCHAR(attr)))); + int32 value = u_enum->GetIndexByName(FName(UTF8_TO_TCHAR(attr))); + if (value == INDEX_NONE) + return PyErr_Format(PyExc_Exception, "unknown enum name \"%s\"", attr); + return PyLong_FromLong(value); #else - return PyLong_FromLong(u_enum->FindEnumIndex(FName(UTF8_TO_TCHAR(attr)))); + int32 value = u_enum->FindEnumIndex(FName(UTF8_TO_TCHAR(attr))); + if (value == INDEX_NONE) + return PyErr_Format(PyExc_Exception, "unknown enum name \"%s\"", attr); + return PyLong_FromLong(value); #endif } } @@ -1091,29 +1311,56 @@ static PyObject *ue_PyUObject_getattro(ue_PyUObject *self, PyObject *attr_name) return ret; } -static int ue_PyUObject_setattro(ue_PyUObject *self, PyObject *attr_name, PyObject *value) +static int ue_PyUObject_setattro(ue_PyUObject* self, PyObject* attr_name, PyObject* value) { ue_py_check_int(self); // first of all check for UProperty if (PyUnicodeOrString_Check(attr_name)) { - char *attr = PyUnicode_AsUTF8(attr_name); + const char* attr = UEPyUnicode_AsUTF8(attr_name); // first check for property - UStruct *u_struct = nullptr; + UStruct* u_struct = nullptr; if (self->ue_object->IsA()) { - u_struct = (UStruct *)self->ue_object; + u_struct = (UStruct*)self->ue_object; } else { - u_struct = (UStruct *)self->ue_object->GetClass(); + u_struct = (UStruct*)self->ue_object->GetClass(); } - UProperty *u_property = u_struct->FindPropertyByName(FName(UTF8_TO_TCHAR(attr))); + UProperty* u_property = u_struct->FindPropertyByName(FName(UTF8_TO_TCHAR(attr))); if (u_property) { - if (ue_py_convert_pyobject(value, u_property, (uint8*)self->ue_object)) +#if WITH_EDITOR + self->ue_object->PreEditChange(u_property); +#endif + if (ue_py_convert_pyobject(value, u_property, (uint8*)self->ue_object, 0)) { +#if WITH_EDITOR + FPropertyChangedEvent PropertyEvent(u_property, EPropertyChangeType::ValueSet); + self->ue_object->PostEditChangeProperty(PropertyEvent); + + if (self->ue_object->HasAnyFlags(RF_ArchetypeObject | RF_ClassDefaultObject)) + { + TArray Instances; + self->ue_object->GetArchetypeInstances(Instances); + for (UObject* Instance : Instances) + { + Instance->PreEditChange(u_property); + if (ue_py_convert_pyobject(value, u_property, (uint8*)Instance, 0)) + { + FPropertyChangedEvent InstancePropertyEvent(u_property, EPropertyChangeType::ValueSet); + Instance->PostEditChangeProperty(InstancePropertyEvent); + } + else + { + PyErr_SetString(PyExc_ValueError, "invalid value for UProperty"); + return -1; + } + } + } +#endif return 0; } PyErr_SetString(PyExc_ValueError, "invalid value for UProperty"); @@ -1127,10 +1374,10 @@ static int ue_PyUObject_setattro(ue_PyUObject *self, PyObject *attr_name, PyObje return -1; } } - return PyObject_GenericSetAttr((PyObject *)self, attr_name, value); + return PyObject_GenericSetAttr((PyObject*)self, attr_name, value); } -static PyObject *ue_PyUObject_str(ue_PyUObject *self) +static PyObject* ue_PyUObject_str(ue_PyUObject* self) { ue_py_check(self); @@ -1143,13 +1390,13 @@ static PyObject *ue_PyUObject_str(ue_PyUObject *self) #endif } -static PyObject *ue_PyUObject_call(ue_PyUObject *self, PyObject *args, PyObject *kw) +static PyObject* ue_PyUObject_call(ue_PyUObject* self, PyObject* args, PyObject* kw) { ue_py_check(self); // if it is a class, create a new object if (self->ue_object->IsA()) { - UClass *u_class = (UClass *)self->ue_object; + UClass* u_class = (UClass*)self->ue_object; if (u_class->HasAnyClassFlags(CLASS_Abstract)) { return PyErr_Format(PyExc_Exception, "abstract classes cannot be instantiated"); @@ -1158,16 +1405,16 @@ static PyObject *ue_PyUObject_call(ue_PyUObject *self, PyObject *args, PyObject { return PyErr_Format(PyExc_Exception, "you cannot use __call__ on actors, they have to be spawned"); } - PyObject *py_name = nullptr; - PyObject *py_outer = Py_None; + PyObject* py_name = nullptr; + PyObject* py_outer = Py_None; if (!PyArg_ParseTuple(args, "|OO:new_object", &py_name, &py_outer)) { return NULL; } int num_args = py_name ? 3 : 1; - PyObject *py_args = PyTuple_New(num_args); - Py_INCREF((PyObject *)self); - PyTuple_SetItem(py_args, 0, (PyObject *)self); + PyObject* py_args = PyTuple_New(num_args); + Py_INCREF((PyObject*)self); + PyTuple_SetItem(py_args, 0, (PyObject*)self); if (py_name) { Py_INCREF(py_outer); @@ -1175,25 +1422,33 @@ static PyObject *ue_PyUObject_call(ue_PyUObject *self, PyObject *args, PyObject Py_INCREF(py_name); PyTuple_SetItem(py_args, 2, py_name); } - PyObject *ret = py_unreal_engine_new_object(nullptr, py_args); + ue_PyUObject* ret = (ue_PyUObject*)py_unreal_engine_new_object(nullptr, py_args); Py_DECREF(py_args); - return (PyObject *)ret; + if (!ret) + { + return NULL; + } + // when new_object is called the reference counting is 2 and is registered in the GC + // UObject crated explicitely from python, will be managed by python... + FUnrealEnginePythonHouseKeeper::Get()->TrackUObject(ret->ue_object); + + return (PyObject*)ret; } // if it is a uscriptstruct, instantiate a new struct if (self->ue_object->IsA()) { - UScriptStruct *u_script_struct = (UScriptStruct *)self->ue_object; - uint8 *data = (uint8*)FMemory::Malloc(u_script_struct->GetStructureSize()); + UScriptStruct* u_script_struct = (UScriptStruct*)self->ue_object; + uint8* data = (uint8*)FMemory::Malloc(u_script_struct->GetStructureSize()); u_script_struct->InitializeStruct(data); #if WITH_EDITOR u_script_struct->InitializeDefaultValue(data); #endif if (kw) { - PyObject *struct_keys = PyObject_GetIter(kw); + PyObject* struct_keys = PyObject_GetIter(kw); for (;;) { - PyObject *key = PyIter_Next(struct_keys); + PyObject* key = PyIter_Next(struct_keys); if (!key) { if (PyErr_Occurred()) @@ -1205,9 +1460,9 @@ static PyObject *ue_PyUObject_call(ue_PyUObject *self, PyObject *args, PyObject } if (!PyUnicodeOrString_Check(key)) continue; - char *struct_key = PyUnicode_AsUTF8(key); + const char* struct_key = UEPyUnicode_AsUTF8(key); - PyObject *value = PyDict_GetItem(kw, key); + PyObject* value = PyDict_GetItem(kw, key); if (!value) { if (PyErr_Occurred()) @@ -1218,10 +1473,10 @@ static PyObject *ue_PyUObject_call(ue_PyUObject *self, PyObject *args, PyObject break; } - UProperty *u_property = ue_struct_get_field_from_name(u_script_struct, struct_key); + UProperty* u_property = ue_struct_get_field_from_name(u_script_struct, (char*)struct_key); if (u_property) { - if (!ue_py_convert_pyobject(value, u_property, data)) + if (!ue_py_convert_pyobject(value, u_property, data, 0)) { FMemory::Free(data); return PyErr_Format(PyExc_Exception, "invalid value for UProperty"); @@ -1234,8 +1489,9 @@ static PyObject *ue_PyUObject_call(ue_PyUObject *self, PyObject *args, PyObject } } } - return py_ue_wrap_uscriptstruct(u_script_struct, data); + return py_ue_new_owned_uscriptstruct_zero_copy(u_script_struct, data); } + return PyErr_Format(PyExc_Exception, "the specified uobject has no __call__ support"); } @@ -1275,12 +1531,12 @@ static PyTypeObject ue_PyUObjectType = { -UClass *unreal_engine_new_uclass(char *name, UClass *outer_parent) +UClass* unreal_engine_new_uclass(char* name, UClass* outer_parent) { bool is_overwriting = false; - UObject *outer = GetTransientPackage(); - UClass *parent = UObject::StaticClass(); + UObject* outer = GetTransientPackage(); + UClass* parent = UObject::StaticClass(); if (outer_parent) { @@ -1288,7 +1544,7 @@ UClass *unreal_engine_new_uclass(char *name, UClass *outer_parent) outer = parent->GetOuter(); } - UClass *new_object = FindObject(ANY_PACKAGE, UTF8_TO_TCHAR(name)); + UClass* new_object = FindObject(ANY_PACKAGE, UTF8_TO_TCHAR(name)); if (!new_object) { new_object = NewObject(outer, UTF8_TO_TCHAR(name), RF_Public | RF_Transient | RF_MarkAsNative); @@ -1303,13 +1559,13 @@ UClass *unreal_engine_new_uclass(char *name, UClass *outer_parent) if (is_overwriting && new_object->Children) { - UField *u_field = new_object->Children; + UField* u_field = new_object->Children; while (u_field) { if (u_field->IsA()) { UE_LOG(LogPython, Warning, TEXT("removing function %s"), *u_field->GetName()); - new_object->RemoveFunctionFromFunctionMap((UFunction *)u_field); + new_object->RemoveFunctionFromFunctionMap((UFunction*)u_field); FLinkerLoad::InvalidateExport(u_field); } u_field = u_field->Next; @@ -1332,542 +1588,62 @@ UClass *unreal_engine_new_uclass(char *name, UClass *outer_parent) new_object->ClassFlags |= (parent->ClassFlags & (CLASS_Inherit | CLASS_ScriptInherit)); new_object->ClassFlags |= CLASS_Native; -#if WITH_EDITOR - new_object->SetMetaData(FBlueprintMetadata::MD_AllowableBlueprintVariableType, TEXT("true")); - if (new_object->IsChildOf()) - { - new_object->SetMetaData(FBlueprintMetadata::MD_BlueprintSpawnableComponent, TEXT("true")); - } -#endif - - new_object->ClassCastFlags = parent->ClassCastFlags; - - - new_object->Bind(); - new_object->StaticLink(true); - - // it could be a class update - if (is_overwriting && new_object->ClassDefaultObject) - { - new_object->GetDefaultObject()->RemoveFromRoot(); - new_object->GetDefaultObject()->ConditionalBeginDestroy(); - new_object->ClassDefaultObject = nullptr; - } - -#if WITH_EDITOR - new_object->PostEditChange(); -#endif - - new_object->GetDefaultObject()->PostInitProperties(); - -#if WITH_EDITOR - new_object->PostLinkerChange(); -#endif - - new_object->AssembleReferenceTokenStream(); - -#if WITH_EDITOR - FBlueprintActionDatabase::Get().RefreshClassActions(new_object); -#endif - - return new_object; -} - -// hack for avoiding loops in class constructors (thanks to the Unreal.js project for the idea) -UClass *ue_py_class_constructor_placeholder = nullptr; -static void UEPyClassConstructor(UClass *u_class, const FObjectInitializer &ObjectInitializer) -{ - if (UPythonClass *u_py_class_casted = Cast(u_class)) - { - ue_py_class_constructor_placeholder = u_class; - } - u_class->ClassConstructor(ObjectInitializer); - ue_py_class_constructor_placeholder = nullptr; -} - -static int unreal_engine_py_init(ue_PyUObject *self, PyObject *args, PyObject *kwds) -{ - // is it subclassing ? - if (PyTuple_Size(args) == 3) - { - // TODO make it smarter on error checking - UE_LOG(LogPython, Warning, TEXT("%s"), UTF8_TO_TCHAR(PyUnicode_AsUTF8(PyObject_Str(PyTuple_GetItem(args, 0))))); - UE_LOG(LogPython, Warning, TEXT("%s"), UTF8_TO_TCHAR(PyUnicode_AsUTF8(PyObject_Str(PyTuple_GetItem(args, 1))))); - UE_LOG(LogPython, Warning, TEXT("%s"), UTF8_TO_TCHAR(PyUnicode_AsUTF8(PyObject_Str(PyTuple_GetItem(args, 2))))); - - PyObject *parents = PyTuple_GetItem(args, 1); - ue_PyUObject *parent = (ue_PyUObject *)PyTuple_GetItem(parents, 0); - - PyObject *class_attributes = PyTuple_GetItem(args, 2); - - PyObject *class_name = PyDict_GetItemString(class_attributes, (char *)"__qualname__"); - char *name = PyUnicode_AsUTF8(class_name); - // check if parent is a uclass - UClass *new_class = unreal_engine_new_uclass(name, (UClass *)parent->ue_object); - if (!new_class) - return -1; - - // map the class to the python object - self->ue_object = new_class; - - PyObject *py_additional_properties = PyDict_New(); - - PyObject *class_attributes_keys = PyObject_GetIter(class_attributes); - for (;;) - { - PyObject *key = PyIter_Next(class_attributes_keys); - if (!key) - { - if (PyErr_Occurred()) - return -1; - break; - } - if (!PyUnicodeOrString_Check(key)) - continue; - char *class_key = PyUnicode_AsUTF8(key); - - PyObject *value = PyDict_GetItem(class_attributes, key); - - if (strlen(class_key) > 2 && class_key[0] == '_' && class_key[1] == '_') - { - continue; - } - - bool prop_added = false; - - if (UProperty *u_property = new_class->FindPropertyByName(FName(UTF8_TO_TCHAR(class_key)))) - { - UE_LOG(LogPython, Warning, TEXT("Found UProperty %s"), UTF8_TO_TCHAR(class_key)); - PyDict_SetItem(py_additional_properties, key, value); - prop_added = true; - } - // add simple property - else if (ue_is_pyuobject(value)) - { - ue_PyUObject *py_obj = (ue_PyUObject *)value; - if (py_obj->ue_object->IsA()) - { - UClass *p_class = (UClass *)py_obj->ue_object; - if (p_class->IsChildOf()) - { - if (!py_ue_add_property(self, Py_BuildValue("(Os)", value, class_key))) - { - unreal_engine_py_log_error(); - return -1; - } - prop_added = true; - } - else - { - if (!py_ue_add_property(self, Py_BuildValue("(OsO)", (PyObject *)ue_get_python_uobject(UObjectProperty::StaticClass()), class_key, value))) - { - unreal_engine_py_log_error(); - return -1; - } - prop_added = true; - } - } - else if (py_obj->ue_object->IsA()) - { - if (!py_ue_add_property(self, Py_BuildValue("(OsO)", (PyObject *)ue_get_python_uobject(UStructProperty::StaticClass()), class_key, value))) - { - unreal_engine_py_log_error(); - return -1; - } - prop_added = true; - } - } - - // add array property - else if (PyList_Check(value)) - { - if (PyList_Size(value) == 1) - { - PyObject *first_item = PyList_GetItem(value, 0); - if (ue_is_pyuobject(first_item)) - { - ue_PyUObject *py_obj = (ue_PyUObject *)first_item; - if (py_obj->ue_object->IsA()) - { - UClass *p_class = (UClass *)py_obj->ue_object; - if (p_class->IsChildOf()) - { - if (!py_ue_add_property(self, Py_BuildValue("(Os)", value, class_key))) - { - unreal_engine_py_log_error(); - return -1; - } - prop_added = true; - } - - else - { - if (!py_ue_add_property(self, Py_BuildValue("([O]sO)", (PyObject *)ue_get_python_uobject(UObjectProperty::StaticClass()), class_key, first_item))) - { - unreal_engine_py_log_error(); - return -1; - } - prop_added = true; - } - } - else if (py_obj->ue_object->IsA()) - { - if (!py_ue_add_property(self, Py_BuildValue("([O]sO)", (PyObject *)ue_get_python_uobject(UStructProperty::StaticClass()), class_key, first_item))) - { - unreal_engine_py_log_error(); - return -1; - } - prop_added = true; - } - } - - } - } -#if ENGINE_MINOR_VERSION >= 15 - else if (PyDict_Check(value)) - { - if (PyDict_Size(value) == 1) - { - PyObject *py_key = nullptr; - PyObject *py_value = nullptr; - Py_ssize_t pos = 0; - PyDict_Next(value, &pos, &py_key, &py_value); - if (ue_is_pyuobject(py_key) && ue_is_pyuobject(py_value)) - { - PyObject *first_item = nullptr; - PyObject *second_item = nullptr; - - ue_PyUObject *py_obj = (ue_PyUObject *)py_key; - if (py_obj->ue_object->IsA()) - { - UClass *p_class = (UClass *)py_obj->ue_object; - if (p_class->IsChildOf()) - { - first_item = py_key; - } - else - { - first_item = (PyObject *)ue_get_python_uobject(UObjectProperty::StaticClass()); - } - } - else if (py_obj->ue_object->IsA()) - { - first_item = (PyObject *)ue_get_python_uobject(UStructProperty::StaticClass()); - } - - ue_PyUObject *py_obj2 = (ue_PyUObject *)py_value; - if (py_obj2->ue_object->IsA()) - { - UClass *p_class = (UClass *)py_obj2->ue_object; - if (p_class->IsChildOf()) - { - second_item = py_value; - } - else - { - second_item = (PyObject *)ue_get_python_uobject(UObjectProperty::StaticClass()); - } - } - else if (py_obj2->ue_object->IsA()) - { - second_item = (PyObject *)ue_get_python_uobject(UStructProperty::StaticClass()); - } - - if (!py_ue_add_property(self, Py_BuildValue("([OO]sOO)", first_item, second_item, class_key, py_key, py_value))) - { - unreal_engine_py_log_error(); - return -1; - } - prop_added = true; - } - } - } -#endif - // function ? - else if (PyCallable_Check(value) && class_key[0] >= 'A' && class_key[0] <= 'Z') - { - uint32 func_flags = FUNC_Native | FUNC_BlueprintCallable | FUNC_Public; - PyObject *is_event = PyObject_GetAttrString(value, (char *)"event"); - if (is_event && PyObject_IsTrue(is_event)) - { - func_flags |= FUNC_Event | FUNC_BlueprintEvent; - } - else if (!is_event) - PyErr_Clear(); - - PyObject *is_multicast = PyObject_GetAttrString(value, (char *)"multicast"); - if (is_multicast && PyObject_IsTrue(is_multicast)) - { - func_flags |= FUNC_NetMulticast; - } - else if (!is_multicast) - PyErr_Clear(); - PyObject *is_server = PyObject_GetAttrString(value, (char *)"server"); - if (is_server && PyObject_IsTrue(is_server)) - { - func_flags |= FUNC_NetServer; - } - else if (!is_server) - PyErr_Clear(); - PyObject *is_client = PyObject_GetAttrString(value, (char *)"client"); - if (is_client && PyObject_IsTrue(is_client)) - { - func_flags |= FUNC_NetClient; - } - else if (!is_client) - PyErr_Clear(); - PyObject *is_reliable = PyObject_GetAttrString(value, (char *)"reliable"); - if (is_reliable && PyObject_IsTrue(is_reliable)) - { - func_flags |= FUNC_NetReliable; - } - else if (!is_reliable) - PyErr_Clear(); - - - PyObject *is_pure = PyObject_GetAttrString(value, (char *)"pure"); - if (is_pure && PyObject_IsTrue(is_pure)) - { - func_flags |= FUNC_BlueprintPure; - } - else if (!is_pure) - PyErr_Clear(); - PyObject *is_static = PyObject_GetAttrString(value, (char *)"static"); - if (is_static && PyObject_IsTrue(is_static)) - { - func_flags |= FUNC_Static; - } - else if (!is_static) - PyErr_Clear(); - PyObject *override_name = PyObject_GetAttrString(value, (char *)"override"); - if (override_name && PyUnicodeOrString_Check(override_name)) - { - class_key = PyUnicode_AsUTF8(override_name); - } - else if (override_name && PyUnicodeOrString_Check(override_name)) - { - class_key = PyUnicode_AsUTF8(override_name); - } - else if (!override_name) - PyErr_Clear(); - if (!unreal_engine_add_function(new_class, class_key, value, func_flags)) - { - UE_LOG(LogPython, Error, TEXT("unable to add function %s"), UTF8_TO_TCHAR(class_key)); - return -1; - } - prop_added = true; - } - - - if (!prop_added) - { - UE_LOG(LogPython, Warning, TEXT("Adding %s as attr"), UTF8_TO_TCHAR(class_key)); - PyObject_SetAttr((PyObject *)self, key, value); - } - } - - if (PyDict_Size(py_additional_properties) > 0) - { - PyObject_SetAttrString((PyObject *)self, (char*)"__additional_uproperties__", py_additional_properties); - } - - UPythonClass *new_u_py_class = (UPythonClass *)new_class; - // TODO: check if we can use this to decref the ue_PyUbject mapped to the class - new_u_py_class->py_uobject = self; - new_u_py_class->ClassConstructor = [](const FObjectInitializer &ObjectInitializer) - { - FScopePythonGIL gil; - UClass *u_class = ue_py_class_constructor_placeholder ? ue_py_class_constructor_placeholder : ObjectInitializer.GetClass(); - ue_py_class_constructor_placeholder = nullptr; - - UEPyClassConstructor(u_class->GetSuperClass(), ObjectInitializer); - - if (UPythonClass *u_py_class_casted = Cast(u_class)) - { - ue_PyUObject *new_self = ue_get_python_uobject(ObjectInitializer.GetObj()); - if (!new_self) - { - unreal_engine_py_log_error(); - return; - } - - // fill __dict__ from class - if (u_py_class_casted->py_uobject && u_py_class_casted->py_uobject->py_dict) - { - PyObject *found_additional_props = PyDict_GetItemString(u_py_class_casted->py_uobject->py_dict, (char *)"__additional_uproperties__"); - // manage UProperties (and automatically maps multicast properties) - if (found_additional_props) - { - PyObject *keys = PyDict_Keys(found_additional_props); - Py_ssize_t items_len = PyList_Size(keys); - for (Py_ssize_t i = 0; i < items_len; i++) - { - PyObject *mc_key = PyList_GetItem(keys, i); - PyObject *mc_value = PyDict_GetItem(found_additional_props, mc_key); - - char *mc_name = PyUnicode_AsUTF8(mc_key); - UProperty *u_property = ObjectInitializer.GetObj()->GetClass()->FindPropertyByName(FName(UTF8_TO_TCHAR(mc_name))); - if (u_property) - { - if (auto casted_prop = Cast(u_property)) - { - FMulticastScriptDelegate multiscript_delegate = casted_prop->GetPropertyValue_InContainer(ObjectInitializer.GetObj()); - - FScriptDelegate script_delegate; - UPythonDelegate *py_delegate = FUnrealEnginePythonHouseKeeper::Get()->NewDelegate(ObjectInitializer.GetObj(), mc_value, casted_prop->SignatureFunction); - // fake UFUNCTION for bypassing checks - script_delegate.BindUFunction(py_delegate, FName("PyFakeCallable")); - - // add the new delegate - multiscript_delegate.Add(script_delegate); - - // re-assign multicast delegate - casted_prop->SetPropertyValue_InContainer(ObjectInitializer.GetObj(), multiscript_delegate); - } - else - { - PyObject_SetAttr((PyObject *)new_self, mc_key, mc_value); - } - } - - } - Py_DECREF(keys); - } - else - { - PyErr_Clear(); - } - PyObject *keys = PyDict_Keys(u_py_class_casted->py_uobject->py_dict); - Py_ssize_t keys_len = PyList_Size(keys); - for (Py_ssize_t i = 0; i < keys_len; i++) - { - PyObject *key = PyList_GetItem(keys, i); - PyObject *value = PyDict_GetItem(u_py_class_casted->py_uobject->py_dict, key); - if (PyUnicode_Check(key)) - { - char *key_name = PyUnicode_AsUTF8(key); - if (!strcmp(key_name, (char *)"__additional_uproperties__")) - continue; - } - // special case to bound function to method - if (PyFunction_Check(value)) - { - PyObject *bound_function = PyObject_CallMethod(value, (char*)"__get__", (char*)"O", (PyObject *)new_self); - if (bound_function) - { - PyObject_SetAttr((PyObject *)new_self, key, bound_function); - Py_DECREF(bound_function); - } - else - { - unreal_engine_py_log_error(); - } - } - else - { - PyObject_SetAttr((PyObject *)new_self, key, value); - } - } - Py_DECREF(keys); - } - // call __init__ - u_py_class_casted->CallPyConstructor(new_self); - } - }; - - - - if (self->py_dict) - { - ue_PyUObject *new_default_self = ue_get_python_uobject(new_u_py_class->ClassDefaultObject); - - if (!new_default_self) - { - unreal_engine_py_log_error(); - UE_LOG(LogPython, Error, TEXT("unable to set dict on new ClassDefaultObject")); - return -1; - } - PyObject *keys = PyDict_Keys(self->py_dict); - - Py_ssize_t keys_len = PyList_Size(keys); - for (Py_ssize_t i = 0; i < keys_len; i++) - { - PyObject *key = PyList_GetItem(keys, i); - PyObject *value = PyDict_GetItem(self->py_dict, key); - // special case to bound function to method - if (PyFunction_Check(value)) - { - PyObject *bound_function = PyObject_CallMethod(value, (char*)"__get__", (char*)"O", (PyObject *)new_default_self); - if (bound_function) - { - PyObject_SetAttr((PyObject *)new_default_self, key, bound_function); - Py_DECREF(bound_function); - } - else - { - unreal_engine_py_log_error(); - } - } - else - { - PyObject_SetAttr((PyObject *)new_default_self, key, value); - } - } - Py_DECREF(keys); - } +#if WITH_EDITOR + new_object->SetMetaData(FBlueprintMetadata::MD_AllowableBlueprintVariableType, TEXT("true")); + if (new_object->IsChildOf()) + { + new_object->SetMetaData(FBlueprintMetadata::MD_BlueprintSpawnableComponent, TEXT("true")); + } +#endif - // add default uproperties values - if (py_additional_properties) - { - ue_PyUObject *new_default_self = ue_get_python_uobject(new_u_py_class->ClassDefaultObject); - if (!new_default_self) - { - unreal_engine_py_log_error(); - UE_LOG(LogPython, Error, TEXT("unable to set properties on new ClassDefaultObject")); - return -1; - } - PyObject *keys = PyDict_Keys(py_additional_properties); - Py_ssize_t keys_len = PyList_Size(keys); - for (Py_ssize_t i = 0; i < keys_len; i++) - { - PyObject *key = PyList_GetItem(keys, i); - PyObject *value = PyDict_GetItem(py_additional_properties, key); + new_object->ClassCastFlags = parent->ClassCastFlags; - PyObject_SetAttr((PyObject *)new_default_self, key, value); - } - Py_DECREF(keys); - } - // add custom constructor (__init__) - PyObject *py_init = PyDict_GetItemString(class_attributes, (char *)"__init__"); - if (py_init && PyCallable_Check(py_init)) - { - // fake initializer - FObjectInitializer initializer(new_u_py_class->ClassDefaultObject, nullptr, false, true); - new_u_py_class->SetPyConstructor(py_init); - ue_PyUObject *new_default_self = ue_get_python_uobject(new_u_py_class->ClassDefaultObject); + new_object->Bind(); + new_object->StaticLink(true); - if (!new_default_self) - { - unreal_engine_py_log_error(); - UE_LOG(LogPython, Error, TEXT("unable to call __init__ on new ClassDefaultObject")); - return -1; - } + // it could be a class update + if (is_overwriting && new_object->ClassDefaultObject) + { + new_object->GetDefaultObject()->RemoveFromRoot(); + new_object->GetDefaultObject()->ConditionalBeginDestroy(); + new_object->ClassDefaultObject = nullptr; + } - new_u_py_class->CallPyConstructor(new_default_self); - } +#if WITH_EDITOR + new_object->PostEditChange(); +#endif + + new_object->GetDefaultObject()->PostInitProperties(); +#if WITH_EDITOR + new_object->PostLinkerChange(); +#endif + + new_object->AssembleReferenceTokenStream(); + +#if WITH_EDITOR + // this is required for avoiding startup crashes #405 + if (GEditor) + { + FBlueprintActionDatabase::Get().RefreshClassActions(new_object); } +#endif - return 0; + return new_object; } + + +int unreal_engine_py_init(ue_PyUObject*, PyObject*, PyObject*); + void unreal_engine_init_py_module() { #if PY_MAJOR_VERSION >= 3 - PyObject *new_unreal_engine_module = PyImport_AddModule("unreal_engine"); + PyObject * new_unreal_engine_module = PyImport_AddModule("unreal_engine"); #else - PyObject *new_unreal_engine_module = Py_InitModule3("unreal_engine", NULL, unreal_engine_py_doc); + PyObject* new_unreal_engine_module = Py_InitModule3("unreal_engine", NULL, unreal_engine_py_doc); +#endif ue_PyUObjectType.tp_new = PyType_GenericNew; ue_PyUObjectType.tp_init = (initproc)unreal_engine_py_init; ue_PyUObjectType.tp_dictoffset = offsetof(ue_PyUObject, py_dict); @@ -1876,19 +1652,20 @@ void unreal_engine_init_py_module() return; Py_INCREF(&ue_PyUObjectType); - PyModule_AddObject(new_unreal_engine_module, "UObject", (PyObject *)&ue_PyUObjectType); -#endif - PyObject *unreal_engine_dict = PyModule_GetDict(new_unreal_engine_module); + PyModule_AddObject(new_unreal_engine_module, "UObject", (PyObject*)& ue_PyUObjectType); + + PyObject* unreal_engine_dict = PyModule_GetDict(new_unreal_engine_module); - PyMethodDef *unreal_engine_function; + PyMethodDef* unreal_engine_function; for (unreal_engine_function = unreal_engine_methods; unreal_engine_function->ml_name != NULL; unreal_engine_function++) { - PyObject *func = PyCFunction_New(unreal_engine_function, NULL); + PyObject* func = PyCFunction_New(unreal_engine_function, NULL); PyDict_SetItemString(unreal_engine_dict, unreal_engine_function->ml_name, func); Py_DECREF(func); } ue_python_init_fvector(new_unreal_engine_module); + ue_python_init_fvector2d(new_unreal_engine_module); ue_python_init_frotator(new_unreal_engine_module); ue_python_init_ftransform(new_unreal_engine_module); ue_python_init_fhitresult(new_unreal_engine_module); @@ -1896,12 +1673,17 @@ void unreal_engine_init_py_module() ue_python_init_flinearcolor(new_unreal_engine_module); ue_python_init_fquat(new_unreal_engine_module); +#if ENGINE_MINOR_VERSION >= 20 + ue_python_init_fframe_number(new_unreal_engine_module); +#endif ue_python_init_frandomstream(new_unreal_engine_module); ue_python_init_fraw_anim_sequence_track(new_unreal_engine_module); +#if WITH_EDITOR ue_python_init_fsoft_skin_vertex(new_unreal_engine_module); +#endif ue_python_init_fmorph_target_delta(new_unreal_engine_module); @@ -1910,6 +1692,7 @@ void unreal_engine_init_py_module() ue_python_init_fviewport_client(new_unreal_engine_module); #if WITH_EDITOR ue_python_init_feditor_viewport_client(new_unreal_engine_module); + ue_python_init_iasset_editor_instance(new_unreal_engine_module); #endif ue_python_init_fpython_output_device(new_unreal_engine_module); @@ -1928,8 +1711,10 @@ void unreal_engine_init_py_module() ue_python_init_enumsimporter(new_unreal_engine_module); ue_python_init_ustructsimporter(new_unreal_engine_module); - #if WITH_EDITOR + ue_python_init_ffoliage_instance(new_unreal_engine_module); + + ue_python_init_fslowtask(new_unreal_engine_module); ue_python_init_swidget(new_unreal_engine_module); ue_python_init_farfilter(new_unreal_engine_module); ue_python_init_fassetdata(new_unreal_engine_module); @@ -1962,21 +1747,10 @@ void unreal_engine_init_py_module() ue_python_init_ivoice_capture(new_unreal_engine_module); - PyObject *py_sys = PyImport_ImportModule("sys"); - PyObject *py_sys_dict = PyModule_GetDict(py_sys); - - PyObject *py_sys_modules = PyDict_GetItemString(py_sys_dict, "modules"); - PyObject *u_classes_importer = py_ue_new_uclassesimporter(); - Py_INCREF(u_classes_importer); - PyDict_SetItemString(py_sys_modules, "unreal_engine.classes", u_classes_importer); + ue_py_register_magic_module((char*)"unreal_engine.classes", py_ue_new_uclassesimporter); + ue_py_register_magic_module((char*)"unreal_engine.enums", py_ue_new_enumsimporter); + ue_py_register_magic_module((char*)"unreal_engine.structs", py_ue_new_ustructsimporter); - PyObject *u_enums_importer = py_ue_new_enumsimporter(); - Py_INCREF(u_enums_importer); - PyDict_SetItemString(py_sys_modules, "unreal_engine.enums", u_enums_importer); - - PyObject *u_structs_importer = py_ue_new_ustructsimporter(); - Py_INCREF(u_structs_importer); - PyDict_SetItemString(py_sys_modules, "unreal_engine.structs", u_structs_importer); PyDict_SetItemString(unreal_engine_dict, "ENGINE_MAJOR_VERSION", PyLong_FromLong(ENGINE_MAJOR_VERSION)); PyDict_SetItemString(unreal_engine_dict, "ENGINE_MINOR_VERSION", PyLong_FromLong(ENGINE_MINOR_VERSION)); @@ -2017,7 +1791,9 @@ void unreal_engine_init_py_module() PyDict_SetItemString(unreal_engine_dict, "RF_MARKASNATIVE", PyLong_FromUnsignedLongLong((uint64)RF_MarkAsNative)); PyDict_SetItemString(unreal_engine_dict, "RF_TRANSACTIONAL", PyLong_FromUnsignedLongLong((uint64)RF_Transactional)); PyDict_SetItemString(unreal_engine_dict, "RF_CLASSDEFAULTOBJECT", PyLong_FromUnsignedLongLong((uint64)RF_ClassDefaultObject)); + PyDict_SetItemString(unreal_engine_dict, "RF_CLASS_DEFAULT_OBJECT", PyLong_FromUnsignedLongLong((uint64)RF_ClassDefaultObject)); PyDict_SetItemString(unreal_engine_dict, "RF_ARCHETYPEOBJECT", PyLong_FromUnsignedLongLong((uint64)RF_ArchetypeObject)); + PyDict_SetItemString(unreal_engine_dict, "RF_ARCHETYPE_OBJECT", PyLong_FromUnsignedLongLong((uint64)RF_ArchetypeObject)); PyDict_SetItemString(unreal_engine_dict, "RF_TRANSIENT", PyLong_FromUnsignedLongLong((uint64)RF_Transient)); PyDict_SetItemString(unreal_engine_dict, "RF_MARKASROOTSET", PyLong_FromUnsignedLongLong((uint64)RF_MarkAsRootSet)); PyDict_SetItemString(unreal_engine_dict, "RF_TAGGARBAGETEMP", PyLong_FromUnsignedLongLong((uint64)RF_TagGarbageTemp)); @@ -2077,18 +1853,18 @@ void unreal_engine_init_py_module() // utility functions -ue_PyUObject *ue_get_python_uobject(UObject *ue_obj) +ue_PyUObject* ue_get_python_uobject(UObject* ue_obj) { if (!ue_obj) return nullptr; - ue_PyUObject *ret = FUnrealEnginePythonHouseKeeper::Get()->GetPyUObject(ue_obj); + ue_PyUObject* ret = FUnrealEnginePythonHouseKeeper::Get()->GetPyUObject(ue_obj); if (!ret) { if (!ue_obj->IsValidLowLevel() || ue_obj->IsPendingKillOrUnreachable()) return nullptr; - ue_PyUObject *ue_py_object = (ue_PyUObject *)PyObject_New(ue_PyUObject, &ue_PyUObjectType); + ue_PyUObject* ue_py_object = (ue_PyUObject*)PyObject_New(ue_PyUObject, &ue_PyUObjectType); if (!ue_py_object) { return nullptr; @@ -2097,6 +1873,7 @@ ue_PyUObject *ue_get_python_uobject(UObject *ue_obj) ue_py_object->py_proxy = nullptr; ue_py_object->auto_rooted = 0; ue_py_object->py_dict = PyDict_New(); + ue_py_object->owned = 0; FUnrealEnginePythonHouseKeeper::Get()->RegisterPyUObject(ue_obj, ue_py_object); @@ -2109,9 +1886,9 @@ ue_PyUObject *ue_get_python_uobject(UObject *ue_obj) } -ue_PyUObject *ue_get_python_uobject_inc(UObject *ue_obj) +ue_PyUObject* ue_get_python_uobject_inc(UObject* ue_obj) { - ue_PyUObject *ret = ue_get_python_uobject(ue_obj); + ue_PyUObject* ret = ue_get_python_uobject(ue_obj); if (ret) { Py_INCREF(ret); @@ -2121,9 +1898,9 @@ ue_PyUObject *ue_get_python_uobject_inc(UObject *ue_obj) void unreal_engine_py_log_error() { - PyObject *type = NULL; - PyObject *value = NULL; - PyObject *traceback = NULL; + PyObject* type = NULL; + PyObject* value = NULL; + PyObject* traceback = NULL; PyErr_Fetch(&type, &value, &traceback); PyErr_NormalizeException(&type, &value, &traceback); @@ -2134,9 +1911,9 @@ void unreal_engine_py_log_error() return; } - char *msg = NULL; + char* msg = NULL; #if PY_MAJOR_VERSION >= 3 - PyObject *zero = PyUnicode_AsUTF8String(PyObject_Str(value)); + PyObject * zero = PyUnicode_AsUTF8String(PyObject_Str(value)); if (zero) { msg = PyBytes_AsString(zero); @@ -2159,19 +1936,19 @@ void unreal_engine_py_log_error() return; } - PyObject *traceback_module = PyImport_ImportModule("traceback"); + PyObject* traceback_module = PyImport_ImportModule("traceback"); if (!traceback_module) { PyErr_Clear(); return; } - PyObject *traceback_dict = PyModule_GetDict(traceback_module); - PyObject *format_exception = PyDict_GetItemString(traceback_dict, "format_exception"); + PyObject* traceback_dict = PyModule_GetDict(traceback_module); + PyObject* format_exception = PyDict_GetItemString(traceback_dict, "format_exception"); if (format_exception) { - PyObject *ret = PyObject_CallFunctionObjArgs(format_exception, type, value, traceback, NULL); + PyObject* ret = PyObject_CallFunctionObjArgs(format_exception, type, value, traceback, NULL); if (!ret) { PyErr_Clear(); @@ -2181,16 +1958,16 @@ void unreal_engine_py_log_error() { for (int i = 0; i < PyList_Size(ret); i++) { - PyObject *item = PyList_GetItem(ret, i); + PyObject* item = PyList_GetItem(ret, i); if (item) { - UE_LOG(LogPython, Error, TEXT("%s"), UTF8_TO_TCHAR(PyUnicode_AsUTF8(PyObject_Str(item)))); + UE_LOG(LogPython, Error, TEXT("%s"), UTF8_TO_TCHAR(UEPyUnicode_AsUTF8(PyObject_Str(item)))); } } } else { - UE_LOG(LogPython, Error, TEXT("%s"), UTF8_TO_TCHAR(PyUnicode_AsUTF8(PyObject_Str(ret)))); + UE_LOG(LogPython, Error, TEXT("%s"), UTF8_TO_TCHAR(UEPyUnicode_AsUTF8(PyObject_Str(ret)))); } } @@ -2198,23 +1975,23 @@ void unreal_engine_py_log_error() } // retrieve a UWorld from a generic UObject (if possible) -UWorld *ue_get_uworld(ue_PyUObject *py_obj) +UWorld* ue_get_uworld(ue_PyUObject* py_obj) { if (py_obj->ue_object->IsA()) { - return (UWorld *)py_obj->ue_object; + return (UWorld*)py_obj->ue_object; } if (py_obj->ue_object->IsA()) { - AActor *actor = (AActor *)py_obj->ue_object; + AActor* actor = (AActor*)py_obj->ue_object; return actor->GetWorld(); } if (py_obj->ue_object->IsA()) { - UActorComponent *component = (UActorComponent *)py_obj->ue_object; + UActorComponent* component = (UActorComponent*)py_obj->ue_object; return component->GetWorld(); } @@ -2222,76 +1999,74 @@ UWorld *ue_get_uworld(ue_PyUObject *py_obj) } // retrieve actor from component (if possible) -AActor *ue_get_actor(ue_PyUObject *py_obj) +AActor* ue_get_actor(ue_PyUObject* py_obj) { if (py_obj->ue_object->IsA()) { - return (AActor *)py_obj->ue_object; + return (AActor*)py_obj->ue_object; } if (py_obj->ue_object->IsA()) { - UActorComponent *tmp_component = (UActorComponent *)py_obj->ue_object; + UActorComponent* tmp_component = (UActorComponent*)py_obj->ue_object; return tmp_component->GetOwner(); } return nullptr; } // convert a property to a python object -PyObject *ue_py_convert_property(UProperty *prop, uint8 *buffer) +PyObject* ue_py_convert_property(UProperty* prop, uint8* buffer, int32 index) { if (auto casted_prop = Cast(prop)) { - bool value = casted_prop->GetPropertyValue_InContainer(buffer); + bool value = casted_prop->GetPropertyValue_InContainer(buffer, index); if (value) { - Py_INCREF(Py_True); - return Py_True; + Py_RETURN_TRUE; } - Py_INCREF(Py_False); - return Py_False; + Py_RETURN_FALSE; } if (auto casted_prop = Cast(prop)) { - int value = casted_prop->GetPropertyValue_InContainer(buffer); + int value = casted_prop->GetPropertyValue_InContainer(buffer, index); return PyLong_FromLong(value); } if (auto casted_prop = Cast(prop)) { - uint32 value = casted_prop->GetPropertyValue_InContainer(buffer); + uint32 value = casted_prop->GetPropertyValue_InContainer(buffer, index); return PyLong_FromUnsignedLong(value); } if (auto casted_prop = Cast(prop)) { - long long value = casted_prop->GetPropertyValue_InContainer(buffer); + long long value = casted_prop->GetPropertyValue_InContainer(buffer, index); return PyLong_FromLongLong(value); } if (auto casted_prop = Cast(prop)) { - uint64 value = casted_prop->GetPropertyValue_InContainer(buffer); + uint64 value = casted_prop->GetPropertyValue_InContainer(buffer, index); return PyLong_FromUnsignedLongLong(value); } if (auto casted_prop = Cast(prop)) { - float value = casted_prop->GetPropertyValue_InContainer(buffer); + float value = casted_prop->GetPropertyValue_InContainer(buffer, index); return PyFloat_FromDouble(value); } if (auto casted_prop = Cast(prop)) { - uint8 value = casted_prop->GetPropertyValue_InContainer(buffer); + uint8 value = casted_prop->GetPropertyValue_InContainer(buffer, index); return PyLong_FromUnsignedLong(value); } #if ENGINE_MINOR_VERSION >= 15 if (auto casted_prop = Cast(prop)) { - void *prop_addr = casted_prop->ContainerPtrToValuePtr(buffer); + void* prop_addr = casted_prop->ContainerPtrToValuePtr(buffer, index); uint64 enum_index = casted_prop->GetUnderlyingProperty()->GetUnsignedIntPropertyValue(prop_addr); return PyLong_FromUnsignedLong(enum_index); } @@ -2299,25 +2074,25 @@ PyObject *ue_py_convert_property(UProperty *prop, uint8 *buffer) if (auto casted_prop = Cast(prop)) { - FString value = casted_prop->GetPropertyValue_InContainer(buffer); + FString value = casted_prop->GetPropertyValue_InContainer(buffer, index); return PyUnicode_FromString(TCHAR_TO_UTF8(*value)); } if (auto casted_prop = Cast(prop)) { - FText value = casted_prop->GetPropertyValue_InContainer(buffer); + FText value = casted_prop->GetPropertyValue_InContainer(buffer, index); return PyUnicode_FromString(TCHAR_TO_UTF8(*value.ToString())); } if (auto casted_prop = Cast(prop)) { - FName value = casted_prop->GetPropertyValue_InContainer(buffer); + FName value = casted_prop->GetPropertyValue_InContainer(buffer, index); return PyUnicode_FromString(TCHAR_TO_UTF8(*value.ToString())); } if (auto casted_prop = Cast(prop)) { - auto value = casted_prop->GetObjectPropertyValue_InContainer(buffer); + auto value = casted_prop->GetObjectPropertyValue_InContainer(buffer, index); if (value) { Py_RETURN_UOBJECT(value); @@ -2327,7 +2102,7 @@ PyObject *ue_py_convert_property(UProperty *prop, uint8 *buffer) if (auto casted_prop = Cast(prop)) { - auto value = casted_prop->GetPropertyValue_InContainer(buffer); + auto value = casted_prop->GetPropertyValue_InContainer(buffer, index); if (value) { Py_RETURN_UOBJECT(value); @@ -2340,53 +2115,56 @@ PyObject *ue_py_convert_property(UProperty *prop, uint8 *buffer) { if (auto casted_struct = Cast(casted_prop->Struct)) { - // check for FVector if (casted_struct == TBaseStructure::Get()) { - FVector vec = *casted_prop->ContainerPtrToValuePtr(buffer); + FVector vec = *casted_prop->ContainerPtrToValuePtr(buffer, index); return py_ue_new_fvector(vec); } + if (casted_struct == TBaseStructure::Get()) + { + FVector2D vec = *casted_prop->ContainerPtrToValuePtr(buffer, index); + return py_ue_new_fvector2d(vec); + } if (casted_struct == TBaseStructure::Get()) { - FRotator rot = *casted_prop->ContainerPtrToValuePtr(buffer); + FRotator rot = *casted_prop->ContainerPtrToValuePtr(buffer, index); return py_ue_new_frotator(rot); } if (casted_struct == TBaseStructure::Get()) { - FTransform transform = *casted_prop->ContainerPtrToValuePtr(buffer); + FTransform transform = *casted_prop->ContainerPtrToValuePtr(buffer, index); return py_ue_new_ftransform(transform); } if (casted_struct == FHitResult::StaticStruct()) { - FHitResult hit = *casted_prop->ContainerPtrToValuePtr(buffer); + FHitResult hit = *casted_prop->ContainerPtrToValuePtr(buffer, index); return py_ue_new_fhitresult(hit); } if (casted_struct == TBaseStructure::Get()) { - FColor color = *casted_prop->ContainerPtrToValuePtr(buffer); + FColor color = *casted_prop->ContainerPtrToValuePtr(buffer, index); return py_ue_new_fcolor(color); } if (casted_struct == TBaseStructure::Get()) { - FLinearColor color = *casted_prop->ContainerPtrToValuePtr(buffer); + FLinearColor color = *casted_prop->ContainerPtrToValuePtr(buffer, index); return py_ue_new_flinearcolor(color); } - return py_ue_new_uscriptstruct(casted_struct, casted_prop->ContainerPtrToValuePtr(buffer)); + return py_ue_new_uscriptstruct(casted_struct, casted_prop->ContainerPtrToValuePtr(buffer, index)); } return PyErr_Format(PyExc_TypeError, "unsupported UStruct type"); } if (auto casted_prop = Cast(prop)) { - auto value = casted_prop->GetPropertyValue_InContainer(buffer); - UObject *strong_obj = value.Get(); + auto value = casted_prop->GetPropertyValue_InContainer(buffer, index); + UObject* strong_obj = value.Get(); if (strong_obj) { Py_RETURN_UOBJECT(strong_obj); } // nullptr - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } if (auto casted_prop = Cast(prop)) @@ -2394,24 +2172,29 @@ PyObject *ue_py_convert_property(UProperty *prop, uint8 *buffer) Py_RETURN_UOBJECT(casted_prop); } + if (auto casted_prop = Cast(prop)) + { + Py_RETURN_UOBJECT(casted_prop); + } + if (auto casted_prop = Cast(prop)) { - FScriptArrayHelper_InContainer array_helper(casted_prop, buffer); + FScriptArrayHelper_InContainer array_helper(casted_prop, buffer, index); - UProperty *array_prop = casted_prop->Inner; + UProperty* array_prop = casted_prop->Inner; // check for TArray, so we can use bytearray optimization if (auto uint8_tarray = Cast(array_prop)) { - uint8 *buf = array_helper.GetRawPtr(); - return PyByteArray_FromStringAndSize((char *)buf, array_helper.Num()); + uint8* buf = array_helper.GetRawPtr(); + return PyByteArray_FromStringAndSize((char*)buf, array_helper.Num()); } - PyObject *py_list = PyList_New(0); + PyObject* py_list = PyList_New(0); for (int i = 0; i < array_helper.Num(); i++) { - PyObject *item = ue_py_convert_property(array_prop, array_helper.GetRawPtr(i)); + PyObject* item = ue_py_convert_property(array_prop, array_helper.GetRawPtr(i), 0); if (!item) { Py_DECREF(py_list); @@ -2427,25 +2210,25 @@ PyObject *ue_py_convert_property(UProperty *prop, uint8 *buffer) #if ENGINE_MINOR_VERSION >= 15 if (auto casted_prop = Cast(prop)) { - FScriptMapHelper_InContainer map_helper(casted_prop, buffer); + FScriptMapHelper_InContainer map_helper(casted_prop, buffer, index); - PyObject *py_dict = PyDict_New(); + PyObject* py_dict = PyDict_New(); for (int32 i = 0; i < map_helper.Num(); i++) { if (map_helper.IsValidIndex(i)) { - uint8 *ptr = map_helper.GetPairPtr(i); + uint8* ptr = map_helper.GetPairPtr(i); - PyObject *py_key = ue_py_convert_property(map_helper.KeyProp, ptr); + PyObject* py_key = ue_py_convert_property(map_helper.KeyProp, ptr, 0); if (!py_key) { Py_DECREF(py_dict); return NULL; } - PyObject *py_value = ue_py_convert_property(map_helper.ValueProp, ptr); + PyObject* py_value = ue_py_convert_property(map_helper.ValueProp, ptr, 0); if (!py_value) { Py_DECREF(py_dict); @@ -2466,7 +2249,7 @@ PyObject *ue_py_convert_property(UProperty *prop, uint8 *buffer) } // convert a python object to a property -bool ue_py_convert_pyobject(PyObject *py_obj, UProperty *prop, uint8 *buffer) +bool ue_py_convert_pyobject(PyObject* py_obj, UProperty* prop, uint8* buffer, int32 index) { if (PyBool_Check(py_obj)) @@ -2476,11 +2259,11 @@ bool ue_py_convert_pyobject(PyObject *py_obj, UProperty *prop, uint8 *buffer) return false; if (PyObject_IsTrue(py_obj)) { - casted_prop->SetPropertyValue_InContainer(buffer, true); + casted_prop->SetPropertyValue_InContainer(buffer, true, index); } else { - casted_prop->SetPropertyValue_InContainer(buffer, false); + casted_prop->SetPropertyValue_InContainer(buffer, false, index); } return true; } @@ -2489,51 +2272,51 @@ bool ue_py_convert_pyobject(PyObject *py_obj, UProperty *prop, uint8 *buffer) { if (auto casted_prop = Cast(prop)) { - PyObject *py_long = PyNumber_Long(py_obj); - casted_prop->SetPropertyValue_InContainer(buffer, PyLong_AsLong(py_long)); + PyObject* py_long = PyNumber_Long(py_obj); + casted_prop->SetPropertyValue_InContainer(buffer, PyLong_AsLong(py_long), index); Py_DECREF(py_long); return true; } if (auto casted_prop = Cast(prop)) { - PyObject *py_long = PyNumber_Long(py_obj); - casted_prop->SetPropertyValue_InContainer(buffer, PyLong_AsUnsignedLong(py_long)); + PyObject* py_long = PyNumber_Long(py_obj); + casted_prop->SetPropertyValue_InContainer(buffer, PyLong_AsUnsignedLong(py_long), index); Py_DECREF(py_long); return true; } if (auto casted_prop = Cast(prop)) { - PyObject *py_long = PyNumber_Long(py_obj); - casted_prop->SetPropertyValue_InContainer(buffer, PyLong_AsLongLong(py_long)); + PyObject* py_long = PyNumber_Long(py_obj); + casted_prop->SetPropertyValue_InContainer(buffer, PyLong_AsLongLong(py_long), index); Py_DECREF(py_long); return true; } if (auto casted_prop = Cast(prop)) { - PyObject *py_long = PyNumber_Long(py_obj); - casted_prop->SetPropertyValue_InContainer(buffer, PyLong_AsUnsignedLongLong(py_long)); + PyObject* py_long = PyNumber_Long(py_obj); + casted_prop->SetPropertyValue_InContainer(buffer, PyLong_AsUnsignedLongLong(py_long), index); Py_DECREF(py_long); return true; } if (auto casted_prop = Cast(prop)) { - PyObject *py_float = PyNumber_Float(py_obj); - casted_prop->SetPropertyValue_InContainer(buffer, PyFloat_AsDouble(py_float)); + PyObject* py_float = PyNumber_Float(py_obj); + casted_prop->SetPropertyValue_InContainer(buffer, PyFloat_AsDouble(py_float), index); Py_DECREF(py_float); return true; } if (auto casted_prop = Cast(prop)) { - PyObject *py_long = PyNumber_Long(py_obj); - casted_prop->SetPropertyValue_InContainer(buffer, PyLong_AsUnsignedLong(py_long)); + PyObject* py_long = PyNumber_Long(py_obj); + casted_prop->SetPropertyValue_InContainer(buffer, PyLong_AsUnsignedLong(py_long), index); Py_DECREF(py_long); return true; } #if ENGINE_MINOR_VERSION >= 15 if (auto casted_prop = Cast(prop)) { - PyObject *py_long = PyNumber_Long(py_obj); - void *prop_addr = casted_prop->ContainerPtrToValuePtr(buffer); + PyObject* py_long = PyNumber_Long(py_obj); + void* prop_addr = casted_prop->ContainerPtrToValuePtr(buffer, index); casted_prop->GetUnderlyingProperty()->SetIntPropertyValue(prop_addr, (uint64)PyLong_AsUnsignedLong(py_long)); Py_DECREF(py_long); return true; @@ -2548,17 +2331,17 @@ bool ue_py_convert_pyobject(PyObject *py_obj, UProperty *prop, uint8 *buffer) { if (auto casted_prop = Cast(prop)) { - casted_prop->SetPropertyValue_InContainer(buffer, UTF8_TO_TCHAR(PyUnicode_AsUTF8(py_obj))); + casted_prop->SetPropertyValue_InContainer(buffer, UTF8_TO_TCHAR(UEPyUnicode_AsUTF8(py_obj)), index); return true; } if (auto casted_prop = Cast(prop)) { - casted_prop->SetPropertyValue_InContainer(buffer, UTF8_TO_TCHAR(PyUnicode_AsUTF8(py_obj))); + casted_prop->SetPropertyValue_InContainer(buffer, UTF8_TO_TCHAR(UEPyUnicode_AsUTF8(py_obj)), index); return true; } if (auto casted_prop = Cast(prop)) { - casted_prop->SetPropertyValue_InContainer(buffer, FText::FromString(UTF8_TO_TCHAR(PyUnicode_AsUTF8(py_obj)))); + casted_prop->SetPropertyValue_InContainer(buffer, FText::FromString(UTF8_TO_TCHAR(UEPyUnicode_AsUTF8(py_obj))), index); return true; } return false; @@ -2568,12 +2351,14 @@ bool ue_py_convert_pyobject(PyObject *py_obj, UProperty *prop, uint8 *buffer) { if (auto casted_prop = Cast(prop)) { - FScriptArrayHelper_InContainer helper(casted_prop, buffer); + FScriptArrayHelper_InContainer helper(casted_prop, buffer, index); if (auto item_casted_prop = Cast(casted_prop->Inner)) { Py_ssize_t pybytes_len = PyBytes_Size(py_obj); + uint8* buf = (uint8*)PyBytes_AsString(py_obj); + // fix array helper size if (helper.Num() < pybytes_len) @@ -2585,7 +2370,7 @@ bool ue_py_convert_pyobject(PyObject *py_obj, UProperty *prop, uint8 *buffer) helper.RemoveValues(pybytes_len, helper.Num() - pybytes_len); } - uint8 *buf = (uint8 *)PyBytes_AsString(py_obj); + FMemory::Memcpy(helper.GetRawPtr(), buf, pybytes_len); return true; } @@ -2598,12 +2383,14 @@ bool ue_py_convert_pyobject(PyObject *py_obj, UProperty *prop, uint8 *buffer) { if (auto casted_prop = Cast(prop)) { - FScriptArrayHelper_InContainer helper(casted_prop, buffer); + FScriptArrayHelper_InContainer helper(casted_prop, buffer, index); if (auto item_casted_prop = Cast(casted_prop->Inner)) { Py_ssize_t pybytes_len = PyByteArray_Size(py_obj); + uint8* buf = (uint8*)PyByteArray_AsString(py_obj); + // fix array helper size if (helper.Num() < pybytes_len) @@ -2615,8 +2402,9 @@ bool ue_py_convert_pyobject(PyObject *py_obj, UProperty *prop, uint8 *buffer) helper.RemoveValues(pybytes_len, helper.Num() - pybytes_len); } - uint8 *buf = (uint8 *)PyByteArray_AsString(py_obj); + FMemory::Memcpy(helper.GetRawPtr(), buf, pybytes_len); + return true; } } @@ -2628,9 +2416,9 @@ bool ue_py_convert_pyobject(PyObject *py_obj, UProperty *prop, uint8 *buffer) { if (auto casted_prop = Cast(prop)) { - FScriptArrayHelper_InContainer helper(casted_prop, buffer); + FScriptArrayHelper_InContainer helper(casted_prop, buffer, index); - UProperty *array_prop = casted_prop->Inner; + UProperty* array_prop = casted_prop->Inner; Py_ssize_t pylist_len = PyList_Size(py_obj); // fix array helper size @@ -2645,8 +2433,8 @@ bool ue_py_convert_pyobject(PyObject *py_obj, UProperty *prop, uint8 *buffer) for (int i = 0; i < (int)pylist_len; i++) { - PyObject *py_item = PyList_GetItem(py_obj, i); - if (!ue_py_convert_pyobject(py_item, array_prop, helper.GetRawPtr(i))) + PyObject* py_item = PyList_GetItem(py_obj, i); + if (!ue_py_convert_pyobject(py_item, array_prop, helper.GetRawPtr(i), 0)) { return false; } @@ -2661,9 +2449,9 @@ bool ue_py_convert_pyobject(PyObject *py_obj, UProperty *prop, uint8 *buffer) { if (auto casted_prop = Cast(prop)) { - FScriptArrayHelper_InContainer helper(casted_prop, buffer); + FScriptArrayHelper_InContainer helper(casted_prop, buffer, index); - UProperty *array_prop = casted_prop->Inner; + UProperty* array_prop = casted_prop->Inner; Py_ssize_t pytuple_len = PyTuple_Size(py_obj); // fix array helper size @@ -2678,8 +2466,8 @@ bool ue_py_convert_pyobject(PyObject *py_obj, UProperty *prop, uint8 *buffer) for (int i = 0; i < (int)pytuple_len; i++) { - PyObject *py_item = PyTuple_GetItem(py_obj, i); - if (!ue_py_convert_pyobject(py_item, array_prop, helper.GetRawPtr(i))) + PyObject* py_item = PyTuple_GetItem(py_obj, i); + if (!ue_py_convert_pyobject(py_item, array_prop, helper.GetRawPtr(i), 0)) { return false; } @@ -2695,25 +2483,25 @@ bool ue_py_convert_pyobject(PyObject *py_obj, UProperty *prop, uint8 *buffer) { if (auto casted_prop = Cast(prop)) { - FScriptMapHelper_InContainer map_helper(casted_prop, buffer); + FScriptMapHelper_InContainer map_helper(casted_prop, buffer, index); - PyObject *py_key = nullptr; - PyObject *py_value = nullptr; + PyObject* py_key = nullptr; + PyObject* py_value = nullptr; Py_ssize_t pos = 0; map_helper.EmptyValues(); while (PyDict_Next(py_obj, &pos, &py_key, &py_value)) { - int32 index = map_helper.AddDefaultValue_Invalid_NeedsRehash(); - uint8 *ptr = map_helper.GetPairPtr(index); + int32 hindex = map_helper.AddDefaultValue_Invalid_NeedsRehash(); + uint8* ptr = map_helper.GetPairPtr(hindex); - if (!ue_py_convert_pyobject(py_key, casted_prop->KeyProp, ptr)) + if (!ue_py_convert_pyobject(py_key, casted_prop->KeyProp, ptr, 0)) { return false; } - if (!ue_py_convert_pyobject(py_value, casted_prop->ValueProp, ptr)) + if (!ue_py_convert_pyobject(py_value, casted_prop->ValueProp, ptr, 0)) { return false; } @@ -2729,78 +2517,92 @@ bool ue_py_convert_pyobject(PyObject *py_obj, UProperty *prop, uint8 *buffer) // structs - if (ue_PyFVector *py_vec = py_ue_is_fvector(py_obj)) + if (ue_PyFVector * py_vec = py_ue_is_fvector(py_obj)) { if (auto casted_prop = Cast(prop)) { if (casted_prop->Struct == TBaseStructure::Get()) { - *casted_prop->ContainerPtrToValuePtr(buffer) = py_vec->vec; + *casted_prop->ContainerPtrToValuePtr(buffer, index) = py_vec->vec; + return true; + } + } + return false; + } + + if (ue_PyFVector2D * py_vec = py_ue_is_fvector2d(py_obj)) + { + if (auto casted_prop = Cast(prop)) + { + if (casted_prop->Struct == TBaseStructure::Get()) + { + *casted_prop->ContainerPtrToValuePtr(buffer, index) = py_vec->vec; return true; } } return false; } - if (ue_PyFRotator *py_rot = py_ue_is_frotator(py_obj)) + if (ue_PyFRotator * py_rot = py_ue_is_frotator(py_obj)) { if (auto casted_prop = Cast(prop)) { if (casted_prop->Struct == TBaseStructure::Get()) { - *casted_prop->ContainerPtrToValuePtr(buffer) = py_rot->rot; + *casted_prop->ContainerPtrToValuePtr(buffer, index) = py_rot->rot; return true; } } return false; } - if (ue_PyFTransform *py_transform = py_ue_is_ftransform(py_obj)) + if (ue_PyFTransform * py_transform = py_ue_is_ftransform(py_obj)) { if (auto casted_prop = Cast(prop)) { if (casted_prop->Struct == TBaseStructure::Get()) { - *casted_prop->ContainerPtrToValuePtr(buffer) = py_transform->transform; + *casted_prop->ContainerPtrToValuePtr(buffer, index) = py_transform->transform; return true; } } return false; } - if (ue_PyFColor *py_color = py_ue_is_fcolor(py_obj)) + if (ue_PyFColor * py_color = py_ue_is_fcolor(py_obj)) { if (auto casted_prop = Cast(prop)) { if (casted_prop->Struct == TBaseStructure::Get()) { - *casted_prop->ContainerPtrToValuePtr(buffer) = py_color->color; + + *casted_prop->ContainerPtrToValuePtr(buffer, index) = py_color->color; return true; } } return false; } - if (ue_PyFLinearColor *py_color = py_ue_is_flinearcolor(py_obj)) + if (ue_PyFLinearColor * py_color = py_ue_is_flinearcolor(py_obj)) { if (auto casted_prop = Cast(prop)) { if (casted_prop->Struct == TBaseStructure::Get()) { - *casted_prop->ContainerPtrToValuePtr(buffer) = py_color->color; + *casted_prop->ContainerPtrToValuePtr(buffer, index) = py_color->color; return true; } } return false; } - if (ue_PyFHitResult *py_hit = py_ue_is_fhitresult(py_obj)) + if (ue_PyFHitResult * py_hit = py_ue_is_fhitresult(py_obj)) { if (auto casted_prop = Cast(prop)) { if (casted_prop->Struct == FHitResult::StaticStruct()) { - *casted_prop->ContainerPtrToValuePtr(buffer) = py_hit->hit; + *casted_prop->ContainerPtrToValuePtr(buffer, index) = py_hit->hit; return true; } } @@ -2810,37 +2612,57 @@ bool ue_py_convert_pyobject(PyObject *py_obj, UProperty *prop, uint8 *buffer) // generic structs if (py_ue_is_uscriptstruct(py_obj)) { - ue_PyUScriptStruct *py_u_struct = (ue_PyUScriptStruct *)py_obj; + ue_PyUScriptStruct* py_u_struct = (ue_PyUScriptStruct*)py_obj; if (auto casted_prop = Cast(prop)) { if (casted_prop->Struct == py_u_struct->u_struct) { - uint8 *dest = casted_prop->ContainerPtrToValuePtr(buffer); - FMemory::Memcpy(dest, py_u_struct->data, py_u_struct->u_struct->GetStructureSize()); + uint8* dest = casted_prop->ContainerPtrToValuePtr(buffer, index); + py_u_struct->u_struct->InitializeStruct(dest); + py_u_struct->u_struct->CopyScriptStruct(dest, py_u_struct->u_struct_ptr); return true; } } return false; } - if (PyObject_IsInstance(py_obj, (PyObject *)&ue_PyUObjectType)) + if (PyObject_IsInstance(py_obj, (PyObject*)& ue_PyUObjectType)) { - ue_PyUObject *ue_obj = (ue_PyUObject *)py_obj; + ue_PyUObject* ue_obj = (ue_PyUObject*)py_obj; if (ue_obj->ue_object->IsA()) { if (auto casted_prop = Cast(prop)) { - casted_prop->SetPropertyValue_InContainer(buffer, ue_obj->ue_object); + casted_prop->SetPropertyValue_InContainer(buffer, ue_obj->ue_object, index); return true; } else if (auto casted_prop_soft_class = Cast(prop)) { - casted_prop_soft_class->SetPropertyValue_InContainer(buffer, FSoftObjectPtr(ue_obj->ue_object)); + casted_prop_soft_class->SetPropertyValue_InContainer(buffer, FSoftObjectPtr(ue_obj->ue_object), index); return true; } else if (auto casted_prop_soft_object = Cast(prop)) { - casted_prop_soft_object->SetPropertyValue_InContainer(buffer, FSoftObjectPtr(ue_obj->ue_object)); + + casted_prop_soft_object->SetPropertyValue_InContainer(buffer, FSoftObjectPtr(ue_obj->ue_object), index); + + return true; + } + else if (auto casted_prop_weak_object = Cast(prop)) + { + + casted_prop_weak_object->SetPropertyValue_InContainer(buffer, FWeakObjectPtr(ue_obj->ue_object), index); + + return true; + } + else if (auto casted_prop_base = Cast(prop)) + { + // ensure the object type is correct, otherwise crash could happen (soon or later) + if (!ue_obj->ue_object->IsA(casted_prop_base->PropertyClass)) + return false; + + casted_prop_base->SetObjectPropertyValue_InContainer(buffer, ue_obj->ue_object, index); + return true; } @@ -2852,21 +2674,42 @@ bool ue_py_convert_pyobject(PyObject *py_obj, UProperty *prop, uint8 *buffer) { if (auto casted_prop = Cast(prop)) { - // ensure the object type is correct, otherwise crash could happen (soon or later) - if (!ue_obj->ue_object->IsA(casted_prop->PropertyClass)) - return false; - casted_prop->SetObjectPropertyValue_InContainer(buffer, ue_obj->ue_object); + // if the property specifies an interface, the object must be of a class that implements it + if (casted_prop->PropertyClass->HasAnyClassFlags(CLASS_Interface)) + { + if (!ue_obj->ue_object->GetClass()->ImplementsInterface(casted_prop->PropertyClass)) + return false; + } + else + { + // ensure the object type is correct, otherwise crash could happen (soon or later) + if (!ue_obj->ue_object->IsA(casted_prop->PropertyClass)) + return false; + } + + casted_prop->SetObjectPropertyValue_InContainer(buffer, ue_obj->ue_object, index); + return true; } else if (auto casted_prop_soft_object = Cast(prop)) - { if (!ue_obj->ue_object->IsA(casted_prop_soft_object->PropertyClass)) return false; - casted_prop_soft_object->SetPropertyValue_InContainer(buffer, FSoftObjectPtr(ue_obj->ue_object)); + + casted_prop_soft_object->SetPropertyValue_InContainer(buffer, FSoftObjectPtr(ue_obj->ue_object), index); + return true; } + else if (auto casted_prop_interface = Cast(prop)) + { + // ensure the object type is correct, otherwise crash could happen (soon or later) + if (!ue_obj->ue_object->GetClass()->ImplementsInterface(casted_prop_interface->InterfaceClass)) + return false; + + casted_prop_interface->SetPropertyValue_InContainer(buffer, FScriptInterface(ue_obj->ue_object), index); + return true; + } } return false; } @@ -2876,13 +2719,17 @@ bool ue_py_convert_pyobject(PyObject *py_obj, UProperty *prop, uint8 *buffer) auto casted_prop_class = Cast(prop); if (casted_prop_class) { - casted_prop_class->SetPropertyValue_InContainer(buffer, nullptr); + + casted_prop_class->SetPropertyValue_InContainer(buffer, nullptr, index); + return true; } auto casted_prop = Cast(prop); if (casted_prop) { - casted_prop->SetObjectPropertyValue_InContainer(buffer, nullptr); + + casted_prop->SetObjectPropertyValue_InContainer(buffer, nullptr, index); + return true; } return false; @@ -2894,24 +2741,24 @@ bool ue_py_convert_pyobject(PyObject *py_obj, UProperty *prop, uint8 *buffer) // check if a python object is a wrapper to a UObject -ue_PyUObject *ue_is_pyuobject(PyObject *obj) +ue_PyUObject* ue_is_pyuobject(PyObject* obj) { - if (!PyObject_IsInstance(obj, (PyObject *)&ue_PyUObjectType)) + if (!PyObject_IsInstance(obj, (PyObject*)& ue_PyUObjectType)) return nullptr; - return (ue_PyUObject *)obj; + return (ue_PyUObject*)obj; } -void ue_bind_events_for_py_class_by_attribute(UObject *u_obj, PyObject *py_class) +void ue_bind_events_for_py_class_by_attribute(UObject* u_obj, PyObject* py_class) { // attempt to register events - PyObject *attrs = PyObject_Dir(py_class); + PyObject* attrs = PyObject_Dir(py_class); if (!attrs) return; - AActor *actor = Cast(u_obj); + AActor* actor = Cast(u_obj); if (!actor) { - UActorComponent *component = Cast(u_obj); + UActorComponent* component = Cast(u_obj); if (!component) return; actor = component->GetOwner(); @@ -2920,19 +2767,19 @@ void ue_bind_events_for_py_class_by_attribute(UObject *u_obj, PyObject *py_class Py_ssize_t len = PyList_Size(attrs); for (Py_ssize_t i = 0; i < len; i++) { - PyObject *py_attr_name = PyList_GetItem(attrs, i); + PyObject* py_attr_name = PyList_GetItem(attrs, i); if (!py_attr_name || !PyUnicodeOrString_Check(py_attr_name)) continue; - PyObject *item = PyObject_GetAttrString(py_class, PyUnicode_AsUTF8(py_attr_name)); + PyObject* item = PyObject_GetAttrString(py_class, UEPyUnicode_AsUTF8(py_attr_name)); if (item && PyCallable_Check(item)) { // check for ue_event signature - PyObject *event_signature = PyObject_GetAttrString(item, (char*)"ue_event"); + PyObject* event_signature = PyObject_GetAttrString(item, (char*)"ue_event"); if (event_signature) { - if (PyUnicode_Check(event_signature)) + if (PyUnicodeOrString_Check(event_signature)) { - FString event_name = FString(UTF8_TO_TCHAR(PyUnicode_AsUTF8(event_signature))); + FString event_name = FString(UTF8_TO_TCHAR(UEPyUnicode_AsUTF8(event_signature))); TArray parts; int n = event_name.ParseIntoArray(parts, UTF8_TO_TCHAR(".")); if (n < 1 || n > 2) @@ -2952,7 +2799,7 @@ void ue_bind_events_for_py_class_by_attribute(UObject *u_obj, PyObject *py_class else { bool found = false; - for (UActorComponent *component : actor->GetComponents()) + for (UActorComponent* component : actor->GetComponents()) { if (component->GetFName() == FName(*parts[0])) { @@ -2989,23 +2836,23 @@ void ue_bind_events_for_py_class_by_attribute(UObject *u_obj, PyObject *py_class } // automatically bind events based on class methods names -void ue_autobind_events_for_pyclass(ue_PyUObject *u_obj, PyObject *py_class) +void ue_autobind_events_for_pyclass(ue_PyUObject* u_obj, PyObject* py_class) { - PyObject *attrs = PyObject_Dir(py_class); + PyObject* attrs = PyObject_Dir(py_class); if (!attrs) return; Py_ssize_t len = PyList_Size(attrs); for (Py_ssize_t i = 0; i < len; i++) { - PyObject *py_attr_name = PyList_GetItem(attrs, i); + PyObject* py_attr_name = PyList_GetItem(attrs, i); if (!py_attr_name || !PyUnicodeOrString_Check(py_attr_name)) continue; - FString attr_name = UTF8_TO_TCHAR(PyUnicode_AsUTF8(py_attr_name)); + FString attr_name = UTF8_TO_TCHAR(UEPyUnicode_AsUTF8(py_attr_name)); if (!attr_name.StartsWith("on_", ESearchCase::CaseSensitive)) continue; // check if the attr is a callable - PyObject *item = PyObject_GetAttrString(py_class, TCHAR_TO_UTF8(*attr_name)); + PyObject* item = PyObject_GetAttrString(py_class, TCHAR_TO_UTF8(*attr_name)); if (item && PyCallable_Check(item)) { TArray parts; @@ -3029,24 +2876,24 @@ void ue_autobind_events_for_pyclass(ue_PyUObject *u_obj, PyObject *py_class) Py_DECREF(attrs); } -static void py_ue_destroy_params(UFunction *u_function, uint8 *buffer) +static void py_ue_destroy_params(UFunction* u_function, uint8* buffer) { // destroy params TFieldIterator DArgs(u_function); for (; DArgs && (DArgs->PropertyFlags & CPF_Parm); ++DArgs) { - UProperty *prop = *DArgs; + UProperty* prop = *DArgs; prop->DestroyValue_InContainer(buffer); } } -PyObject *py_ue_ufunction_call(UFunction *u_function, UObject *u_obj, PyObject *args, int argn, PyObject *kwargs) +PyObject* py_ue_ufunction_call(UFunction* u_function, UObject* u_obj, PyObject* args, int argn, PyObject* kwargs) { // check for __super call if (kwargs) { - PyObject *is_super_call = PyDict_GetItemString(kwargs, (char *)"__super"); + PyObject* is_super_call = PyDict_GetItemString(kwargs, (char*)"__super"); if (is_super_call) { if (!u_function->GetSuperFunction()) @@ -3058,12 +2905,12 @@ PyObject *py_ue_ufunction_call(UFunction *u_function, UObject *u_obj, PyObject * } //NOTE: u_function->PropertiesSize maps to local variable uproperties + ufunction paramaters uproperties - uint8 *buffer = (uint8 *)FMemory_Alloca(u_function->ParmsSize); + uint8* buffer = (uint8*)FMemory_Alloca(u_function->ParmsSize); FMemory::Memzero(buffer, u_function->ParmsSize); // initialize args for (TFieldIterator IArgs(u_function); IArgs && IArgs->HasAnyPropertyFlags(CPF_Parm); ++IArgs) { - UProperty *prop = *IArgs; + UProperty* prop = *IArgs; if (!prop->HasAnyPropertyFlags(CPF_ZeroConstructor)) { prop->InitializeValue_InContainer(buffer); @@ -3074,7 +2921,7 @@ PyObject *py_ue_ufunction_call(UFunction *u_function, UObject *u_obj, PyObject * { if (!prop->IsInContainer(u_function->ParmsSize)) { - return PyErr_Format(PyExc_Exception, "Attempting to import func param property that's out of bounds. %s", *u_function->GetName()); + return PyErr_Format(PyExc_Exception, "Attempting to import func param property that's out of bounds. %s", TCHAR_TO_UTF8(*u_function->GetName())); } #if WITH_EDITOR FString default_key = FString("CPP_Default_") + prop->GetName(); @@ -3099,16 +2946,16 @@ PyObject *py_ue_ufunction_call(UFunction *u_function, UObject *u_obj, PyObject * TFieldIterator PArgs(u_function); for (; PArgs && ((PArgs->PropertyFlags & (CPF_Parm | CPF_ReturnParm)) == CPF_Parm); ++PArgs) { - UProperty *prop = *PArgs; + UProperty* prop = *PArgs; if (argn < tuple_len) { - PyObject *py_arg = PyTuple_GetItem(args, argn); + PyObject* py_arg = PyTuple_GetItem(args, argn); if (!py_arg) { py_ue_destroy_params(u_function, buffer); return PyErr_Format(PyExc_TypeError, "unable to get pyobject for property %s", TCHAR_TO_UTF8(*prop->GetName())); } - if (!ue_py_convert_pyobject(py_arg, prop, buffer)) + if (!ue_py_convert_pyobject(py_arg, prop, buffer, 0)) { py_ue_destroy_params(u_function, buffer); return PyErr_Format(PyExc_TypeError, "unable to convert pyobject to property %s (%s)", TCHAR_TO_UTF8(*prop->GetName()), TCHAR_TO_UTF8(*prop->GetClass()->GetName())); @@ -3116,11 +2963,11 @@ PyObject *py_ue_ufunction_call(UFunction *u_function, UObject *u_obj, PyObject * } else if (kwargs) { - char *prop_name = TCHAR_TO_UTF8(*prop->GetName()); - PyObject *dict_value = PyDict_GetItemString(kwargs, prop_name); + char* prop_name = TCHAR_TO_UTF8(*prop->GetName()); + PyObject* dict_value = PyDict_GetItemString(kwargs, prop_name); if (dict_value) { - if (!ue_py_convert_pyobject(dict_value, prop, buffer)) + if (!ue_py_convert_pyobject(dict_value, prop, buffer, 0)) { py_ue_destroy_params(u_function, buffer); return PyErr_Format(PyExc_TypeError, "unable to convert pyobject to property %s (%s)", TCHAR_TO_UTF8(*prop->GetName()), TCHAR_TO_UTF8(*prop->GetClass()->GetName())); @@ -3137,18 +2984,20 @@ PyObject *py_ue_ufunction_call(UFunction *u_function, UObject *u_obj, PyObject * FScopeCycleCounterUObject ObjectScope(u_obj); FScopeCycleCounterUObject FunctionScope(u_function); + Py_BEGIN_ALLOW_THREADS; u_obj->ProcessEvent(u_function, buffer); + Py_END_ALLOW_THREADS; - PyObject *ret = nullptr; + PyObject* ret = nullptr; int has_ret_param = 0; TFieldIterator Props(u_function); for (; Props; ++Props) { - UProperty *prop = *Props; + UProperty* prop = *Props; if (prop->GetPropertyFlags() & CPF_ReturnParm) { - ret = ue_py_convert_property(prop, buffer); + ret = ue_py_convert_property(prop, buffer, 0); if (!ret) { // destroy params @@ -3162,7 +3011,7 @@ PyObject *py_ue_ufunction_call(UFunction *u_function, UObject *u_obj, PyObject * if (has_out_params > 0) { - PyObject *multi_ret = PyTuple_New(has_out_params + has_ret_param); + PyObject* multi_ret = PyTuple_New(has_out_params + has_ret_param); if (ret) { PyTuple_SetItem(multi_ret, 0, ret); @@ -3170,13 +3019,13 @@ PyObject *py_ue_ufunction_call(UFunction *u_function, UObject *u_obj, PyObject * TFieldIterator OProps(u_function); for (; OProps; ++OProps) { - UProperty *prop = *OProps; + UProperty* prop = *OProps; if (prop->HasAnyPropertyFlags(CPF_OutParm) && (prop->IsA() || prop->HasAnyPropertyFlags(CPF_ConstParm) == false)) { // skip return param as it must be always the first if (prop->GetPropertyFlags() & CPF_ReturnParm) continue; - PyObject *py_out = ue_py_convert_property(prop, buffer); + PyObject* py_out = ue_py_convert_property(prop, buffer, 0); if (!py_out) { Py_DECREF(multi_ret); @@ -3199,14 +3048,61 @@ PyObject *py_ue_ufunction_call(UFunction *u_function, UObject *u_obj, PyObject * if (ret) return ret; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; +} + +PyObject* ue_unbind_pyevent(ue_PyUObject* u_obj, FString event_name, PyObject* py_callable, bool fail_on_wrong_property) +{ + UProperty* u_property = u_obj->ue_object->GetClass()->FindPropertyByName(FName(*event_name)); + if (!u_property) + { + if (fail_on_wrong_property) + return PyErr_Format(PyExc_Exception, "unable to find event property %s", TCHAR_TO_UTF8(*event_name)); + Py_RETURN_NONE; + } + + if (auto casted_prop = Cast(u_property)) + { + UPythonDelegate* py_delegate = FUnrealEnginePythonHouseKeeper::Get()->FindDelegate(u_obj->ue_object, py_callable); + if (py_delegate != nullptr) + { +#if ENGINE_MINOR_VERSION < 23 + FMulticastScriptDelegate multiscript_delegate = casted_prop->GetPropertyValue_InContainer(u_obj->ue_object); +#else + FMulticastScriptDelegate multiscript_delegate = *casted_prop->GetMulticastDelegate(u_obj->ue_object); +#endif + + multiscript_delegate.Remove(py_delegate, FName("PyFakeCallable")); + + // re-assign multicast delegate +#if ENGINE_MINOR_VERSION < 23 + casted_prop->SetPropertyValue_InContainer(u_obj->ue_object, multiscript_delegate); +#else + casted_prop->SetMulticastDelegate(u_obj->ue_object, multiscript_delegate); +#endif + } + } + else if (auto casted_prop_delegate = Cast(u_property)) + { + FScriptDelegate script_delegate = casted_prop_delegate->GetPropertyValue_InContainer(u_obj->ue_object); + script_delegate.Unbind(); + + // re-assign multicast delegate + casted_prop_delegate->SetPropertyValue_InContainer(u_obj->ue_object, script_delegate); + } + else + { + if (fail_on_wrong_property) + return PyErr_Format(PyExc_Exception, "property %s is not an event", TCHAR_TO_UTF8(*event_name)); + } + + Py_RETURN_NONE; } -PyObject *ue_bind_pyevent(ue_PyUObject *u_obj, FString event_name, PyObject *py_callable, bool fail_on_wrong_property) +PyObject* ue_bind_pyevent(ue_PyUObject* u_obj, FString event_name, PyObject* py_callable, bool fail_on_wrong_property) { - UProperty *u_property = u_obj->ue_object->GetClass()->FindPropertyByName(FName(*event_name)); + UProperty* u_property = u_obj->ue_object->GetClass()->FindPropertyByName(FName(*event_name)); if (!u_property) { if (fail_on_wrong_property) @@ -3216,10 +3112,14 @@ PyObject *ue_bind_pyevent(ue_PyUObject *u_obj, FString event_name, PyObject *py_ if (auto casted_prop = Cast(u_property)) { +#if ENGINE_MINOR_VERSION < 23 FMulticastScriptDelegate multiscript_delegate = casted_prop->GetPropertyValue_InContainer(u_obj->ue_object); +#else + FMulticastScriptDelegate multiscript_delegate = *casted_prop->GetMulticastDelegate(u_obj->ue_object); +#endif FScriptDelegate script_delegate; - UPythonDelegate *py_delegate = FUnrealEnginePythonHouseKeeper::Get()->NewDelegate(u_obj->ue_object, py_callable, casted_prop->SignatureFunction); + UPythonDelegate* py_delegate = FUnrealEnginePythonHouseKeeper::Get()->NewDelegate(u_obj->ue_object, py_callable, casted_prop->SignatureFunction); // fake UFUNCTION for bypassing checks script_delegate.BindUFunction(py_delegate, FName("PyFakeCallable")); @@ -3227,7 +3127,22 @@ PyObject *ue_bind_pyevent(ue_PyUObject *u_obj, FString event_name, PyObject *py_ multiscript_delegate.Add(script_delegate); // re-assign multicast delegate +#if ENGINE_MINOR_VERSION < 23 casted_prop->SetPropertyValue_InContainer(u_obj->ue_object, multiscript_delegate); +#else + casted_prop->SetMulticastDelegate(u_obj->ue_object, multiscript_delegate); +#endif + } + else if (auto casted_prop_delegate = Cast(u_property)) + { + + FScriptDelegate script_delegate = casted_prop_delegate->GetPropertyValue_InContainer(u_obj->ue_object); + UPythonDelegate* py_delegate = FUnrealEnginePythonHouseKeeper::Get()->NewDelegate(u_obj->ue_object, py_callable, casted_prop_delegate->SignatureFunction); + // fake UFUNCTION for bypassing checks + script_delegate.BindUFunction(py_delegate, FName("PyFakeCallable")); + + // re-assign multicast delegate + casted_prop_delegate->SetPropertyValue_InContainer(u_obj->ue_object, script_delegate); } else { @@ -3238,10 +3153,10 @@ PyObject *ue_bind_pyevent(ue_PyUObject *u_obj, FString event_name, PyObject *py_ Py_RETURN_NONE; } -UFunction *unreal_engine_add_function(UClass *u_class, char *name, PyObject *py_callable, uint32 function_flags) +UFunction* unreal_engine_add_function(UClass* u_class, char* name, PyObject* py_callable, uint32 function_flags) { - UFunction *parent_function = u_class->GetSuperClass()->FindFunctionByName(UTF8_TO_TCHAR(name)); + UFunction* parent_function = u_class->GetSuperClass()->FindFunctionByName(UTF8_TO_TCHAR(name)); // if the function is not available in the parent // check for name collision if (!parent_function) @@ -3253,7 +3168,7 @@ UFunction *unreal_engine_add_function(UClass *u_class, char *name, PyObject *py_ } } - UPythonFunction *function = NewObject(u_class, UTF8_TO_TCHAR(name), RF_Public | RF_Transient | RF_MarkAsNative); + UPythonFunction* function = NewObject(u_class, UTF8_TO_TCHAR(name), RF_Public | RF_Transient | RF_MarkAsNative); function->SetPyCallable(py_callable); #if ENGINE_MINOR_VERSION < 18 @@ -3271,34 +3186,34 @@ UFunction *unreal_engine_add_function(UClass *u_class, char *name, PyObject *py_ // iterate all arguments using inspect.signature() // this is required to maintaining args order - PyObject *inspect = PyImport_ImportModule("inspect"); + PyObject* inspect = PyImport_ImportModule("inspect"); if (!inspect) { return NULL; } - PyObject *signature = PyObject_CallMethod(inspect, (char *)"signature", (char *)"O", py_callable); + PyObject* signature = PyObject_CallMethod(inspect, (char*)"signature", (char*)"O", py_callable); if (!signature) { return NULL; } - PyObject *parameters = PyObject_GetAttrString(signature, "parameters"); + PyObject* parameters = PyObject_GetAttrString(signature, "parameters"); if (!parameters) { return NULL; } - PyObject *annotations = PyObject_GetAttrString(py_callable, "__annotations__"); + PyObject* annotations = PyObject_GetAttrString(py_callable, "__annotations__"); - UField **next_property = &function->Children; - UProperty **next_property_link = &function->PropertyLink; + UField** next_property = &function->Children; + UProperty** next_property_link = &function->PropertyLink; - PyObject *parameters_keys = PyObject_GetIter(parameters); + PyObject* parameters_keys = PyObject_GetIter(parameters); // do not process args if no annotations are available while (annotations) { - PyObject *key = PyIter_Next(parameters_keys); + PyObject* key = PyIter_Next(parameters_keys); if (!key) { if (PyErr_Occurred()) @@ -3308,60 +3223,138 @@ UFunction *unreal_engine_add_function(UClass *u_class, char *name, PyObject *py_ if (!PyUnicodeOrString_Check(key)) continue; - char *p_name = PyUnicode_AsUTF8(key); + const char* p_name = UEPyUnicode_AsUTF8(key); - PyObject *value = PyDict_GetItem(annotations, key); + PyObject* value = PyDict_GetItem(annotations, key); if (!value) continue; - UProperty *prop = nullptr; + UProperty* prop = nullptr; if (PyType_Check(value)) { - if ((PyTypeObject *)value == &PyFloat_Type) + if ((PyTypeObject*)value == &PyFloat_Type) { prop = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); } - else if ((PyTypeObject *)value == &PyUnicode_Type) + else if ((PyTypeObject*)value == &PyUnicode_Type) { prop = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); } - else if ((PyTypeObject *)value == &PyBool_Type) + else if ((PyTypeObject*)value == &PyBool_Type) { prop = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); } - else if ((PyTypeObject *)value == &PyLong_Type) + else if ((PyTypeObject*)value == &PyLong_Type) { prop = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); } - } - else if (ue_PyUObject *py_obj = ue_is_pyuobject(value)) - { - if (py_obj->ue_object->IsA()) + else if ((PyTypeObject*)value == &ue_PyFVectorType) + { + UStructProperty* prop_struct = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); + prop_struct->Struct = TBaseStructure::Get(); + prop = prop_struct; + } + else if ((PyTypeObject*)value == &ue_PyFVector2DType) + { + UStructProperty* prop_struct = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); + prop_struct->Struct = TBaseStructure::Get(); + prop = prop_struct; + } + else if ((PyTypeObject*)value == &ue_PyFRotatorType) + { + UStructProperty* prop_struct = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); + prop_struct->Struct = TBaseStructure::Get(); + prop = prop_struct; + } + else if ((PyTypeObject*)value == &ue_PyFLinearColorType) + { + UStructProperty* prop_struct = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); + prop_struct->Struct = TBaseStructure::Get(); + prop = prop_struct; + } + else if ((PyTypeObject*)value == &ue_PyFColorType) + { + UStructProperty* prop_struct = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); + prop_struct->Struct = TBaseStructure::Get(); + prop = prop_struct; + } + else if ((PyTypeObject*)value == &ue_PyFTransformType) + { + UStructProperty* prop_struct = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); + prop_struct->Struct = TBaseStructure::Get(); + prop = prop_struct; + } +#if ENGINE_MINOR_VERSION > 18 + else if ((PyTypeObject*)value == &ue_PyFQuatType) + { + UStructProperty* prop_struct = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); + prop_struct->Struct = TBaseStructure::Get(); + prop = prop_struct; + } +#endif + else if (PyObject_IsInstance(value, (PyObject*)& PyType_Type)) { - UClass *p_u_class = (UClass *)py_obj->ue_object; - if (p_u_class->IsChildOf()) + // Method annotation like foo:typing.Type[Pawn] produces annotations like typing.Type[Pawn], with .__args__ = (Pawn,) + PyObject* type_args = PyObject_GetAttrString(value, "__args__"); + if (!type_args) { - UClassProperty *prop_base = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); - if (p_u_class == UClass::StaticClass()) - { - prop_base->SetMetaClass(UObject::StaticClass()); - } - else - { - prop_base->SetMetaClass(p_u_class->GetClass()); - } - prop_base->PropertyClass = UClass::StaticClass(); - prop = prop_base; + UE_LOG(LogPython, Error, TEXT("missing type info on %s"), UTF8_TO_TCHAR(name)); + return nullptr; } - else + if (PyTuple_Size(type_args) != 1) { - UObjectProperty *prop_base = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); - prop_base->SetPropertyClass(p_u_class); - prop = prop_base; + Py_DECREF(type_args); + UE_LOG(LogPython, Error, TEXT("exactly one class is allowed in type info for %s"), UTF8_TO_TCHAR(name)); + return nullptr; + } + PyObject* py_class = PyTuple_GetItem(type_args, 0); + ue_PyUObject* py_obj = ue_is_pyuobject(py_class); + if (!py_obj) + { + Py_DECREF(type_args); + UE_LOG(LogPython, Error, TEXT("type for %s must be a ue_PyUObject"), UTF8_TO_TCHAR(name)); + return nullptr; } + if (!py_obj->ue_object->IsA()) + { + Py_DECREF(type_args); + UE_LOG(LogPython, Error, TEXT("type for %s must be a UClass"), UTF8_TO_TCHAR(name)); + return nullptr; + } + UClassProperty* prop_class = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); + prop_class->SetMetaClass((UClass*)py_obj->ue_object); + prop_class->PropertyClass = UClass::StaticClass(); + prop = prop_class; + Py_DECREF(type_args); + } + } + else if (ue_PyUObject * py_obj = ue_is_pyuobject(value)) + { + if (py_obj->ue_object->IsA()) + { + UClass* p_u_class = (UClass*)py_obj->ue_object; + UObjectProperty* prop_base = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); + prop_base->SetPropertyClass(p_u_class); + prop = prop_base; + } +#if ENGINE_MINOR_VERSION > 17 + else if (py_obj->ue_object->IsA()) + { + UEnumProperty* prop_enum = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); + UNumericProperty* prop_underlying = NewObject(prop_enum, TEXT("UnderlyingType"), RF_Public); + prop_enum->SetEnum((UEnum*)py_obj->ue_object); + prop_enum->AddCppProperty(prop_underlying); + prop = prop_enum; + } +#endif + else if (py_obj->ue_object->IsA()) + { + UStructProperty* prop_struct = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); + prop_struct->Struct = (UScriptStruct*)py_obj->ue_object; + prop = prop_struct; } } - // TODO add native types (like vectors, rotators...) + if (prop) { prop->SetPropertyFlags(CPF_Parm); @@ -3380,59 +3373,137 @@ UFunction *unreal_engine_add_function(UClass *u_class, char *name, PyObject *py_ // check for return value if (annotations) { - PyObject *py_return_value = PyDict_GetItemString(annotations, "return"); + PyObject* py_return_value = PyDict_GetItemString(annotations, "return"); if (py_return_value) { UE_LOG(LogPython, Warning, TEXT("Return Value found")); - UProperty *prop = nullptr; - char *p_name = (char *) "ReturnValue"; + UProperty* prop = nullptr; + char* p_name = (char*) "ReturnValue"; if (PyType_Check(py_return_value)) { - if ((PyTypeObject *)py_return_value == &PyFloat_Type) + if ((PyTypeObject*)py_return_value == &PyFloat_Type) { prop = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); } - else if ((PyTypeObject *)py_return_value == &PyUnicode_Type) + else if ((PyTypeObject*)py_return_value == &PyUnicode_Type) { prop = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); } - else if ((PyTypeObject *)py_return_value == &PyBool_Type) + else if ((PyTypeObject*)py_return_value == &PyBool_Type) { prop = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); } - else if ((PyTypeObject *)py_return_value == &PyLong_Type) + else if ((PyTypeObject*)py_return_value == &PyLong_Type) { prop = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); } - } - else if (ue_PyUObject *py_obj = ue_is_pyuobject(py_return_value)) - { - if (py_obj->ue_object->IsA()) + else if ((PyTypeObject*)py_return_value == &ue_PyFVectorType) + { + UStructProperty* prop_struct = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); + prop_struct->Struct = TBaseStructure::Get(); + prop = prop_struct; + } + else if ((PyTypeObject*)py_return_value == &ue_PyFVector2DType) + { + UStructProperty* prop_struct = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); + prop_struct->Struct = TBaseStructure::Get(); + prop = prop_struct; + } + else if ((PyTypeObject*)py_return_value == &ue_PyFRotatorType) { - UClass *p_u_class = (UClass *)py_obj->ue_object; - if (p_u_class->IsChildOf()) + UStructProperty* prop_struct = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); + prop_struct->Struct = TBaseStructure::Get(); + prop = prop_struct; + } + else if ((PyTypeObject*)py_return_value == &ue_PyFLinearColorType) + { + UStructProperty* prop_struct = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); + prop_struct->Struct = TBaseStructure::Get(); + prop = prop_struct; + } + else if ((PyTypeObject*)py_return_value == &ue_PyFColorType) + { + UStructProperty* prop_struct = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); + prop_struct->Struct = TBaseStructure::Get(); + prop = prop_struct; + } + else if ((PyTypeObject*)py_return_value == &ue_PyFTransformType) + { + UStructProperty* prop_struct = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); + prop_struct->Struct = TBaseStructure::Get(); + prop = prop_struct; + } +#if ENGINE_MINOR_VERSION > 18 + else if ((PyTypeObject*)py_return_value == &ue_PyFQuatType) + { + UStructProperty* prop_struct = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); + prop_struct->Struct = TBaseStructure::Get(); + prop = prop_struct; + } +#endif + else if (PyObject_IsInstance(py_return_value, (PyObject*)& PyType_Type)) + { + // Method annotation like foo:typing.Type[Pawn] produces annotations like typing.Type[Pawn], with .__args__ = (Pawn,) + PyObject* type_args = PyObject_GetAttrString(py_return_value, "__args__"); + if (!type_args) { - UClassProperty *prop_base = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); - if (p_u_class == UClass::StaticClass()) - { - prop_base->SetMetaClass(UObject::StaticClass()); - } - else - { - prop_base->SetMetaClass(p_u_class->GetClass()); - } - prop_base->PropertyClass = UClass::StaticClass(); - prop = prop_base; + UE_LOG(LogPython, Error, TEXT("missing type info on %s"), UTF8_TO_TCHAR(name)); + return nullptr; } - else + if (PyTuple_Size(type_args) != 1) + { + Py_DECREF(type_args); + UE_LOG(LogPython, Error, TEXT("exactly one class is allowed in type info for %s"), UTF8_TO_TCHAR(name)); + return nullptr; + } + PyObject* py_class = PyTuple_GetItem(type_args, 0); + ue_PyUObject* py_obj = ue_is_pyuobject(py_class); + if (!py_obj) { - UObjectProperty *prop_base = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); - prop_base->SetPropertyClass(p_u_class); - prop = prop_base; + Py_DECREF(type_args); + UE_LOG(LogPython, Error, TEXT("type for %s must be a ue_PyUObject"), UTF8_TO_TCHAR(name)); + return nullptr; } + if (!py_obj->ue_object->IsA()) + { + Py_DECREF(type_args); + UE_LOG(LogPython, Error, TEXT("type for %s must be a UClass"), UTF8_TO_TCHAR(name)); + return nullptr; + } + UClassProperty* prop_class = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); + prop_class->SetMetaClass((UClass*)py_obj->ue_object); + prop_class->PropertyClass = UClass::StaticClass(); + prop = prop_class; + Py_DECREF(type_args); + } + } + else if (ue_PyUObject * py_obj = ue_is_pyuobject(py_return_value)) + { + if (py_obj->ue_object->IsA()) + { + UClass* p_u_class = (UClass*)py_obj->ue_object; + UObjectProperty* prop_base = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); + prop_base->SetPropertyClass(p_u_class); + prop = prop_base; + } +#if ENGINE_MINOR_VERSION > 17 + else if (py_obj->ue_object->IsA()) + { + UEnumProperty* prop_enum = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); + UNumericProperty* prop_underlying = NewObject(prop_enum, TEXT("UnderlyingType"), RF_Public); + prop_enum->SetEnum((UEnum*)py_obj->ue_object); + prop_enum->AddCppProperty(prop_underlying); + prop = prop_enum; + } +#endif + else if (py_obj->ue_object->IsA()) + { + UStructProperty* prop_struct = NewObject(function, UTF8_TO_TCHAR(p_name), RF_Public); + prop_struct->Struct = (UScriptStruct*)py_obj->ue_object; + prop = prop_struct; } } - // TODO add native types (like vectors, rotators...) + if (prop) { prop->SetPropertyFlags(CPF_Parm | CPF_OutParm | CPF_ReturnParm); @@ -3460,11 +3531,11 @@ UFunction *unreal_engine_add_function(UClass *u_class, char *name, PyObject *py_ TFieldIterator It(parent_function); while (It) { - UProperty *p = *It; + UProperty* p = *It; if (p->PropertyFlags & CPF_Parm) { UE_LOG(LogPython, Warning, TEXT("Parent PROP: %s %d/%d %d %d %d %s %p"), *p->GetName(), (int)p->PropertyFlags, (int)UFunction::GetDefaultIgnoredSignatureCompatibilityFlags(), (int)(p->PropertyFlags & ~UFunction::GetDefaultIgnoredSignatureCompatibilityFlags()), p->GetSize(), p->GetOffset_ForGC(), *p->GetClass()->GetName(), p->GetClass()); - UClassProperty *ucp = Cast(p); + UClassProperty* ucp = Cast(p); if (ucp) { UE_LOG(LogPython, Warning, TEXT("Parent UClassProperty = %p %s %p %s"), ucp->PropertyClass, *ucp->PropertyClass->GetName(), ucp->MetaClass, *ucp->MetaClass->GetName()); @@ -3476,11 +3547,11 @@ UFunction *unreal_engine_add_function(UClass *u_class, char *name, PyObject *py_ TFieldIterator It2(function); while (It2) { - UProperty *p = *It2; + UProperty* p = *It2; if (p->PropertyFlags & CPF_Parm) { UE_LOG(LogPython, Warning, TEXT("Function PROP: %s %d/%d %d %d %d %s %p"), *p->GetName(), (int)p->PropertyFlags, (int)UFunction::GetDefaultIgnoredSignatureCompatibilityFlags(), (int)(p->PropertyFlags & ~UFunction::GetDefaultIgnoredSignatureCompatibilityFlags()), p->GetSize(), p->GetOffset_ForGC(), *p->GetClass()->GetName(), p->GetClass()); - UClassProperty *ucp = Cast(p); + UClassProperty* ucp = Cast(p); if (ucp) { UE_LOG(LogPython, Warning, TEXT("Function UClassProperty = %p %s %p %s"), ucp->PropertyClass, *ucp->PropertyClass->GetName(), ucp->MetaClass, *ucp->MetaClass->GetName()); @@ -3500,7 +3571,7 @@ UFunction *unreal_engine_add_function(UClass *u_class, char *name, PyObject *py_ TFieldIterator props(function, EFieldIteratorFlags::ExcludeSuper); for (; props; ++props) { - UProperty *p = *props; + UProperty* p = *props; if (p->HasAnyPropertyFlags(CPF_Parm)) { function->NumParms++; @@ -3529,9 +3600,9 @@ UFunction *unreal_engine_add_function(UClass *u_class, char *name, PyObject *py_ #endif #if ENGINE_MINOR_VERSION > 18 - function->SetNativeFunc((FNativeFuncPtr)&UPythonFunction::CallPythonCallable); + function->SetNativeFunc((FNativeFuncPtr)& UPythonFunction::CallPythonCallable); #else - function->SetNativeFunc((Native)&UPythonFunction::CallPythonCallable); + function->SetNativeFunc((Native)& UPythonFunction::CallPythonCallable); #endif function->Next = u_class->Children; @@ -3564,30 +3635,34 @@ UFunction *unreal_engine_add_function(UClass *u_class, char *name, PyObject *py_ #endif #if WITH_EDITOR - FBlueprintActionDatabase::Get().RefreshClassActions(u_class); + // this is required for avoiding startup crashes #405 + if (GEditor) + { + FBlueprintActionDatabase::Get().RefreshClassActions(u_class); + } #endif return function; } -FGuid *ue_py_check_fguid(PyObject *py_obj) +FGuid* ue_py_check_fguid(PyObject* py_obj) { - ue_PyUScriptStruct *ue_py_struct = py_ue_is_uscriptstruct(py_obj); + ue_PyUScriptStruct* ue_py_struct = py_ue_is_uscriptstruct(py_obj); if (!ue_py_struct) { return nullptr; } - if (ue_py_struct->u_struct == FindObject(ANY_PACKAGE, UTF8_TO_TCHAR((char *)"Guid"))) + if (ue_py_struct->u_struct == FindObject(ANY_PACKAGE, UTF8_TO_TCHAR((char*)"Guid"))) { - return (FGuid*)ue_py_struct->data; + return (FGuid*)ue_py_struct->u_struct_ptr; } return nullptr; } -uint8 * do_ue_py_check_struct(PyObject *py_obj, UScriptStruct* chk_u_struct) +uint8* do_ue_py_check_struct(PyObject* py_obj, UScriptStruct* chk_u_struct) { - ue_PyUScriptStruct *ue_py_struct = py_ue_is_uscriptstruct(py_obj); + ue_PyUScriptStruct* ue_py_struct = py_ue_is_uscriptstruct(py_obj); if (!ue_py_struct) { return nullptr; @@ -3595,15 +3670,15 @@ uint8 * do_ue_py_check_struct(PyObject *py_obj, UScriptStruct* chk_u_struct) if (ue_py_struct->u_struct == chk_u_struct) { - return ue_py_struct->data; + return ue_py_struct->u_struct_ptr; } return nullptr; } -bool do_ue_py_check_childstruct(PyObject *py_obj, UScriptStruct* parent_u_struct) +bool do_ue_py_check_childstruct(PyObject* py_obj, UScriptStruct* parent_u_struct) { - ue_PyUScriptStruct *ue_py_struct = py_ue_is_uscriptstruct(py_obj); + ue_PyUScriptStruct* ue_py_struct = py_ue_is_uscriptstruct(py_obj); if (!ue_py_struct) { return false; @@ -3612,24 +3687,16 @@ bool do_ue_py_check_childstruct(PyObject *py_obj, UScriptStruct* parent_u_struct return ue_py_struct->u_struct->IsChildOf(parent_u_struct); } + + #if PY_MAJOR_VERSION >= 3 -static PyObject *init_unreal_engine() +static PyObject * init_unreal_engine() { - - ue_PyUObjectType.tp_new = PyType_GenericNew; - ue_PyUObjectType.tp_init = (initproc)unreal_engine_py_init; - ue_PyUObjectType.tp_dictoffset = offsetof(ue_PyUObject, py_dict); - - if (PyType_Ready(&ue_PyUObjectType) < 0) - return nullptr; - PyObject *new_unreal_engine_module = PyModule_Create(&unreal_engine_module); + PyObject* new_unreal_engine_module = PyModule_Create(&unreal_engine_module); if (!new_unreal_engine_module) return nullptr; - Py_INCREF(&ue_PyUObjectType); - PyModule_AddObject(new_unreal_engine_module, "UObject", (PyObject *)&ue_PyUObjectType); - return new_unreal_engine_module; } -#endif \ No newline at end of file +#endif diff --git a/Source/UnrealEnginePython/Private/UEPyModule.h b/Source/UnrealEnginePython/Private/UEPyModule.h index 375245a1c..9d865cb16 100644 --- a/Source/UnrealEnginePython/Private/UEPyModule.h +++ b/Source/UnrealEnginePython/Private/UEPyModule.h @@ -4,41 +4,38 @@ #include "PythonDelegate.h" #include "PythonSmartDelegate.h" #include "UEPyUScriptStruct.h" +#include "PythonHouseKeeper.h" + +// common wrappersno +#include "Wrappers/UEPyFVector.h" +#include "Wrappers/UEPyFRotator.h" +#include "Wrappers/UEPyFQuat.h" +#include "Wrappers/UEPyFTransform.h" +#include "Wrappers/UEPyFColor.h" +#include "Wrappers/UEPyFLinearColor.h" + +// backward compatibility for UE4.20 TCHAR_TO_WCHAR +#ifndef TCHAR_TO_WCHAR + // SIZEOF_WCHAR_T is provided by pyconfig.h + #if SIZEOF_WCHAR_T == (PLATFORM_TCHAR_IS_4_BYTES ? 4 : 2) + #define TCHAR_TO_WCHAR(str) str + #else + #define TCHAR_TO_WCHAR(str) (wchar_t*)StringCast(static_cast(str)).Get() + #endif +#endif - -//#include "UEPyModule.generated.h" - -typedef struct -{ - PyObject_HEAD - /* Type-specific fields go here. */ - UObject *ue_object; - // reference to proxy class (can be null) - PyObject *py_proxy; - // the __dict__ - PyObject *py_dict; - // if true RemoveFromRoot will be called at object destruction time - int auto_rooted; -} ue_PyUObject; - - - - - -void unreal_engine_py_log_error(); -ue_PyUObject *ue_get_python_uobject(UObject *); -ue_PyUObject *ue_get_python_uobject_inc(UObject *); UWorld *ue_get_uworld(ue_PyUObject *); AActor *ue_get_actor(ue_PyUObject *); -PyObject *ue_py_convert_property(UProperty *, uint8 *); -bool ue_py_convert_pyobject(PyObject *, UProperty *, uint8 *); +PyObject *ue_py_convert_property(UProperty *, uint8 *, int32); +bool ue_py_convert_pyobject(PyObject *, UProperty *, uint8 *, int32); ue_PyUObject *ue_is_pyuobject(PyObject *); void ue_bind_events_for_py_class_by_attribute(UObject *, PyObject *); void ue_autobind_events_for_pyclass(ue_PyUObject *, PyObject *); PyObject *ue_bind_pyevent(ue_PyUObject *, FString, PyObject *, bool); +PyObject *ue_unbind_pyevent(ue_PyUObject *, FString, PyObject *, bool); PyObject *py_ue_ufunction_call(UFunction *, UObject *, PyObject *, int, PyObject *); diff --git a/Source/UnrealEnginePython/Private/UEPySubclassing.cpp b/Source/UnrealEnginePython/Private/UEPySubclassing.cpp new file mode 100644 index 000000000..548a83935 --- /dev/null +++ b/Source/UnrealEnginePython/Private/UEPySubclassing.cpp @@ -0,0 +1,507 @@ +#include "UEPyModule.h" +#include "PythonClass.h" +#include "UObject/UEPyObject.h" + +// hack for avoiding loops in class constructors (thanks to the Unreal.js project for the idea) +UClass *ue_py_class_constructor_placeholder = nullptr; +static void UEPyClassConstructor(UClass *u_class, const FObjectInitializer &ObjectInitializer) +{ + if (UPythonClass *u_py_class_casted = Cast(u_class)) + { + ue_py_class_constructor_placeholder = u_class; + } + u_class->ClassConstructor(ObjectInitializer); + ue_py_class_constructor_placeholder = nullptr; +} + +int unreal_engine_py_init(ue_PyUObject *self, PyObject *args, PyObject *kwds) +{ + + // is it subclassing ? + if (PyTuple_Size(args) == 3) + { + // TODO make it smarter on error checking + UE_LOG(LogPython, Warning, TEXT("%s"), UTF8_TO_TCHAR(UEPyUnicode_AsUTF8(PyObject_Str(PyTuple_GetItem(args, 0))))); + UE_LOG(LogPython, Warning, TEXT("%s"), UTF8_TO_TCHAR(UEPyUnicode_AsUTF8(PyObject_Str(PyTuple_GetItem(args, 1))))); + UE_LOG(LogPython, Warning, TEXT("%s"), UTF8_TO_TCHAR(UEPyUnicode_AsUTF8(PyObject_Str(PyTuple_GetItem(args, 2))))); + + PyObject *parents = PyTuple_GetItem(args, 1); + ue_PyUObject *parent = (ue_PyUObject *)PyTuple_GetItem(parents, 0); + + PyObject *class_attributes = PyTuple_GetItem(args, 2); + + PyObject *class_name = PyDict_GetItemString(class_attributes, (char *)"__qualname__"); + const char *name = UEPyUnicode_AsUTF8(class_name); + // check if parent is a uclass + UClass *new_class = unreal_engine_new_uclass((char *)name, (UClass *)parent->ue_object); + if (!new_class) + return -1; + + // map the class to the python object + self->ue_object = new_class; + self->py_proxy = nullptr; + self->auto_rooted = 0; + self->py_dict = PyDict_New(); + + FUnrealEnginePythonHouseKeeper::Get()->RegisterPyUObject(new_class, self); + + PyObject *py_additional_properties = PyDict_New(); + + PyObject *class_attributes_keys = PyObject_GetIter(class_attributes); + for (;;) + { + PyObject *key = PyIter_Next(class_attributes_keys); + if (!key) + { + if (PyErr_Occurred()) + return -1; + break; + } + if (!PyUnicodeOrString_Check(key)) + continue; + const char *class_key = UEPyUnicode_AsUTF8(key); + + PyObject *value = PyDict_GetItem(class_attributes, key); + + if (strlen(class_key) > 2 && class_key[0] == '_' && class_key[1] == '_') + { + continue; + } + + bool prop_added = false; + + if (UProperty *u_property = new_class->FindPropertyByName(FName(UTF8_TO_TCHAR(class_key)))) + { + UE_LOG(LogPython, Warning, TEXT("Found UProperty %s"), UTF8_TO_TCHAR(class_key)); + PyDict_SetItem(py_additional_properties, key, value); + prop_added = true; + } + // add simple property + else if (ue_is_pyuobject(value)) + { + ue_PyUObject *py_obj = (ue_PyUObject *)value; + if (py_obj->ue_object->IsA()) + { + UClass *p_class = (UClass *)py_obj->ue_object; + if (p_class->IsChildOf()) + { + if (!py_ue_add_property(self, Py_BuildValue("(Os)", value, class_key))) + { + unreal_engine_py_log_error(); + return -1; + } + prop_added = true; + } + else + { + if (!py_ue_add_property(self, Py_BuildValue("(OsO)", (PyObject *)ue_get_python_uobject(UObjectProperty::StaticClass()), class_key, value))) + { + unreal_engine_py_log_error(); + return -1; + } + prop_added = true; + } + } + else if (py_obj->ue_object->IsA()) + { + if (!py_ue_add_property(self, Py_BuildValue("(OsO)", (PyObject *)ue_get_python_uobject(UStructProperty::StaticClass()), class_key, value))) + { + unreal_engine_py_log_error(); + return -1; + } + prop_added = true; + } + } + + // add array property + else if (PyList_Check(value)) + { + if (PyList_Size(value) == 1) + { + PyObject *first_item = PyList_GetItem(value, 0); + if (ue_is_pyuobject(first_item)) + { + ue_PyUObject *py_obj = (ue_PyUObject *)first_item; + if (py_obj->ue_object->IsA()) + { + UClass *p_class = (UClass *)py_obj->ue_object; + if (p_class->IsChildOf()) + { + if (!py_ue_add_property(self, Py_BuildValue("(Os)", value, class_key))) + { + unreal_engine_py_log_error(); + return -1; + } + prop_added = true; + } + + else + { + if (!py_ue_add_property(self, Py_BuildValue("([O]sO)", (PyObject *)ue_get_python_uobject(UObjectProperty::StaticClass()), class_key, first_item))) + { + unreal_engine_py_log_error(); + return -1; + } + prop_added = true; + } + } + else if (py_obj->ue_object->IsA()) + { + if (!py_ue_add_property(self, Py_BuildValue("([O]sO)", (PyObject *)ue_get_python_uobject(UStructProperty::StaticClass()), class_key, first_item))) + { + unreal_engine_py_log_error(); + return -1; + } + prop_added = true; + } + } + + } + } +#if ENGINE_MINOR_VERSION >= 15 + else if (PyDict_Check(value)) + { + if (PyDict_Size(value) == 1) + { + PyObject *py_key = nullptr; + PyObject *py_value = nullptr; + Py_ssize_t pos = 0; + PyDict_Next(value, &pos, &py_key, &py_value); + if (ue_is_pyuobject(py_key) && ue_is_pyuobject(py_value)) + { + PyObject *first_item = nullptr; + PyObject *second_item = nullptr; + + ue_PyUObject *py_obj = (ue_PyUObject *)py_key; + if (py_obj->ue_object->IsA()) + { + UClass *p_class = (UClass *)py_obj->ue_object; + if (p_class->IsChildOf()) + { + first_item = py_key; + } + else + { + first_item = (PyObject *)ue_get_python_uobject(UObjectProperty::StaticClass()); + } + } + else if (py_obj->ue_object->IsA()) + { + first_item = (PyObject *)ue_get_python_uobject(UStructProperty::StaticClass()); + } + + ue_PyUObject *py_obj2 = (ue_PyUObject *)py_value; + if (py_obj2->ue_object->IsA()) + { + UClass *p_class = (UClass *)py_obj2->ue_object; + if (p_class->IsChildOf()) + { + second_item = py_value; + } + else + { + second_item = (PyObject *)ue_get_python_uobject(UObjectProperty::StaticClass()); + } + } + else if (py_obj2->ue_object->IsA()) + { + second_item = (PyObject *)ue_get_python_uobject(UStructProperty::StaticClass()); + } + + if (!py_ue_add_property(self, Py_BuildValue("([OO]sOO)", first_item, second_item, class_key, py_key, py_value))) + { + unreal_engine_py_log_error(); + return -1; + } + prop_added = true; + } + } + } +#endif + // function ? + else if (PyCallable_Check(value) && class_key[0] >= 'A' && class_key[0] <= 'Z') + { + uint32 func_flags = FUNC_Native | FUNC_BlueprintCallable | FUNC_Public; + PyObject *is_event = PyObject_GetAttrString(value, (char *)"event"); + if (is_event && PyObject_IsTrue(is_event)) + { + func_flags |= FUNC_Event | FUNC_BlueprintEvent; + } + else if (!is_event) + PyErr_Clear(); + + PyObject *is_multicast = PyObject_GetAttrString(value, (char *)"multicast"); + if (is_multicast && PyObject_IsTrue(is_multicast)) + { + func_flags |= FUNC_NetMulticast; + } + else if (!is_multicast) + PyErr_Clear(); + PyObject *is_server = PyObject_GetAttrString(value, (char *)"server"); + if (is_server && PyObject_IsTrue(is_server)) + { + func_flags |= FUNC_NetServer; + } + else if (!is_server) + PyErr_Clear(); + PyObject *is_client = PyObject_GetAttrString(value, (char *)"client"); + if (is_client && PyObject_IsTrue(is_client)) + { + func_flags |= FUNC_NetClient; + } + else if (!is_client) + PyErr_Clear(); + PyObject *is_reliable = PyObject_GetAttrString(value, (char *)"reliable"); + if (is_reliable && PyObject_IsTrue(is_reliable)) + { + func_flags |= FUNC_NetReliable; + } + else if (!is_reliable) + PyErr_Clear(); + + + PyObject *is_pure = PyObject_GetAttrString(value, (char *)"pure"); + if (is_pure && PyObject_IsTrue(is_pure)) + { + func_flags |= FUNC_BlueprintPure; + } + else if (!is_pure) + PyErr_Clear(); + PyObject *is_static = PyObject_GetAttrString(value, (char *)"static"); + if (is_static && PyObject_IsTrue(is_static)) + { + func_flags |= FUNC_Static; + } + else if (!is_static) + PyErr_Clear(); + PyObject *override_name = PyObject_GetAttrString(value, (char *)"override"); + if (override_name && PyUnicodeOrString_Check(override_name)) + { + class_key = UEPyUnicode_AsUTF8(override_name); + } + else if (override_name && PyUnicodeOrString_Check(override_name)) + { + class_key = UEPyUnicode_AsUTF8(override_name); + } + else if (!override_name) + PyErr_Clear(); + if (!unreal_engine_add_function(new_class, (char *)class_key, value, func_flags)) + { + UE_LOG(LogPython, Error, TEXT("unable to add function %s"), UTF8_TO_TCHAR(class_key)); + return -1; + } + prop_added = true; + } + + + if (!prop_added) + { + UE_LOG(LogPython, Warning, TEXT("Adding %s as attr"), UTF8_TO_TCHAR(class_key)); + PyObject_SetAttr((PyObject *)self, key, value); + } + } + + if (PyDict_Size(py_additional_properties) > 0) + { + PyObject_SetAttrString((PyObject *)self, (char*)"__additional_uproperties__", py_additional_properties); + } + + UPythonClass *new_u_py_class = (UPythonClass *)new_class; + // TODO: check if we can use this to decref the ue_PyUbject mapped to the class + new_u_py_class->py_uobject = self; + new_u_py_class->ClassConstructor = [](const FObjectInitializer &ObjectInitializer) + { + FScopePythonGIL gil; + UClass *u_class = ue_py_class_constructor_placeholder ? ue_py_class_constructor_placeholder : ObjectInitializer.GetClass(); + ue_py_class_constructor_placeholder = nullptr; + + UEPyClassConstructor(u_class->GetSuperClass(), ObjectInitializer); + + if (UPythonClass *u_py_class_casted = Cast(u_class)) + { + ue_PyUObject *new_self = ue_get_python_uobject(ObjectInitializer.GetObj()); + if (!new_self) + { + unreal_engine_py_log_error(); + return; + } + + // fill __dict__ from class + if (u_py_class_casted->py_uobject && u_py_class_casted->py_uobject->py_dict) + { + PyObject *found_additional_props = PyDict_GetItemString(u_py_class_casted->py_uobject->py_dict, (char *)"__additional_uproperties__"); + // manage UProperties (and automatically maps multicast properties) + if (found_additional_props) + { + PyObject *keys = PyDict_Keys(found_additional_props); + Py_ssize_t items_len = PyList_Size(keys); + for (Py_ssize_t i = 0; i < items_len; i++) + { + PyObject *mc_key = PyList_GetItem(keys, i); + PyObject *mc_value = PyDict_GetItem(found_additional_props, mc_key); + + const char *mc_name = UEPyUnicode_AsUTF8(mc_key); + UProperty *u_property = ObjectInitializer.GetObj()->GetClass()->FindPropertyByName(FName(UTF8_TO_TCHAR(mc_name))); + if (u_property) + { + if (auto casted_prop = Cast(u_property)) + { +#if ENGINE_MINOR_VERSION >= 23 + FMulticastScriptDelegate multiscript_delegate = *casted_prop->GetMulticastDelegate(ObjectInitializer.GetObj()); +#else + + FMulticastScriptDelegate multiscript_delegate = casted_prop->GetPropertyValue_InContainer(ObjectInitializer.GetObj()); +#endif + + FScriptDelegate script_delegate; + UPythonDelegate *py_delegate = FUnrealEnginePythonHouseKeeper::Get()->NewDelegate(ObjectInitializer.GetObj(), mc_value, casted_prop->SignatureFunction); + // fake UFUNCTION for bypassing checks + script_delegate.BindUFunction(py_delegate, FName("PyFakeCallable")); + + // add the new delegate + multiscript_delegate.Add(script_delegate); + + // re-assign multicast delegate +#if ENGINE_MINOR_VERSION >= 23 + casted_prop->SetMulticastDelegate(ObjectInitializer.GetObj(), multiscript_delegate); +#else + casted_prop->SetPropertyValue_InContainer(ObjectInitializer.GetObj(), multiscript_delegate); +#endif + } + else + { + PyObject_SetAttr((PyObject *)new_self, mc_key, mc_value); + } + } + + } + Py_DECREF(keys); + } + else + { + PyErr_Clear(); + } + PyObject *keys = PyDict_Keys(u_py_class_casted->py_uobject->py_dict); + Py_ssize_t keys_len = PyList_Size(keys); + for (Py_ssize_t i = 0; i < keys_len; i++) + { + PyObject *key = PyList_GetItem(keys, i); + PyObject *value = PyDict_GetItem(u_py_class_casted->py_uobject->py_dict, key); + if (PyUnicodeOrString_Check(key)) + { + const char *key_name = UEPyUnicode_AsUTF8(key); + if (!strcmp(key_name, (char *)"__additional_uproperties__")) + continue; + } + // special case to bound function to method + if (PyFunction_Check(value)) + { + PyObject *bound_function = PyObject_CallMethod(value, (char*)"__get__", (char*)"O", (PyObject *)new_self); + if (bound_function) + { + PyObject_SetAttr((PyObject *)new_self, key, bound_function); + Py_DECREF(bound_function); + } + else + { + unreal_engine_py_log_error(); + } + } + else + { + PyObject_SetAttr((PyObject *)new_self, key, value); + } + } + Py_DECREF(keys); + } + // call __init__ + u_py_class_casted->CallPyConstructor(new_self); + } + }; + + + + if (self->py_dict) + { + ue_PyUObject *new_default_self = ue_get_python_uobject(new_u_py_class->ClassDefaultObject); + + if (!new_default_self) + { + unreal_engine_py_log_error(); + UE_LOG(LogPython, Error, TEXT("unable to set dict on new ClassDefaultObject")); + return -1; + } + PyObject *keys = PyDict_Keys(self->py_dict); + + Py_ssize_t keys_len = PyList_Size(keys); + for (Py_ssize_t i = 0; i < keys_len; i++) + { + PyObject *key = PyList_GetItem(keys, i); + PyObject *value = PyDict_GetItem(self->py_dict, key); + // special case to bound function to method + if (PyFunction_Check(value)) + { + PyObject *bound_function = PyObject_CallMethod(value, (char*)"__get__", (char*)"O", (PyObject *)new_default_self); + if (bound_function) + { + PyObject_SetAttr((PyObject *)new_default_self, key, bound_function); + Py_DECREF(bound_function); + } + else + { + unreal_engine_py_log_error(); + } + } + else + { + PyObject_SetAttr((PyObject *)new_default_self, key, value); + } + } + Py_DECREF(keys); + } + + // add default uproperties values + if (py_additional_properties) + { + ue_PyUObject *new_default_self = ue_get_python_uobject(new_u_py_class->ClassDefaultObject); + if (!new_default_self) + { + unreal_engine_py_log_error(); + UE_LOG(LogPython, Error, TEXT("unable to set properties on new ClassDefaultObject")); + return -1; + } + PyObject *keys = PyDict_Keys(py_additional_properties); + Py_ssize_t keys_len = PyList_Size(keys); + for (Py_ssize_t i = 0; i < keys_len; i++) + { + PyObject *key = PyList_GetItem(keys, i); + PyObject *value = PyDict_GetItem(py_additional_properties, key); + + PyObject_SetAttr((PyObject *)new_default_self, key, value); + } + Py_DECREF(keys); + } + + // add custom constructor (__init__) + PyObject *py_init = PyDict_GetItemString(class_attributes, (char *)"__init__"); + if (py_init && PyCallable_Check(py_init)) + { + // fake initializer + FObjectInitializer initializer(new_u_py_class->ClassDefaultObject, nullptr, false, true); + new_u_py_class->SetPyConstructor(py_init); + ue_PyUObject *new_default_self = ue_get_python_uobject(new_u_py_class->ClassDefaultObject); + + if (!new_default_self) + { + unreal_engine_py_log_error(); + UE_LOG(LogPython, Error, TEXT("unable to call __init__ on new ClassDefaultObject")); + return -1; + } + + new_u_py_class->CallPyConstructor(new_default_self); + } + + } + + return 0; +} \ No newline at end of file diff --git a/Source/UnrealEnginePython/Private/UEPyTicker.cpp b/Source/UnrealEnginePython/Private/UEPyTicker.cpp index 73af0f7a5..25f558f49 100644 --- a/Source/UnrealEnginePython/Private/UEPyTicker.cpp +++ b/Source/UnrealEnginePython/Private/UEPyTicker.cpp @@ -1,4 +1,3 @@ -#include "UnrealEnginePythonPrivatePCH.h" #include "UEPyTicker.h" diff --git a/Source/UnrealEnginePython/Private/UEPyTicker.h b/Source/UnrealEnginePython/Private/UEPyTicker.h index 0972a3055..79a830c65 100644 --- a/Source/UnrealEnginePython/Private/UEPyTicker.h +++ b/Source/UnrealEnginePython/Private/UEPyTicker.h @@ -2,12 +2,14 @@ #pragma once -#include "UnrealEnginePython.h" +#include "UEPyModule.h" +#include "Runtime/Core/Public/Containers/Ticker.h" -typedef struct { +typedef struct +{ PyObject_HEAD - /* Type-specific fields go here. */ - FDelegateHandle dhandle; + /* Type-specific fields go here. */ + FDelegateHandle dhandle; bool garbaged; TSharedPtr delegate_ptr; } ue_PyFDelegateHandle; diff --git a/Source/UnrealEnginePython/Private/UEPyTimer.cpp b/Source/UnrealEnginePython/Private/UEPyTimer.cpp index f00a22b3c..adbc82ad9 100644 --- a/Source/UnrealEnginePython/Private/UEPyTimer.cpp +++ b/Source/UnrealEnginePython/Private/UEPyTimer.cpp @@ -1,7 +1,9 @@ -#include "UnrealEnginePythonPrivatePCH.h" #include "UEPyTimer.h" +#include "Engine/World.h" +#include "Runtime/Engine/Public/TimerManager.h" + static PyObject *py_ue_ftimerhandle_clear(ue_PyFTimerHandle *self, PyObject * args) { if (!self->world.IsValid()) @@ -125,6 +127,8 @@ PyObject *py_ue_set_timer(ue_PyUObject *self, PyObject * args) return PyErr_Format(PyExc_Exception, "unable to allocate FTimerHandle python object"); } + new(&ret->thandle) FTimerHandle; + FTimerDelegate timer_delegate; TSharedRef py_delegate = MakeShareable(new FPythonSmartDelegate); py_delegate->SetPyCallable(py_callable); diff --git a/Source/UnrealEnginePython/Private/UEPyTimer.h b/Source/UnrealEnginePython/Private/UEPyTimer.h index aec770fae..db8631b3f 100644 --- a/Source/UnrealEnginePython/Private/UEPyTimer.h +++ b/Source/UnrealEnginePython/Private/UEPyTimer.h @@ -2,12 +2,14 @@ -#include "UnrealEnginePython.h" +#include "UEPyModule.h" +#include "Engine/EngineTypes.h" -typedef struct { +typedef struct +{ PyObject_HEAD - /* Type-specific fields go here. */ - FTimerHandle thandle; + /* Type-specific fields go here. */ + FTimerHandle thandle; TWeakObjectPtr world; TSharedPtr delegate_ptr; } ue_PyFTimerHandle; diff --git a/Source/UnrealEnginePython/Private/UEPyUClassesImporter.cpp b/Source/UnrealEnginePython/Private/UEPyUClassesImporter.cpp index 1d2ee0a28..193d300e3 100644 --- a/Source/UnrealEnginePython/Private/UEPyUClassesImporter.cpp +++ b/Source/UnrealEnginePython/Private/UEPyUClassesImporter.cpp @@ -1,4 +1,4 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPyUClassesImporter.h" static PyObject *ue_PyUClassesImporter_getattro(ue_PyUClassesImporter *self, PyObject *attr_name) { @@ -7,7 +7,7 @@ static PyObject *ue_PyUClassesImporter_getattro(ue_PyUClassesImporter *self, PyO { if (PyUnicodeOrString_Check(attr_name)) { - char *attr = PyUnicode_AsUTF8(attr_name); + const char *attr = UEPyUnicode_AsUTF8(attr_name); if (attr[0] != '_') { UClass *u_class = FindObject(ANY_PACKAGE, UTF8_TO_TCHAR(attr)); diff --git a/Source/UnrealEnginePython/Private/UEPyUClassesImporter.h b/Source/UnrealEnginePython/Private/UEPyUClassesImporter.h index 6a514b7a5..a20574749 100644 --- a/Source/UnrealEnginePython/Private/UEPyUClassesImporter.h +++ b/Source/UnrealEnginePython/Private/UEPyUClassesImporter.h @@ -2,11 +2,12 @@ -#include "UnrealEnginePython.h" +#include "UEPyModule.h" -typedef struct { +typedef struct +{ PyObject_HEAD - /* Type-specific fields go here. */ + /* Type-specific fields go here. */ } ue_PyUClassesImporter; PyObject *py_ue_new_uclassesimporter(); diff --git a/Source/UnrealEnginePython/Private/UEPyUScriptStruct.cpp b/Source/UnrealEnginePython/Private/UEPyUScriptStruct.cpp index 7b230baf8..28df03059 100644 --- a/Source/UnrealEnginePython/Private/UEPyUScriptStruct.cpp +++ b/Source/UnrealEnginePython/Private/UEPyUScriptStruct.cpp @@ -1,12 +1,13 @@ // Copyright 20Tab S.r.l. -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPyUScriptStruct.h" static PyObject *py_ue_uscriptstruct_get_field(ue_PyUScriptStruct *self, PyObject * args) { char *name; - if (!PyArg_ParseTuple(args, "s:get_field", &name)) + int index = 0; + if (!PyArg_ParseTuple(args, "s|i:get_field", &name, &index)) { return nullptr; } @@ -15,14 +16,30 @@ static PyObject *py_ue_uscriptstruct_get_field(ue_PyUScriptStruct *self, PyObjec if (!u_property) return PyErr_Format(PyExc_Exception, "unable to find property %s", name); - return ue_py_convert_property(u_property, self->data); + return ue_py_convert_property(u_property, self->u_struct_ptr, index); +} + +static PyObject *py_ue_uscriptstruct_get_field_array_dim(ue_PyUScriptStruct *self, PyObject * args) +{ + char *name; + if (!PyArg_ParseTuple(args, "s:get_field_array_dim", &name)) + { + return nullptr; + } + + UProperty *u_property = self->u_struct->FindPropertyByName(FName(UTF8_TO_TCHAR(name))); + if (!u_property) + return PyErr_Format(PyExc_Exception, "unable to find property %s", name); + + return PyLong_FromLongLong(u_property->ArrayDim); } static PyObject *py_ue_uscriptstruct_set_field(ue_PyUScriptStruct *self, PyObject * args) { char *name; PyObject *value; - if (!PyArg_ParseTuple(args, "sO:set_field", &name, &value)) + int index = 0; + if (!PyArg_ParseTuple(args, "sO|i:set_field", &name, &value, &index)) { return nullptr; } @@ -32,7 +49,7 @@ static PyObject *py_ue_uscriptstruct_set_field(ue_PyUScriptStruct *self, PyObjec return PyErr_Format(PyExc_Exception, "unable to find property %s", name); - if (!ue_py_convert_pyobject(value, u_property, self->data)) + if (!ue_py_convert_pyobject(value, u_property, self->u_struct_ptr, index)) { return PyErr_Format(PyExc_Exception, "unable to set property %s", name); } @@ -61,10 +78,7 @@ static PyObject *py_ue_uscriptstruct_get_struct(ue_PyUScriptStruct *self, PyObje Py_RETURN_UOBJECT(self->u_struct); } -static PyObject *py_ue_uscriptstruct_clone(ue_PyUScriptStruct *self, PyObject * args) -{ - return py_ue_new_uscriptstruct(self->u_struct, self->data); -} +static PyObject *py_ue_uscriptstruct_clone(ue_PyUScriptStruct *, PyObject *); PyObject *py_ue_uscriptstruct_as_dict(ue_PyUScriptStruct * self, PyObject * args) { @@ -81,7 +95,7 @@ PyObject *py_ue_uscriptstruct_as_dict(ue_PyUScriptStruct * self, PyObject * args TFieldIterator SArgs(self->u_struct); for (; SArgs; ++SArgs) { - PyObject *struct_value = ue_py_convert_property(*SArgs, self->data); + PyObject *struct_value = ue_py_convert_property(*SArgs, self->u_struct_ptr, 0); if (!struct_value) { Py_DECREF(py_struct_dict); @@ -113,6 +127,7 @@ static PyObject *py_ue_uscriptstruct_ref(ue_PyUScriptStruct *, PyObject *); static PyMethodDef ue_PyUScriptStruct_methods[] = { { "get_field", (PyCFunction)py_ue_uscriptstruct_get_field, METH_VARARGS, "" }, { "set_field", (PyCFunction)py_ue_uscriptstruct_set_field, METH_VARARGS, "" }, + { "get_field_array_dim", (PyCFunction)py_ue_uscriptstruct_get_field_array_dim, METH_VARARGS, "" }, { "fields", (PyCFunction)py_ue_uscriptstruct_fields, METH_VARARGS, "" }, { "get_struct", (PyCFunction)py_ue_uscriptstruct_get_struct, METH_VARARGS, "" }, { "clone", (PyCFunction)py_ue_uscriptstruct_clone, METH_VARARGS, "" }, @@ -125,7 +140,7 @@ static PyMethodDef ue_PyUScriptStruct_methods[] = { static PyObject *ue_PyUScriptStruct_str(ue_PyUScriptStruct *self) { return PyUnicode_FromFormat("", - TCHAR_TO_UTF8(*self->u_struct->GetName()), self->u_struct->GetStructureSize(), self->data); + TCHAR_TO_UTF8(*self->u_struct->GetName()), self->u_struct->GetStructureSize(), self->u_struct_ptr); } static UProperty *get_field_from_name(UScriptStruct *u_struct, char *name) @@ -168,14 +183,14 @@ static PyObject *ue_PyUScriptStruct_getattro(ue_PyUScriptStruct *self, PyObject { if (PyUnicodeOrString_Check(attr_name)) { - char *attr = PyUnicode_AsUTF8(attr_name); + const char *attr = UEPyUnicode_AsUTF8(attr_name); // first check for property - UProperty *u_property = get_field_from_name(self->u_struct, attr); + UProperty *u_property = get_field_from_name(self->u_struct, (char *)attr); if (u_property) { // swallow previous exception PyErr_Clear(); - return ue_py_convert_property(u_property, self->data); + return ue_py_convert_property(u_property, self->u_struct_ptr, 0); } } } @@ -187,12 +202,12 @@ static int ue_PyUScriptStruct_setattro(ue_PyUScriptStruct *self, PyObject *attr_ // first of all check for UProperty if (PyUnicodeOrString_Check(attr_name)) { - char *attr = PyUnicode_AsUTF8(attr_name); + const char *attr = UEPyUnicode_AsUTF8(attr_name); // first check for property - UProperty *u_property = get_field_from_name(self->u_struct, attr); + UProperty *u_property = get_field_from_name(self->u_struct, (char *)attr); if (u_property) { - if (ue_py_convert_pyobject(value, u_property, self->data)) + if (ue_py_convert_pyobject(value, u_property, self->u_struct_ptr, 0)) { return 0; } @@ -211,9 +226,9 @@ static void ue_PyUScriptStruct_dealloc(ue_PyUScriptStruct *self) #if defined(UEPY_MEMORY_DEBUG) UE_LOG(LogPython, Warning, TEXT("Destroying ue_PyUScriptStruct %p with size %d"), self, self->u_struct->GetStructureSize()); #endif - if (!self->is_ptr) + if (self->u_struct_owned) { - FMemory::Free(self->data); + FMemory::Free(self->u_struct_ptr); } Py_TYPE(self)->tp_free((PyObject *)self); } @@ -271,25 +286,21 @@ static int ue_py_uscriptstruct_init(ue_PyUScriptStruct *self, PyObject *args, Py } self->u_struct = (UScriptStruct *)py_u_obj->ue_object; - self->data = (uint8*)FMemory::Malloc(self->u_struct->GetStructureSize()); - self->u_struct->InitializeStruct(self->data); + self->u_struct_ptr = (uint8*)FMemory::Malloc(self->u_struct->GetStructureSize()); + self->u_struct->InitializeStruct(self->u_struct_ptr); #if WITH_EDITOR - self->u_struct->InitializeDefaultValue(self->data); + self->u_struct->InitializeDefaultValue(self->u_struct_ptr); #endif - self->original_data = self->data; - self->is_ptr = 0; + self->u_struct_owned = 1; return 0; } -// get the original pointer of a struct +// get the original pointer of a struct (dumb function for backward compatibility with older scripts from +// a dark age where strctures were passed by value) static PyObject *py_ue_uscriptstruct_ref(ue_PyUScriptStruct *self, PyObject * args) { - ue_PyUScriptStruct *ret = (ue_PyUScriptStruct *)PyObject_New(ue_PyUScriptStruct, &ue_PyUScriptStructType); - ret->u_struct = self->u_struct; - ret->data = self->original_data; - ret->original_data = ret->data; - ret->is_ptr = 1; - return (PyObject *)ret; + Py_INCREF(self); + return (PyObject *)self; } static PyObject *ue_py_uscriptstruct_richcompare(ue_PyUScriptStruct *u_struct1, PyObject *py_obj, int op) @@ -300,7 +311,7 @@ static PyObject *ue_py_uscriptstruct_richcompare(ue_PyUScriptStruct *u_struct1, return PyErr_Format(PyExc_NotImplementedError, "can only compare with another UScriptStruct"); } - bool equals = (u_struct1->u_struct == u_struct2->u_struct && !memcmp(u_struct1->data, u_struct2->data, u_struct1->u_struct->GetStructureSize())); + bool equals = (u_struct1->u_struct == u_struct2->u_struct && !memcmp(u_struct1->u_struct_ptr, u_struct2->u_struct_ptr, u_struct1->u_struct->GetStructureSize())); if (op == Py_EQ) { @@ -337,26 +348,44 @@ void ue_python_init_uscriptstruct(PyObject *ue_module) } PyObject *py_ue_new_uscriptstruct(UScriptStruct *u_struct, uint8 *data) +{ + ue_PyUScriptStruct *ret = (ue_PyUScriptStruct *)PyObject_New(ue_PyUScriptStruct, &ue_PyUScriptStructType); + ret->u_struct = u_struct; + ret->u_struct_ptr = data; + ret->u_struct_owned = 0; + return (PyObject *)ret; +} + +PyObject *py_ue_new_owned_uscriptstruct(UScriptStruct *u_struct, uint8 *data) { ue_PyUScriptStruct *ret = (ue_PyUScriptStruct *)PyObject_New(ue_PyUScriptStruct, &ue_PyUScriptStructType); ret->u_struct = u_struct; uint8 *struct_data = (uint8*)FMemory::Malloc(u_struct->GetStructureSize()); ret->u_struct->InitializeStruct(struct_data); ret->u_struct->CopyScriptStruct(struct_data, data); - ret->data = struct_data; - ret->original_data = data; - ret->is_ptr = 0; + ret->u_struct_ptr = struct_data; + ret->u_struct_owned = 1; return (PyObject *)ret; } -// generate a new python UScriptStruct from an already allocated data block -PyObject *py_ue_wrap_uscriptstruct(UScriptStruct *u_struct, uint8 *data) +PyObject *py_ue_new_owned_uscriptstruct_zero_copy(UScriptStruct *u_struct, uint8 *data) { ue_PyUScriptStruct *ret = (ue_PyUScriptStruct *)PyObject_New(ue_PyUScriptStruct, &ue_PyUScriptStructType); ret->u_struct = u_struct; - ret->data = data; - ret->original_data = data; - ret->is_ptr = 0; + ret->u_struct_ptr = data; + ret->u_struct_owned = 1; + return (PyObject *)ret; +} + +static PyObject *py_ue_uscriptstruct_clone(ue_PyUScriptStruct *self, PyObject * args) +{ + ue_PyUScriptStruct *ret = (ue_PyUScriptStruct *)PyObject_New(ue_PyUScriptStruct, &ue_PyUScriptStructType); + ret->u_struct = self->u_struct; + uint8 *struct_data = (uint8*)FMemory::Malloc(self->u_struct->GetStructureSize()); + ret->u_struct->InitializeStruct(struct_data); + ret->u_struct->CopyScriptStruct(struct_data, self->u_struct_ptr); + ret->u_struct_ptr = struct_data; + ret->u_struct_owned = 1; return (PyObject *)ret; } diff --git a/Source/UnrealEnginePython/Private/UEPyUScriptStruct.h b/Source/UnrealEnginePython/Private/UEPyUScriptStruct.h index d7fcba2e2..1078cf686 100644 --- a/Source/UnrealEnginePython/Private/UEPyUScriptStruct.h +++ b/Source/UnrealEnginePython/Private/UEPyUScriptStruct.h @@ -1,21 +1,20 @@ #pragma once -#include "UnrealEnginePython.h" +#include "UEPyModule.h" typedef struct { PyObject_HEAD /* Type-specific fields go here. */ UScriptStruct *u_struct; - uint8 *data; - // if 1, data points to un-owned memory - int is_ptr; - // points to the original struct memory (do not try this at home !) - uint8 *original_data; + uint8 *u_struct_ptr; + // if set, the struct is responsible for freeing memory + int u_struct_owned; } ue_PyUScriptStruct; PyObject *py_ue_new_uscriptstruct(UScriptStruct *, uint8 *); -PyObject *py_ue_wrap_uscriptstruct(UScriptStruct *, uint8 *); +PyObject *py_ue_new_owned_uscriptstruct(UScriptStruct *, uint8 *); +PyObject *py_ue_new_owned_uscriptstruct_zero_copy(UScriptStruct *, uint8 *); ue_PyUScriptStruct *py_ue_is_uscriptstruct(PyObject *); UProperty *ue_struct_get_field_from_name(UScriptStruct *, char *); diff --git a/Source/UnrealEnginePython/Private/UEPyUStructsImporter.cpp b/Source/UnrealEnginePython/Private/UEPyUStructsImporter.cpp index 873824889..6710864a1 100644 --- a/Source/UnrealEnginePython/Private/UEPyUStructsImporter.cpp +++ b/Source/UnrealEnginePython/Private/UEPyUStructsImporter.cpp @@ -1,13 +1,18 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPyUStructsImporter.h" -static PyObject *ue_PyUStructsImporter_getattro(ue_PyUStructsImporter *self, PyObject *attr_name) { +static PyObject *ue_PyUStructsImporter_getattro(ue_PyUStructsImporter *self, PyObject *attr_name) +{ PyObject *py_attr = PyObject_GenericGetAttr((PyObject *)self, attr_name); - if (!py_attr) { - if (PyUnicodeOrString_Check(attr_name)) { - char *attr = PyUnicode_AsUTF8(attr_name); - if (attr[0] != '_') { + if (!py_attr) + { + if (PyUnicodeOrString_Check(attr_name)) + { + const char *attr = UEPyUnicode_AsUTF8(attr_name); + if (attr[0] != '_') + { UScriptStruct *u_struct = FindObject(ANY_PACKAGE, UTF8_TO_TCHAR(attr)); - if (u_struct) { + if (u_struct) + { // swallow old exception PyErr_Clear(); Py_RETURN_UOBJECT(u_struct); @@ -51,7 +56,8 @@ static PyTypeObject ue_PyUStructsImporterType = { 0, }; -void ue_python_init_ustructsimporter(PyObject *ue_module) { +void ue_python_init_ustructsimporter(PyObject *ue_module) +{ ue_PyUStructsImporterType.tp_new = PyType_GenericNew; if (PyType_Ready(&ue_PyUStructsImporterType) < 0) @@ -61,7 +67,8 @@ void ue_python_init_ustructsimporter(PyObject *ue_module) { PyModule_AddObject(ue_module, "UStructsImporter", (PyObject *)&ue_PyUStructsImporterType); } -PyObject *py_ue_new_ustructsimporter() { +PyObject *py_ue_new_ustructsimporter() +{ ue_PyUStructsImporter *ret = (ue_PyUStructsImporter *)PyObject_New(ue_PyUStructsImporter, &ue_PyUStructsImporterType); return (PyObject *)ret; } diff --git a/Source/UnrealEnginePython/Private/UEPyUStructsImporter.h b/Source/UnrealEnginePython/Private/UEPyUStructsImporter.h index 172416a98..d40c9bb59 100644 --- a/Source/UnrealEnginePython/Private/UEPyUStructsImporter.h +++ b/Source/UnrealEnginePython/Private/UEPyUStructsImporter.h @@ -2,11 +2,12 @@ -#include "UnrealEnginePython.h" +#include "UEPyModule.h" -typedef struct { +typedef struct +{ PyObject_HEAD - /* Type-specific fields go here. */ + /* Type-specific fields go here. */ } ue_PyUStructsImporter; PyObject *py_ue_new_ustructsimporter(); diff --git a/Source/UnrealEnginePython/Private/UEPyVisualLogger.cpp b/Source/UnrealEnginePython/Private/UEPyVisualLogger.cpp index 8ec49d0ae..b84d3357c 100644 --- a/Source/UnrealEnginePython/Private/UEPyVisualLogger.cpp +++ b/Source/UnrealEnginePython/Private/UEPyVisualLogger.cpp @@ -1,4 +1,4 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPyVisualLogger.h" #include "Runtime/Engine/Public/VisualLogger/VisualLogger.h" diff --git a/Source/UnrealEnginePython/Private/UEPyVisualLogger.h b/Source/UnrealEnginePython/Private/UEPyVisualLogger.h index 4dff1740d..4f61ef91c 100644 --- a/Source/UnrealEnginePython/Private/UEPyVisualLogger.h +++ b/Source/UnrealEnginePython/Private/UEPyVisualLogger.h @@ -2,7 +2,7 @@ -#include "UnrealEnginePython.h" +#include "UEPyModule.h" PyObject *py_ue_vlog(ue_PyUObject *, PyObject *); PyObject *py_ue_vlog_cylinder(ue_PyUObject *, PyObject *); diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyActor.cpp b/Source/UnrealEnginePython/Private/UObject/UEPyActor.cpp index f705074ef..e319bcc94 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyActor.cpp +++ b/Source/UnrealEnginePython/Private/UObject/UEPyActor.cpp @@ -1,9 +1,9 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPyActor.h" -#include "Runtime/LevelSequence/Public/LevelSequenceActor.h" -#include "Runtime/LevelSequence/Public/LevelSequence.h" -#include "PythonComponent.h" -#include "UEPyObject.h" +#if WITH_EDITOR +#include "Editor.h" +#include "Editor/UnrealEd/Public/ComponentTypeRegistry.h" +#endif PyObject *py_ue_actor_has_tag(ue_PyUObject * self, PyObject * args) { @@ -13,24 +13,42 @@ PyObject *py_ue_actor_has_tag(ue_PyUObject * self, PyObject * args) char *tag; if (!PyArg_ParseTuple(args, "s:actor_has_tag", &tag)) { - return NULL; + return nullptr; } - if (!self->ue_object->IsA()) - { + AActor *actor = ue_py_check_type(self); + if (!actor) return PyErr_Format(PyExc_Exception, "uobject is not an AActor"); + + if (actor->ActorHasTag(FName(UTF8_TO_TCHAR(tag)))) + { + Py_RETURN_TRUE; } - AActor *actor = (AActor *)self->ue_object; + Py_RETURN_FALSE; +} - if (actor->ActorHasTag(FName(UTF8_TO_TCHAR(tag)))) +PyObject *py_ue_component_has_tag(ue_PyUObject * self, PyObject * args) +{ + + ue_py_check(self); + + char *tag; + if (!PyArg_ParseTuple(args, "s:component_has_tag", &tag)) { - Py_INCREF(Py_True); - return Py_True; + return nullptr; + } + + UActorComponent *component = ue_py_check_type(self); + if (!component) + return PyErr_Format(PyExc_Exception, "uobject is not an UActorComponent"); + + if (component->ComponentHasTag(FName(UTF8_TO_TCHAR(tag)))) + { + Py_RETURN_TRUE; } - Py_INCREF(Py_False); - return Py_False; + Py_RETURN_FALSE; } PyObject *py_ue_actor_begin_play(ue_PyUObject * self, PyObject * args) @@ -42,11 +60,15 @@ PyObject *py_ue_actor_begin_play(ue_PyUObject * self, PyObject * args) if (!actor) return PyErr_Format(PyExc_Exception, "uobject is not an AActor"); + Py_BEGIN_ALLOW_THREADS; + #if ENGINE_MINOR_VERSION > 14 actor->DispatchBeginPlay(); #else actor->BeginPlay(); #endif + Py_END_ALLOW_THREADS; + Py_RETURN_NONE; } @@ -55,13 +77,9 @@ PyObject *py_ue_get_actor_bounds(ue_PyUObject * self, PyObject * args) ue_py_check(self); - - if (!self->ue_object->IsA()) - { + AActor *actor = ue_py_check_type(self); + if (!actor) return PyErr_Format(PyExc_Exception, "uobject is not an AActor"); - } - - AActor *actor = (AActor *)self->ue_object; FVector origin; FVector extent; @@ -69,7 +87,6 @@ PyObject *py_ue_get_actor_bounds(ue_PyUObject * self, PyObject * args) actor->GetActorBounds(false, origin, extent); return Py_BuildValue("OO", py_ue_new_fvector(origin), py_ue_new_fvector(extent)); - } PyObject *py_ue_get_actor_component(ue_PyUObject * self, PyObject * args) @@ -117,14 +134,15 @@ PyObject *py_ue_actor_destroy_component(ue_PyUObject * self, PyObject * args) if (!component) return PyErr_Format(PyExc_Exception, "argument is not a UActorComponent"); + Py_BEGIN_ALLOW_THREADS #if ENGINE_MINOR_VERSION >= 17 - component->DestroyComponent(); + component->DestroyComponent(); #else - actor->K2_DestroyComponent(component); + actor->K2_DestroyComponent(component); #endif + Py_END_ALLOW_THREADS - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyObject *py_ue_actor_destroy(ue_PyUObject * self, PyObject * args) @@ -138,7 +156,9 @@ PyObject *py_ue_actor_destroy(ue_PyUObject * self, PyObject * args) return PyErr_Format(PyExc_Exception, "uobject is not an AActor"); } + Py_BEGIN_ALLOW_THREADS; actor->Destroy(); + Py_END_ALLOW_THREADS; Py_RETURN_NONE; @@ -183,6 +203,67 @@ PyObject *py_ue_get_actor_velocity(ue_PyUObject *self, PyObject * args) #if WITH_EDITOR +PyObject *py_ue_component_type_registry_invalidate_class(ue_PyUObject *self, PyObject * args) +{ + ue_py_check(self); + + UClass *Class = ue_py_check_type(self); + if (!Class) + return PyErr_Format(PyExc_Exception, "uobject is not a UClass"); + + if (!Class->IsChildOf()) + { + return PyErr_Format(PyExc_Exception, "uobject is not a subclass of UActorComponent"); + } + + FComponentTypeRegistry::Get().InvalidateClass(Class); + + Py_RETURN_NONE; +} + +PyObject *py_ue_get_folder_path(ue_PyUObject *self, PyObject * args) +{ + + ue_py_check(self); + + AActor *actor = ue_py_check_type(self); + if (!actor) + return PyErr_Format(PyExc_Exception, "uobject is not an actor"); + + const FName DirPath = actor->GetFolderPath(); + + return PyUnicode_FromString(TCHAR_TO_UTF8(*DirPath.ToString())); +} + +PyObject *py_ue_set_folder_path(ue_PyUObject *self, PyObject * args) +{ + + ue_py_check(self); + + char *path; + PyObject *py_bool = nullptr; + + if (!PyArg_ParseTuple(args, "s|O:set_folder_path", &path, &py_bool)) + return nullptr; + + AActor *actor = ue_py_check_type(self); + if (!actor) + return PyErr_Format(PyExc_Exception, "uobject is not an actor"); + + FName DirPath = FName(UTF8_TO_TCHAR(path)); + + if (py_bool && PyObject_IsTrue(py_bool)) + { + actor->SetFolderPath_Recursively(DirPath); + } + else + { + actor->SetFolderPath(DirPath); + } + + Py_RETURN_NONE; +} + PyObject *py_ue_get_actor_label(ue_PyUObject *self, PyObject * args) { @@ -220,8 +301,36 @@ PyObject *py_ue_set_actor_label(ue_PyUObject *self, PyObject * args) actor->SetActorLabel(UTF8_TO_TCHAR(label), true); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; +} + +PyObject *py_ue_set_actor_hidden_in_game(ue_PyUObject *self, PyObject * args) +{ + + ue_py_check(self); + + AActor *actor = ue_get_actor(self); + if (!actor) + return PyErr_Format(PyExc_Exception, "cannot retrieve Actor from uobject"); + + PyObject *py_bool = nullptr; + if (!PyArg_ParseTuple(args, "O:set_actor_hidden_in_game", &py_bool)) + { + return nullptr; + } + + if (PyObject_IsTrue(py_bool)) + { + actor->SetActorHiddenInGame(true); + } + else + { + actor->SetActorHiddenInGame(false); + } + + + + Py_RETURN_NONE; } PyObject *py_ue_find_actor_by_label(ue_PyUObject * self, PyObject * args) @@ -286,11 +395,12 @@ PyObject *py_ue_register_component(ue_PyUObject *self, PyObject * args) UActorComponent *component = (UActorComponent *)self->ue_object; + Py_BEGIN_ALLOW_THREADS; if (!component->IsRegistered()) component->RegisterComponent(); + Py_END_ALLOW_THREADS; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyObject *py_ue_component_is_registered(ue_PyUObject *self, PyObject * args) @@ -298,21 +408,16 @@ PyObject *py_ue_component_is_registered(ue_PyUObject *self, PyObject * args) ue_py_check(self); - if (!self->ue_object->IsA()) - { + UActorComponent *component = ue_py_check_type(self); + if (!component) return PyErr_Format(PyExc_Exception, "uobject is not a component"); - } - - UActorComponent *component = (UActorComponent *)self->ue_object; if (component->IsRegistered()) { - Py_INCREF(Py_True); - return Py_True; + Py_RETURN_TRUE; } - Py_INCREF(Py_False); - return Py_False; + Py_RETURN_FALSE; } PyObject *py_ue_setup_attachment(ue_PyUObject *self, PyObject * args) @@ -321,16 +426,26 @@ PyObject *py_ue_setup_attachment(ue_PyUObject *self, PyObject * args) ue_py_check(self); PyObject *py_component; - if (!PyArg_ParseTuple(args, "O:setup_attachment", &py_component)) + char *socket_name = nullptr; + + if (!PyArg_ParseTuple(args, "O|s:setup_attachment", &py_component)) return nullptr; USceneComponent *child = ue_py_check_type(self); if (!child) - { return PyErr_Format(PyExc_Exception, "uobject is not a USceneComponent"); - } - UActorComponent *parent = ue_py_check_type(py_component); + USceneComponent *parent = ue_py_check_type(py_component); + if (!parent) + return PyErr_Format(PyExc_Exception, "argument is not a USceneComponent"); + + FName SocketName = NAME_None; + if (socket_name) + SocketName = FName(UTF8_TO_TCHAR(socket_name)); + + Py_BEGIN_ALLOW_THREADS; + child->SetupAttachment(parent, SocketName); + Py_END_ALLOW_THREADS; Py_RETURN_NONE; } @@ -343,8 +458,10 @@ PyObject *py_ue_unregister_component(ue_PyUObject * self, PyObject * args) if (!component) return PyErr_Format(PyExc_Exception, "uobject is not an UActorComponent"); + Py_BEGIN_ALLOW_THREADS; if (component->IsRegistered()) component->UnregisterComponent(); + Py_END_ALLOW_THREADS; Py_RETURN_NONE; } @@ -357,7 +474,9 @@ PyObject *py_ue_destroy_component(ue_PyUObject * self, PyObject * args) if (!component) return PyErr_Format(PyExc_Exception, "uobject is not an UActorComponent"); + Py_BEGIN_ALLOW_THREADS; component->DestroyComponent(); + Py_END_ALLOW_THREADS; Py_RETURN_NONE; } @@ -386,7 +505,10 @@ PyObject *py_ue_add_instance_component(ue_PyUObject * self, PyObject * args) return PyErr_Format(PyExc_Exception, "argument is not a UActorComponent"); } + Py_BEGIN_ALLOW_THREADS; actor->AddInstanceComponent(component); + Py_END_ALLOW_THREADS; + Py_RETURN_NONE; } @@ -402,29 +524,16 @@ PyObject *py_ue_add_actor_component(ue_PyUObject * self, PyObject * args) PyObject *py_parent = nullptr; if (!PyArg_ParseTuple(args, "Os|O:add_actor_component", &obj, &name, &py_parent)) { - return NULL; + return nullptr; } - if (!self->ue_object->IsA()) - { + AActor *actor = ue_py_check_type(self); + if (!actor) return PyErr_Format(PyExc_Exception, "uobject is not an AActor"); - } - - AActor *actor = (AActor *)self->ue_object; - - if (!ue_is_pyuobject(obj)) - { - return PyErr_Format(PyExc_Exception, "argument is not a UObject"); - } - ue_PyUObject *py_obj = (ue_PyUObject *)obj; - - if (!py_obj->ue_object->IsA()) - { + UClass *u_class = ue_py_check_type(obj); + if (!u_class) return PyErr_Format(PyExc_Exception, "argument is not a UClass"); - } - - UClass *u_class = (UClass *)py_obj->ue_object; if (!u_class->IsChildOf()) { @@ -441,24 +550,31 @@ PyObject *py_ue_add_actor_component(ue_PyUObject * self, PyObject * args) return PyErr_Format(PyExc_Exception, "argument is not a USceneComponent"); } } + UActorComponent *component = nullptr; + Py_BEGIN_ALLOW_THREADS; + component = NewObject(actor, u_class, FName(UTF8_TO_TCHAR(name)), RF_Public); + if (component) + { - UActorComponent *component = NewObject(actor, u_class, FName(UTF8_TO_TCHAR(name)), RF_Public); - if (!component) - return PyErr_Format(PyExc_Exception, "unable to create component"); + if (py_parent && component->IsA()) + { + USceneComponent *scene_component = (USceneComponent *)component; + scene_component->SetupAttachment(parent_component); + } - if (py_parent && component->IsA()) - { - USceneComponent *scene_component = (USceneComponent *)component; - scene_component->SetupAttachment(parent_component); - } + if (actor->GetWorld() && !component->IsRegistered()) + { + component->RegisterComponent(); + } - if (actor->GetWorld() && !component->IsRegistered()) - { - component->RegisterComponent(); + if (component->bWantsInitializeComponent && !component->HasBeenInitialized() && component->IsRegistered()) + component->InitializeComponent(); } - if (component->bWantsInitializeComponent && !component->HasBeenInitialized() && component->IsRegistered()) - component->InitializeComponent(); + Py_END_ALLOW_THREADS; + + if (!component) + return PyErr_Format(PyExc_Exception, "unable to create component"); Py_RETURN_UOBJECT(component); } @@ -473,7 +589,7 @@ PyObject *py_ue_add_python_component(ue_PyUObject * self, PyObject * args) char *class_name; if (!PyArg_ParseTuple(args, "sss:add_python_component", &name, &module_name, &class_name)) { - return NULL; + return nullptr; } AActor *actor = ue_py_check_type(self); @@ -482,20 +598,27 @@ PyObject *py_ue_add_python_component(ue_PyUObject * self, PyObject * args) return PyErr_Format(PyExc_Exception, "uobject is not an AActor"); } - UPythonComponent *component = NewObject(actor, FName(UTF8_TO_TCHAR(name)), RF_Public); - if (!component) - return PyErr_Format(PyExc_Exception, "unable to create component"); - - component->PythonModule = FString(UTF8_TO_TCHAR(module_name)); - component->PythonClass = FString(UTF8_TO_TCHAR(class_name)); + UPythonComponent *component = nullptr; + Py_BEGIN_ALLOW_THREADS; + component = NewObject(actor, FName(UTF8_TO_TCHAR(name)), RF_Public); - if (actor->GetWorld() && !component->IsRegistered()) + if (component) { - component->RegisterComponent(); + component->PythonModule = FString(UTF8_TO_TCHAR(module_name)); + component->PythonClass = FString(UTF8_TO_TCHAR(class_name)); + + if (actor->GetWorld() && !component->IsRegistered()) + { + component->RegisterComponent(); + } + + if (component->bWantsInitializeComponent && !component->HasBeenInitialized() && component->IsRegistered()) + component->InitializeComponent(); } + Py_END_ALLOW_THREADS; - if (component->bWantsInitializeComponent && !component->HasBeenInitialized() && component->IsRegistered()) - component->InitializeComponent(); + if (!component) + return PyErr_Format(PyExc_Exception, "unable to create component"); Py_RETURN_UOBJECT(component); } @@ -509,7 +632,7 @@ PyObject *py_ue_actor_create_default_subobject(ue_PyUObject * self, PyObject * a char *name; if (!PyArg_ParseTuple(args, "Os:actor_create_default_subobject", &obj, &name)) { - return NULL; + return nullptr; } AActor *actor = ue_py_check_type(self); @@ -523,7 +646,12 @@ PyObject *py_ue_actor_create_default_subobject(ue_PyUObject * self, PyObject * a if (!FUObjectThreadContext::Get().TopInitializer()) return PyErr_Format(PyExc_Exception, "CreateDefaultSubobject() can be called only in a constructor"); - UObject *ret_obj = actor->CreateDefaultSubobject(FName(UTF8_TO_TCHAR(name)), UObject::StaticClass(), u_class, false, false, true); + UObject *ret_obj = nullptr; + + Py_BEGIN_ALLOW_THREADS; + ret_obj = actor->CreateDefaultSubobject(FName(UTF8_TO_TCHAR(name)), UObject::StaticClass(), u_class, false, false, true); + Py_END_ALLOW_THREADS; + if (!ret_obj) return PyErr_Format(PyExc_Exception, "unable to create component"); @@ -557,32 +685,23 @@ PyObject *py_ue_add_actor_root_component(ue_PyUObject * self, PyObject * args) char *name; if (!PyArg_ParseTuple(args, "Os:add_actor_root_component", &obj, &name)) { - return NULL; + return nullptr; } - if (!self->ue_object->IsA()) - { + AActor *actor = ue_py_check_type(self); + if (!actor) return PyErr_Format(PyExc_Exception, "uobject is not an AActor"); - } - - AActor *actor = (AActor *)self->ue_object; - - if (!ue_is_pyuobject(obj)) - { - return PyErr_Format(PyExc_Exception, "argument is not a UObject"); - } - ue_PyUObject *py_obj = (ue_PyUObject *)obj; - if (!py_obj->ue_object->IsA()) - { - return PyErr_Format(PyExc_Exception, "argument is not a class"); - } + UClass *u_class = ue_py_check_type(obj); + if (!u_class) + return PyErr_Format(PyExc_Exception, "argument is not a UClass"); - USceneComponent *component = NewObject(actor, (UClass *)py_obj->ue_object, FName(UTF8_TO_TCHAR(name)), RF_Public); + USceneComponent *component = NewObject(actor, u_class, FName(UTF8_TO_TCHAR(name)), RF_Public); if (!component) return PyErr_Format(PyExc_Exception, "unable to create component"); + Py_BEGIN_ALLOW_THREADS; actor->SetRootComponent(component); if (actor->GetWorld() && !component->IsRegistered()) @@ -593,6 +712,8 @@ PyObject *py_ue_add_actor_root_component(ue_PyUObject * self, PyObject * args) if (component->bWantsInitializeComponent && !component->HasBeenInitialized() && component->IsRegistered()) component->InitializeComponent(); + Py_END_ALLOW_THREADS; + Py_RETURN_UOBJECT(component); } @@ -607,29 +728,20 @@ PyObject *py_ue_actor_has_component_of_type(ue_PyUObject * self, PyObject * args return NULL; } - if (!ue_is_pyuobject(obj)) - { - return PyErr_Format(PyExc_Exception, "argument is not a UObject"); - } - - ue_PyUObject *py_obj = (ue_PyUObject *)obj; - - if (!self->ue_object->IsA()) - { + AActor *actor = ue_get_actor(self); + if (!actor) return PyErr_Format(PyExc_Exception, "uobject is not an AActor"); - } - AActor *actor = (AActor *)self->ue_object; + UClass *u_class = ue_py_check_type(obj); + if (!u_class) + return PyErr_Format(PyExc_Exception, "argument is not a UClass"); - if (actor->GetComponentByClass((UClass *)py_obj->ue_object)) + if (actor->GetComponentByClass(u_class)) { - Py_INCREF(Py_True); - return Py_True; + Py_RETURN_TRUE; } - Py_INCREF(Py_False); - return Py_False; - + Py_RETURN_TRUE; } PyObject *py_ue_get_actor_component_by_type(ue_PyUObject * self, PyObject * args) @@ -640,38 +752,19 @@ PyObject *py_ue_get_actor_component_by_type(ue_PyUObject * self, PyObject * args PyObject *obj; if (!PyArg_ParseTuple(args, "O:get_actor_component_by_type", &obj)) { - return NULL; - } - - ue_PyUObject *py_obj = nullptr; - - if (ue_is_pyuobject(obj)) - { - py_obj = (ue_PyUObject *)obj; - } - // shortcut for finding class by string - else if (PyUnicodeOrString_Check(obj)) - { - char *class_name = PyUnicode_AsUTF8(obj); - UClass *u_class = FindObject(ANY_PACKAGE, UTF8_TO_TCHAR(class_name)); - - if (u_class) - { - py_obj = ue_get_python_uobject(u_class); - } + return nullptr; } - if (!py_obj) - return PyErr_Format(PyExc_Exception, "argument is not a UObject"); - AActor *actor = ue_get_actor(self); if (!actor) return PyErr_Format(PyExc_Exception, "uobject is not an AActor"); - if (!py_obj->ue_object->IsA()) + UClass *u_class = ue_py_check_type(obj); + if (!u_class) return PyErr_Format(PyExc_Exception, "argument is not a UClass"); - UActorComponent *component = actor->GetComponentByClass((UClass *)py_obj->ue_object); + + UActorComponent *component = actor->GetComponentByClass(u_class); if (component) { Py_RETURN_UOBJECT(component); @@ -689,32 +782,41 @@ PyObject *py_ue_get_actor_components_by_type(ue_PyUObject * self, PyObject * arg PyObject *obj; if (!PyArg_ParseTuple(args, "O:get_actor_components_by_type", &obj)) { - return NULL; + return nullptr; } - ue_PyUObject *py_obj = nullptr; + AActor *actor = ue_get_actor(self); + if (!actor) + return PyErr_Format(PyExc_Exception, "uobject is not an AActor"); + + UClass *u_class = ue_py_check_type(obj); + if (!u_class) + return PyErr_Format(PyExc_Exception, "argument is not a UClass"); + + PyObject *components = PyList_New(0); - if (ue_is_pyuobject(obj)) + for (UActorComponent *component : actor->GetComponentsByClass(u_class)) { - py_obj = (ue_PyUObject *)obj; + ue_PyUObject *item = ue_get_python_uobject(component); + if (item) + PyList_Append(components, (PyObject *)item); } - // shortcut for finding class by string - else if (PyUnicodeOrString_Check(obj)) - { - char *class_name = PyUnicode_AsUTF8(obj); - UClass *u_class = FindObject(ANY_PACKAGE, UTF8_TO_TCHAR(class_name)); - if (u_class) - { - py_obj = ue_get_python_uobject(u_class); - } - } + return components; - if (!py_obj) - return PyErr_Format(PyExc_Exception, "argument is not a UObject"); +} - if (!py_obj->ue_object->IsA()) - return PyErr_Format(PyExc_Exception, "argument is not a UClass"); +PyObject *py_ue_get_actor_components_by_tag(ue_PyUObject * self, PyObject * args) +{ + + ue_py_check(self); + + char *tag; + PyObject *py_uclass = nullptr; + if (!PyArg_ParseTuple(args, "s|O:get_actor_components_by_tag", &tag, &py_uclass)) + { + return nullptr; + } AActor *actor = ue_get_actor(self); if (!actor) @@ -722,7 +824,23 @@ PyObject *py_ue_get_actor_components_by_type(ue_PyUObject * self, PyObject * arg PyObject *components = PyList_New(0); - for (UActorComponent *component : actor->GetComponentsByClass((UClass *)py_obj->ue_object)) + UClass *u_class = UActorComponent::StaticClass(); + + if (py_uclass) + { + u_class = ue_py_check_type(py_uclass); + if (!u_class) + { + return PyErr_Format(PyExc_Exception, "argument is not a UClass"); + } + + if (!u_class->IsChildOf()) + { + return PyErr_Format(PyExc_Exception, "argument is not a UClass inheriting from UActorComponent"); + } + } + + for (UActorComponent *component : actor->GetComponentsByTag(u_class, FName(UTF8_TO_TCHAR(tag)))) { ue_PyUObject *item = ue_get_python_uobject(component); if (item) @@ -783,15 +901,19 @@ PyObject *py_ue_actor_spawn(ue_PyUObject * self, PyObject * args, PyObject *kwar rotation = py_rotation->rot; } + AActor *actor = nullptr; + if (kwargs && PyDict_Size(kwargs) > 0) { FTransform transform; transform.SetTranslation(location); transform.SetRotation(rotation.Quaternion()); - AActor *actor = world->SpawnActorDeferred(u_class, transform); + Py_BEGIN_ALLOW_THREADS; + actor = world->SpawnActorDeferred(u_class, transform); + Py_END_ALLOW_THREADS; if (!actor) return PyErr_Format(PyExc_Exception, "unable to spawn a new Actor"); - ue_PyUObject *py_actor = ue_get_python_uobject(actor); + ue_PyUObject *py_actor = ue_get_python_uobject_inc(actor); if (!py_actor) return PyErr_Format(PyExc_Exception, "uobject is in invalid state"); @@ -802,15 +924,20 @@ PyObject *py_ue_actor_spawn(ue_PyUObject * self, PyObject * args, PyObject *kwar PyObject *void_ret = py_ue_set_property(py_actor, Py_BuildValue("OO", py_key, PyDict_GetItem(kwargs, py_key))); if (!void_ret) { + Py_DECREF(py_iter); return PyErr_Format(PyExc_Exception, "unable to set property for new Actor"); } } Py_DECREF(py_iter); + Py_BEGIN_ALLOW_THREADS; UGameplayStatics::FinishSpawningActor(actor, transform); + Py_END_ALLOW_THREADS; return (PyObject *)py_actor; } - AActor *actor = world->SpawnActor(u_class, &location, &rotation); + Py_BEGIN_ALLOW_THREADS; + actor = world->SpawnActor(u_class, &location, &rotation); + Py_END_ALLOW_THREADS; if (!actor) return PyErr_Format(PyExc_Exception, "unable to spawn a new Actor"); Py_RETURN_UOBJECT(actor); @@ -822,16 +949,18 @@ PyObject *py_ue_get_overlapping_actors(ue_PyUObject * self, PyObject * args) ue_py_check(self); - AActor *actor = ue_get_actor(self); - if (!actor) - return PyErr_Format(PyExc_Exception, "cannot retrieve actor from UObject"); PyObject *class_filter = nullptr; if (!PyArg_ParseTuple(args, "|O:get_overlapping_actors", &class_filter)) { - return NULL; + return nullptr; } + AActor *actor = ue_get_actor(self); + if (!actor) + return PyErr_Format(PyExc_Exception, "cannot retrieve actor from UObject"); + + UClass *filtering = AActor::StaticClass(); if (class_filter) @@ -887,7 +1016,9 @@ PyObject *py_ue_actor_set_level_sequence(ue_PyUObject * self, PyObject * args) return PyErr_Format(PyExc_Exception, "argument is not a LevelSequence"); } + Py_BEGIN_ALLOW_THREADS; actor->SetSequence(sequence); + Py_END_ALLOW_THREADS; Py_RETURN_NONE; } diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyActor.h b/Source/UnrealEnginePython/Private/UObject/UEPyActor.h index 5e46abbb1..9776c0354 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyActor.h +++ b/Source/UnrealEnginePython/Private/UObject/UEPyActor.h @@ -2,9 +2,21 @@ -#include "UnrealEnginePython.h" +#include "UEPyModule.h" +#include "EngineUtils.h" + +#include "Runtime/LevelSequence/Public/LevelSequenceActor.h" +#include "Runtime/LevelSequence/Public/LevelSequence.h" + +#include "PythonComponent.h" +#include "Kismet/GameplayStatics.h" +#include "Wrappers/UEPyFVector.h" +#include "Wrappers/UEPyFRotator.h" +#include "UObject/UEPyObject.h" +#include "UObject/UObjectThreadContext.h" PyObject *py_ue_actor_has_tag(ue_PyUObject *, PyObject *); +PyObject *py_ue_component_has_tag(ue_PyUObject *, PyObject *); PyObject *py_ue_actor_begin_play(ue_PyUObject *, PyObject *); PyObject *py_ue_get_actor_bounds(ue_PyUObject *, PyObject *); PyObject *py_ue_get_actor_component(ue_PyUObject *, PyObject *); @@ -15,8 +27,12 @@ PyObject *py_ue_actor_set_level_sequence(ue_PyUObject *, PyObject *); #if WITH_EDITOR PyObject *py_ue_get_actor_label(ue_PyUObject *, PyObject *); PyObject *py_ue_set_actor_label(ue_PyUObject *, PyObject *); +PyObject *py_ue_get_folder_path(ue_PyUObject *, PyObject *); +PyObject *py_ue_set_folder_path(ue_PyUObject *, PyObject *); +PyObject *py_ue_set_actor_hidden_in_game(ue_PyUObject *, PyObject *); PyObject *py_ue_find_actor_by_label(ue_PyUObject *, PyObject *); PyObject *py_ue_get_editor_world_counterpart_actor(ue_PyUObject *, PyObject *); +PyObject *py_ue_component_type_registry_invalidate_class(ue_PyUObject *, PyObject *); #endif PyObject *py_ue_get_owner(ue_PyUObject *, PyObject *); PyObject *py_ue_add_actor_component(ue_PyUObject *, PyObject *); @@ -26,6 +42,7 @@ PyObject *py_ue_add_actor_root_component(ue_PyUObject *, PyObject *); PyObject *py_ue_actor_has_component_of_type(ue_PyUObject *, PyObject *); PyObject *py_ue_get_actor_component_by_type(ue_PyUObject *, PyObject *); PyObject *py_ue_get_actor_components_by_type(ue_PyUObject *, PyObject *); +PyObject *py_ue_get_actor_components_by_tag(ue_PyUObject *, PyObject *); PyObject *py_ue_actor_spawn(ue_PyUObject * self, PyObject *, PyObject *); PyObject *py_ue_get_overlapping_actors(ue_PyUObject *, PyObject *); diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyAnimSequence.cpp b/Source/UnrealEnginePython/Private/UObject/UEPyAnimSequence.cpp index 215b0fb63..2674c0d1b 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyAnimSequence.cpp +++ b/Source/UnrealEnginePython/Private/UObject/UEPyAnimSequence.cpp @@ -1,9 +1,8 @@ -#include "UnrealEnginePythonPrivatePCH.h" -#include "Animation/AnimSequence.h" -#include "Animation/BlendSpaceBase.h" -#include "Animation/AnimMontage.h" +#include "UEPyAnimSequence.h" -PyObject *py_ue_anim_get_skeleton(ue_PyUObject * self, PyObject * args) { + +PyObject *py_ue_anim_get_skeleton(ue_PyUObject * self, PyObject * args) +{ ue_py_check(self); UAnimationAsset *anim = ue_py_check_type(self); @@ -11,17 +10,119 @@ PyObject *py_ue_anim_get_skeleton(ue_PyUObject * self, PyObject * args) { return PyErr_Format(PyExc_Exception, "UObject is not a UAnimationAsset."); USkeleton *skeleton = anim->GetSkeleton(); - if (!skeleton) { + if (!skeleton) + { Py_RETURN_NONE; } Py_RETURN_UOBJECT((UObject *)skeleton); } +PyObject *py_ue_anim_get_bone_transform(ue_PyUObject * self, PyObject * args) +{ + ue_py_check(self); + + int track_index; + float frame_time; + PyObject *py_b_use_raw_data = nullptr; + + if (!PyArg_ParseTuple(args, "if|O:get_bone_transform", &track_index, &frame_time, &py_b_use_raw_data)) + { + return nullptr; + } + + UAnimSequence *anim = ue_py_check_type(self); + if (!anim) + return PyErr_Format(PyExc_Exception, "UObject is not a UAnimSequence."); + + bool bUseRawData = false; + if (py_b_use_raw_data && PyObject_IsTrue(py_b_use_raw_data)) + bUseRawData = true; + + FTransform OutAtom; + anim->GetBoneTransform(OutAtom, track_index, frame_time, bUseRawData); + + return py_ue_new_ftransform(OutAtom); +} + +PyObject *py_ue_anim_extract_bone_transform(ue_PyUObject * self, PyObject * args) +{ + ue_py_check(self); + + PyObject *py_sources; + float frame_time; + + if (!PyArg_ParseTuple(args, "Of:extract_bone_transform", &py_sources, &frame_time)) + { + return nullptr; + } + + UAnimSequence *anim = ue_py_check_type(self); + if (!anim) + return PyErr_Format(PyExc_Exception, "UObject is not a UAnimSequence."); + + ue_PyFRawAnimSequenceTrack *rast = py_ue_is_fraw_anim_sequence_track(py_sources); + if (rast) + { + FTransform OutAtom; + anim->ExtractBoneTransform(rast->raw_anim_sequence_track, OutAtom, frame_time); + + return py_ue_new_ftransform(OutAtom); + } + + return PyErr_Format(PyExc_Exception, "argument is not an FRawAnimSequenceTrack"); + +} + +PyObject *py_ue_anim_extract_root_motion(ue_PyUObject * self, PyObject * args) +{ + ue_py_check(self); + + float start_time; + float delta_time; + PyObject *py_b_allow_looping = nullptr; + + if (!PyArg_ParseTuple(args, "ff|O:extract_root_motion", &start_time, &delta_time, &py_b_allow_looping)) + { + return nullptr; + } + + UAnimSequence *anim = ue_py_check_type(self); + if (!anim) + return PyErr_Format(PyExc_Exception, "UObject is not a UAnimSequence."); + + bool bAllowLooping = false; + if (py_b_allow_looping && PyObject_IsTrue(py_b_allow_looping)) + bAllowLooping = true; + + return py_ue_new_ftransform(anim->ExtractRootMotion(start_time, delta_time, bAllowLooping)); +} + + + + + #if WITH_EDITOR #if ENGINE_MINOR_VERSION > 13 -PyObject *py_ue_anim_sequence_get_raw_animation_data(ue_PyUObject * self, PyObject * args) { +#if ENGINE_MINOR_VERSION < 23 +PyObject *py_ue_anim_sequence_update_compressed_track_map_from_raw(ue_PyUObject * self, PyObject * args) +{ + ue_py_check(self); + + UAnimSequence *anim_seq = ue_py_check_type(self); + if (!anim_seq) + return PyErr_Format(PyExc_Exception, "UObject is not a UAnimSequence."); + + anim_seq->UpdateCompressedTrackMapFromRaw(); + + Py_RETURN_NONE; +} +#endif + + +PyObject *py_ue_anim_sequence_get_raw_animation_data(ue_PyUObject * self, PyObject * args) +{ ue_py_check(self); UAnimSequence *anim_seq = ue_py_check_type(self); @@ -30,7 +131,8 @@ PyObject *py_ue_anim_sequence_get_raw_animation_data(ue_PyUObject * self, PyObje PyObject *py_list = PyList_New(0); - for (FRawAnimSequenceTrack rast : anim_seq->GetRawAnimationData()) { + for (FRawAnimSequenceTrack rast : anim_seq->GetRawAnimationData()) + { PyObject *py_item = py_ue_new_fraw_anim_sequence_track(rast); PyList_Append(py_list, py_item); Py_DECREF(py_item); @@ -39,7 +141,8 @@ PyObject *py_ue_anim_sequence_get_raw_animation_data(ue_PyUObject * self, PyObje return py_list; } -PyObject *py_ue_anim_sequence_get_raw_animation_track(ue_PyUObject * self, PyObject * args) { +PyObject *py_ue_anim_sequence_get_raw_animation_track(ue_PyUObject * self, PyObject * args) +{ ue_py_check(self); int index; @@ -56,7 +159,57 @@ PyObject *py_ue_anim_sequence_get_raw_animation_track(ue_PyUObject * self, PyObj return py_ue_new_fraw_anim_sequence_track(anim_seq->GetRawAnimationTrack(index)); } -PyObject *py_ue_anim_sequence_add_new_raw_track(ue_PyUObject * self, PyObject * args) { +PyObject *py_ue_anim_add_key_to_sequence(ue_PyUObject * self, PyObject * args) +{ + ue_py_check(self); + + float frame_time; + char *track_name; + PyObject *py_transform; + if (!PyArg_ParseTuple(args, "fsO:add_key_to_sequence", &frame_time, &track_name, &py_transform)) + return nullptr; + + UAnimSequence *anim_seq = ue_py_check_type(self); + if (!anim_seq) + return PyErr_Format(PyExc_Exception, "UObject is not a UAnimSequence."); + + ue_PyFTransform *ue_py_transform = py_ue_is_ftransform(py_transform); + if (!ue_py_transform) + return PyErr_Format(PyExc_Exception, "argument is not a FTransform."); + + anim_seq->AddKeyToSequence(frame_time, FName(UTF8_TO_TCHAR(track_name)), ue_py_transform->transform); + + Py_RETURN_NONE; +} + +PyObject *py_ue_anim_sequence_apply_raw_anim_changes(ue_PyUObject * self, PyObject * args) +{ + ue_py_check(self); + + UAnimSequence *anim_seq = ue_py_check_type(self); + if (!anim_seq) + return PyErr_Format(PyExc_Exception, "UObject is not a UAnimSequence."); + + + if (anim_seq->DoesNeedRebake()) + { + anim_seq->Modify(true); + anim_seq->BakeTrackCurvesToRawAnimation(); + } + + if (anim_seq->DoesNeedRecompress()) + { + anim_seq->Modify(true); + anim_seq->RequestSyncAnimRecompression(false); + } + + Py_RETURN_NONE; +} + + + +PyObject *py_ue_anim_sequence_add_new_raw_track(ue_PyUObject * self, PyObject * args) +{ ue_py_check(self); char *name; @@ -70,12 +223,15 @@ PyObject *py_ue_anim_sequence_add_new_raw_track(ue_PyUObject * self, PyObject * FRawAnimSequenceTrack *rast = nullptr; - if (py_rast) { + if (py_rast) + { ue_PyFRawAnimSequenceTrack *py_f_rast = py_ue_is_fraw_anim_sequence_track(py_rast); - if (py_f_rast) { + if (py_f_rast) + { rast = &py_f_rast->raw_anim_sequence_track; } - else { + else + { return PyErr_Format(PyExc_Exception, "argument is not a FRawAnimSequenceTrack."); } } @@ -84,33 +240,68 @@ PyObject *py_ue_anim_sequence_add_new_raw_track(ue_PyUObject * self, PyObject * int32 index = anim_seq->AddNewRawTrack(FName(UTF8_TO_TCHAR(name)), rast); - if (anim_seq->DoesNeedRebake()) - anim_seq->BakeTrackCurvesToRawAnimation(); - anim_seq->MarkRawDataAsModified(); + anim_seq->MarkPackageDirty(); return PyLong_FromLong(index); } -PyObject *py_ue_add_anim_composite_section(ue_PyUObject * self, PyObject * args) { - ue_py_check(self); +PyObject *py_ue_anim_sequence_update_raw_track(ue_PyUObject * self, PyObject * args) +{ + ue_py_check(self); - char *name; - float time; - if (!PyArg_ParseTuple(args, "sf:add_anim_composite_section", &name, &time)) - return nullptr; + int track_index; + PyObject *py_rast; + if (!PyArg_ParseTuple(args, "iO:update_raw_track", &track_index, &py_rast)) + return nullptr; - UAnimMontage *anim = ue_py_check_type(self); - if (!anim) - return PyErr_Format(PyExc_Exception, "UObject is not a UAnimMontage."); + UAnimSequence *anim_seq = ue_py_check_type(self); + if (!anim_seq) + return PyErr_Format(PyExc_Exception, "UObject is not a UAnimSequence."); - return PyLong_FromLong(anim->AddAnimCompositeSection(FName(UTF8_TO_TCHAR(name)), time)); + ue_PyFRawAnimSequenceTrack *py_f_rast = py_ue_is_fraw_anim_sequence_track(py_rast); + if (!py_f_rast) + { + return PyErr_Format(PyExc_Exception, "argument is not a FRawAnimSequenceTrack."); + } + + anim_seq->Modify(); + + FRawAnimSequenceTrack& RawRef = anim_seq->GetRawAnimationTrack(track_index); + + RawRef.PosKeys = py_f_rast->raw_anim_sequence_track.PosKeys; + RawRef.RotKeys = py_f_rast->raw_anim_sequence_track.RotKeys; + RawRef.ScaleKeys = py_f_rast->raw_anim_sequence_track.ScaleKeys; + + anim_seq->MarkRawDataAsModified(); + anim_seq->MarkPackageDirty(); + + Py_RETURN_NONE; +} + + + +PyObject *py_ue_add_anim_composite_section(ue_PyUObject * self, PyObject * args) +{ + ue_py_check(self); + + char *name; + float time; + if (!PyArg_ParseTuple(args, "sf:add_anim_composite_section", &name, &time)) + return nullptr; + + UAnimMontage *anim = ue_py_check_type(self); + if (!anim) + return PyErr_Format(PyExc_Exception, "UObject is not a UAnimMontage."); + + return PyLong_FromLong(anim->AddAnimCompositeSection(FName(UTF8_TO_TCHAR(name)), time)); } #endif #endif -PyObject *py_ue_anim_set_skeleton(ue_PyUObject * self, PyObject * args) { +PyObject *py_ue_anim_set_skeleton(ue_PyUObject * self, PyObject * args) +{ ue_py_check(self); PyObject *py_skeleton; @@ -126,11 +317,12 @@ PyObject *py_ue_anim_set_skeleton(ue_PyUObject * self, PyObject * args) { return PyErr_Format(PyExc_Exception, "argument is not a USkeleton."); anim->SetSkeleton(skeleton); - + Py_RETURN_NONE; } -PyObject *py_ue_get_blend_parameter(ue_PyUObject * self, PyObject * args) { +PyObject *py_ue_get_blend_parameter(ue_PyUObject * self, PyObject * args) +{ ue_py_check(self); int index; @@ -146,10 +338,11 @@ PyObject *py_ue_get_blend_parameter(ue_PyUObject * self, PyObject * args) { const FBlendParameter & parameter = blend->GetBlendParameter(index); - return py_ue_new_uscriptstruct(FBlendParameter::StaticStruct(), (uint8 *)¶meter); + return py_ue_new_owned_uscriptstruct(FBlendParameter::StaticStruct(), (uint8 *)¶meter); } -PyObject *py_ue_set_blend_parameter(ue_PyUObject * self, PyObject * args) { +PyObject *py_ue_set_blend_parameter(ue_PyUObject * self, PyObject * args) +{ ue_py_check(self); int index; diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyAnimSequence.h b/Source/UnrealEnginePython/Private/UObject/UEPyAnimSequence.h index 4bae0606b..afc0be7f9 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyAnimSequence.h +++ b/Source/UnrealEnginePython/Private/UObject/UEPyAnimSequence.h @@ -1,18 +1,28 @@ #pragma once +#include "UEPyModule.h" +#include "Animation/AnimSequence.h" +#include "Animation/BlendSpaceBase.h" +#include "Animation/AnimMontage.h" +#include "Wrappers/UEPyFRawAnimSequenceTrack.h" -#include "UnrealEnginePython.h" - PyObject *py_ue_anim_get_skeleton(ue_PyUObject *, PyObject *); #if WITH_EDITOR PyObject *py_ue_anim_sequence_get_raw_animation_data(ue_PyUObject *, PyObject *); PyObject *py_ue_anim_sequence_get_raw_animation_track(ue_PyUObject *, PyObject *); PyObject *py_ue_anim_sequence_add_new_raw_track(ue_PyUObject *, PyObject *); +PyObject *py_ue_anim_sequence_update_raw_track(ue_PyUObject *, PyObject *); PyObject *py_ue_add_anim_composite_section(ue_PyUObject *, PyObject *); +PyObject *py_ue_anim_sequence_update_compressed_track_map_from_raw(ue_PyUObject *, PyObject *); +PyObject *py_ue_anim_sequence_apply_raw_anim_changes(ue_PyUObject *, PyObject *); +PyObject *py_ue_anim_add_key_to_sequence(ue_PyUObject *, PyObject *); #endif PyObject *py_ue_anim_set_skeleton(ue_PyUObject *, PyObject *); +PyObject *py_ue_anim_get_bone_transform(ue_PyUObject *, PyObject *); +PyObject *py_ue_anim_extract_bone_transform(ue_PyUObject *, PyObject *); +PyObject *py_ue_anim_extract_root_motion(ue_PyUObject *, PyObject *); PyObject *py_ue_get_blend_parameter(ue_PyUObject *, PyObject *); PyObject *py_ue_set_blend_parameter(ue_PyUObject *, PyObject *); diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyAttaching.cpp b/Source/UnrealEnginePython/Private/UObject/UEPyAttaching.cpp index 4fd21b6b0..fa94aa950 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyAttaching.cpp +++ b/Source/UnrealEnginePython/Private/UObject/UEPyAttaching.cpp @@ -1,6 +1,7 @@ -#include "UnrealEnginePythonPrivatePCH.h" - +#include "UEPyAttaching.h" +#include "Components/SceneComponent.h" +#include "GameFramework/Actor.h" PyObject *py_ue_get_socket_location(ue_PyUObject *self, PyObject * args) { diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyAttaching.h b/Source/UnrealEnginePython/Private/UObject/UEPyAttaching.h index eaf1ffd25..e80be26a9 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyAttaching.h +++ b/Source/UnrealEnginePython/Private/UObject/UEPyAttaching.h @@ -2,7 +2,7 @@ -#include "UnrealEnginePython.h" +#include "UEPyModule.h" PyObject *py_ue_get_socket_location(ue_PyUObject *, PyObject *); PyObject *py_ue_get_socket_rotation(ue_PyUObject *, PyObject *); diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyAudio.cpp b/Source/UnrealEnginePython/Private/UObject/UEPyAudio.cpp index 8f319db59..b2f193257 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyAudio.cpp +++ b/Source/UnrealEnginePython/Private/UObject/UEPyAudio.cpp @@ -1,25 +1,31 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPyAudio.h" + #include "Sound/SoundWaveProcedural.h" +#include "Kismet/GameplayStatics.h" -PyObject *py_ue_queue_audio(ue_PyUObject *self, PyObject * args) { +PyObject *py_ue_queue_audio(ue_PyUObject *self, PyObject * args) +{ // Writes from a Python buffer object to a USoundWaveProcedural class ue_py_check(self); Py_buffer sound_buffer; - if (!PyArg_ParseTuple(args, "y*:queue_audio", &sound_buffer)) { + if (!PyArg_ParseTuple(args, "y*:queue_audio", &sound_buffer)) + { return NULL; } USoundWaveProcedural *sound_wave_procedural = ue_py_check_type(self); - if (!sound_wave_procedural) { + if (!sound_wave_procedural) + { // Clean up PyBuffer_Release(&sound_buffer); return PyErr_Format(PyExc_Exception, "UObject is not a USoundWaveProcedural."); } // Convert the buffer uint8 *buffer = (uint8 *)sound_buffer.buf; - if (buffer == nullptr) { + if (buffer == nullptr) + { // Clean up PyBuffer_Release(&sound_buffer); return PyErr_Format(PyExc_Exception, "Invalid sound buffer."); @@ -34,24 +40,28 @@ PyObject *py_ue_queue_audio(ue_PyUObject *self, PyObject * args) { Py_RETURN_NONE; } -PyObject *py_ue_get_available_audio_byte_count(ue_PyUObject *self, PyObject * args) { - +PyObject *py_ue_get_available_audio_byte_count(ue_PyUObject *self, PyObject * args) +{ + ue_py_check(self); USoundWaveProcedural *sound_wave_procedural = ue_py_check_type(self); - if (!sound_wave_procedural) { + if (!sound_wave_procedural) + { return PyErr_Format(PyExc_Exception, "UObject is not a USoundWaveProcedural."); } - + return PyLong_FromLong(sound_wave_procedural->GetAvailableAudioByteCount()); } -PyObject *py_ue_reset_audio(ue_PyUObject *self, PyObject * args) { +PyObject *py_ue_reset_audio(ue_PyUObject *self, PyObject * args) +{ ue_py_check(self); USoundWaveProcedural *sound_wave_procedural = ue_py_check_type(self); - if (!sound_wave_procedural) { + if (!sound_wave_procedural) + { return PyErr_Format(PyExc_Exception, "UObject is not a USoundWaveProcedural."); } @@ -60,7 +70,8 @@ PyObject *py_ue_reset_audio(ue_PyUObject *self, PyObject * args) { Py_RETURN_NONE; } -PyObject *py_ue_sound_get_data(ue_PyUObject *self, PyObject * args) { +PyObject *py_ue_sound_get_data(ue_PyUObject *self, PyObject * args) +{ ue_py_check(self); USoundWave *sound = ue_py_check_type(self); @@ -76,12 +87,14 @@ PyObject *py_ue_sound_get_data(ue_PyUObject *self, PyObject * args) { return py_data; } -PyObject *py_ue_sound_set_data(ue_PyUObject *self, PyObject * args) { +PyObject *py_ue_sound_set_data(ue_PyUObject *self, PyObject * args) +{ ue_py_check(self); Py_buffer sound_buffer; - if (!PyArg_ParseTuple(args, "y*:sound_set_data", &sound_buffer)) { + if (!PyArg_ParseTuple(args, "y*:sound_set_data", &sound_buffer)) + { return NULL; } @@ -100,7 +113,8 @@ PyObject *py_ue_sound_set_data(ue_PyUObject *self, PyObject * args) { Py_RETURN_NONE; } -PyObject *py_ue_play_sound_at_location(ue_PyUObject *self, PyObject * args) { +PyObject *py_ue_play_sound_at_location(ue_PyUObject *self, PyObject * args) +{ ue_py_check(self); @@ -110,16 +124,19 @@ PyObject *py_ue_play_sound_at_location(ue_PyUObject *self, PyObject * args) { float pitch = 1; float start = 0; - if (!PyArg_ParseTuple(args, "OO|fff:play_sound_at_location", &sound, &py_location, &volume, &pitch, &start)) { + if (!PyArg_ParseTuple(args, "OO|fff:play_sound_at_location", &sound, &py_location, &volume, &pitch, &start)) + { return NULL; } USoundBase *sound_object = nullptr; - if (ue_is_pyuobject(sound)) { + if (ue_is_pyuobject(sound)) + { sound_object = ue_py_check_type(sound); } - else if (PyUnicodeOrString_Check(sound)) { - sound_object = FindObject(ANY_PACKAGE, UTF8_TO_TCHAR(PyUnicode_AsUTF8(sound))); + else if (PyUnicodeOrString_Check(sound)) + { + sound_object = FindObject(ANY_PACKAGE, UTF8_TO_TCHAR(UEPyUnicode_AsUTF8(sound))); } if (!sound_object) @@ -131,6 +148,5 @@ PyObject *py_ue_play_sound_at_location(ue_PyUObject *self, PyObject * args) { UGameplayStatics::PlaySoundAtLocation(self->ue_object, sound_object, location->vec, volume, pitch, start); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } \ No newline at end of file diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyAudio.h b/Source/UnrealEnginePython/Private/UObject/UEPyAudio.h index b783c5c1b..671dd6bc1 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyAudio.h +++ b/Source/UnrealEnginePython/Private/UObject/UEPyAudio.h @@ -2,7 +2,7 @@ -#include "UnrealEnginePython.h" +#include "UEPyModule.h" PyObject *py_ue_queue_audio(ue_PyUObject *self, PyObject * args); PyObject *py_ue_play_sound_at_location(ue_PyUObject *, PyObject *); diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyCapture.cpp b/Source/UnrealEnginePython/Private/UObject/UEPyCapture.cpp index 02aec9493..26f2194c4 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyCapture.cpp +++ b/Source/UnrealEnginePython/Private/UObject/UEPyCapture.cpp @@ -1,4 +1,4 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPyCapture.h" #include "Runtime/MovieSceneCapture/Public/MovieSceneCapture.h" @@ -17,14 +17,26 @@ for a queue of UMovieSceneCapture objects #include "Slate/SceneViewport.h" #include "AutomatedLevelSequenceCapture.h" +#include "Slate/UEPySPythonEditorViewport.h" +#include "GameFramework/GameModeBase.h" +#include "GameFramework/GameMode.h" +#include "Runtime/CoreUObject/Public/Serialization/ObjectReader.h" +#include "Runtime/CoreUObject/Public/Serialization/ObjectWriter.h" +#include "Runtime/Slate/Public/Framework/Application/SlateApplication.h" +#include "Runtime/Core/Public/Containers/Ticker.h" + + struct FInEditorMultiCapture : TSharedFromThis { - static TWeakPtr CreateInEditorMultiCapture(TArray InCaptureObjects) + static TWeakPtr CreateInEditorMultiCapture(TArray InCaptureObjects, PyObject *py_callable) { // FInEditorCapture owns itself, so should only be kept alive by itself, or a pinned (=> temporary) weakptr FInEditorMultiCapture* Capture = new FInEditorMultiCapture; Capture->CaptureObjects = InCaptureObjects; + Capture->py_callable = py_callable; + if (Capture->py_callable) + Py_INCREF(Capture->py_callable); for (UMovieSceneCapture *SceneCapture : Capture->CaptureObjects) { SceneCapture->AddToRoot(); @@ -46,6 +58,10 @@ struct FInEditorMultiCapture : TSharedFromThis SceneCapture->RemoveFromRoot(); } OnlyStrongReference = nullptr; + { + FScopePythonGIL gil; + Py_XDECREF(py_callable); + } } void Dequeue() @@ -115,6 +131,22 @@ struct FInEditorMultiCapture : TSharedFromThis bool PlaySession(float DeltaTime) { + + + if (py_callable) + { + GEditor->RequestEndPlayMap(); + FScopePythonGIL gil; + ue_PyUObject *py_capture = ue_get_python_uobject(CurrentCaptureObject); + PyObject *py_ret = PyObject_CallFunction(py_callable, "O", py_capture); + if (!py_ret) + { + unreal_engine_py_log_error(); + } + Py_XDECREF(py_ret); + } + + GEditor->RequestPlaySession(true, nullptr, false); return false; } @@ -265,8 +297,9 @@ struct FInEditorMultiCapture : TSharedFromThis void NextCapture(bool bIsSimulating) { - + FEditorDelegates::EndPIE.RemoveAll(this); + // remove item from the TArray; CaptureObjects.RemoveAt(0); @@ -300,13 +333,16 @@ struct FInEditorMultiCapture : TSharedFromThis TSubclassOf CachedGameMode; TArray CaptureObjects; + + PyObject *py_callable; }; PyObject *py_unreal_engine_in_editor_capture(PyObject * self, PyObject * args) { PyObject *py_scene_captures; + PyObject *py_callable = nullptr; - if (!PyArg_ParseTuple(args, "O:in_editor_capture", &py_scene_captures)) + if (!PyArg_ParseTuple(args, "O|O:in_editor_capture", &py_scene_captures, &py_callable)) { return nullptr; } @@ -338,9 +374,11 @@ PyObject *py_unreal_engine_in_editor_capture(PyObject * self, PyObject * args) Captures.Add(capture); } - FInEditorMultiCapture::CreateInEditorMultiCapture(Captures); + Py_BEGIN_ALLOW_THREADS + FInEditorMultiCapture::CreateInEditorMultiCapture(Captures, py_callable); + Py_END_ALLOW_THREADS - Py_RETURN_NONE; + Py_RETURN_NONE; } PyObject *py_ue_set_level_sequence_asset(ue_PyUObject *self, PyObject *args) @@ -364,8 +402,11 @@ PyObject *py_ue_set_level_sequence_asset(ue_PyUObject *self, PyObject *args) if (!capture) return PyErr_Format(PyExc_Exception, "uobject is not a UAutomatedLevelSequenceCapture"); +#if ENGINE_MINOR_VERSION < 20 capture->SetLevelSequenceAsset(sequence->GetPathName()); - +#else + capture->LevelSequenceAsset = FSoftObjectPath(sequence->GetPathName()); +#endif Py_RETURN_NONE; } #endif @@ -389,15 +430,11 @@ PyObject *py_ue_capture_initialize(ue_PyUObject * self, PyObject * args) #if WITH_EDITOR if (py_widget) { - ue_PySWidget *s_widget = py_ue_is_swidget(py_widget); - if (!s_widget) - return PyErr_Format(PyExc_Exception, "argument is not a SWidget"); - - if (s_widget->s_widget->GetType().Compare(FName("SPythonEditorViewport")) == 0) + TSharedPtr Viewport = py_ue_is_swidget(py_widget); + if (Viewport.IsValid()) { - TSharedRef s_viewport = StaticCastSharedRef(s_widget->s_widget); - capture->Initialize(s_viewport->GetSceneViewport()); + capture->Initialize(Viewport->GetSceneViewport()); capture->StartWarmup(); } else diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyCapture.h b/Source/UnrealEnginePython/Private/UObject/UEPyCapture.h index 1ef58340d..6049f3bb6 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyCapture.h +++ b/Source/UnrealEnginePython/Private/UObject/UEPyCapture.h @@ -1,7 +1,7 @@ #pragma once -#include "UnrealEnginePython.h" +#include "UEPyModule.h" PyObject *py_ue_capture_initialize(ue_PyUObject *, PyObject *); diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyController.cpp b/Source/UnrealEnginePython/Private/UObject/UEPyController.cpp index 3dcd6e2a2..15519285a 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyController.cpp +++ b/Source/UnrealEnginePython/Private/UObject/UEPyController.cpp @@ -1,5 +1,9 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPyController.h" +#include "GameFramework/Controller.h" +#include "GameFramework/HUD.h" +#include "GameFramework/Pawn.h" +#include "GameFramework/PlayerController.h" PyObject *py_ue_controller_posses(ue_PyUObject * self, PyObject * args) { diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyController.h b/Source/UnrealEnginePython/Private/UObject/UEPyController.h index 964f82c05..70140638f 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyController.h +++ b/Source/UnrealEnginePython/Private/UObject/UEPyController.h @@ -2,7 +2,7 @@ -#include "UnrealEnginePython.h" +#include "UEPyModule.h" PyObject *py_ue_controller_posses(ue_PyUObject *, PyObject *); PyObject *py_ue_controller_unposses(ue_PyUObject *, PyObject *); diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyDataTable.cpp b/Source/UnrealEnginePython/Private/UObject/UEPyDataTable.cpp index a41e4df26..727c02c08 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyDataTable.cpp +++ b/Source/UnrealEnginePython/Private/UObject/UEPyDataTable.cpp @@ -1,4 +1,4 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPyDataTable.h" #if WITH_EDITOR @@ -38,7 +38,7 @@ PyObject *py_ue_data_table_add_row(ue_PyUObject * self, PyObject * args) if (!row) return PyErr_Format(PyExc_Exception, "unable to add row"); data_table->RowStruct->InitializeStruct(row); - data_table->RowStruct->CopyScriptStruct(row, u_struct->data); + data_table->RowStruct->CopyScriptStruct(row, u_struct->u_struct_ptr); Py_RETURN_NONE; @@ -108,9 +108,13 @@ PyObject *py_ue_data_table_as_dict(ue_PyUObject * self, PyObject * args) PyObject *py_dict = PyDict_New(); +#if ENGINE_MINOR_VERSION > 20 + for (TMap::TConstIterator RowMapIter(data_table->GetRowMap().CreateConstIterator()); RowMapIter; ++RowMapIter) +#else for (TMap::TConstIterator RowMapIter(data_table->RowMap.CreateConstIterator()); RowMapIter; ++RowMapIter) +#endif { - PyDict_SetItemString(py_dict, TCHAR_TO_UTF8(*RowMapIter->Key.ToString()), py_ue_new_uscriptstruct(data_table->RowStruct, RowMapIter->Value)); + PyDict_SetItemString(py_dict, TCHAR_TO_UTF8(*RowMapIter->Key.ToString()), py_ue_new_owned_uscriptstruct(data_table->RowStruct, RowMapIter->Value)); } return py_dict; @@ -152,13 +156,17 @@ PyObject *py_ue_data_table_find_row(ue_PyUObject * self, PyObject * args) return PyErr_Format(PyExc_Exception, "uobject is not a UDataTable"); uint8 **data = nullptr; +#if ENGINE_MINOR_VERSION > 20 + data = (uint8 **)data_table->GetRowMap().Find(FName(UTF8_TO_TCHAR(name))); +#else data = data_table->RowMap.Find(FName(UTF8_TO_TCHAR(name))); +#endif if (!data) { return PyErr_Format(PyExc_Exception, "key not found in UDataTable"); } - return py_ue_new_uscriptstruct(data_table->RowStruct, *data); + return py_ue_new_owned_uscriptstruct(data_table->RowStruct, *data); } PyObject *py_ue_data_table_get_all_rows(ue_PyUObject * self, PyObject * args) @@ -172,9 +180,13 @@ PyObject *py_ue_data_table_get_all_rows(ue_PyUObject * self, PyObject * args) PyObject *py_list = PyList_New(0); +#if ENGINE_MINOR_VERSION > 20 + for (TMap::TConstIterator RowMapIter(data_table->GetRowMap().CreateConstIterator()); RowMapIter; ++RowMapIter) +#else for (TMap::TConstIterator RowMapIter(data_table->RowMap.CreateConstIterator()); RowMapIter; ++RowMapIter) +#endif { - PyList_Append(py_list, py_ue_new_uscriptstruct(data_table->RowStruct, RowMapIter->Value)); + PyList_Append(py_list, py_ue_new_owned_uscriptstruct(data_table->RowStruct, RowMapIter->Value)); } return py_list; diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyDataTable.h b/Source/UnrealEnginePython/Private/UObject/UEPyDataTable.h index a08ee72b5..5552d4d2c 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyDataTable.h +++ b/Source/UnrealEnginePython/Private/UObject/UEPyDataTable.h @@ -1,7 +1,7 @@ #pragma once -#include "UnrealEnginePython.h" +#include "UEPyModule.h" PyObject *py_ue_data_table_add_row(ue_PyUObject *, PyObject *); diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyExporter.cpp b/Source/UnrealEnginePython/Private/UObject/UEPyExporter.cpp index 3edbc509d..4f10efbdb 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyExporter.cpp +++ b/Source/UnrealEnginePython/Private/UObject/UEPyExporter.cpp @@ -1,4 +1,4 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPyExporter.h" #include "Exporters/Exporter.h" diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyExporter.h b/Source/UnrealEnginePython/Private/UObject/UEPyExporter.h index 72eda9b35..32518724d 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyExporter.h +++ b/Source/UnrealEnginePython/Private/UObject/UEPyExporter.h @@ -2,7 +2,7 @@ -#include "UnrealEnginePython.h" +#include "UEPyModule.h" PyObject *py_ue_export_to_file(ue_PyUObject *, PyObject *); \ No newline at end of file diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyFoliage.cpp b/Source/UnrealEnginePython/Private/UObject/UEPyFoliage.cpp new file mode 100644 index 000000000..0a9498d2a --- /dev/null +++ b/Source/UnrealEnginePython/Private/UObject/UEPyFoliage.cpp @@ -0,0 +1,149 @@ +#include "UEPyFoliage.h" + +#include "Runtime/Foliage/Public/FoliageType.h" +#include "Runtime/Foliage/Public/InstancedFoliageActor.h" +#include "Wrappers/UEPyFFoliageInstance.h" + +PyObject *py_ue_get_instanced_foliage_actor_for_current_level(ue_PyUObject *self, PyObject * args) +{ + ue_py_check(self); + + UWorld *world = ue_get_uworld(self); + if (!world) + return PyErr_Format(PyExc_Exception, "unable to retrieve UWorld from uobject"); + + Py_RETURN_UOBJECT(AInstancedFoliageActor::GetInstancedFoliageActorForCurrentLevel(world, true)); +} + +PyObject *py_ue_get_instanced_foliage_actor_for_level(ue_PyUObject *self, PyObject * args) +{ + ue_py_check(self); + + ULevel *level = ue_py_check_type(self); + if (!level) + return PyErr_Format(PyExc_Exception, "uobject is not a ULevel"); + + Py_RETURN_UOBJECT(AInstancedFoliageActor::GetInstancedFoliageActorForLevel(level, true)); +} + +PyObject *py_ue_get_foliage_types(ue_PyUObject *self, PyObject * args) +{ + ue_py_check(self); + + AInstancedFoliageActor *foliage_actor = ue_py_check_type(self); + if (!foliage_actor) + return PyErr_Format(PyExc_Exception, "uobject is not a AInstancedFoliageActor"); + + PyObject *py_list = PyList_New(0); + + TArray FoliageTypes; +#if ENGINE_MINOR_VERSION >=23 + foliage_actor->FoliageInfos.GetKeys(FoliageTypes); +#else + foliage_actor->FoliageMeshes.GetKeys(FoliageTypes); +#endif + + for (UFoliageType *FoliageType : FoliageTypes) + { + PyList_Append(py_list, (PyObject*)ue_get_python_uobject(FoliageType)); + } + + return py_list; +} + +#if WITH_EDITOR +PyObject *py_ue_get_foliage_instances(ue_PyUObject *self, PyObject * args) +{ + ue_py_check(self); + + PyObject *py_foliage_type; + + if (!PyArg_ParseTuple(args, "O:get_foliage_instances", &py_foliage_type)) + { + return nullptr; + } + + AInstancedFoliageActor *foliage_actor = ue_py_check_type(self); + if (!foliage_actor) + return PyErr_Format(PyExc_Exception, "uobject is not a AInstancedFoliageActor"); + + UFoliageType *foliage_type = ue_py_check_type(py_foliage_type); + if (!foliage_type) + return PyErr_Format(PyExc_Exception, "argument is not a UFoliageType"); + +#if ENGINE_MINOR_VERSION >= 23 + if (!foliage_actor->FoliageInfos.Contains(foliage_type)) +#else + if (!foliage_actor->FoliageMeshes.Contains(foliage_type)) +#endif + { + return PyErr_Format(PyExc_Exception, "specified UFoliageType not found in AInstancedFoliageActor"); + } + +#if ENGINE_MINOR_VERSION >= 23 + FFoliageInfo& info = foliage_actor->FoliageInfos[foliage_type].Get(); +#else + FFoliageMeshInfo& info = foliage_actor->FoliageMeshes[foliage_type].Get(); +#endif + + PyObject *py_list = PyList_New(0); + + for (int32 i=0; i(py_uobject); + if (!u_object) + return PyErr_Format(PyExc_Exception, "argument is not a UObject"); + + UFoliageType *foliage_type = nullptr; + + AInstancedFoliageActor *ifa = AInstancedFoliageActor::GetInstancedFoliageActorForCurrentLevel(world, true); + if (u_object->IsA()) + { +#if ENGINE_MINOR_VERSION >= 23 + foliage_type = ifa->GetLocalFoliageTypeForSource(u_object); +#else + foliage_type = ifa->GetLocalFoliageTypeForMesh((UStaticMesh *)u_object); +#endif + if (!foliage_type) + { + ifa->AddMesh((UStaticMesh *)u_object, &foliage_type); + } + } + else if (u_object->IsA()) + { + foliage_type = (UFoliageType *)u_object; + ifa->AddFoliageType(foliage_type); + + } + + if (!foliage_type) + return PyErr_Format(PyExc_Exception, "unable to add foliage asset"); + + Py_RETURN_UOBJECT(foliage_type); + +} +#endif + diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyFoliage.h b/Source/UnrealEnginePython/Private/UObject/UEPyFoliage.h new file mode 100644 index 000000000..e92b7818f --- /dev/null +++ b/Source/UnrealEnginePython/Private/UObject/UEPyFoliage.h @@ -0,0 +1,11 @@ +#pragma once + +#include "UEPyModule.h" + +PyObject *py_ue_get_instanced_foliage_actor_for_current_level(ue_PyUObject *, PyObject *); +PyObject *py_ue_get_instanced_foliage_actor_for_level(ue_PyUObject *, PyObject *); +PyObject *py_ue_get_foliage_types(ue_PyUObject *, PyObject *); +#if WITH_EDITOR +PyObject *py_ue_get_foliage_instances(ue_PyUObject *, PyObject *); +PyObject *py_ue_add_foliage_asset(ue_PyUObject *, PyObject *); +#endif diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyHUD.cpp b/Source/UnrealEnginePython/Private/UObject/UEPyHUD.cpp index fde17cb6f..8f1aadee0 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyHUD.cpp +++ b/Source/UnrealEnginePython/Private/UObject/UEPyHUD.cpp @@ -1,5 +1,6 @@ -#include "UnrealEnginePythonPrivatePCH.h" -#include "Runtime/Engine/Classes/GameFramework/HUD.h" +#include "UEPyHUD.h" +#include "GameFramework/HUD.h" +#include "Engine/Texture.h" PyObject *py_ue_hud_draw_2d_line(ue_PyUObject *self, PyObject * args) { diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyHUD.h b/Source/UnrealEnginePython/Private/UObject/UEPyHUD.h index d39041f90..64d2d2847 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyHUD.h +++ b/Source/UnrealEnginePython/Private/UObject/UEPyHUD.h @@ -2,7 +2,8 @@ -#include "UnrealEnginePython.h" +#include "UEPyModule.h" + PyObject *py_ue_hud_draw_2d_line(ue_PyUObject *self, PyObject * args); PyObject *py_ue_hud_draw_line(ue_PyUObject *self, PyObject * args); diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyInput.cpp b/Source/UnrealEnginePython/Private/UObject/UEPyInput.cpp index 47578a83b..78fa7d3cf 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyInput.cpp +++ b/Source/UnrealEnginePython/Private/UObject/UEPyInput.cpp @@ -1,4 +1,8 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPyInput.h" + +#include "Kismet/GameplayStatics.h" +#include "Engine/World.h" +#include "GameFramework/PlayerInput.h" PyObject *py_ue_is_input_key_down(ue_PyUObject *self, PyObject * args) @@ -380,7 +384,7 @@ PyObject *py_ue_bind_action(ue_PyUObject *self, PyObject * args) return NULL; } - if (!PyCalllable_Check_Extended(py_callable)) + if (!PyCallable_Check(py_callable)) { return PyErr_Format(PyExc_Exception, "object is not a callable"); } @@ -427,7 +431,7 @@ PyObject *py_ue_bind_axis(ue_PyUObject *self, PyObject * args) return NULL; } - if (!PyCalllable_Check_Extended(py_callable)) + if (!PyCallable_Check(py_callable)) { return PyErr_Format(PyExc_Exception, "object is not a callable"); } @@ -475,7 +479,7 @@ PyObject *py_ue_bind_key(ue_PyUObject *self, PyObject * args) return NULL; } - if (!PyCalllable_Check_Extended(py_callable)) + if (!PyCallable_Check(py_callable)) { return PyErr_Format(PyExc_Exception, "object is not a callable"); } diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyInput.h b/Source/UnrealEnginePython/Private/UObject/UEPyInput.h index 169df1fc3..9e8481c16 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyInput.h +++ b/Source/UnrealEnginePython/Private/UObject/UEPyInput.h @@ -2,7 +2,7 @@ -#include "UnrealEnginePython.h" +#include "UEPyModule.h" PyObject *py_ue_is_input_key_down(ue_PyUObject *, PyObject *); diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyLandscape.cpp b/Source/UnrealEnginePython/Private/UObject/UEPyLandscape.cpp index 900c1434a..adacab7ec 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyLandscape.cpp +++ b/Source/UnrealEnginePython/Private/UObject/UEPyLandscape.cpp @@ -1,37 +1,42 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPyLandscape.h" + + +#if WITH_EDITOR + +#include "Wrappers/UEPyFRawMesh.h" #include "Runtime/Landscape/Classes/LandscapeProxy.h" #include "Runtime/Landscape/Classes/LandscapeInfo.h" +#include "GameFramework/GameModeBase.h" -#if WITH_EDITOR -PyObject *py_ue_create_landscape_info(ue_PyUObject *self, PyObject * args) +PyObject* py_ue_create_landscape_info(ue_PyUObject* self, PyObject* args) { ue_py_check(self); - ALandscapeProxy *landscape = ue_py_check_type(self); + ALandscapeProxy* landscape = ue_py_check_type(self); if (!landscape) return PyErr_Format(PyExc_Exception, "uobject is not a ULandscapeProxy"); Py_RETURN_UOBJECT(landscape->CreateLandscapeInfo()); } -PyObject *py_ue_get_landscape_info(ue_PyUObject *self, PyObject * args) +PyObject* py_ue_get_landscape_info(ue_PyUObject* self, PyObject* args) { ue_py_check(self); - ALandscapeProxy *landscape = ue_py_check_type(self); + ALandscapeProxy* landscape = ue_py_check_type(self); if (!landscape) return PyErr_Format(PyExc_Exception, "uobject is not a ULandscapeProxy"); - ULandscapeInfo *info = landscape->GetLandscapeInfo(); + ULandscapeInfo* info = landscape->GetLandscapeInfo(); if (!info) Py_RETURN_NONE; Py_RETURN_UOBJECT(info); } -PyObject *py_ue_landscape_import(ue_PyUObject *self, PyObject * args) +PyObject* py_ue_landscape_import(ue_PyUObject* self, PyObject* args) { ue_py_check(self); @@ -46,7 +51,7 @@ PyObject *py_ue_landscape_import(ue_PyUObject *self, PyObject * args) if (!PyArg_ParseTuple(args, "iiiiy*|i:landscape_import", §ion_size, §ions_per_component, &component_x, &component_y, &heightmap_buffer, &layer_type)) return nullptr; - ALandscapeProxy *landscape = ue_py_check_type(self); + ALandscapeProxy* landscape = ue_py_check_type(self); if (!landscape) return PyErr_Format(PyExc_Exception, "uobject is not a ULandscapeProxy"); @@ -57,16 +62,29 @@ PyObject *py_ue_landscape_import(ue_PyUObject *self, PyObject * args) if (heightmap_buffer.len < (Py_ssize_t)(size_x * size_y * sizeof(uint16))) return PyErr_Format(PyExc_Exception, "not enough heightmap data, expecting %lu bytes", size_x * size_y * sizeof(uint16)); - uint16 *data = (uint16 *)heightmap_buffer.buf; + uint16* data = (uint16*)heightmap_buffer.buf; TArray infos; +#if ENGINE_MINOR_VERSION < 23 landscape->Import(FGuid::NewGuid(), 0, 0, size_x - 1, size_y - 1, sections_per_component, section_size, data, nullptr, infos, (ELandscapeImportAlphamapType)layer_type); +#else + TMap> HeightDataPerLayers; + TArray HeightData; + for (uint32 i = 0; i < (heightmap_buffer.len / sizeof(uint16)); i++) + { + HeightData.Add(data[i]); + } + HeightDataPerLayers.Add(FGuid(), HeightData); + TMap> MaterialLayersInfo; + MaterialLayersInfo.Add(FGuid(), infos); + landscape->Import(FGuid::NewGuid(), 0, 0, size_x - 1, size_y - 1, sections_per_component, section_size, HeightDataPerLayers, nullptr, MaterialLayersInfo, (ELandscapeImportAlphamapType)layer_type); +#endif Py_RETURN_NONE; } -PyObject *py_ue_landscape_export_to_raw_mesh(ue_PyUObject *self, PyObject * args) +PyObject* py_ue_landscape_export_to_raw_mesh(ue_PyUObject* self, PyObject* args) { ue_py_check(self); @@ -76,14 +94,18 @@ PyObject *py_ue_landscape_export_to_raw_mesh(ue_PyUObject *self, PyObject * args if (!PyArg_ParseTuple(args, "|i:landscape_import", &lod)) return nullptr; - ALandscapeProxy *landscape = ue_py_check_type(self); + ALandscapeProxy* landscape = ue_py_check_type(self); if (!landscape) return PyErr_Format(PyExc_Exception, "uobject is not a ULandscapeProxy"); +#if ENGINE_MINOR_VERSION > 21 + return PyErr_Format(PyExc_Exception, "MeshDescription struct is still unsupported");; +#else FRawMesh raw_mesh; if (!landscape->ExportToRawMesh(lod, raw_mesh)) return PyErr_Format(PyExc_Exception, "unable to export landscape to FRawMesh"); return py_ue_new_fraw_mesh(raw_mesh); +#endif } #endif diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyLandscape.h b/Source/UnrealEnginePython/Private/UObject/UEPyLandscape.h index 84060a343..e9c7ab19e 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyLandscape.h +++ b/Source/UnrealEnginePython/Private/UObject/UEPyLandscape.h @@ -2,7 +2,7 @@ -#include "UnrealEnginePython.h" +#include "UEPyModule.h" #if WITH_EDITOR PyObject *py_ue_create_landscape_info(ue_PyUObject *self, PyObject *); diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyMaterial.cpp b/Source/UnrealEnginePython/Private/UObject/UEPyMaterial.cpp index 381e3ee6a..c958094f6 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyMaterial.cpp +++ b/Source/UnrealEnginePython/Private/UObject/UEPyMaterial.cpp @@ -1,12 +1,82 @@ +#include "UEPyMaterial.h" -#include "UnrealEnginePythonPrivatePCH.h" #if WITH_EDITOR #include "Editor/UnrealEd/Classes/MaterialGraph/MaterialGraph.h" #include "Editor/UnrealEd/Public/Kismet2/BlueprintEditorUtils.h" #include "Editor/UnrealEd/Classes/MaterialGraph/MaterialGraphSchema.h" #endif +#include "Materials/MaterialInstanceConstant.h" +#include "Materials/MaterialInstanceDynamic.h" +#include "Wrappers/UEPyFLinearColor.h" +#include "Wrappers/UEPyFVector.h" +#include "Engine/Texture.h" +#include "Components/PrimitiveComponent.h" +#include "Engine/StaticMesh.h" + +PyObject *py_ue_set_material_by_name(ue_PyUObject *self, PyObject * args) +{ + + ue_py_check(self); + + char *slot_name; + PyObject *py_mat; + if (!PyArg_ParseTuple(args, "sO:set_material_by_name", &slot_name, &py_mat)) + { + return nullptr; + } + + UPrimitiveComponent *primitive = ue_py_check_type(self); + if (!primitive) + return PyErr_Format(PyExc_Exception, "uobject is not a UPrimitiveComponent"); + + UMaterialInterface *material = ue_py_check_type(py_mat); + if (!material) + return PyErr_Format(PyExc_Exception, "argument is not a UMaterialInterface"); + + primitive->SetMaterialByName(FName(UTF8_TO_TCHAR(slot_name)), material); + + Py_RETURN_NONE; +} + +PyObject *py_ue_set_material(ue_PyUObject *self, PyObject * args) +{ + + ue_py_check(self); + + int slot; + PyObject *py_mat; + if (!PyArg_ParseTuple(args, "iO:set_material", &slot, &py_mat)) + { + return nullptr; + } + + UMaterialInterface *material = ue_py_check_type(py_mat); + if (!material) + return PyErr_Format(PyExc_Exception, "argument is not a UMaterialInterface"); + +#if ENGINE_MINOR_VERSION >= 20 +#if WITH_EDITOR + UStaticMesh *mesh = ue_py_check_type(self); + if (mesh) + { + mesh->SetMaterial(slot, material); + Py_RETURN_NONE; + } +#endif +#endif + + UPrimitiveComponent *primitive = ue_py_check_type(self); + if (!primitive) + return PyErr_Format(PyExc_Exception, "uobject is not a UPrimitiveComponent"); + + + primitive->SetMaterial(slot, material); + + Py_RETURN_NONE; +} + PyObject *py_ue_set_material_scalar_parameter(ue_PyUObject *self, PyObject * args) { @@ -48,6 +118,81 @@ PyObject *py_ue_set_material_scalar_parameter(ue_PyUObject *self, PyObject * arg } +PyObject *py_ue_set_material_static_switch_parameter(ue_PyUObject *self, PyObject * args) +{ + + ue_py_check(self); + + char *switchName = nullptr; + PyObject *py_bool = nullptr; + if (!PyArg_ParseTuple(args, "sO:set_material_static_switch_parameter", &switchName, &py_bool)) + { + return NULL; + } + + FName parameterName(UTF8_TO_TCHAR(switchName)); + + bool switchValue = false; + if (PyObject_IsTrue(py_bool)) + { + switchValue = true; + } + + bool valid = false; + +#if WITH_EDITOR + if (self->ue_object->IsA()) + { + UMaterialInstance *material_instance = (UMaterialInstance *)self->ue_object; + valid = true; + FStaticParameterSet staticParameterSet = material_instance->GetStaticParameters(); + + bool isExisting = false; + for (auto& parameter : staticParameterSet.StaticSwitchParameters) + { +#if ENGINE_MINOR_VERSION < 19 + if (parameter.bOverride && parameter.ParameterName == parameterName) +#else + if (parameter.bOverride && parameter.ParameterInfo.Name == parameterName) +#endif + { + parameter.Value = switchValue; + isExisting = true; + break; + } + } + + if (!isExisting) + { + FStaticSwitchParameter SwitchParameter; +#if ENGINE_MINOR_VERSION < 19 + SwitchParameter.ParameterName = parameterName; +#else + SwitchParameter.ParameterInfo.Name = parameterName; +#endif + SwitchParameter.Value = switchValue; + + SwitchParameter.bOverride = true; + staticParameterSet.StaticSwitchParameters.Add(SwitchParameter); + } + + + material_instance->UpdateStaticPermutation(staticParameterSet); + + } + + +#endif + + if (!valid) + { + return PyErr_Format(PyExc_Exception, "uobject is not a MaterialInstance"); + } + + Py_RETURN_NONE; + +} + PyObject *py_ue_get_material_scalar_parameter(ue_PyUObject *self, PyObject * args) { @@ -207,20 +352,13 @@ PyObject *py_ue_set_material_texture_parameter(ue_PyUObject *self, PyObject * ar PyObject *textureObject = nullptr; if (!PyArg_ParseTuple(args, "sO:set_texture_parameter", &textureName, &textureObject)) { - return NULL; - } - - if (!ue_is_pyuobject(textureObject)) - { - return PyErr_Format(PyExc_Exception, "argument is not a UObject"); + return nullptr; } - ue_PyUObject *py_obj = (ue_PyUObject *)textureObject; - if (!py_obj->ue_object->IsA()) + UTexture *ue_texture = ue_py_check_type(textureObject); + if (!ue_texture) return PyErr_Format(PyExc_Exception, "uobject is not a UTexture"); - UTexture *ue_texture = (UTexture *)py_obj->ue_object; - FName parameterName(UTF8_TO_TCHAR(textureName)); bool valid = false; @@ -300,44 +438,6 @@ PyObject *py_ue_create_material_instance_dynamic(ue_PyUObject *self, PyObject * Py_RETURN_UOBJECT(material_dynamic); } -PyObject *py_ue_set_material(ue_PyUObject *self, PyObject * args) -{ - - ue_py_check(self); - - int index; - PyObject *py_material = nullptr; - - if (!PyArg_ParseTuple(args, "iO:set_material", &index, &py_material)) - { - return NULL; - } - - if (!self->ue_object->IsA()) - { - return PyErr_Format(PyExc_Exception, "uobject is not a UPrimitiveComponent"); - } - - UPrimitiveComponent *component = (UPrimitiveComponent *)self->ue_object; - - if (!ue_is_pyuobject(py_material)) - { - return PyErr_Format(PyExc_Exception, "argument is not a UObject"); - } - - ue_PyUObject *py_obj = (ue_PyUObject *)py_material; - - if (!py_obj->ue_object->IsA()) - { - return PyErr_Format(PyExc_Exception, "uobject is not a UMaterialInterface"); - } - - UMaterialInterface *material_interface = (UMaterialInterface *)py_obj->ue_object; - - component->SetMaterial(index, material_interface); - - Py_RETURN_NONE; -} #if WITH_EDITOR @@ -405,7 +505,11 @@ PyObject *py_ue_static_mesh_set_collision_for_lod(ue_PyUObject *self, PyObject * enabled = true; } +#if ENGINE_MINOR_VERSION >= 23 + FMeshSectionInfo info = mesh->GetSectionInfoMap().Get(lod_index, material_index); +#else FMeshSectionInfo info = mesh->SectionInfoMap.Get(lod_index, material_index); +#endif info.bEnableCollision = enabled; mesh->SectionInfoMap.Set(lod_index, material_index, info); diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyMaterial.h b/Source/UnrealEnginePython/Private/UObject/UEPyMaterial.h index a97a13082..95ebe3942 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyMaterial.h +++ b/Source/UnrealEnginePython/Private/UObject/UEPyMaterial.h @@ -1,10 +1,11 @@ #pragma once -#include "UnrealEnginePython.h" +#include "UEPyModule.h" PyObject *py_ue_set_material_scalar_parameter(ue_PyUObject *, PyObject *); +PyObject *py_ue_set_material_static_switch_parameter(ue_PyUObject *, PyObject *); PyObject *py_ue_set_material_vector_parameter(ue_PyUObject *, PyObject *); PyObject *py_ue_set_material_texture_parameter(ue_PyUObject *, PyObject *); @@ -17,6 +18,7 @@ PyObject *py_ue_create_material_instance_dynamic(ue_PyUObject *, PyObject *); PyObject *py_ue_set_material(ue_PyUObject *, PyObject *); +PyObject *py_ue_set_material_by_name(ue_PyUObject *, PyObject *); #if WITH_EDITOR PyObject *py_ue_set_material_parent(ue_PyUObject *, PyObject *); diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyMovements.cpp b/Source/UnrealEnginePython/Private/UObject/UEPyMovements.cpp index 3ea892907..d325ddefe 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyMovements.cpp +++ b/Source/UnrealEnginePython/Private/UObject/UEPyMovements.cpp @@ -1,29 +1,43 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPyMovements.h" +#include "Components/ActorComponent.h" +#include "GameFramework/Pawn.h" +#include "GameFramework/PlayerController.h" +#include "GameFramework/Character.h" +#include "Wrappers/UEPyFVector.h" +#include "Wrappers/UEPyFRotator.h" +#include "GameFramework/CharacterMovementComponent.h" -PyObject *py_ue_add_controller_yaw_input(ue_PyUObject *self, PyObject * args) { +PyObject *py_ue_add_controller_yaw_input(ue_PyUObject *self, PyObject * args) +{ ue_py_check(self); float val; - if (!PyArg_ParseTuple(args, "f:add_controller_yaw_input", &val)) { + if (!PyArg_ParseTuple(args, "f:add_controller_yaw_input", &val)) + { return NULL; } APawn *pawn = nullptr; - if (self->ue_object->IsA()) { + if (self->ue_object->IsA()) + { pawn = (APawn *)self->ue_object; } - else if (UActorComponent *component = ue_py_check_type(self)) { + else if (UActorComponent *component = ue_py_check_type(self)) + { AActor *actor = component->GetOwner(); - if (actor) { - if (actor->IsA()) { + if (actor) + { + if (actor->IsA()) + { pawn = (APawn *)actor; } } } - else if (APlayerController *player = ue_py_check_type(self)) { + else if (APlayerController *player = ue_py_check_type(self)) + { player->AddYawInput(val); Py_RETURN_NONE; } @@ -36,30 +50,37 @@ PyObject *py_ue_add_controller_yaw_input(ue_PyUObject *self, PyObject * args) { Py_RETURN_NONE; } -PyObject *py_ue_add_controller_pitch_input(ue_PyUObject *self, PyObject * args) { +PyObject *py_ue_add_controller_pitch_input(ue_PyUObject *self, PyObject * args) +{ ue_py_check(self); float val; - if (!PyArg_ParseTuple(args, "f:add_controller_pitch_input", &val)) { + if (!PyArg_ParseTuple(args, "f:add_controller_pitch_input", &val)) + { return NULL; } APawn *pawn = nullptr; - if (self->ue_object->IsA()) { + if (self->ue_object->IsA()) + { pawn = (APawn *)self->ue_object; } - else if (self->ue_object->IsA()) { + else if (self->ue_object->IsA()) + { UActorComponent *component = (UActorComponent *)self->ue_object; AActor *actor = component->GetOwner(); - if (actor) { - if (actor->IsA()) { + if (actor) + { + if (actor->IsA()) + { pawn = (APawn *)actor; } } } - else if (APlayerController *player = ue_py_check_type(self)) { + else if (APlayerController *player = ue_py_check_type(self)) + { player->AddPitchInput(val); Py_RETURN_NONE; } @@ -72,29 +93,36 @@ PyObject *py_ue_add_controller_pitch_input(ue_PyUObject *self, PyObject * args) Py_RETURN_NONE; } -PyObject *py_ue_add_controller_roll_input(ue_PyUObject *self, PyObject * args) { +PyObject *py_ue_add_controller_roll_input(ue_PyUObject *self, PyObject * args) +{ ue_py_check(self); float val; - if (!PyArg_ParseTuple(args, "f:add_controller_roll_input", &val)) { + if (!PyArg_ParseTuple(args, "f:add_controller_roll_input", &val)) + { return NULL; } APawn *pawn = nullptr; - if (self->ue_object->IsA()) { + if (self->ue_object->IsA()) + { pawn = (APawn *)self->ue_object; } - else if (UActorComponent *component = ue_py_check_type(self)) { + else if (UActorComponent *component = ue_py_check_type(self)) + { AActor *actor = component->GetOwner(); - if (actor) { - if (actor->IsA()) { + if (actor) + { + if (actor->IsA()) + { pawn = (APawn *)actor; } } } - else if (APlayerController *player = ue_py_check_type(self)) { + else if (APlayerController *player = ue_py_check_type(self)) + { player->AddRollInput(val); Py_RETURN_NONE; } @@ -107,7 +135,8 @@ PyObject *py_ue_add_controller_roll_input(ue_PyUObject *self, PyObject * args) { Py_RETURN_NONE; } -PyObject *py_ue_add_movement_input(ue_PyUObject *self, PyObject * args) { +PyObject *py_ue_add_movement_input(ue_PyUObject *self, PyObject * args) +{ ue_py_check(self); @@ -115,24 +144,30 @@ PyObject *py_ue_add_movement_input(ue_PyUObject *self, PyObject * args) { float scale = 1; PyObject *py_force = nullptr; bool force = false; - if (!PyArg_ParseTuple(args, "O|fO:add_movement_input", &py_obj_movement, &scale, &py_force)) { + if (!PyArg_ParseTuple(args, "O|fO:add_movement_input", &py_obj_movement, &scale, &py_force)) + { return NULL; } - if (py_force && PyObject_IsTrue(py_force)) { + if (py_force && PyObject_IsTrue(py_force)) + { force = true; } APawn *pawn = nullptr; - if (self->ue_object->IsA()) { + if (self->ue_object->IsA()) + { pawn = (APawn *)self->ue_object; } - else if (self->ue_object->IsA()) { + else if (self->ue_object->IsA()) + { UActorComponent *component = (UActorComponent *)self->ue_object; AActor *actor = component->GetOwner(); - if (actor) { - if (actor->IsA()) { + if (actor) + { + if (actor->IsA()) + { pawn = (APawn *)actor; } } @@ -152,20 +187,25 @@ PyObject *py_ue_add_movement_input(ue_PyUObject *self, PyObject * args) { return Py_None; } -PyObject *py_ue_get_control_rotation(ue_PyUObject *self, PyObject * args) { +PyObject *py_ue_get_control_rotation(ue_PyUObject *self, PyObject * args) +{ ue_py_check(self); APawn *pawn = nullptr; - if (self->ue_object->IsA()) { + if (self->ue_object->IsA()) + { pawn = (APawn *)self->ue_object; } - else if (self->ue_object->IsA()) { + else if (self->ue_object->IsA()) + { UActorComponent *component = (UActorComponent *)self->ue_object; AActor *actor = component->GetOwner(); - if (actor) { - if (actor->IsA()) { + if (actor) + { + if (actor->IsA()) + { pawn = (APawn *)actor; } } @@ -178,20 +218,25 @@ PyObject *py_ue_get_control_rotation(ue_PyUObject *self, PyObject * args) { return py_ue_new_frotator(rot); } -PyObject *py_ue_jump(ue_PyUObject *self, PyObject * args) { +PyObject *py_ue_jump(ue_PyUObject *self, PyObject * args) +{ ue_py_check(self); ACharacter *character = nullptr; - if (self->ue_object->IsA()) { + if (self->ue_object->IsA()) + { character = (ACharacter *)self->ue_object; } - else if (self->ue_object->IsA()) { + else if (self->ue_object->IsA()) + { UActorComponent *component = (UActorComponent *)self->ue_object; AActor *actor = component->GetOwner(); - if (actor) { - if (actor->IsA()) { + if (actor) + { + if (actor->IsA()) + { character = (ACharacter *)actor; } } @@ -206,20 +251,25 @@ PyObject *py_ue_jump(ue_PyUObject *self, PyObject * args) { return Py_None; } -PyObject *py_ue_crouch(ue_PyUObject *self, PyObject * args) { +PyObject *py_ue_crouch(ue_PyUObject *self, PyObject * args) +{ ue_py_check(self); ACharacter *character = nullptr; - if (self->ue_object->IsA()) { + if (self->ue_object->IsA()) + { character = (ACharacter *)self->ue_object; } - else if (self->ue_object->IsA()) { + else if (self->ue_object->IsA()) + { UActorComponent *component = (UActorComponent *)self->ue_object; AActor *actor = component->GetOwner(); - if (actor) { - if (actor->IsA()) { + if (actor) + { + if (actor->IsA()) + { character = (ACharacter *)actor; } } @@ -234,20 +284,25 @@ PyObject *py_ue_crouch(ue_PyUObject *self, PyObject * args) { return Py_None; } -PyObject *py_ue_stop_jumping(ue_PyUObject *self, PyObject * args) { +PyObject *py_ue_stop_jumping(ue_PyUObject *self, PyObject * args) +{ ue_py_check(self); ACharacter *character = nullptr; - if (self->ue_object->IsA()) { + if (self->ue_object->IsA()) + { character = (ACharacter *)self->ue_object; } - else if (self->ue_object->IsA()) { + else if (self->ue_object->IsA()) + { UActorComponent *component = (UActorComponent *)self->ue_object; AActor *actor = component->GetOwner(); - if (actor) { - if (actor->IsA()) { + if (actor) + { + if (actor->IsA()) + { character = (ACharacter *)actor; } } @@ -262,20 +317,25 @@ PyObject *py_ue_stop_jumping(ue_PyUObject *self, PyObject * args) { return Py_None; } -PyObject *py_ue_uncrouch(ue_PyUObject *self, PyObject * args) { +PyObject *py_ue_uncrouch(ue_PyUObject *self, PyObject * args) +{ ue_py_check(self); ACharacter *character = nullptr; - if (self->ue_object->IsA()) { + if (self->ue_object->IsA()) + { character = (ACharacter *)self->ue_object; } - else if (self->ue_object->IsA()) { + else if (self->ue_object->IsA()) + { UActorComponent *component = (UActorComponent *)self->ue_object; AActor *actor = component->GetOwner(); - if (actor) { - if (actor->IsA()) { + if (actor) + { + if (actor->IsA()) + { character = (ACharacter *)actor; } } @@ -291,7 +351,8 @@ PyObject *py_ue_uncrouch(ue_PyUObject *self, PyObject * args) { } -PyObject *py_ue_launch(ue_PyUObject *self, PyObject * args) { +PyObject *py_ue_launch(ue_PyUObject *self, PyObject * args) +{ ue_py_check(self); @@ -300,20 +361,25 @@ PyObject *py_ue_launch(ue_PyUObject *self, PyObject * args) { PyObject *py_z_override = nullptr; bool xy_override = false; bool z_override; - if (!PyArg_ParseTuple(args, "O|OO:launch", &py_obj_force, &py_xy_override, &z_override)) { + if (!PyArg_ParseTuple(args, "O|OO:launch", &py_obj_force, &py_xy_override, &z_override)) + { return NULL; } ACharacter *character = nullptr; - if (self->ue_object->IsA()) { + if (self->ue_object->IsA()) + { character = (ACharacter *)self->ue_object; } - else if (self->ue_object->IsA()) { + else if (self->ue_object->IsA()) + { UActorComponent *component = (UActorComponent *)self->ue_object; AActor *actor = component->GetOwner(); - if (actor) { - if (actor->IsA()) { + if (actor) + { + if (actor->IsA()) + { character = (ACharacter *)actor; } } @@ -322,11 +388,13 @@ PyObject *py_ue_launch(ue_PyUObject *self, PyObject * args) { if (!character) return PyErr_Format(PyExc_Exception, "uobject is not a character"); - if (py_xy_override && PyObject_IsTrue(py_xy_override)) { + if (py_xy_override && PyObject_IsTrue(py_xy_override)) + { xy_override = true; } - if (py_z_override && PyObject_IsTrue(py_z_override)) { + if (py_z_override && PyObject_IsTrue(py_z_override)) + { z_override = true; } @@ -341,20 +409,25 @@ PyObject *py_ue_launch(ue_PyUObject *self, PyObject * args) { return Py_None; } -PyObject *py_ue_is_jumping(ue_PyUObject *self, PyObject * args) { +PyObject *py_ue_is_jumping(ue_PyUObject *self, PyObject * args) +{ ue_py_check(self); ACharacter *character = nullptr; - if (self->ue_object->IsA()) { + if (self->ue_object->IsA()) + { character = (ACharacter *)self->ue_object; } - else if (self->ue_object->IsA()) { + else if (self->ue_object->IsA()) + { UActorComponent *component = (UActorComponent *)self->ue_object; AActor *actor = component->GetOwner(); - if (actor) { - if (actor->IsA()) { + if (actor) + { + if (actor->IsA()) + { character = (ACharacter *)actor; } } @@ -363,7 +436,8 @@ PyObject *py_ue_is_jumping(ue_PyUObject *self, PyObject * args) { if (!character) return PyErr_Format(PyExc_Exception, "uobject is not a character"); - if (character->IsJumpProvidingForce()) { + if (character->IsJumpProvidingForce()) + { Py_INCREF(Py_True); return Py_True; } @@ -372,20 +446,25 @@ PyObject *py_ue_is_jumping(ue_PyUObject *self, PyObject * args) { return Py_False; } -PyObject *py_ue_is_crouched(ue_PyUObject *self, PyObject * args) { +PyObject *py_ue_is_crouched(ue_PyUObject *self, PyObject * args) +{ ue_py_check(self); ACharacter *character = nullptr; - if (self->ue_object->IsA()) { + if (self->ue_object->IsA()) + { character = (ACharacter *)self->ue_object; } - else if (self->ue_object->IsA()) { + else if (self->ue_object->IsA()) + { UActorComponent *component = (UActorComponent *)self->ue_object; AActor *actor = component->GetOwner(); - if (actor) { - if (actor->IsA()) { + if (actor) + { + if (actor->IsA()) + { character = (ACharacter *)actor; } } @@ -394,7 +473,8 @@ PyObject *py_ue_is_crouched(ue_PyUObject *self, PyObject * args) { if (!character) return PyErr_Format(PyExc_Exception, "uobject is not a character"); - if (character->bIsCrouched) { + if (character->bIsCrouched) + { Py_INCREF(Py_True); return Py_True; } @@ -403,20 +483,25 @@ PyObject *py_ue_is_crouched(ue_PyUObject *self, PyObject * args) { return Py_False; } -PyObject *py_ue_is_falling(ue_PyUObject *self, PyObject * args) { +PyObject *py_ue_is_falling(ue_PyUObject *self, PyObject * args) +{ ue_py_check(self); ACharacter *character = nullptr; - if (self->ue_object->IsA()) { + if (self->ue_object->IsA()) + { character = (ACharacter *)self->ue_object; } - else if (self->ue_object->IsA()) { + else if (self->ue_object->IsA()) + { UActorComponent *component = (UActorComponent *)self->ue_object; AActor *actor = component->GetOwner(); - if (actor) { - if (actor->IsA()) { + if (actor) + { + if (actor->IsA()) + { character = (ACharacter *)actor; } } @@ -426,9 +511,11 @@ PyObject *py_ue_is_falling(ue_PyUObject *self, PyObject * args) { return PyErr_Format(PyExc_Exception, "uobject is not a character"); UMovementComponent *movement = character->GetMovementComponent(); - if (movement && movement->IsA()) { + if (movement && movement->IsA()) + { UCharacterMovementComponent *character_movement = (UCharacterMovementComponent *)movement; - if (character_movement->IsFalling()) { + if (character_movement->IsFalling()) + { Py_INCREF(Py_True); return Py_True; } @@ -438,20 +525,25 @@ PyObject *py_ue_is_falling(ue_PyUObject *self, PyObject * args) { return Py_False; } -PyObject *py_ue_is_flying(ue_PyUObject *self, PyObject * args) { +PyObject *py_ue_is_flying(ue_PyUObject *self, PyObject * args) +{ ue_py_check(self); ACharacter *character = nullptr; - if (self->ue_object->IsA()) { + if (self->ue_object->IsA()) + { character = (ACharacter *)self->ue_object; } - else if (self->ue_object->IsA()) { + else if (self->ue_object->IsA()) + { UActorComponent *component = (UActorComponent *)self->ue_object; AActor *actor = component->GetOwner(); - if (actor) { - if (actor->IsA()) { + if (actor) + { + if (actor->IsA()) + { character = (ACharacter *)actor; } } @@ -461,9 +553,11 @@ PyObject *py_ue_is_flying(ue_PyUObject *self, PyObject * args) { return PyErr_Format(PyExc_Exception, "uobject is not a character"); UMovementComponent *movement = character->GetMovementComponent(); - if (movement && movement->IsA()) { + if (movement && movement->IsA()) + { UCharacterMovementComponent *character_movement = (UCharacterMovementComponent *)movement; - if (character_movement->IsFlying()) { + if (character_movement->IsFlying()) + { Py_INCREF(Py_True); return Py_True; } @@ -473,20 +567,25 @@ PyObject *py_ue_is_flying(ue_PyUObject *self, PyObject * args) { return Py_False; } -PyObject *py_ue_can_jump(ue_PyUObject *self, PyObject * args) { +PyObject *py_ue_can_jump(ue_PyUObject *self, PyObject * args) +{ ue_py_check(self); ACharacter *character = nullptr; - if (self->ue_object->IsA()) { + if (self->ue_object->IsA()) + { character = (ACharacter *)self->ue_object; } - else if (self->ue_object->IsA()) { + else if (self->ue_object->IsA()) + { UActorComponent *component = (UActorComponent *)self->ue_object; AActor *actor = component->GetOwner(); - if (actor) { - if (actor->IsA()) { + if (actor) + { + if (actor->IsA()) + { character = (ACharacter *)actor; } } @@ -495,7 +594,8 @@ PyObject *py_ue_can_jump(ue_PyUObject *self, PyObject * args) { if (!character) return PyErr_Format(PyExc_Exception, "uobject is not a character"); - if (character->CanJump()) { + if (character->CanJump()) + { Py_INCREF(Py_True); return Py_True; } @@ -504,20 +604,25 @@ PyObject *py_ue_can_jump(ue_PyUObject *self, PyObject * args) { return Py_False; } -PyObject *py_ue_can_crouch(ue_PyUObject *self, PyObject * args) { +PyObject *py_ue_can_crouch(ue_PyUObject *self, PyObject * args) +{ ue_py_check(self); ACharacter *character = nullptr; - if (self->ue_object->IsA()) { + if (self->ue_object->IsA()) + { character = (ACharacter *)self->ue_object; } - else if (self->ue_object->IsA()) { + else if (self->ue_object->IsA()) + { UActorComponent *component = (UActorComponent *)self->ue_object; AActor *actor = component->GetOwner(); - if (actor) { - if (actor->IsA()) { + if (actor) + { + if (actor->IsA()) + { character = (ACharacter *)actor; } } @@ -526,7 +631,8 @@ PyObject *py_ue_can_crouch(ue_PyUObject *self, PyObject * args) { if (!character) return PyErr_Format(PyExc_Exception, "uobject is not a character"); - if (character->CanCrouch()) { + if (character->CanCrouch()) + { Py_INCREF(Py_True); return Py_True; } diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyMovements.h b/Source/UnrealEnginePython/Private/UObject/UEPyMovements.h index 13729feb3..4b597660b 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyMovements.h +++ b/Source/UnrealEnginePython/Private/UObject/UEPyMovements.h @@ -2,7 +2,7 @@ -#include "UnrealEnginePython.h" +#include "UEPyModule.h" PyObject *py_ue_add_controller_yaw_input(ue_PyUObject *, PyObject *); diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyNavigation.cpp b/Source/UnrealEnginePython/Private/UObject/UEPyNavigation.cpp index 859475fc3..84e33582b 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyNavigation.cpp +++ b/Source/UnrealEnginePython/Private/UObject/UEPyNavigation.cpp @@ -1,6 +1,12 @@ -#include "UnrealEnginePythonPrivatePCH.h" - +#include "UEPyNavigation.h" +#if ENGINE_MINOR_VERSION < 20 +#include "AI/Navigation/NavigationSystem.h" +#else +#include "Blueprint/AIBlueprintHelperLibrary.h" +#endif +#include "GameFramework/Pawn.h" +#include "Engine/World.h" PyObject *py_ue_simple_move_to_location(ue_PyUObject *self, PyObject * args) { @@ -41,9 +47,12 @@ PyObject *py_ue_simple_move_to_location(ue_PyUObject *self, PyObject * args) if (!controller) return PyErr_Format(PyExc_Exception, "Pawn has no controller"); +#if ENGINE_MINOR_VERSION < 20 world->GetNavigationSystem()->SimpleMoveToLocation(controller, vec); +#else + UAIBlueprintHelperLibrary::SimpleMoveToLocation(controller, vec); +#endif - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyNavigation.h b/Source/UnrealEnginePython/Private/UObject/UEPyNavigation.h index f09f464a6..48e0cc497 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyNavigation.h +++ b/Source/UnrealEnginePython/Private/UObject/UEPyNavigation.h @@ -2,6 +2,6 @@ -#include "UnrealEnginePython.h" +#include "UEPyModule.h" PyObject *py_ue_simple_move_to_location(ue_PyUObject *, PyObject *); \ No newline at end of file diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyObject.cpp b/Source/UnrealEnginePython/Private/UObject/UEPyObject.cpp index 5420dd74a..3b2983b99 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyObject.cpp +++ b/Source/UnrealEnginePython/Private/UObject/UEPyObject.cpp @@ -1,15 +1,23 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPyObject.h" #include "PythonDelegate.h" #include "PythonFunction.h" +#include "Components/ActorComponent.h" +#include "Engine/UserDefinedEnum.h" #if WITH_EDITOR #include "Runtime/AssetRegistry/Public/AssetRegistryModule.h" #include "ObjectTools.h" #include "UnrealEd.h" #include "Runtime/Core/Public/HAL/FeedbackContextAnsi.h" + +#include "Wrappers/UEPyFObjectThumbnail.h" #endif +#include "Runtime/Core/Public/Misc/OutputDeviceNull.h" +#include "Runtime/CoreUObject/Public/Serialization/ObjectWriter.h" +#include "Runtime/CoreUObject/Public/Serialization/ObjectReader.h" + PyObject *py_ue_get_class(ue_PyUObject * self, PyObject * args) { @@ -79,16 +87,47 @@ PyObject *py_ue_set_obj_flags(ue_PyUObject * self, PyObject * args) ue_py_check(self); uint64 flags; - if (!PyArg_ParseTuple(args, "K:set_obj_flags", &flags)) + PyObject *py_reset = nullptr; + if (!PyArg_ParseTuple(args, "K|O:set_obj_flags", &flags, &py_reset)) { return nullptr; } + if (py_reset && PyObject_IsTrue(py_reset)) + { + self->ue_object->ClearFlags(self->ue_object->GetFlags()); + } + self->ue_object->SetFlags((EObjectFlags)flags); Py_RETURN_NONE; } +PyObject *py_ue_clear_obj_flags(ue_PyUObject * self, PyObject * args) +{ + + ue_py_check(self); + + uint64 flags; + if (!PyArg_ParseTuple(args, "K:clear_obj_flags", &flags)) + { + return nullptr; + } + + self->ue_object->ClearFlags((EObjectFlags)flags); + + Py_RETURN_NONE; +} + +PyObject *py_ue_reset_obj_flags(ue_PyUObject * self, PyObject * args) +{ + + ue_py_check(self); + + self->ue_object->ClearFlags(self->ue_object->GetFlags()); + + Py_RETURN_NONE; +} #if WITH_EDITOR PyObject *py_ue_class_set_config_name(ue_PyUObject * self, PyObject * args) @@ -287,7 +326,9 @@ PyObject *py_ue_post_edit_change(ue_PyUObject *self, PyObject * args) ue_py_check(self); #if WITH_EDITOR + Py_BEGIN_ALLOW_THREADS; self->ue_object->PostEditChange(); + Py_END_ALLOW_THREADS; #endif Py_RETURN_NONE; } @@ -297,9 +338,9 @@ PyObject *py_ue_post_edit_change_property(ue_PyUObject *self, PyObject * args) ue_py_check(self); char *prop_name = nullptr; - int change_type = 0; + int change_type = (int)EPropertyChangeType::Unspecified; - if (!PyArg_ParseTuple(args, "si:post_edit_change_property", &prop_name, &change_type)) + if (!PyArg_ParseTuple(args, "s|i:post_edit_change_property", &prop_name, &change_type)) { return nullptr; } @@ -321,8 +362,10 @@ PyObject *py_ue_post_edit_change_property(ue_PyUObject *self, PyObject * args) return PyErr_Format(PyExc_Exception, "unable to find property %s", prop_name); #if WITH_EDITOR + Py_BEGIN_ALLOW_THREADS; FPropertyChangedEvent changed(prop, change_type); self->ue_object->PostEditChangeProperty(changed); + Py_END_ALLOW_THREADS; #endif Py_RETURN_NONE; } @@ -332,7 +375,9 @@ PyObject *py_ue_modify(ue_PyUObject *self, PyObject * args) ue_py_check(self); #if WITH_EDITOR + Py_BEGIN_ALLOW_THREADS; self->ue_object->Modify(); + Py_END_ALLOW_THREADS; #endif Py_RETURN_NONE; } @@ -368,7 +413,9 @@ PyObject *py_ue_pre_edit_change(ue_PyUObject *self, PyObject * args) } #if WITH_EDITOR + Py_BEGIN_ALLOW_THREADS; self->ue_object->PreEditChange(prop); + Py_END_ALLOW_THREADS; #endif Py_RETURN_NONE; } @@ -435,6 +482,87 @@ PyObject *py_ue_get_metadata(ue_PyUObject * self, PyObject * args) return PyErr_Format(PyExc_TypeError, "the object does not support MetaData"); } +PyObject *py_ue_get_metadata_tag(ue_PyUObject * self, PyObject * args) +{ + + ue_py_check(self); + + char *metadata_tag_key; + if (!PyArg_ParseTuple(args, "s:get_metadata_tag", &metadata_tag_key)) + { + return nullptr; + } + + const FString& Value = self->ue_object->GetOutermost()->GetMetaData()->GetValue(self->ue_object, UTF8_TO_TCHAR(metadata_tag_key)); + return PyUnicode_FromString(TCHAR_TO_UTF8(*Value)); +} + +PyObject *py_ue_has_metadata_tag(ue_PyUObject * self, PyObject * args) +{ + + ue_py_check(self); + + char *metadata_tag_key; + if (!PyArg_ParseTuple(args, "s:has_metadata_tag", &metadata_tag_key)) + { + return nullptr; + } + + if (self->ue_object->GetOutermost()->GetMetaData()->HasValue(self->ue_object, UTF8_TO_TCHAR(metadata_tag_key))) + { + Py_RETURN_TRUE; + } + Py_RETURN_FALSE; +} + +PyObject *py_ue_remove_metadata_tag(ue_PyUObject * self, PyObject * args) +{ + + ue_py_check(self); + + char *metadata_tag_key; + if (!PyArg_ParseTuple(args, "s:remove_metadata_tag", &metadata_tag_key)) + { + return nullptr; + } + + self->ue_object->GetOutermost()->GetMetaData()->RemoveValue(self->ue_object, UTF8_TO_TCHAR(metadata_tag_key)); + Py_RETURN_NONE; +} + +PyObject *py_ue_set_metadata_tag(ue_PyUObject * self, PyObject * args) +{ + + ue_py_check(self); + + char *metadata_tag_key; + char *metadata_tag_value; + if (!PyArg_ParseTuple(args, "ss:set_metadata_tag", &metadata_tag_key, &metadata_tag_value)) + { + return nullptr; + } + + self->ue_object->GetOutermost()->GetMetaData()->SetValue(self->ue_object, UTF8_TO_TCHAR(metadata_tag_key), UTF8_TO_TCHAR(metadata_tag_value)); + Py_RETURN_NONE; +} + + +PyObject *py_ue_metadata_tags(ue_PyUObject * self, PyObject * args) +{ + ue_py_check(self); + + TMap *TagsMap = self->ue_object->GetOutermost()->GetMetaData()->GetMapForObject(self->ue_object); + if (!TagsMap) + Py_RETURN_NONE; + + PyObject* py_list = PyList_New(0); + for (TPair< FName, FString>& Pair : *TagsMap) + { + PyList_Append(py_list, PyUnicode_FromString(TCHAR_TO_UTF8(*Pair.Key.ToString()))); + } + return py_list; +} + PyObject *py_ue_has_metadata(ue_PyUObject * self, PyObject * args) { @@ -451,11 +579,9 @@ PyObject *py_ue_has_metadata(ue_PyUObject * self, PyObject * args) UClass *u_class = (UClass *)self->ue_object; if (u_class->HasMetaData(FName(UTF8_TO_TCHAR(metadata_key)))) { - Py_INCREF(Py_True); - return Py_True; + Py_RETURN_TRUE; } - Py_INCREF(Py_False); - return Py_False; + Py_RETURN_FALSE; } if (self->ue_object->IsA()) @@ -490,7 +616,7 @@ PyObject *py_ue_call_function(ue_PyUObject * self, PyObject * args, PyObject *kw if (PyUnicodeOrString_Check(func_id)) { - function = self->ue_object->FindFunction(FName(UTF8_TO_TCHAR(PyUnicode_AsUTF8(func_id)))); + function = self->ue_object->FindFunction(FName(UTF8_TO_TCHAR(UEPyUnicode_AsUTF8(func_id)))); } if (!function) @@ -514,8 +640,7 @@ PyObject *py_ue_find_function(ue_PyUObject * self, PyObject * args) UFunction *function = self->ue_object->FindFunction(FName(UTF8_TO_TCHAR(name))); if (!function) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } Py_RETURN_UOBJECT((UObject *)function); @@ -554,8 +679,7 @@ PyObject *py_ue_set_name(ue_PyUObject *self, PyObject * args) if (self->ue_object->Rename(UTF8_TO_TCHAR(name))) { - Py_INCREF(Py_True); - return Py_True; + Py_RETURN_TRUE; } Py_RETURN_FALSE; @@ -646,7 +770,9 @@ PyObject *py_ue_save_config(ue_PyUObject *self, PyObject * args) ue_py_check(self); + Py_BEGIN_ALLOW_THREADS; self->ue_object->SaveConfig(); + Py_END_ALLOW_THREADS; Py_RETURN_NONE; } @@ -658,9 +784,10 @@ PyObject *py_ue_set_property(ue_PyUObject *self, PyObject * args) char *property_name; PyObject *property_value; - if (!PyArg_ParseTuple(args, "sO:set_property", &property_name, &property_value)) + int index = 0; + if (!PyArg_ParseTuple(args, "sO|i:set_property", &property_name, &property_value, &index)) { - return NULL; + return nullptr; } UStruct *u_struct = nullptr; @@ -679,7 +806,7 @@ PyObject *py_ue_set_property(ue_PyUObject *self, PyObject * args) return PyErr_Format(PyExc_Exception, "unable to find property %s", property_name); - if (!ue_py_convert_pyobject(property_value, u_property, (uint8 *)self->ue_object)) + if (!ue_py_convert_pyobject(property_value, u_property, (uint8 *)self->ue_object, index)) { return PyErr_Format(PyExc_Exception, "unable to set property %s", property_name); } @@ -715,8 +842,11 @@ PyObject *py_ue_set_property_flags(ue_PyUObject *self, PyObject * args) if (!u_property) return PyErr_Format(PyExc_Exception, "unable to find property %s", property_name); - +#if ENGINE_MINOR_VERSION < 20 u_property->SetPropertyFlags(flags); +#else + u_property->SetPropertyFlags((EPropertyFlags)flags); +#endif Py_RETURN_NONE; } @@ -748,7 +878,11 @@ PyObject *py_ue_add_property_flags(ue_PyUObject *self, PyObject * args) return PyErr_Format(PyExc_Exception, "unable to find property %s", property_name); +#if ENGINE_MINOR_VERSION < 20 u_property->SetPropertyFlags(u_property->GetPropertyFlags() | flags); +#else + u_property->SetPropertyFlags(u_property->GetPropertyFlags() | (EPropertyFlags)flags); +#endif Py_RETURN_NONE; } @@ -909,11 +1043,15 @@ PyObject *py_ue_call(ue_PyUObject *self, PyObject * args) char *call_args; if (!PyArg_ParseTuple(args, "s:call", &call_args)) { - return NULL; + return nullptr; } FOutputDeviceNull od_null; - if (!self->ue_object->CallFunctionByNameWithArguments(UTF8_TO_TCHAR(call_args), od_null, NULL, true)) + bool success = false; + Py_BEGIN_ALLOW_THREADS; + success = self->ue_object->CallFunctionByNameWithArguments(UTF8_TO_TCHAR(call_args), od_null, NULL, true); + Py_END_ALLOW_THREADS; + if (!success) { return PyErr_Format(PyExc_Exception, "error while calling \"%s\"", call_args); } @@ -926,22 +1064,84 @@ PyObject *py_ue_broadcast(ue_PyUObject *self, PyObject *args) ue_py_check(self); - char *property_name; - if (!PyArg_ParseTuple(args, "s:broadcast", &property_name)) + Py_ssize_t args_len = PyTuple_Size(args); + if (args_len < 1) { - return NULL; + return PyErr_Format(PyExc_Exception, "you need to specify the event to trigger"); + } + + PyObject *py_property_name = PyTuple_GetItem(args, 0); + if (!PyUnicodeOrString_Check(py_property_name)) + { + return PyErr_Format(PyExc_Exception, "event name must be a unicode string"); } + const char *property_name = UEPyUnicode_AsUTF8(py_property_name); + UProperty *u_property = self->ue_object->GetClass()->FindPropertyByName(FName(UTF8_TO_TCHAR(property_name))); if (!u_property) return PyErr_Format(PyExc_Exception, "unable to find event property %s", property_name); if (auto casted_prop = Cast(u_property)) { +#if ENGINE_MINOR_VERSION >= 23 + FMulticastScriptDelegate multiscript_delegate = *casted_prop->GetMulticastDelegate(self->ue_object); +#else FMulticastScriptDelegate multiscript_delegate = casted_prop->GetPropertyValue_InContainer(self->ue_object); +#endif uint8 *parms = (uint8 *)FMemory_Alloca(casted_prop->SignatureFunction->PropertiesSize); FMemory::Memzero(parms, casted_prop->SignatureFunction->PropertiesSize); + + uint32 argn = 1; + + // initialize args + for (TFieldIterator IArgs(casted_prop->SignatureFunction); IArgs && IArgs->HasAnyPropertyFlags(CPF_Parm); ++IArgs) + { + UProperty *prop = *IArgs; + if (!prop->HasAnyPropertyFlags(CPF_ZeroConstructor)) + { + prop->InitializeValue_InContainer(parms); + } + + if ((IArgs->PropertyFlags & (CPF_Parm | CPF_ReturnParm)) == CPF_Parm) + { + if (!prop->IsInContainer(casted_prop->SignatureFunction->ParmsSize)) + { + return PyErr_Format(PyExc_Exception, "Attempting to import func param property that's out of bounds. %s", TCHAR_TO_UTF8(*casted_prop->SignatureFunction->GetName())); + } + + PyObject *py_arg = PyTuple_GetItem(args, argn); + if (!py_arg) + { + PyErr_Clear(); +#if WITH_EDITOR + FString default_key = FString("CPP_Default_") + prop->GetName(); + FString default_key_value = casted_prop->SignatureFunction->GetMetaData(FName(*default_key)); + if (!default_key_value.IsEmpty()) + { +#if ENGINE_MINOR_VERSION >= 17 + prop->ImportText(*default_key_value, prop->ContainerPtrToValuePtr(parms), PPF_None, NULL); +#else + prop->ImportText(*default_key_value, prop->ContainerPtrToValuePtr(parms), PPF_Localized, NULL); +#endif + } +#endif + } + else if (!ue_py_convert_pyobject(py_arg, prop, parms, 0)) + { + return PyErr_Format(PyExc_TypeError, "unable to convert pyobject to property %s (%s)", TCHAR_TO_UTF8(*prop->GetName()), TCHAR_TO_UTF8(*prop->GetClass()->GetName())); + } + + + } + + argn++; + + } + + Py_BEGIN_ALLOW_THREADS; multiscript_delegate.ProcessMulticastDelegate(parms); + Py_END_ALLOW_THREADS; } else { @@ -957,7 +1157,37 @@ PyObject *py_ue_get_property(ue_PyUObject *self, PyObject * args) ue_py_check(self); char *property_name; - if (!PyArg_ParseTuple(args, "s:get_property", &property_name)) + int index = 0; + if (!PyArg_ParseTuple(args, "s|i:get_property", &property_name, &index)) + { + return nullptr; + } + + UStruct *u_struct = nullptr; + + if (self->ue_object->IsA()) + { + u_struct = (UStruct *)self->ue_object; + } + else + { + u_struct = (UStruct *)self->ue_object->GetClass(); + } + + UProperty *u_property = u_struct->FindPropertyByName(FName(UTF8_TO_TCHAR(property_name))); + if (!u_property) + return PyErr_Format(PyExc_Exception, "unable to find property %s", property_name); + + return ue_py_convert_property(u_property, (uint8 *)self->ue_object, index); +} + +PyObject *py_ue_get_property_array_dim(ue_PyUObject *self, PyObject * args) +{ + + ue_py_check(self); + + char *property_name; + if (!PyArg_ParseTuple(args, "s:get_property_array_dim", &property_name)) { return NULL; } @@ -977,7 +1207,7 @@ PyObject *py_ue_get_property(ue_PyUObject *self, PyObject * args) if (!u_property) return PyErr_Format(PyExc_Exception, "unable to find property %s", property_name); - return ue_py_convert_property(u_property, (uint8 *)self->ue_object); + return PyLong_FromLongLong(u_property->ArrayDim); } #if WITH_EDITOR @@ -1070,6 +1300,54 @@ PyObject *py_ue_get_uproperty(ue_PyUObject *self, PyObject * args) } +PyObject *py_ue_get_inner(ue_PyUObject *self, PyObject * args) +{ + + ue_py_check(self); + + UArrayProperty *u_property = ue_py_check_type(self); + if (!u_property) + return PyErr_Format(PyExc_Exception, "object is not a UArrayProperty"); + + UProperty* inner = u_property->Inner; + if (!inner) + Py_RETURN_NONE; + + Py_RETURN_UOBJECT(inner); +} + +PyObject *py_ue_get_key_prop(ue_PyUObject *self, PyObject * args) +{ + + ue_py_check(self); + + UMapProperty *u_property = ue_py_check_type(self); + if (!u_property) + return PyErr_Format(PyExc_Exception, "object is not a UMapProperty"); + + UProperty* key = u_property->KeyProp; + if (!key) + Py_RETURN_NONE; + + Py_RETURN_UOBJECT(key); +} + +PyObject *py_ue_get_value_prop(ue_PyUObject *self, PyObject * args) +{ + + ue_py_check(self); + + UMapProperty *u_property = ue_py_check_type(self); + if (!u_property) + return PyErr_Format(PyExc_Exception, "object is not a UMapProperty"); + + UProperty* value = u_property->ValueProp; + if (!value) + Py_RETURN_NONE; + + Py_RETURN_UOBJECT(value); +} + PyObject *py_ue_has_property(ue_PyUObject *self, PyObject * args) { @@ -1135,12 +1413,10 @@ PyObject *py_ue_is_rooted(ue_PyUObject *self, PyObject * args) if (self->ue_object->IsRooted()) { - Py_INCREF(Py_True); - return Py_True; + Py_RETURN_TRUE; } - Py_INCREF(Py_False); - return Py_False; + Py_RETURN_FALSE; } @@ -1151,8 +1427,56 @@ PyObject *py_ue_add_to_root(ue_PyUObject *self, PyObject * args) self->ue_object->AddToRoot(); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; +} + +PyObject *py_ue_own(ue_PyUObject *self, PyObject * args) +{ + + ue_py_check(self); + + if (self->owned) + { + return PyErr_Format(PyExc_Exception, "uobject already owned"); + } + + Py_DECREF(self); + + self->owned = 1; + FUnrealEnginePythonHouseKeeper::Get()->TrackUObject(self->ue_object); + + Py_RETURN_NONE; +} + +PyObject *py_ue_disown(ue_PyUObject *self, PyObject * args) +{ + + ue_py_check(self); + + if (!self->owned) + { + return PyErr_Format(PyExc_Exception, "uobject not owned"); + } + + Py_INCREF(self); + + self->owned = 0; + FUnrealEnginePythonHouseKeeper::Get()->UntrackUObject(self->ue_object); + + Py_RETURN_NONE; +} + +PyObject *py_ue_is_owned(ue_PyUObject *self, PyObject * args) +{ + + ue_py_check(self); + + if (!self->owned) + { + Py_RETURN_FALSE; + } + + Py_RETURN_TRUE; } PyObject *py_ue_auto_root(ue_PyUObject *self, PyObject * args) @@ -1197,6 +1521,57 @@ PyObject *py_ue_bind_event(ue_PyUObject * self, PyObject * args) return ue_bind_pyevent(self, FString(event_name), py_callable, true); } +PyObject *py_ue_unbind_event(ue_PyUObject * self, PyObject * args) +{ + ue_py_check(self); + + char *event_name; + PyObject *py_callable; + if (!PyArg_ParseTuple(args, "sO:bind_event", &event_name, &py_callable)) + { + return NULL; + } + + if (!PyCallable_Check(py_callable)) + { + return PyErr_Format(PyExc_Exception, "object is not callable"); + } + + return ue_unbind_pyevent(self, FString(event_name), py_callable, true); +} + +PyObject *py_ue_delegate_bind_ufunction(ue_PyUObject * self, PyObject * args) +{ + ue_py_check(self); + + char *delegate_name; + PyObject *py_obj; + char *fname; + + if (!PyArg_ParseTuple(args, "sOs:delegate_bind_ufunction", &delegate_name, &py_obj, &fname)) + return nullptr; + + UProperty *u_property = self->ue_object->GetClass()->FindPropertyByName(FName(delegate_name)); + if (!u_property) + return PyErr_Format(PyExc_Exception, "unable to find property %s", delegate_name); + + UDelegateProperty *Prop = Cast(u_property); + if (!Prop) + return PyErr_Format(PyExc_Exception, "property is not a UDelegateProperty"); + + UObject *Object = ue_py_check_type(py_obj); + if (!Object) + return PyErr_Format(PyExc_Exception, "argument is not a UObject"); + + FScriptDelegate script_delegate; + script_delegate.BindUFunction(Object, FName(fname)); + + // re-assign multicast delegate + Prop->SetPropertyValue_InContainer(self->ue_object, script_delegate); + + Py_RETURN_NONE; +} + #if PY_MAJOR_VERSION >= 3 PyObject *py_ue_add_function(ue_PyUObject * self, PyObject * args) { @@ -1424,7 +1799,11 @@ PyObject *py_ue_add_property(ue_PyUObject * self, PyObject * args) { UArrayProperty *u_array = (UArrayProperty *)scope; u_array->AddCppProperty(u_property); +#if ENGINE_MINOR_VERSION < 20 u_property->SetPropertyFlags(flags); +#else + u_property->SetPropertyFlags((EPropertyFlags)flags); +#endif if (u_property->GetClass() == UObjectProperty::StaticClass()) { UObjectProperty *obj_prop = (UObjectProperty *)u_property; @@ -1456,9 +1835,13 @@ PyObject *py_ue_add_property(ue_PyUObject * self, PyObject * args) } UMapProperty *u_map = (UMapProperty *)scope; - +#if ENGINE_MINOR_VERSION < 20 u_property->SetPropertyFlags(flags); u_property2->SetPropertyFlags(flags); +#else + u_property->SetPropertyFlags((EPropertyFlags)flags); + u_property2->SetPropertyFlags((EPropertyFlags)flags); +#endif if (u_property->GetClass() == UObjectProperty::StaticClass()) { @@ -1545,7 +1928,11 @@ PyObject *py_ue_add_property(ue_PyUObject * self, PyObject * args) } } +#if ENGINE_MINOR_VERSION < 20 u_property->SetPropertyFlags(flags); +#else + u_property->SetPropertyFlags((EPropertyFlags)flags); +#endif u_property->ArrayDim = 1; UStruct *u_struct = (UStruct *)self->ue_object; @@ -1565,7 +1952,7 @@ PyObject *py_ue_add_property(ue_PyUObject * self, PyObject * args) // TODO add default value Py_RETURN_UOBJECT(u_property); -} + } PyObject *py_ue_as_dict(ue_PyUObject * self, PyObject * args) { @@ -1593,7 +1980,7 @@ PyObject *py_ue_as_dict(ue_PyUObject * self, PyObject * args) TFieldIterator SArgs(u_struct); for (; SArgs; ++SArgs) { - PyObject *struct_value = ue_py_convert_property(*SArgs, (uint8 *)u_object); + PyObject *struct_value = ue_py_convert_property(*SArgs, (uint8 *)u_object, 0); if (!struct_value) { Py_DECREF(py_struct_dict); @@ -1609,16 +1996,47 @@ PyObject *py_ue_get_cdo(ue_PyUObject * self, PyObject * args) ue_py_check(self); - if (!self->ue_object->IsA()) + UClass *u_class = ue_py_check_type(self); + if (!u_class) { return PyErr_Format(PyExc_Exception, "uobject is not a UClass"); } - UClass *u_class = (UClass *)self->ue_object; - Py_RETURN_UOBJECT(u_class->GetDefaultObject()); } +PyObject *py_ue_get_archetype(ue_PyUObject * self, PyObject * args) +{ + + ue_py_check(self); + + UObject *Archetype = self->ue_object->GetArchetype(); + + if (!Archetype) + return PyErr_Format(PyExc_Exception, "uobject has no archetype"); + + Py_RETURN_UOBJECT(Archetype); +} + +PyObject *py_ue_get_archetype_instances(ue_PyUObject * self, PyObject * args) +{ + + ue_py_check(self); + + TArray Instances; + + self->ue_object->GetArchetypeInstances(Instances); + + PyObject *py_list = PyList_New(0); + + for (UObject *Instance : Instances) + { + PyList_Append(py_list, (PyObject *)ue_get_python_uobject(Instance)); + } + + return py_list; +} + #if WITH_EDITOR PyObject *py_ue_save_package(ue_PyUObject * self, PyObject * args) @@ -1658,6 +2076,8 @@ PyObject *py_ue_save_package(ue_PyUObject * self, PyObject * args) has_package = true; } + bool bIsMap = u_object->IsA(); + if (!package || name) { if (!name) @@ -1670,18 +2090,14 @@ PyObject *py_ue_save_package(ue_PyUObject * self, PyObject * args) if (u_object->HasAnyFlags(RF_Transient)) { u_object->ClearFlags(RF_Transient); - u_object->SetFlags(RF_Public | RF_Standalone); } } - package = (UPackage *)StaticFindObject(nullptr, ANY_PACKAGE, UTF8_TO_TCHAR(name), true); // create a new package if it does not exist - if (!package) - { - package = CreatePackage(nullptr, UTF8_TO_TCHAR(name)); - } + package = CreatePackage(nullptr, UTF8_TO_TCHAR(name)); if (!package) return PyErr_Format(PyExc_Exception, "unable to create package"); - package->FileName = *FPackageName::LongPackageNameToFilename(UTF8_TO_TCHAR(name), FPackageName::GetAssetPackageExtension()); + + package->FileName = *FPackageName::LongPackageNameToFilename(UTF8_TO_TCHAR(name), bIsMap ? FPackageName::GetMapPackageExtension() : FPackageName::GetAssetPackageExtension()); if (has_package) { FString split_path; @@ -1705,22 +2121,25 @@ PyObject *py_ue_save_package(ue_PyUObject * self, PyObject * args) } } + // ensure the right flags are applied + u_object->SetFlags(RF_Public | RF_Standalone); + package->FullyLoad(); package->MarkPackageDirty(); if (package->FileName.IsNone()) { - package->FileName = *FPackageName::LongPackageNameToFilename(*package->GetPathName(), FPackageName::GetAssetPackageExtension()); + package->FileName = *FPackageName::LongPackageNameToFilename(*package->GetPathName(), bIsMap ? FPackageName::GetMapPackageExtension() : FPackageName::GetAssetPackageExtension()); UE_LOG(LogPython, Warning, TEXT("no file mapped to UPackage %s, setting its FileName to %s"), *package->GetPathName(), *package->FileName.ToString()); } // NOTE: FileName may not be a fully qualified filepath if (FPackageName::IsValidLongPackageName(package->FileName.ToString())) { - package->FileName = *FPackageName::LongPackageNameToFilename(package->GetPathName(), FPackageName::GetAssetPackageExtension()); + package->FileName = *FPackageName::LongPackageNameToFilename(package->GetPathName(), bIsMap ? FPackageName::GetMapPackageExtension() : FPackageName::GetAssetPackageExtension()); } - if (UPackage::SavePackage(package, u_object, RF_Public | RF_Standalone, *package->FileName.ToString())) + if (UPackage::SavePackage(package, u_object, RF_Standalone, *package->FileName.ToString())) { FAssetRegistryModule::AssetCreated(u_object); Py_RETURN_UOBJECT(u_object); @@ -1741,7 +2160,10 @@ PyObject *py_ue_import_custom_properties(ue_PyUObject * self, PyObject * args) } FFeedbackContextAnsi context; + + Py_BEGIN_ALLOW_THREADS; self->ue_object->ImportCustomProperties(UTF8_TO_TCHAR(t3d), &context); + Py_END_ALLOW_THREADS; TArray errors; context.GetErrors(errors); @@ -1794,12 +2216,10 @@ PyObject *py_ue_asset_reimport(ue_PyUObject * self, PyObject * args) if (FReimportManager::Instance()->Reimport(self->ue_object, ask_for_new_file, show_notification, f_filename)) { - Py_INCREF(Py_True); - return Py_True; + Py_RETURN_TRUE; } - Py_INCREF(Py_False); - return Py_False; + Py_RETURN_FALSE; } PyObject *py_ue_duplicate(ue_PyUObject * self, PyObject * args) @@ -1821,11 +2241,15 @@ PyObject *py_ue_duplicate(ue_PyUObject * self, PyObject * args) TSet refused; + UObject *new_asset = nullptr; + + Py_BEGIN_ALLOW_THREADS; #if ENGINE_MINOR_VERSION < 14 - UObject *new_asset = ObjectTools::DuplicateSingleObject(self->ue_object, pgn, refused); + new_asset = ObjectTools::DuplicateSingleObject(self->ue_object, pgn, refused); #else - UObject *new_asset = ObjectTools::DuplicateSingleObject(self->ue_object, pgn, refused, (py_overwrite && PyObject_IsTrue(py_overwrite))); + new_asset = ObjectTools::DuplicateSingleObject(self->ue_object, pgn, refused, (py_overwrite && PyObject_IsTrue(py_overwrite))); #endif + Py_END_ALLOW_THREADS; if (!new_asset) return PyErr_Format(PyExc_Exception, "unable to duplicate object"); diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyObject.h b/Source/UnrealEnginePython/Private/UObject/UEPyObject.h index a941f2ce9..6fb4678fe 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyObject.h +++ b/Source/UnrealEnginePython/Private/UObject/UEPyObject.h @@ -2,7 +2,7 @@ -#include "UnrealEnginePython.h" +#include "UEPyModule.h" PyObject *py_ue_get_class(ue_PyUObject *, PyObject *); PyObject *py_ue_is_a(ue_PyUObject *, PyObject *); @@ -23,17 +23,26 @@ PyObject *py_ue_get_property_struct(ue_PyUObject *, PyObject *); PyObject *py_ue_properties(ue_PyUObject *, PyObject *); PyObject *py_ue_call(ue_PyUObject *, PyObject *); PyObject *py_ue_get_property(ue_PyUObject *, PyObject *); +PyObject *py_ue_get_property_array_dim(ue_PyUObject *, PyObject *); PyObject *py_ue_get_uproperty(ue_PyUObject *, PyObject *); +PyObject *py_ue_get_inner(ue_PyUObject *, PyObject *); +PyObject *py_ue_get_key_prop(ue_PyUObject *, PyObject *); +PyObject *py_ue_get_value_prop(ue_PyUObject *, PyObject *); PyObject *py_ue_get_property_class(ue_PyUObject *, PyObject *); PyObject *py_ue_has_property(ue_PyUObject *, PyObject *); PyObject *py_ue_is_rooted(ue_PyUObject *, PyObject *); PyObject *py_ue_add_to_root(ue_PyUObject *, PyObject *); PyObject *py_ue_remove_from_root(ue_PyUObject *, PyObject *); PyObject *py_ue_auto_root(ue_PyUObject *, PyObject *); +PyObject *py_ue_own(ue_PyUObject *, PyObject *); +PyObject *py_ue_disown(ue_PyUObject *, PyObject *); +PyObject *py_ue_is_owned(ue_PyUObject *, PyObject *); PyObject *py_ue_save_config(ue_PyUObject *, PyObject *); PyObject *py_ue_get_cdo(ue_PyUObject *, PyObject *); +PyObject *py_ue_get_archetype(ue_PyUObject *, PyObject *); +PyObject *py_ue_get_archetype_instances(ue_PyUObject *, PyObject *); PyObject *py_ue_enum_values(ue_PyUObject *, PyObject *); PyObject *py_ue_enum_names(ue_PyUObject *, PyObject *); #if ENGINE_MINOR_VERSION >= 15 @@ -42,6 +51,7 @@ PyObject *py_ue_enum_user_defined_names(ue_PyUObject *, PyObject *); PyObject *py_ue_bind_event(ue_PyUObject *, PyObject *); +PyObject *py_ue_unbind_event(ue_PyUObject *, PyObject *); PyObject *py_ue_add_function(ue_PyUObject *, PyObject *); PyObject *py_ue_add_property(ue_PyUObject *, PyObject *); @@ -71,6 +81,9 @@ PyObject *py_ue_class_get_flags(ue_PyUObject *, PyObject *); PyObject *py_ue_class_set_flags(ue_PyUObject *, PyObject *); PyObject *py_ue_get_obj_flags(ue_PyUObject *, PyObject *); PyObject *py_ue_set_obj_flags(ue_PyUObject *, PyObject *); +PyObject *py_ue_clear_obj_flags(ue_PyUObject *, PyObject *); +PyObject *py_ue_reset_obj_flags(ue_PyUObject *, PyObject *); +PyObject *py_ue_delegate_bind_ufunction(ue_PyUObject *, PyObject *); #if WITH_EDITOR @@ -85,6 +98,12 @@ PyObject *py_ue_get_metadata(ue_PyUObject *, PyObject *); PyObject *py_ue_set_metadata(ue_PyUObject *, PyObject *); PyObject *py_ue_has_metadata(ue_PyUObject *, PyObject *); +PyObject *py_ue_get_metadata_tag(ue_PyUObject *, PyObject *); +PyObject *py_ue_set_metadata_tag(ue_PyUObject *, PyObject *); +PyObject *py_ue_has_metadata_tag(ue_PyUObject *, PyObject *); +PyObject *py_ue_remove_metadata_tag(ue_PyUObject *, PyObject *); +PyObject *py_ue_metadata_tags(ue_PyUObject *, PyObject *); + PyObject *py_ue_import_custom_properties(ue_PyUObject *, PyObject *); #endif @@ -93,4 +112,4 @@ PyObject *py_ue_render_thumbnail(ue_PyUObject *, PyObject *); PyObject *py_ue_to_bytes(ue_PyUObject *, PyObject *); PyObject *py_ue_to_bytearray(ue_PyUObject *, PyObject *); -PyObject *py_ue_from_bytes(ue_PyUObject *, PyObject *); \ No newline at end of file +PyObject *py_ue_from_bytes(ue_PyUObject *, PyObject *); diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyPackage.cpp b/Source/UnrealEnginePython/Private/UObject/UEPyPackage.cpp index 26c0ed481..3c042f9db 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyPackage.cpp +++ b/Source/UnrealEnginePython/Private/UObject/UEPyPackage.cpp @@ -1,30 +1,36 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPyPackage.h" -PyObject *py_ue_package_is_dirty(ue_PyUObject *self, PyObject * args) { - +PyObject *py_ue_package_is_dirty(ue_PyUObject *self, PyObject * args) +{ ue_py_check(self); - if (!self->ue_object->IsA()) { + + UPackage *package = ue_py_check_type(self); + if (!package) return PyErr_Format(PyExc_Exception, "uobject is not an UPackage"); - } - UPackage *package = (UPackage *)self->ue_object; + if (package->IsDirty()) Py_RETURN_TRUE; Py_RETURN_FALSE; } -PyObject *py_ue_package_get_filename(ue_PyUObject *self, PyObject * args) { +PyObject *py_ue_package_get_filename(ue_PyUObject *self, PyObject * args) +{ ue_py_check(self); - if (!self->ue_object->IsA()) { + UPackage *package = ue_py_check_type(self); + if (!package) return PyErr_Format(PyExc_Exception, "uobject is not an UPackage"); - } - - UPackage *package = (UPackage *)self->ue_object; - return PyUnicode_FromString(TCHAR_TO_UTF8(*package->FileName.ToString())); + + FString Filename; + if (!FPackageName::DoesPackageExist(package->GetPathName(), nullptr, &Filename)) + return PyErr_Format(PyExc_Exception, "package does not exist"); + + return PyUnicode_FromString(TCHAR_TO_UTF8(*Filename)); } -PyObject *py_ue_package_make_unique_object_name(ue_PyUObject *self, PyObject * args) { +PyObject *py_ue_package_make_unique_object_name(ue_PyUObject *self, PyObject * args) +{ ue_py_check(self); diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyPackage.h b/Source/UnrealEnginePython/Private/UObject/UEPyPackage.h index e3f086f2d..d64b0d6b3 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyPackage.h +++ b/Source/UnrealEnginePython/Private/UObject/UEPyPackage.h @@ -2,7 +2,7 @@ -#include "UnrealEnginePython.h" +#include "UEPyModule.h" PyObject *py_ue_package_is_dirty(ue_PyUObject *, PyObject *); PyObject *py_ue_package_get_filename(ue_PyUObject *, PyObject *); diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyPawn.cpp b/Source/UnrealEnginePython/Private/UObject/UEPyPawn.cpp index 9a2f8124f..26565827c 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyPawn.cpp +++ b/Source/UnrealEnginePython/Private/UObject/UEPyPawn.cpp @@ -1,5 +1,7 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPyPawn.h" +#include "GameFramework/Pawn.h" +#include "GameFramework/Controller.h" PyObject *py_ue_pawn_get_controller(ue_PyUObject * self, PyObject * args) { diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyPawn.h b/Source/UnrealEnginePython/Private/UObject/UEPyPawn.h index dea9f55c1..c885caf57 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyPawn.h +++ b/Source/UnrealEnginePython/Private/UObject/UEPyPawn.h @@ -2,6 +2,6 @@ -#include "UnrealEnginePython.h" +#include "UEPyModule.h" PyObject *py_ue_pawn_get_controller(ue_PyUObject *, PyObject *); diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyPhysics.cpp b/Source/UnrealEnginePython/Private/UObject/UEPyPhysics.cpp index 95d278def..bd8036577 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyPhysics.cpp +++ b/Source/UnrealEnginePython/Private/UObject/UEPyPhysics.cpp @@ -1,9 +1,13 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPyPhysics.h" #if ENGINE_MINOR_VERSION >= 18 #include "Runtime/Engine/Public/DestructibleInterface.h" +#else +#include "Components/DestructibleComponent.h" #endif +#include "Components/PrimitiveComponent.h" + PyObject *py_ue_set_simulate_physics(ue_PyUObject * self, PyObject * args) { @@ -137,10 +141,13 @@ PyObject *py_ue_add_angular_impulse(ue_PyUObject * self, PyObject * args) if (py_obj_b_vel_change && PyObject_IsTrue(py_obj_b_vel_change)) b_vel_change = true; +#if ENGINE_MINOR_VERSION >= 18 + primitive->AddAngularImpulseInRadians(impulse, f_bone_name, b_vel_change); +#else primitive->AddAngularImpulse(impulse, f_bone_name, b_vel_change); +#endif - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } @@ -237,10 +244,13 @@ PyObject *py_ue_add_torque(ue_PyUObject * self, PyObject * args) if (py_obj_b_accel_change && PyObject_IsTrue(py_obj_b_accel_change)) b_accel_change = true; +#if ENGINE_MINOR_VERSION >= 18 + primitive->AddTorqueInRadians(torque, f_bone_name, b_accel_change); +#else primitive->AddTorque(torque, f_bone_name, b_accel_change); +#endif - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } @@ -369,10 +379,13 @@ PyObject *py_ue_set_physics_angular_velocity(ue_PyUObject * self, PyObject * arg f_bone_name = FName(UTF8_TO_TCHAR(bone_name)); } +#if ENGINE_MINOR_VERSION >= 18 + primitive->SetPhysicsAngularVelocityInDegrees(new_ang_vel, add_to_current, f_bone_name); +#else primitive->SetPhysicsAngularVelocity(new_ang_vel, add_to_current, f_bone_name); +#endif - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyObject *py_ue_get_physics_angular_velocity(ue_PyUObject * self, PyObject * args) diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyPhysics.h b/Source/UnrealEnginePython/Private/UObject/UEPyPhysics.h index 853068e41..2932a20e3 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyPhysics.h +++ b/Source/UnrealEnginePython/Private/UObject/UEPyPhysics.h @@ -2,7 +2,7 @@ -#include "UnrealEnginePython.h" +#include "UEPyModule.h" PyObject *py_ue_set_simulate_physics(ue_PyUObject *, PyObject *); PyObject *py_ue_add_impulse(ue_PyUObject *, PyObject *); diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyPlayer.cpp b/Source/UnrealEnginePython/Private/UObject/UEPyPlayer.cpp index 745c1f426..1a7be4f29 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyPlayer.cpp +++ b/Source/UnrealEnginePython/Private/UObject/UEPyPlayer.cpp @@ -1,4 +1,11 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPyPlayer.h" +#include "Kismet/GameplayStatics.h" +#include "Engine/World.h" +#include "GameFramework/PlayerController.h" +#include "GameFramework/HUD.h" +#include "GameFramework/GameMode.h" +#include "GameFramework/PlayerState.h" +#include "GameFramework/GameModeBase.h" PyObject *py_ue_get_player_controller(ue_PyUObject *self, PyObject * args) { diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyPlayer.h b/Source/UnrealEnginePython/Private/UObject/UEPyPlayer.h index 09a342a08..62422e83a 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyPlayer.h +++ b/Source/UnrealEnginePython/Private/UObject/UEPyPlayer.h @@ -2,7 +2,7 @@ -#include "UnrealEnginePython.h" +#include "UEPyModule.h" PyObject *py_ue_create_player(ue_PyUObject *, PyObject *); PyObject *py_ue_get_num_players(ue_PyUObject *, PyObject *); diff --git a/Source/UnrealEnginePython/Private/UObject/UEPySequencer.cpp b/Source/UnrealEnginePython/Private/UObject/UEPySequencer.cpp index 7dd063f76..8858a7936 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPySequencer.cpp +++ b/Source/UnrealEnginePython/Private/UObject/UEPySequencer.cpp @@ -1,4 +1,4 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPySequencer.h" #include "Runtime/MovieScene/Public/MovieScene.h" #include "Runtime/MovieScene/Public/MovieScenePossessable.h" @@ -11,15 +11,201 @@ #include "Editor/Sequencer/Public/ISequencer.h" #include "Editor/Sequencer/Public/ISequencerModule.h" #include "Editor/UnrealEd/Public/Toolkits/AssetEditorManager.h" +#if ENGINE_MINOR_VERSION >= 20 +#include "LevelSequenceEditor/Private/LevelSequenceEditorToolkit.h" +#else #include "Private/LevelSequenceEditorToolkit.h" +#endif #include "Tracks/MovieSceneCameraCutTrack.h" +#if ENGINE_MINOR_VERSION < 20 #include "Sections/IKeyframeSection.h" +#endif #include "Sections/MovieSceneFloatSection.h" #include "Sections/MovieSceneBoolSection.h" #include "Sections/MovieScene3DTransformSection.h" #include "Sections/MovieSceneVectorSection.h" #include "Runtime/MovieScene/Public/MovieSceneFolder.h" #include "Runtime/MovieScene/Public/MovieSceneSpawnable.h" +#include "Runtime/MovieScene/Public/MovieScenePossessable.h" +#if ENGINE_MINOR_VERSION < 18 +#include "Editor/UnrealEd/Private/FbxImporter.h" +#else +#include "Editor/UnrealEd/Public/FbxImporter.h" +#endif +#include "Editor/MovieSceneTools/Public/MatineeImportTools.h" +#endif + +#include "GameFramework/Actor.h" +#include "Runtime/LevelSequence/Public/LevelSequence.h" +#include "Engine/World.h" + +#if ENGINE_MINOR_VERSION >= 20 +#include "Wrappers/UEPyFFrameNumber.h" +#endif + + +#if ENGINE_MINOR_VERSION >= 20 +static bool magic_get_frame_number(UMovieScene *MovieScene, PyObject *py_obj, FFrameNumber *dest) +{ + ue_PyFFrameNumber *py_frame_number = py_ue_is_fframe_number(py_obj); + if (py_frame_number) + { + *dest = py_frame_number->frame_number; + return true; + } + + if (PyNumber_Check(py_obj)) + { + PyObject *f_value = PyNumber_Float(py_obj); + float value = PyFloat_AsDouble(f_value); + Py_DECREF(f_value); + *dest = MovieScene->GetTickResolution().AsFrameNumber(value); + return true; + } + + return false; + +} + +#if WITH_EDITOR +#if ENGINE_MINOR_VERSION > 21 +static void ImportTransformChannel(const FRichCurve& Source, FMovieSceneFloatChannel* Dest, FFrameRate DestFrameRate, bool bNegateTangents) +{ + TMovieSceneChannelData ChannelData = Dest->GetData(); + ChannelData.Reset(); + double DecimalRate = DestFrameRate.AsDecimal(); + for (int32 KeyIndex = 0; KeyIndex < Source.Keys.Num(); ++KeyIndex) + { + float ArriveTangent = Source.Keys[KeyIndex].ArriveTangent; + if (KeyIndex > 0) + { + ArriveTangent = ArriveTangent / ((Source.Keys[KeyIndex].Value - Source.Keys[KeyIndex - 1].Value) * DecimalRate); + } + + float LeaveTangent = Source.Keys[KeyIndex].LeaveTangent; + if (KeyIndex < Source.Keys.Num() - 1) + { + LeaveTangent = LeaveTangent / ((Source.Keys[KeyIndex + 1].Value - Source.Keys[KeyIndex].Value) * DecimalRate); + } + + if (bNegateTangents) + { + ArriveTangent = -ArriveTangent; + LeaveTangent = -LeaveTangent; + } + + FFrameNumber KeyTime = (Source.Keys[KeyIndex].Value * DestFrameRate).RoundToFrame(); + if (ChannelData.FindKey(KeyTime) == INDEX_NONE) + { + FMovieSceneFloatValue NewKey(Source.Keys[KeyIndex].Value); + + NewKey.InterpMode = Source.Keys[KeyIndex].InterpMode; + NewKey.TangentMode = Source.Keys[KeyIndex].TangentMode; + NewKey.Tangent.ArriveTangent = ArriveTangent / DestFrameRate.AsDecimal(); + NewKey.Tangent.LeaveTangent = LeaveTangent / DestFrameRate.AsDecimal(); + NewKey.Tangent.TangentWeightMode = RCTWM_WeightedNone; + NewKey.Tangent.ArriveTangentWeight = 0.0f; + NewKey.Tangent.LeaveTangentWeight = 0.0f; + ChannelData.AddKey(KeyTime, NewKey); + } + } + + Dest->AutoSetTangents(); +} +#else +static void ImportTransformChannel(const FInterpCurveFloat& Source, FMovieSceneFloatChannel* Dest, FFrameRate DestFrameRate, bool bNegateTangents) +{ + TMovieSceneChannelData ChannelData = Dest->GetData(); + ChannelData.Reset(); + double DecimalRate = DestFrameRate.AsDecimal(); + for (int32 KeyIndex = 0; KeyIndex < Source.Points.Num(); ++KeyIndex) + { + float ArriveTangent = Source.Points[KeyIndex].ArriveTangent; + if (KeyIndex > 0) + { + ArriveTangent = ArriveTangent / ((Source.Points[KeyIndex].InVal - Source.Points[KeyIndex - 1].InVal) * DecimalRate); + } + + float LeaveTangent = Source.Points[KeyIndex].LeaveTangent; + if (KeyIndex < Source.Points.Num() - 1) + { + LeaveTangent = LeaveTangent / ((Source.Points[KeyIndex + 1].InVal - Source.Points[KeyIndex].InVal) * DecimalRate); + } + + if (bNegateTangents) + { + ArriveTangent = -ArriveTangent; + LeaveTangent = -LeaveTangent; + } + + FFrameNumber KeyTime = (Source.Points[KeyIndex].InVal * DestFrameRate).RoundToFrame(); +#if ENGINE_MINOR_VERSION > 20 + FMatineeImportTools::SetOrAddKey(ChannelData, KeyTime, Source.Points[KeyIndex].OutVal, ArriveTangent, LeaveTangent, Source.Points[KeyIndex].InterpMode, DestFrameRate); +#else + FMatineeImportTools::SetOrAddKey(ChannelData, KeyTime, Source.Points[KeyIndex].OutVal, ArriveTangent, LeaveTangent, Source.Points[KeyIndex].InterpMode); +#endif + } + + Dest->AutoSetTangents(); +} +#endif + +static bool ImportFBXTransform(FString NodeName, UMovieScene3DTransformSection* TransformSection, UnFbx::FFbxCurvesAPI& CurveAPI) +{ + + + // Look for transforms explicitly + FTransform DefaultTransform; + +#if ENGINE_MINOR_VERSION > 21 + FRichCurve Translation[3]; + FRichCurve EulerRotation[3]; + FRichCurve Scale[3]; +#else + FInterpCurveFloat Translation[3]; + FInterpCurveFloat EulerRotation[3]; + FInterpCurveFloat Scale[3]; +#endif + CurveAPI.GetConvertedTransformCurveData(NodeName, Translation[0], Translation[1], Translation[2], EulerRotation[0], EulerRotation[1], EulerRotation[2], Scale[0], Scale[1], Scale[2], DefaultTransform); + + + TransformSection->Modify(); + + FFrameRate FrameRate = TransformSection->GetTypedOuter()->GetTickResolution(); + + + FVector Location = DefaultTransform.GetLocation(), Rotation = DefaultTransform.GetRotation().Euler(), Scale3D = DefaultTransform.GetScale3D(); + + TArrayView Channels = TransformSection->GetChannelProxy().GetChannels(); + + Channels[0]->SetDefault(Location.X); + Channels[1]->SetDefault(Location.Y); + Channels[2]->SetDefault(Location.Z); + + Channels[3]->SetDefault(Rotation.X); + Channels[4]->SetDefault(Rotation.Y); + Channels[5]->SetDefault(Rotation.Z); + + Channels[6]->SetDefault(Scale3D.X); + Channels[7]->SetDefault(Scale3D.Y); + Channels[8]->SetDefault(Scale3D.Z); + + ImportTransformChannel(Translation[0], Channels[0], FrameRate, false); + ImportTransformChannel(Translation[1], Channels[1], FrameRate, true); + ImportTransformChannel(Translation[2], Channels[2], FrameRate, false); + + ImportTransformChannel(EulerRotation[0], Channels[3], FrameRate, false); + ImportTransformChannel(EulerRotation[1], Channels[4], FrameRate, true); + ImportTransformChannel(EulerRotation[2], Channels[5], FrameRate, true); + + ImportTransformChannel(Scale[0], Channels[6], FrameRate, false); + ImportTransformChannel(Scale[1], Channels[7], FrameRate, false); + ImportTransformChannel(Scale[2], Channels[8], FrameRate, false); + + return true; +} +#endif + #endif #if WITH_EDITOR @@ -54,14 +240,17 @@ PyObject *py_ue_sequencer_changed(ue_PyUObject *self, PyObject * args) ISequencer *sequencer = toolkit->GetSequencer().Get(); #if ENGINE_MINOR_VERSION < 13 sequencer->NotifyMovieSceneDataChanged(); +#else +#if ENGINE_MINOR_VERSION > 16 + sequencer->NotifyMovieSceneDataChanged(EMovieSceneDataChangeType::RefreshAllImmediately); #else sequencer->NotifyMovieSceneDataChanged(EMovieSceneDataChangeType::Unknown); +#endif #endif } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } #endif @@ -70,8 +259,8 @@ PyObject *py_ue_sequencer_possessable_tracks(ue_PyUObject *self, PyObject * args ue_py_check(self); - char *guid; - if (!PyArg_ParseTuple(args, "s:sequencer_possessable_tracks", &guid)) + PyObject *py_possessable; + if (!PyArg_ParseTuple(args, "O:sequencer_possessable_tracks", &py_possessable)) { return NULL; } @@ -80,7 +269,25 @@ PyObject *py_ue_sequencer_possessable_tracks(ue_PyUObject *self, PyObject * args return PyErr_Format(PyExc_Exception, "uobject is not a LevelSequence"); FGuid f_guid; - if (!FGuid::Parse(FString(guid), f_guid)) + if (PyUnicodeOrString_Check(py_possessable)) + { + const char *guid = UEPyUnicode_AsUTF8(py_possessable); + if (!FGuid::Parse(FString(guid), f_guid)) + { + return PyErr_Format(PyExc_Exception, "invalid GUID"); + } + } + else + { + FMovieScenePossessable *possessable = (FMovieScenePossessable *)do_ue_py_check_struct(py_possessable, FMovieScenePossessable::StaticStruct()); + if (possessable) + { + f_guid = possessable->GetGuid(); + } + + } + + if (!f_guid.IsValid()) { return PyErr_Format(PyExc_Exception, "invalid GUID"); } @@ -163,7 +370,7 @@ PyObject *py_ue_sequencer_find_possessable(ue_PyUObject *self, PyObject * args) return PyErr_Format(PyExc_Exception, "unable to find uobject with GUID \"%s\"", guid); Py_RETURN_UOBJECT(u_obj); - } +} PyObject *py_ue_sequencer_find_spawnable(ue_PyUObject *self, PyObject * args) { @@ -188,7 +395,7 @@ PyObject *py_ue_sequencer_find_spawnable(ue_PyUObject *self, PyObject * args) ULevelSequence *seq = (ULevelSequence *)self->ue_object; FMovieSceneSpawnable *spawnable = seq->MovieScene->FindSpawnable(f_guid); - PyObject *ret = py_ue_new_uscriptstruct(spawnable->StaticStruct(), (uint8 *)spawnable); + PyObject *ret = py_ue_new_owned_uscriptstruct(spawnable->StaticStruct(), (uint8 *)spawnable); Py_INCREF(ret); return ret; } @@ -284,7 +491,7 @@ PyObject *py_ue_sequencer_add_actor(ue_PyUObject *self, PyObject * args) } return PyUnicode_FromString(TCHAR_TO_UTF8(*new_guid.ToString())); - } +} PyObject *py_ue_sequencer_add_actor_component(ue_PyUObject *self, PyObject * args) { @@ -441,7 +648,7 @@ PyObject *py_ue_sequencer_possessables(ue_PyUObject *self, PyObject * args) for (int32 i = 0; i < scene->GetPossessableCount(); i++) { FMovieScenePossessable possessable = scene->GetPossessable(i); - PyObject *py_possessable = py_ue_new_uscriptstruct(possessable.StaticStruct(), (uint8 *)&possessable); + PyObject *py_possessable = py_ue_new_owned_uscriptstruct(possessable.StaticStruct(), (uint8 *)&possessable); PyList_Append(py_possessables, py_possessable); } @@ -644,12 +851,36 @@ PyObject *py_ue_sequencer_track_add_section(ue_PyUObject *self, PyObject * args) ue_py_check(self); - if (!self->ue_object->IsA()) + PyObject *py_section = nullptr; + if (!PyArg_ParseTuple(args, "|O:sequencer_track_add_section", &py_section)) + return nullptr; + + + UMovieSceneTrack *track = ue_py_check_type(self); + if (!track) return PyErr_Format(PyExc_Exception, "uobject is not a UMovieSceneTrack"); - UMovieSceneTrack *track = (UMovieSceneTrack *)self->ue_object; + UMovieSceneSection *new_section = nullptr; + + if (!py_section) + { + new_section = track->CreateNewSection(); + } + else + { + new_section = ue_py_check_type(py_section); + if (!new_section) + { + UClass *u_class = ue_py_check_type(py_section); + if (u_class && u_class->IsChildOf()) + { + new_section = NewObject(track, u_class, NAME_None); + } + } + } - UMovieSceneSection *new_section = track->CreateNewSection(); + if (!new_section) + return PyErr_Format(PyExc_Exception, "argument is not a UMovieSceneSection"); track->AddSection(*new_section); @@ -694,6 +925,191 @@ PyObject *py_ue_sequencer_add_master_track(ue_PyUObject *self, PyObject * args) } #if WITH_EDITOR + +PyObject *py_ue_sequencer_set_playback_range(ue_PyUObject *self, PyObject * args) +{ + + ue_py_check(self); + + ULevelSequence *seq = ue_py_check_type(self); + if (!seq) + return PyErr_Format(PyExc_Exception, "uobject is not a LevelSequence"); + UMovieScene *scene = seq->GetMovieScene(); + +#if ENGINE_MINOR_VERSION < 20 + float start_time; + float end_time; + if (!PyArg_ParseTuple(args, "ff:sequencer_set_playback_range", &start_time, &end_time)) + { + return nullptr; + } + + scene->SetPlaybackRange(start_time, end_time); +#else + PyObject *py_start; + PyObject *py_end; + if (!PyArg_ParseTuple(args, "OO:sequencer_set_playback_range", &py_start, &py_end)) + { + return nullptr; + } + + FFrameNumber FrameStart; + FFrameNumber FrameEnd; + + if (!magic_get_frame_number(scene, py_start, &FrameStart)) + return PyErr_Format(PyExc_Exception, "range must use float or FrameNumber"); + + if (!magic_get_frame_number(scene, py_end, &FrameEnd)) + return PyErr_Format(PyExc_Exception, "range must use float or FrameNumber"); + + scene->SetPlaybackRange(TRange::Inclusive(FrameStart, FrameEnd)); + +#endif + + Py_RETURN_NONE; +} + +PyObject *py_ue_sequencer_get_playback_range(ue_PyUObject *self, PyObject * args) +{ + + ue_py_check(self); + + ULevelSequence *seq = ue_py_check_type(self); + if (!seq) + return PyErr_Format(PyExc_Exception, "uobject is not a LevelSequence"); + UMovieScene *scene = seq->GetMovieScene(); + +#if ENGINE_MINOR_VERSION < 20 + TRange range = scene->GetPlaybackRange(); + return Py_BuildValue("(ff)", range.GetLowerBoundValue(), range.GetUpperBoundValue()); +#else + TRange range = scene->GetPlaybackRange(); + + return Py_BuildValue("(OO)", py_ue_new_fframe_number(range.GetLowerBoundValue()), py_ue_new_fframe_number(range.GetUpperBoundValue())); + +#endif +} + +PyObject *py_ue_sequencer_set_working_range(ue_PyUObject *self, PyObject * args) +{ + + ue_py_check(self); + + ULevelSequence *seq = ue_py_check_type(self); + if (!seq) + return PyErr_Format(PyExc_Exception, "uobject is not a LevelSequence"); + UMovieScene *scene = seq->GetMovieScene(); + + float start_time; + float end_time; + if (!PyArg_ParseTuple(args, "ff:sequencer_set_working_range", &start_time, &end_time)) + { + return nullptr; + } + + scene->SetWorkingRange(start_time, end_time); + + Py_RETURN_NONE; +} + +PyObject *py_ue_sequencer_set_view_range(ue_PyUObject *self, PyObject * args) +{ + + ue_py_check(self); + + ULevelSequence *seq = ue_py_check_type(self); + if (!seq) + return PyErr_Format(PyExc_Exception, "uobject is not a LevelSequence"); + UMovieScene *scene = seq->GetMovieScene(); + + float start_time; + float end_time; + if (!PyArg_ParseTuple(args, "ff:sequencer_set_view_range", &start_time, &end_time)) + { + return nullptr; + } + + scene->SetViewRange(start_time, end_time); + + Py_RETURN_NONE; +} + +PyObject *py_ue_sequencer_set_section_range(ue_PyUObject *self, PyObject * args) +{ + + ue_py_check(self); + + UMovieSceneSection *section = ue_py_check_type(self); + if (!section) + return PyErr_Format(PyExc_Exception, "uobject is not a MovieSceneSection"); + +#if ENGINE_MINOR_VERSION < 20 + float start_time; + float end_time; + if (!PyArg_ParseTuple(args, "ff:sequencer_set_section_range", &start_time, &end_time)) + { + return nullptr; + } + +#if ENGINE_MINOR_VERSION > 17 + section->SetRange(TRange::Inclusive(start_time, end_time)); +#else + section->SetRange(TRange(TRangeBound::Inclusive(start_time), TRangeBound::Inclusive(end_time))); +#endif + + +#else + PyObject *py_start; + PyObject *py_end; + if (!PyArg_ParseTuple(args, "OO:sequencer_set_section_range", &py_start, &py_end)) + { + return nullptr; + } + + UMovieSceneTrack *Track = section->GetTypedOuter(); + if (!Track) + return PyErr_Format(PyExc_Exception, "unable to retrieve track from section"); + UMovieScene *MovieScene = Track->GetTypedOuter(); + if (!MovieScene) + return PyErr_Format(PyExc_Exception, "unable to retrieve scene from section"); + + FFrameNumber FrameStart; + FFrameNumber FrameEnd; + + if (!magic_get_frame_number(MovieScene, py_start, &FrameStart)) + return PyErr_Format(PyExc_Exception, "range must use float or FrameNumber"); + + if (!magic_get_frame_number(MovieScene, py_end, &FrameEnd)) + return PyErr_Format(PyExc_Exception, "range must use float or FrameNumber"); + + section->SetRange(TRange::Inclusive(FrameStart, FrameEnd)); +#endif + + Py_RETURN_NONE; +} + +PyObject *py_ue_sequencer_get_selection_range(ue_PyUObject *self, PyObject * args) +{ + + ue_py_check(self); + + ULevelSequence *seq = ue_py_check_type(self); + if (!seq) + return PyErr_Format(PyExc_Exception, "uobject is not a LevelSequence"); + UMovieScene *scene = seq->GetMovieScene(); + +#if ENGINE_MINOR_VERSION < 20 + TRange range = scene->GetSelectionRange(); + return Py_BuildValue("(ff)", range.GetLowerBoundValue(), range.GetUpperBoundValue()); +#else + TRange range = scene->GetSelectionRange(); + + return Py_BuildValue("(OO)", py_ue_new_fframe_number(range.GetLowerBoundValue()), py_ue_new_fframe_number(range.GetUpperBoundValue())); + +#endif +} + + PyObject *py_ue_sequencer_section_add_key(ue_PyUObject *self, PyObject * args) { @@ -702,15 +1118,30 @@ PyObject *py_ue_sequencer_section_add_key(ue_PyUObject *self, PyObject * args) float time; PyObject *py_value; int interpolation = 0; - if (!PyArg_ParseTuple(args, "fO|i:sequencer_section_add_key", &time, &py_value, &interpolation)) + PyObject *py_unwind = nullptr; + + if (!PyArg_ParseTuple(args, "fO|iO:sequencer_section_add_key", &time, &py_value, &interpolation, &py_unwind)) { - return NULL; + return nullptr; } - if (!self->ue_object->IsA()) + UMovieSceneSection *section = ue_py_check_type(self); + if (!section) return PyErr_Format(PyExc_Exception, "uobject is not a MovieSceneSection"); - UMovieSceneSection *section = (UMovieSceneSection *)self->ue_object; +#if ENGINE_MINOR_VERSION >= 20 + UMovieSceneTrack *Track = section->GetTypedOuter(); + if (!Track) + return PyErr_Format(PyExc_Exception, "unable to retrieve track from section"); + UMovieScene *MovieScene = Track->GetTypedOuter(); + if (!MovieScene) + return PyErr_Format(PyExc_Exception, "unable to retrieve scene from section"); + + FFrameNumber FrameNumber = MovieScene->GetTickResolution().AsFrameNumber(time); + EMovieSceneKeyInterpolation InterpolationMode = (EMovieSceneKeyInterpolation)interpolation; + + section->Modify(); +#endif if (auto section_float = Cast(section)) { @@ -719,7 +1150,32 @@ PyObject *py_ue_sequencer_section_add_key(ue_PyUObject *self, PyObject * args) PyObject *f_value = PyNumber_Float(py_value); float value = PyFloat_AsDouble(f_value); Py_DECREF(f_value); +#if ENGINE_MINOR_VERSION < 20 section_float->AddKey(time, value, (EMovieSceneKeyInterpolation)interpolation); +#else + FMovieSceneFloatChannel& Channel = (FMovieSceneFloatChannel&)section_float->GetChannel(); + int32 RetValue = -1; + switch (InterpolationMode) + { + case(EMovieSceneKeyInterpolation::Auto): + RetValue = Channel.AddCubicKey(FrameNumber, value, RCTM_Auto); + break; + case(EMovieSceneKeyInterpolation::User): + RetValue = Channel.AddCubicKey(FrameNumber, value, RCTM_User); + case(EMovieSceneKeyInterpolation::Break): + RetValue = Channel.AddCubicKey(FrameNumber, value, RCTM_Break); + break; + case(EMovieSceneKeyInterpolation::Linear): + RetValue = Channel.AddLinearKey(FrameNumber, value); + break; + case(EMovieSceneKeyInterpolation::Constant): + RetValue = Channel.AddConstantKey(FrameNumber, value); + break; + default: + return PyErr_Format(PyExc_Exception, "unsupported interpolation"); + } + return PyLong_FromLong(RetValue); +#endif Py_RETURN_NONE; } } @@ -731,7 +1187,13 @@ PyObject *py_ue_sequencer_section_add_key(ue_PyUObject *self, PyObject * args) bool value = false; if (PyObject_IsTrue(py_value)) value = true; +#if ENGINE_MINOR_VERSION < 20 section_bool->AddKey(time, value, (EMovieSceneKeyInterpolation)interpolation); +#else + FMovieSceneBoolChannel& Channel = section_bool->GetChannel(); + int32 RetValue = Channel.GetData().AddKey(FrameNumber, value); + return PyLong_FromLong(RetValue); +#endif Py_RETURN_NONE; } } @@ -740,10 +1202,10 @@ PyObject *py_ue_sequencer_section_add_key(ue_PyUObject *self, PyObject * args) { if (ue_PyFTransform *py_transform = py_ue_is_ftransform(py_value)) { - bool unwind = false; + bool unwind = (py_unwind && PyObject_IsTrue(py_unwind)); FTransform transform = py_transform->transform; - +#if ENGINE_MINOR_VERSION < 20 FTransformKey tx = FTransformKey(EKey3DTransformChannel::Translation, EAxis::X, transform.GetLocation().X, unwind); FTransformKey ty = FTransformKey(EKey3DTransformChannel::Translation, EAxis::Y, transform.GetLocation().Y, unwind); FTransformKey tz = FTransformKey(EKey3DTransformChannel::Translation, EAxis::Z, transform.GetLocation().Z, unwind); @@ -751,9 +1213,10 @@ PyObject *py_ue_sequencer_section_add_key(ue_PyUObject *self, PyObject * args) section_transform->AddKey(time, ty, (EMovieSceneKeyInterpolation)interpolation); section_transform->AddKey(time, tz, (EMovieSceneKeyInterpolation)interpolation); - FTransformKey rx = FTransformKey(EKey3DTransformChannel::Rotation, EAxis::X, transform.GetRotation().X, unwind); - FTransformKey ry = FTransformKey(EKey3DTransformChannel::Rotation, EAxis::Y, transform.GetRotation().Y, unwind); - FTransformKey rz = FTransformKey(EKey3DTransformChannel::Rotation, EAxis::Z, transform.GetRotation().Z, unwind); + + FTransformKey rx = FTransformKey(EKey3DTransformChannel::Rotation, EAxis::X, transform.GetRotation().Euler().X, unwind); + FTransformKey ry = FTransformKey(EKey3DTransformChannel::Rotation, EAxis::Y, transform.GetRotation().Euler().Y, unwind); + FTransformKey rz = FTransformKey(EKey3DTransformChannel::Rotation, EAxis::Z, transform.GetRotation().Euler().Z, unwind); section_transform->AddKey(time, rx, (EMovieSceneKeyInterpolation)interpolation); section_transform->AddKey(time, ry, (EMovieSceneKeyInterpolation)interpolation); section_transform->AddKey(time, rz, (EMovieSceneKeyInterpolation)interpolation); @@ -764,8 +1227,82 @@ PyObject *py_ue_sequencer_section_add_key(ue_PyUObject *self, PyObject * args) section_transform->AddKey(time, sx, (EMovieSceneKeyInterpolation)interpolation); section_transform->AddKey(time, sy, (EMovieSceneKeyInterpolation)interpolation); section_transform->AddKey(time, sz, (EMovieSceneKeyInterpolation)interpolation); - Py_RETURN_NONE; +#else + int RetValueTX, RetValueTY, RetValueTZ = -1; + int RetValueRX, RetValueRY, RetValueRZ = -1; + int RetValueSX, RetValueSY, RetValueSZ = -1; + FMovieSceneFloatChannel *ChannelTX = section_transform->GetChannelProxy().GetChannel(0); + FMovieSceneFloatChannel *ChannelTY = section_transform->GetChannelProxy().GetChannel(1); + FMovieSceneFloatChannel *ChannelTZ = section_transform->GetChannelProxy().GetChannel(2); + FMovieSceneFloatChannel *ChannelRX = section_transform->GetChannelProxy().GetChannel(3); + FMovieSceneFloatChannel *ChannelRY = section_transform->GetChannelProxy().GetChannel(4); + FMovieSceneFloatChannel *ChannelRZ = section_transform->GetChannelProxy().GetChannel(5); + FMovieSceneFloatChannel *ChannelSX = section_transform->GetChannelProxy().GetChannel(6); + FMovieSceneFloatChannel *ChannelSY = section_transform->GetChannelProxy().GetChannel(7); + FMovieSceneFloatChannel *ChannelSZ = section_transform->GetChannelProxy().GetChannel(8); + + switch (InterpolationMode) + { + case(EMovieSceneKeyInterpolation::Auto): + RetValueTX = ChannelTX->AddCubicKey(FrameNumber, transform.GetTranslation().X, RCTM_Auto); + RetValueTY = ChannelTY->AddCubicKey(FrameNumber, transform.GetTranslation().Y, RCTM_Auto); + RetValueTZ = ChannelTZ->AddCubicKey(FrameNumber, transform.GetTranslation().Z, RCTM_Auto); + RetValueRX = ChannelRX->AddCubicKey(FrameNumber, transform.GetRotation().Euler().X, RCTM_Auto); + RetValueRY = ChannelRY->AddCubicKey(FrameNumber, transform.GetRotation().Euler().Y, RCTM_Auto); + RetValueRZ = ChannelRZ->AddCubicKey(FrameNumber, transform.GetRotation().Euler().Z, RCTM_Auto); + RetValueSX = ChannelSX->AddCubicKey(FrameNumber, transform.GetScale3D().X, RCTM_Auto); + RetValueSY = ChannelSY->AddCubicKey(FrameNumber, transform.GetScale3D().Y, RCTM_Auto); + RetValueSZ = ChannelSZ->AddCubicKey(FrameNumber, transform.GetScale3D().Z, RCTM_Auto); + break; + case(EMovieSceneKeyInterpolation::User): + RetValueTX = ChannelTX->AddCubicKey(FrameNumber, transform.GetTranslation().X, RCTM_User); + RetValueTY = ChannelTY->AddCubicKey(FrameNumber, transform.GetTranslation().Y, RCTM_User); + RetValueTZ = ChannelTZ->AddCubicKey(FrameNumber, transform.GetTranslation().Z, RCTM_User); + RetValueRX = ChannelRX->AddCubicKey(FrameNumber, transform.GetRotation().Euler().X, RCTM_User); + RetValueRY = ChannelRY->AddCubicKey(FrameNumber, transform.GetRotation().Euler().Y, RCTM_User); + RetValueRZ = ChannelRZ->AddCubicKey(FrameNumber, transform.GetRotation().Euler().Z, RCTM_User); + RetValueSX = ChannelSX->AddCubicKey(FrameNumber, transform.GetScale3D().X, RCTM_User); + RetValueSY = ChannelSY->AddCubicKey(FrameNumber, transform.GetScale3D().Y, RCTM_User); + RetValueSZ = ChannelSZ->AddCubicKey(FrameNumber, transform.GetScale3D().Z, RCTM_User); + case(EMovieSceneKeyInterpolation::Break): + RetValueTX = ChannelTX->AddCubicKey(FrameNumber, transform.GetTranslation().X, RCTM_Break); + RetValueTY = ChannelTY->AddCubicKey(FrameNumber, transform.GetTranslation().Y, RCTM_Break); + RetValueTZ = ChannelTZ->AddCubicKey(FrameNumber, transform.GetTranslation().Z, RCTM_Break); + RetValueRX = ChannelRX->AddCubicKey(FrameNumber, transform.GetRotation().Euler().X, RCTM_Break); + RetValueRY = ChannelRY->AddCubicKey(FrameNumber, transform.GetRotation().Euler().Y, RCTM_Break); + RetValueRZ = ChannelRZ->AddCubicKey(FrameNumber, transform.GetRotation().Euler().Z, RCTM_Break); + RetValueSX = ChannelSX->AddCubicKey(FrameNumber, transform.GetScale3D().X, RCTM_Break); + RetValueSY = ChannelSY->AddCubicKey(FrameNumber, transform.GetScale3D().Y, RCTM_Break); + RetValueSZ = ChannelSZ->AddCubicKey(FrameNumber, transform.GetScale3D().Z, RCTM_Break); + break; + case(EMovieSceneKeyInterpolation::Linear): + RetValueTX = ChannelTX->AddLinearKey(FrameNumber, transform.GetTranslation().X); + RetValueTY = ChannelTY->AddLinearKey(FrameNumber, transform.GetTranslation().Y); + RetValueTZ = ChannelTZ->AddLinearKey(FrameNumber, transform.GetTranslation().Z); + RetValueRX = ChannelRX->AddLinearKey(FrameNumber, transform.GetRotation().Euler().X); + RetValueRY = ChannelRY->AddLinearKey(FrameNumber, transform.GetRotation().Euler().Y); + RetValueRZ = ChannelRZ->AddLinearKey(FrameNumber, transform.GetRotation().Euler().Z); + RetValueSX = ChannelSX->AddLinearKey(FrameNumber, transform.GetScale3D().X); + RetValueSY = ChannelSY->AddLinearKey(FrameNumber, transform.GetScale3D().Y); + RetValueSZ = ChannelSZ->AddLinearKey(FrameNumber, transform.GetScale3D().Z); + break; + case(EMovieSceneKeyInterpolation::Constant): + RetValueTX = ChannelTX->AddConstantKey(FrameNumber, transform.GetTranslation().X); + RetValueTY = ChannelTY->AddConstantKey(FrameNumber, transform.GetTranslation().Y); + RetValueTZ = ChannelTZ->AddConstantKey(FrameNumber, transform.GetTranslation().Z); + RetValueRX = ChannelRX->AddConstantKey(FrameNumber, transform.GetRotation().Euler().X); + RetValueRY = ChannelRY->AddConstantKey(FrameNumber, transform.GetRotation().Euler().Y); + RetValueRZ = ChannelRZ->AddConstantKey(FrameNumber, transform.GetRotation().Euler().Z); + RetValueSX = ChannelSX->AddConstantKey(FrameNumber, transform.GetScale3D().X); + RetValueSY = ChannelSY->AddConstantKey(FrameNumber, transform.GetScale3D().Y); + RetValueSZ = ChannelSZ->AddConstantKey(FrameNumber, transform.GetScale3D().Z); + break; + default: + return PyErr_Format(PyExc_Exception, "unsupported interpolation"); + } + return Py_BuildValue("((iii)(iii)(iii))", RetValueTX, RetValueTY, RetValueTZ, RetValueRX, RetValueRY, RetValueRZ, RetValueSX, RetValueSY, RetValueSZ); +#endif } } @@ -774,16 +1311,56 @@ PyObject *py_ue_sequencer_section_add_key(ue_PyUObject *self, PyObject * args) if (ue_PyFVector *py_vector = py_ue_is_fvector(py_value)) { FVector vec = py_vector->vec; +#if ENGINE_MINOR_VERSION < 20 FVectorKey vx = FVectorKey(EKeyVectorChannel::X, vec.X); FVectorKey vy = FVectorKey(EKeyVectorChannel::Y, vec.Y); FVectorKey vz = FVectorKey(EKeyVectorChannel::Z, vec.Z); + section_vector->AddKey(time, vx, (EMovieSceneKeyInterpolation)interpolation); section_vector->AddKey(time, vy, (EMovieSceneKeyInterpolation)interpolation); section_vector->AddKey(time, vz, (EMovieSceneKeyInterpolation)interpolation); +#else + int RetValueVX, RetValueVY, RetValueVZ = -1; + + FMovieSceneFloatChannel& ChannelX = (FMovieSceneFloatChannel&)section_vector->GetChannel(0); + FMovieSceneFloatChannel& ChannelY = (FMovieSceneFloatChannel&)section_vector->GetChannel(1); + FMovieSceneFloatChannel& ChannelZ = (FMovieSceneFloatChannel&)section_vector->GetChannel(2); + + switch (InterpolationMode) + { + case(EMovieSceneKeyInterpolation::Auto): + RetValueVX = ChannelX.AddCubicKey(FrameNumber, vec.X, RCTM_Auto); + RetValueVY = ChannelY.AddCubicKey(FrameNumber, vec.Y, RCTM_Auto); + RetValueVZ = ChannelZ.AddCubicKey(FrameNumber, vec.Z, RCTM_Auto); + break; + case(EMovieSceneKeyInterpolation::User): + RetValueVX = ChannelX.AddCubicKey(FrameNumber, vec.X, RCTM_User); + RetValueVY = ChannelY.AddCubicKey(FrameNumber, vec.Y, RCTM_User); + RetValueVZ = ChannelZ.AddCubicKey(FrameNumber, vec.Z, RCTM_User); + case(EMovieSceneKeyInterpolation::Break): + RetValueVX = ChannelX.AddCubicKey(FrameNumber, vec.X, RCTM_Break); + RetValueVY = ChannelY.AddCubicKey(FrameNumber, vec.Y, RCTM_Break); + RetValueVZ = ChannelZ.AddCubicKey(FrameNumber, vec.Z, RCTM_Break); + break; + case(EMovieSceneKeyInterpolation::Linear): + RetValueVX = ChannelX.AddLinearKey(FrameNumber, vec.X); + RetValueVY = ChannelY.AddLinearKey(FrameNumber, vec.Y); + RetValueVZ = ChannelZ.AddLinearKey(FrameNumber, vec.Z); + break; + case(EMovieSceneKeyInterpolation::Constant): + RetValueVX = ChannelX.AddConstantKey(FrameNumber, vec.X); + RetValueVY = ChannelY.AddConstantKey(FrameNumber, vec.Y); + RetValueVZ = ChannelZ.AddConstantKey(FrameNumber, vec.Z); + break; + default: + return PyErr_Format(PyExc_Exception, "unsupported interpolation"); + } + return Py_BuildValue("(iii)", RetValueVX, RetValueVY, RetValueVZ); +#endif Py_RETURN_NONE; - } +} } return PyErr_Format(PyExc_Exception, "unsupported section type: %s", TCHAR_TO_UTF8(*section->GetClass()->GetName())); @@ -1015,5 +1592,203 @@ PyObject *py_ue_sequencer_get_display_name(ue_PyUObject *self, PyObject * args) return PyErr_Format(PyExc_Exception, "the uobject does not expose the GetDefaultDisplayName() method"); } + +PyObject *py_ue_sequencer_import_fbx_transform(ue_PyUObject *self, PyObject * args) +{ + ue_py_check(self); + + char *filename; + char *nodename; + PyObject *py_force_front_x_axis = nullptr; + + if (!PyArg_ParseTuple(args, "ss|o:sequencer_import_fbx_transform", &filename, &nodename, &py_force_front_x_axis)) + return nullptr; + + UMovieScene3DTransformSection *section = ue_py_check_type(self); + if (!section) + return PyErr_Format(PyExc_Exception, "uobject is not a UMovieScene3DTransformSection"); + + UnFbx::FFbxImporter* FbxImporter = UnFbx::FFbxImporter::GetInstance(); + + UnFbx::FBXImportOptions* ImportOptions = FbxImporter->GetImportOptions(); + bool bConverteScene = ImportOptions->bConvertScene; + bool bConverteSceneUnit = ImportOptions->bConvertSceneUnit; + bool bForceFrontXAxis = ImportOptions->bForceFrontXAxis; + + ImportOptions->bConvertScene = true; + ImportOptions->bConvertSceneUnit = true; + ImportOptions->bForceFrontXAxis = py_force_front_x_axis && PyObject_IsTrue(py_force_front_x_axis); + + FString FbxFilename = FString(UTF8_TO_TCHAR(filename)); + FString FbxNodeName = FString(UTF8_TO_TCHAR(nodename)); + + const FString Extension = FPaths::GetExtension(FbxFilename); + if (!FbxImporter->ImportFromFile(FbxFilename, Extension, true)) + { + FbxImporter->ReleaseScene(); + ImportOptions->bConvertScene = bConverteScene; + ImportOptions->bConvertSceneUnit = bConverteSceneUnit; + ImportOptions->bForceFrontXAxis = bForceFrontXAxis; + return PyErr_Format(PyExc_Exception, "unable to import Fbx file"); + } + + UnFbx::FFbxCurvesAPI CurveAPI; + FbxImporter->PopulateAnimatedCurveData(CurveAPI); + + TArray AllNodeNames; +#if ENGINE_MINOR_VERSION < 18 + CurveAPI.GetAnimatedNodeNameArray(AllNodeNames); +#else + CurveAPI.GetAllNodeNameArray(AllNodeNames); +#endif + + for (FString NodeName : AllNodeNames) + { + if (NodeName != FbxNodeName) + continue; + + // Look for transforms explicitly +#if ENGINE_MINOR_VERSION > 21 + FRichCurve Translation[3]; + FRichCurve EulerRotation[3]; + FRichCurve Scale[3]; +#else + FInterpCurveFloat Translation[3]; + FInterpCurveFloat EulerRotation[3]; + FInterpCurveFloat Scale[3]; +#endif + FTransform DefaultTransform; +#if ENGINE_MINOR_VERSION >= 18 + CurveAPI.GetConvertedTransformCurveData(NodeName, Translation[0], Translation[1], Translation[2], EulerRotation[0], EulerRotation[1], EulerRotation[2], Scale[0], Scale[1], Scale[2], DefaultTransform); +#if ENGINE_MINOR_VERSION < 20 + for (int32 ChannelIndex = 0; ChannelIndex < 3; ++ChannelIndex) + { + EAxis::Type ChannelAxis = EAxis::X; + if (ChannelIndex == 1) + { + ChannelAxis = EAxis::Y; + } + else if (ChannelIndex == 2) + { + ChannelAxis = EAxis::Z; + } + + section->GetTranslationCurve(ChannelAxis).SetDefaultValue(DefaultTransform.GetLocation()[ChannelIndex]); + section->GetRotationCurve(ChannelAxis).SetDefaultValue(DefaultTransform.GetRotation().Euler()[ChannelIndex]); + section->GetScaleCurve(ChannelAxis).SetDefaultValue(DefaultTransform.GetScale3D()[ChannelIndex]); + } +#endif + +#else + CurveAPI.GetConvertedTransformCurveData(NodeName, Translation[0], Translation[1], Translation[2], EulerRotation[0], EulerRotation[1], EulerRotation[2], Scale[0], Scale[1], Scale[2]); + +#endif +#if ENGINE_MINOR_VERSION < 20 + float MinTime = FLT_MAX; + float MaxTime = -FLT_MAX; + + const int NumCurves = 3; // Trans, Rot, Scale + for (int32 CurveIndex = 0; CurveIndex < NumCurves; ++CurveIndex) + { + for (int32 ChannelIndex = 0; ChannelIndex < 3; ++ChannelIndex) + { + EAxis::Type ChannelAxis = EAxis::X; + if (ChannelIndex == 1) + { + ChannelAxis = EAxis::Y; + } + else if (ChannelIndex == 2) + { + ChannelAxis = EAxis::Z; + } + + FInterpCurveFloat* CurveFloat = nullptr; + FRichCurve* ChannelCurve = nullptr; + bool bNegative = false; + + if (CurveIndex == 0) + { + CurveFloat = &Translation[ChannelIndex]; + ChannelCurve = §ion->GetTranslationCurve(ChannelAxis); + if (ChannelIndex == 1) + { + bNegative = true; + } + } + else if (CurveIndex == 1) + { + CurveFloat = &EulerRotation[ChannelIndex]; + ChannelCurve = §ion->GetRotationCurve(ChannelAxis); + if (ChannelIndex == 1 || ChannelIndex == 2) + { + bNegative = true; + } + } + else if (CurveIndex == 2) + { + CurveFloat = &Scale[ChannelIndex]; + ChannelCurve = §ion->GetScaleCurve(ChannelAxis); + } + + if (ChannelCurve != nullptr && CurveFloat != nullptr) + { + ChannelCurve->Reset(); + + for (int32 KeyIndex = 0; KeyIndex < CurveFloat->Points.Num(); ++KeyIndex) + { + MinTime = FMath::Min(MinTime, CurveFloat->Points[KeyIndex].InVal); + MaxTime = FMath::Max(MaxTime, CurveFloat->Points[KeyIndex].InVal); + + float ArriveTangent = CurveFloat->Points[KeyIndex].ArriveTangent; + if (KeyIndex > 0) + { + ArriveTangent = ArriveTangent / (CurveFloat->Points[KeyIndex].InVal - CurveFloat->Points[KeyIndex - 1].InVal); + } + + float LeaveTangent = CurveFloat->Points[KeyIndex].LeaveTangent; + if (KeyIndex < CurveFloat->Points.Num() - 1) + { + LeaveTangent = LeaveTangent / (CurveFloat->Points[KeyIndex + 1].InVal - CurveFloat->Points[KeyIndex].InVal); + } + + if (bNegative) + { + ArriveTangent = -ArriveTangent; + LeaveTangent = -LeaveTangent; + } + + FMatineeImportTools::SetOrAddKey(*ChannelCurve, CurveFloat->Points[KeyIndex].InVal, CurveFloat->Points[KeyIndex].OutVal, ArriveTangent, LeaveTangent, CurveFloat->Points[KeyIndex].InterpMode); + + } + + ChannelCurve->RemoveRedundantKeys(KINDA_SMALL_NUMBER); + ChannelCurve->AutoSetTangents(); + } + } + } + +#else + ImportFBXTransform(nodename, section, CurveAPI); +#endif + +#if ENGINE_MINOR_VERSION < 20 + section->SetStartTime(MinTime); + section->SetEndTime(MaxTime); +#endif + + FbxImporter->ReleaseScene(); + ImportOptions->bConvertScene = bConverteScene; + ImportOptions->bConvertSceneUnit = bConverteSceneUnit; + ImportOptions->bForceFrontXAxis = bForceFrontXAxis; + Py_RETURN_NONE; + } + + FbxImporter->ReleaseScene(); + ImportOptions->bConvertScene = bConverteScene; + ImportOptions->bConvertSceneUnit = bConverteSceneUnit; + ImportOptions->bForceFrontXAxis = bForceFrontXAxis; + return PyErr_Format(PyExc_Exception, "unable to find specified node in Fbx file"); + +} #endif diff --git a/Source/UnrealEnginePython/Private/UObject/UEPySequencer.h b/Source/UnrealEnginePython/Private/UObject/UEPySequencer.h index 4e10c1187..83185d612 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPySequencer.h +++ b/Source/UnrealEnginePython/Private/UObject/UEPySequencer.h @@ -2,13 +2,19 @@ -#include "UnrealEnginePython.h" +#include "UEPyModule.h" PyObject *py_ue_sequencer_master_tracks(ue_PyUObject *, PyObject *); PyObject *py_ue_sequencer_possessable_tracks(ue_PyUObject *, PyObject *); PyObject *py_ue_sequencer_track_sections(ue_PyUObject *, PyObject *); PyObject *py_ue_sequencer_get_camera_cut_track(ue_PyUObject *, PyObject *); #if WITH_EDITOR +PyObject *py_ue_sequencer_set_playback_range(ue_PyUObject *, PyObject *); +PyObject *py_ue_sequencer_set_view_range(ue_PyUObject *, PyObject *); +PyObject *py_ue_sequencer_set_working_range(ue_PyUObject *, PyObject *); +PyObject *py_ue_sequencer_set_section_range(ue_PyUObject *, PyObject *); +PyObject *py_ue_sequencer_get_playback_range(ue_PyUObject *, PyObject *); +PyObject *py_ue_sequencer_get_selection_range(ue_PyUObject *, PyObject *); PyObject *py_ue_sequencer_folders(ue_PyUObject *, PyObject *); PyObject *py_ue_sequencer_create_folder(ue_PyUObject *, PyObject *); PyObject *py_ue_sequencer_set_display_name(ue_PyUObject *, PyObject *); @@ -30,6 +36,7 @@ PyObject *py_ue_sequencer_remove_spawnable(ue_PyUObject *, PyObject *); PyObject *py_ue_sequencer_remove_camera_cut_track(ue_PyUObject *, PyObject *); PyObject *py_ue_sequencer_remove_master_track(ue_PyUObject *, PyObject *); PyObject *py_ue_sequencer_remove_track(ue_PyUObject *, PyObject *); +PyObject *py_ue_sequencer_import_fbx_transform(ue_PyUObject *, PyObject *); #endif PyObject *py_ue_sequencer_sections(ue_PyUObject *, PyObject *); PyObject *py_ue_sequencer_possessables(ue_PyUObject *, PyObject *); diff --git a/Source/UnrealEnginePython/Private/UObject/UEPySkeletal.cpp b/Source/UnrealEnginePython/Private/UObject/UEPySkeletal.cpp index 3d11753e7..3386d4537 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPySkeletal.cpp +++ b/Source/UnrealEnginePython/Private/UObject/UEPySkeletal.cpp @@ -1,13 +1,20 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPySkeletal.h" #include "Runtime/Engine/Public/ComponentReregisterContext.h" #if WITH_EDITOR #include "Developer/MeshUtilities/Public/MeshUtilities.h" +#include "Wrappers/UEPyFMorphTargetDelta.h" +#include "Wrappers/UEPyFSoftSkinVertex.h" +#if ENGINE_MINOR_VERSION > 20 +#include "Runtime/Engine/Public/Rendering/SkeletalMeshLODImporterData.h" +#endif #if ENGINE_MINOR_VERSION > 18 #include "Runtime/Engine/Public/Rendering/SkeletalMeshModel.h" #endif #endif +#include "Animation/AnimInstance.h" + PyObject *py_ue_get_anim_instance(ue_PyUObject *self, PyObject * args) { @@ -197,6 +204,8 @@ PyObject *py_ue_skeleton_add_bone(ue_PyUObject *self, PyObject * args) } #endif +#if WITH_EDITOR + #if ENGINE_MINOR_VERSION > 12 PyObject *py_ue_skeletal_mesh_set_soft_vertices(ue_PyUObject *self, PyObject * args) { @@ -276,6 +285,7 @@ PyObject *py_ue_skeletal_mesh_set_soft_vertices(ue_PyUObject *self, PyObject * a } #endif + #if ENGINE_MINOR_VERSION > 12 PyObject *py_ue_skeletal_mesh_get_soft_vertices(ue_PyUObject *self, PyObject * args) { @@ -391,6 +401,7 @@ PyObject *py_ue_skeletal_mesh_get_lod(ue_PyUObject *self, PyObject * args) return py_list; } + PyObject *py_ue_skeletal_mesh_get_raw_indices(ue_PyUObject *self, PyObject * args) { @@ -436,6 +447,7 @@ PyObject *py_ue_skeletal_mesh_get_raw_indices(ue_PyUObject *self, PyObject * arg return py_list; } +#endif PyObject *py_ue_skeletal_mesh_set_skeleton(ue_PyUObject * self, PyObject * args) { @@ -472,6 +484,7 @@ PyObject *py_ue_skeletal_mesh_set_skeleton(ue_PyUObject * self, PyObject * args) Py_RETURN_NONE; } +#if WITH_EDITOR #if ENGINE_MINOR_VERSION > 12 PyObject *py_ue_skeletal_mesh_set_bone_map(ue_PyUObject *self, PyObject * args) { @@ -808,7 +821,9 @@ PyObject *py_ue_skeletal_mesh_set_required_bones(ue_PyUObject *self, PyObject * Py_RETURN_NONE; } +#endif +#if WITH_EDITOR PyObject *py_ue_skeletal_mesh_lods_num(ue_PyUObject *self, PyObject * args) { ue_py_check(self); @@ -850,7 +865,6 @@ PyObject *py_ue_skeletal_mesh_sections_num(ue_PyUObject *self, PyObject * args) return PyLong_FromLong(resource->LODModels[lod_index].Sections.Num()); } -#if WITH_EDITOR PyObject *py_ue_skeletal_mesh_build_lod(ue_PyUObject *self, PyObject * args, PyObject * kwargs) { ue_py_check(self); @@ -891,7 +905,12 @@ PyObject *py_ue_skeletal_mesh_build_lod(ue_PyUObject *self, PyObject * args, PyO #else resource->LODModels.Add(new FSkeletalMeshLODModel()); #endif + +#if ENGINE_MINOR_VERSION < 20 mesh->LODInfo.AddZeroed(); +#else + mesh->AddLODInfo(); +#endif } else { @@ -909,10 +928,20 @@ PyObject *py_ue_skeletal_mesh_build_lod(ue_PyUObject *self, PyObject * args, PyO FSkeletalMeshLODModel& LODModel = resource->LODModels[lod_index]; #endif +#if ENGINE_MINOR_VERSION < 20 mesh->LODInfo[lod_index].LODHysteresis = 0.02; +#else + mesh->GetLODInfo(lod_index)->LODHysteresis = 0.02; +#endif FSkeletalMeshOptimizationSettings settings; + +#if ENGINE_MINOR_VERSION < 20 mesh->LODInfo[lod_index].ReductionSettings = settings; +#else + mesh->GetLODInfo(lod_index)->ReductionSettings = settings; +#endif + LODModel.NumTexCoords = 1; @@ -927,9 +956,15 @@ PyObject *py_ue_skeletal_mesh_build_lod(ue_PyUObject *self, PyObject * args, PyO TArray soft_vertices; TArray points; +#if ENGINE_MINOR_VERSION > 20 + TArray wedges; + TArray faces; + TArray influences; +#else TArray wedges; TArray faces; TArray influences; +#endif TArray points_to_map; TArray tangentsX; @@ -950,7 +985,11 @@ PyObject *py_ue_skeletal_mesh_build_lod(ue_PyUObject *self, PyObject * args, PyO points_to_map.Add(vertex_index); +#if ENGINE_MINOR_VERSION > 20 + SkeletalMeshImportData::FMeshWedge wedge; +#else FMeshWedge wedge; +#endif wedge.iVertex = vertex_index; wedge.Color = ss_vertex->ss_vertex.Color; for (int32 i = 0; i < MAX_TEXCOORDS; i++) @@ -961,7 +1000,11 @@ PyObject *py_ue_skeletal_mesh_build_lod(ue_PyUObject *self, PyObject * args, PyO for (int32 i = 0; i < MAX_TOTAL_INFLUENCES; i++) { +#if ENGINE_MINOR_VERSION > 20 + SkeletalMeshImportData::FVertInfluence influence; +#else FVertInfluence influence; +#endif influence.VertIndex = wedge_index; influence.BoneIndex = ss_vertex->ss_vertex.InfluenceBones[i]; influence.Weight = ss_vertex->ss_vertex.InfluenceWeights[i] / 255.f; @@ -983,7 +1026,11 @@ PyObject *py_ue_skeletal_mesh_build_lod(ue_PyUObject *self, PyObject * args, PyO for (int32 i = 0; i < wedges.Num(); i += 3) { +#if ENGINE_MINOR_VERSION > 20 + SkeletalMeshImportData::FMeshFace face; +#else FMeshFace face; +#endif face.iWedge[0] = i; face.iWedge[1] = i + 1; face.iWedge[2] = i + 2; @@ -1038,6 +1085,9 @@ PyObject *py_ue_skeletal_mesh_build_lod(ue_PyUObject *self, PyObject * args, PyO mesh->Skeleton->RecreateBoneTree(mesh); mesh->Skeleton->SetPreviewMesh(mesh); + // calculate bounds from points + mesh->SetImportedBounds(FBoxSphereBounds(points.GetData(), points.Num())); + mesh->Skeleton->PostEditChange(); mesh->Skeleton->MarkPackageDirty(); @@ -1046,7 +1096,7 @@ PyObject *py_ue_skeletal_mesh_build_lod(ue_PyUObject *self, PyObject * args, PyO Py_RETURN_NONE; } -#endif + PyObject *py_ue_skeletal_mesh_register_morph_target(ue_PyUObject *self, PyObject * args) { @@ -1072,15 +1122,12 @@ PyObject *py_ue_skeletal_mesh_register_morph_target(ue_PyUObject *self, PyObject return PyErr_Format(PyExc_Exception, "the MorphTarget has no valid data"); #endif -#if WITH_EDITOR mesh->PreEditChange(nullptr); -#endif mesh->RegisterMorphTarget(morph); -#if WITH_EDITOR mesh->PostEditChange(); -#endif + mesh->MarkPackageDirty(); Py_RETURN_NONE; @@ -1210,3 +1257,4 @@ PyObject *py_ue_skeletal_mesh_to_import_vertex_map(ue_PyUObject *self, PyObject return py_list; } +#endif diff --git a/Source/UnrealEnginePython/Private/UObject/UEPySkeletal.h b/Source/UnrealEnginePython/Private/UObject/UEPySkeletal.h index e40a40f49..3b32e9e03 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPySkeletal.h +++ b/Source/UnrealEnginePython/Private/UObject/UEPySkeletal.h @@ -2,7 +2,7 @@ -#include "UnrealEnginePython.h" +#include "UEPyModule.h" PyObject *py_ue_get_anim_instance(ue_PyUObject *, PyObject *); PyObject *py_ue_set_skeletal_mesh(ue_PyUObject *, PyObject *); diff --git a/Source/UnrealEnginePython/Private/UObject/UEPySpline.cpp b/Source/UnrealEnginePython/Private/UObject/UEPySpline.cpp index 77cd215a4..e0142e011 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPySpline.cpp +++ b/Source/UnrealEnginePython/Private/UObject/UEPySpline.cpp @@ -1,23 +1,27 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPySpline.h" #include "Components/SplineComponent.h" -PyObject *py_ue_get_spline_length(ue_PyUObject * self, PyObject * args) { +PyObject *py_ue_get_spline_length(ue_PyUObject * self, PyObject * args) +{ ue_py_check(self); USplineComponent *spline = nullptr; - if (self->ue_object->IsA()) { + if (self->ue_object->IsA()) + { spline = (USplineComponent *)self->ue_object; } - else { + else + { return PyErr_Format(PyExc_Exception, "uobject is not a USplineComponent"); } - if (!spline) { + if (!spline) + { return PyErr_Format(PyExc_Exception, "unable to get spline object"); } @@ -25,29 +29,34 @@ PyObject *py_ue_get_spline_length(ue_PyUObject * self, PyObject * args) { } -PyObject *py_ue_get_world_location_at_distance_along_spline(ue_PyUObject * self, PyObject * args) { +PyObject *py_ue_get_world_location_at_distance_along_spline(ue_PyUObject * self, PyObject * args) +{ ue_py_check(self); float distance = 0; - if (!PyArg_ParseTuple(args, "f:get_world_location_at_distance_along_spline", &distance)) { + if (!PyArg_ParseTuple(args, "f:get_world_location_at_distance_along_spline", &distance)) + { return NULL; } USplineComponent *spline = nullptr; - if (self->ue_object->IsA()) { + if (self->ue_object->IsA()) + { spline = (USplineComponent *)self->ue_object; } - else { + else + { return PyErr_Format(PyExc_Exception, "uobject is not a USplineComponent"); } - if (!spline) { + if (!spline) + { return PyErr_Format(PyExc_Exception, "unable to get spline object"); } - - + + FVector location = spline->GetWorldLocationAtDistanceAlongSpline(distance); return py_ue_new_fvector(location); } diff --git a/Source/UnrealEnginePython/Private/UObject/UEPySpline.h b/Source/UnrealEnginePython/Private/UObject/UEPySpline.h index 5fb9d747c..27f686c3b 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPySpline.h +++ b/Source/UnrealEnginePython/Private/UObject/UEPySpline.h @@ -2,7 +2,7 @@ -#include "UnrealEnginePython.h" +#include "UEPyModule.h" PyObject *py_ue_get_spline_length(ue_PyUObject *, PyObject *); diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyStaticMesh.cpp b/Source/UnrealEnginePython/Private/UObject/UEPyStaticMesh.cpp index 350a0b3fe..eaf1a1cf8 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyStaticMesh.cpp +++ b/Source/UnrealEnginePython/Private/UObject/UEPyStaticMesh.cpp @@ -1,15 +1,92 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPyStaticMesh.h" +#include "Engine/StaticMesh.h" + +PyObject *py_ue_static_mesh_get_bounds(ue_PyUObject *self, PyObject * args) +{ + ue_py_check(self); + UStaticMesh *mesh = ue_py_check_type(self); + if (!mesh) + return PyErr_Format(PyExc_Exception, "uobject is not a UStaticMesh"); + + FBoxSphereBounds bounds = mesh->GetBounds(); + UScriptStruct *u_struct = FindObject(ANY_PACKAGE, UTF8_TO_TCHAR("BoxSphereBounds")); + if (!u_struct) + { + return PyErr_Format(PyExc_Exception, "unable to get BoxSphereBounds struct"); + } + return py_ue_new_owned_uscriptstruct(u_struct, (uint8 *)&bounds); +} #if WITH_EDITOR -PyObject *py_ue_static_mesh_build(ue_PyUObject *self, PyObject * args) { +#include "Wrappers/UEPyFRawMesh.h" +#include "Editor/UnrealEd/Private/GeomFitUtils.h" +#include "FbxMeshUtils.h" + +static PyObject *generate_kdop(ue_PyUObject *self, const FVector *directions, uint32 num_directions) +{ + UStaticMesh *mesh = ue_py_check_type(self); + if (!mesh) + return PyErr_Format(PyExc_Exception, "uobject is not a UStaticMesh"); + + TArray DirArray; + for (uint32 i = 0; i < num_directions; i++) + { + DirArray.Add(directions[i]); + } + + if (GenerateKDopAsSimpleCollision(mesh, DirArray) == INDEX_NONE) + { + return PyErr_Format(PyExc_Exception, "unable to generate KDop vectors"); + } + + PyObject *py_list = PyList_New(0); + for (FVector v : DirArray) + { + PyList_Append(py_list, py_ue_new_fvector(v)); + } + return py_list; +} + +PyObject *py_ue_static_mesh_generate_kdop10x(ue_PyUObject *self, PyObject * args) +{ + ue_py_check(self); + return generate_kdop(self, KDopDir10X, 10); +} + +PyObject *py_ue_static_mesh_generate_kdop10y(ue_PyUObject *self, PyObject * args) +{ + ue_py_check(self); + return generate_kdop(self, KDopDir10Y, 10); +} + +PyObject *py_ue_static_mesh_generate_kdop10z(ue_PyUObject *self, PyObject * args) +{ + ue_py_check(self); + return generate_kdop(self, KDopDir10Z, 10); +} + +PyObject *py_ue_static_mesh_generate_kdop18(ue_PyUObject *self, PyObject * args) +{ + ue_py_check(self); + return generate_kdop(self, KDopDir18, 18); +} + +PyObject *py_ue_static_mesh_generate_kdop26(ue_PyUObject *self, PyObject * args) +{ + ue_py_check(self); + return generate_kdop(self, KDopDir26, 26); +} + +PyObject *py_ue_static_mesh_build(ue_PyUObject *self, PyObject * args) +{ ue_py_check(self); UStaticMesh *mesh = ue_py_check_type(self); if (!mesh) return PyErr_Format(PyExc_Exception, "uobject is not a UStaticMesh"); - + #if ENGINE_MINOR_VERSION > 13 mesh->ImportVersion = EImportStaticMeshVersion::LastVersion; #endif @@ -18,7 +95,8 @@ PyObject *py_ue_static_mesh_build(ue_PyUObject *self, PyObject * args) { Py_RETURN_NONE; } -PyObject *py_ue_static_mesh_create_body_setup(ue_PyUObject *self, PyObject * args) { +PyObject *py_ue_static_mesh_create_body_setup(ue_PyUObject *self, PyObject * args) +{ ue_py_check(self); @@ -31,7 +109,8 @@ PyObject *py_ue_static_mesh_create_body_setup(ue_PyUObject *self, PyObject * arg Py_RETURN_NONE; } -PyObject *py_ue_static_mesh_get_raw_mesh(ue_PyUObject *self, PyObject * args) { +PyObject *py_ue_static_mesh_get_raw_mesh(ue_PyUObject *self, PyObject * args) +{ ue_py_check(self); @@ -53,4 +132,24 @@ PyObject *py_ue_static_mesh_get_raw_mesh(ue_PyUObject *self, PyObject * args) { return py_ue_new_fraw_mesh(raw_mesh); } -#endif \ No newline at end of file +PyObject *py_ue_static_mesh_import_lod(ue_PyUObject *self, PyObject * args) +{ + ue_py_check(self); + + char *filename; + int lod_level; + if (!PyArg_ParseTuple(args, "si:static_mesh_import_lod", &filename, &lod_level)) + return nullptr; + + UStaticMesh *mesh = ue_py_check_type(self); + if (!mesh) + return PyErr_Format(PyExc_Exception, "uobject is not a UStaticMesh"); + + if (FbxMeshUtils::ImportStaticMeshLOD(mesh, FString(UTF8_TO_TCHAR(filename)), lod_level)) + { + Py_RETURN_TRUE; + } + Py_RETURN_FALSE; +} + +#endif diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyStaticMesh.h b/Source/UnrealEnginePython/Private/UObject/UEPyStaticMesh.h index ae17a44e5..46a8c76be 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyStaticMesh.h +++ b/Source/UnrealEnginePython/Private/UObject/UEPyStaticMesh.h @@ -2,10 +2,19 @@ -#include "UnrealEnginePython.h" +#include "UEPyModule.h" + +PyObject *py_ue_static_mesh_get_bounds(ue_PyUObject *self, PyObject * args); #if WITH_EDITOR PyObject *py_ue_static_mesh_build(ue_PyUObject *, PyObject *); PyObject *py_ue_static_mesh_create_body_setup(ue_PyUObject *, PyObject *); PyObject *py_ue_static_mesh_get_raw_mesh(ue_PyUObject *, PyObject *); -#endif \ No newline at end of file + +PyObject *py_ue_static_mesh_generate_kdop10x(ue_PyUObject *, PyObject *); +PyObject *py_ue_static_mesh_generate_kdop10y(ue_PyUObject *, PyObject *); +PyObject *py_ue_static_mesh_generate_kdop10z(ue_PyUObject *, PyObject *); +PyObject *py_ue_static_mesh_generate_kdop18(ue_PyUObject *, PyObject *); +PyObject *py_ue_static_mesh_generate_kdop26(ue_PyUObject *, PyObject *); +PyObject *py_ue_static_mesh_import_lod(ue_PyUObject *, PyObject *); +#endif diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyTexture.cpp b/Source/UnrealEnginePython/Private/UObject/UEPyTexture.cpp index 52ec3c289..44f53890c 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyTexture.cpp +++ b/Source/UnrealEnginePython/Private/UObject/UEPyTexture.cpp @@ -1,7 +1,9 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPyTexture.h" #include "Runtime/Engine/Public/ImageUtils.h" #include "Runtime/Engine/Classes/Engine/Texture.h" +#include "Engine/TextureRenderTarget2D.h" +#include "Engine/Texture2D.h" PyObject *py_ue_texture_update_resource(ue_PyUObject *self, PyObject * args) { @@ -12,7 +14,9 @@ PyObject *py_ue_texture_update_resource(ue_PyUObject *self, PyObject * args) if (!texture) return PyErr_Format(PyExc_Exception, "object is not a Texture"); + Py_BEGIN_ALLOW_THREADS; texture->UpdateResource(); + Py_END_ALLOW_THREADS; Py_RETURN_NONE; } @@ -40,6 +44,20 @@ PyObject *py_ue_texture_get_height(ue_PyUObject *self, PyObject * args) return PyLong_FromLong(texture->GetSizeY()); } +PyObject *py_ue_texture_has_alpha_channel(ue_PyUObject *self, PyObject * args) +{ + + ue_py_check(self); + + UTexture2D *texture = ue_py_check_type(self); + if (!texture) + return PyErr_Format(PyExc_Exception, "object is not a Texture"); + + if (texture->HasAlphaChannel()) + Py_RETURN_TRUE; + Py_RETURN_FALSE; +} + PyObject *py_ue_texture_get_data(ue_PyUObject *self, PyObject * args) { @@ -75,7 +93,7 @@ PyObject *py_ue_texture_get_source_data(ue_PyUObject *self, PyObject * args) if (!PyArg_ParseTuple(args, "|i:texture_get_data", &mipmap)) { - return NULL; + return nullptr; } UTexture2D *tex = ue_py_check_type(self); @@ -92,6 +110,66 @@ PyObject *py_ue_texture_get_source_data(ue_PyUObject *self, PyObject * args) tex->Source.UnlockMip(mipmap); return bytes; } + +PyObject *py_ue_texture_set_source_data(ue_PyUObject *self, PyObject * args) +{ + + ue_py_check(self); + + Py_buffer py_buf; + int mipmap = 0; + + if (!PyArg_ParseTuple(args, "z*|i:texture_set_source_data", &py_buf, &mipmap)) + { + return NULL; + } + + UTexture2D *tex = ue_py_check_type(self); + if (!tex) + { + PyBuffer_Release(&py_buf); + return PyErr_Format(PyExc_Exception, "object is not a Texture2D"); + } + + + if (!py_buf.buf) + { + PyBuffer_Release(&py_buf); + return PyErr_Format(PyExc_Exception, "invalid data"); + } + + if (mipmap >= tex->GetNumMips()) + { + PyBuffer_Release(&py_buf); + return PyErr_Format(PyExc_Exception, "invalid mipmap id"); + } + + int32 wanted_len = py_buf.len; + int32 len = tex->Source.GetSizeX() * tex->Source.GetSizeY() * 4; + // avoid making mess + if (wanted_len > len) + { + UE_LOG(LogPython, Warning, TEXT("truncating buffer to %d bytes"), len); + wanted_len = len; + } + + const uint8 *blob = tex->Source.LockMip(mipmap); + + FMemory::Memcpy((void *)blob, py_buf.buf, wanted_len); + + PyBuffer_Release(&py_buf); + + tex->Source.UnlockMip(mipmap); + Py_BEGIN_ALLOW_THREADS; + tex->MarkPackageDirty(); +#if WITH_EDITOR + tex->PostEditChange(); +#endif + + tex->UpdateResource(); + Py_END_ALLOW_THREADS; + Py_RETURN_NONE; +} #endif PyObject *py_ue_render_target_get_data(ue_PyUObject *self, PyObject * args) @@ -147,27 +225,34 @@ PyObject *py_ue_render_target_get_data_to_buffer(ue_PyUObject *self, PyObject * UTextureRenderTarget2D *tex = ue_py_check_type(self); if (!tex) + { + PyBuffer_Release(&py_buf); return PyErr_Format(PyExc_Exception, "object is not a TextureRenderTarget"); + } FTextureRenderTarget2DResource *resource = (FTextureRenderTarget2DResource *)tex->Resource; if (!resource) { + PyBuffer_Release(&py_buf); return PyErr_Format(PyExc_Exception, "cannot get render target resource"); } Py_ssize_t data_len = (Py_ssize_t)(tex->GetSurfaceWidth() * 4 * tex->GetSurfaceHeight()); if (py_buf.len < data_len) { + PyBuffer_Release(&py_buf); return PyErr_Format(PyExc_Exception, "buffer is not big enough"); } TArray pixels; if (!resource->ReadPixels(pixels)) { + PyBuffer_Release(&py_buf); return PyErr_Format(PyExc_Exception, "unable to read pixels"); } FMemory::Memcpy(py_buf.buf, pixels.GetData(), data_len); + PyBuffer_Release(&py_buf); Py_RETURN_NONE; } @@ -186,14 +271,23 @@ PyObject *py_ue_texture_set_data(ue_PyUObject *self, PyObject * args) UTexture2D *tex = ue_py_check_type(self); if (!tex) + { + PyBuffer_Release(&py_buf); return PyErr_Format(PyExc_Exception, "object is not a Texture2D"); + } if (!py_buf.buf) + { + PyBuffer_Release(&py_buf); return PyErr_Format(PyExc_Exception, "invalid data"); + } if (mipmap >= tex->GetNumMips()) + { + PyBuffer_Release(&py_buf); return PyErr_Format(PyExc_Exception, "invalid mipmap id"); + } char *blob = (char*)tex->PlatformData->Mips[mipmap].BulkData.Lock(LOCK_READ_WRITE); int32 len = tex->PlatformData->Mips[mipmap].BulkData.GetBulkDataSize(); @@ -205,17 +299,21 @@ PyObject *py_ue_texture_set_data(ue_PyUObject *self, PyObject * args) wanted_len = len; } FMemory::Memcpy(blob, py_buf.buf, wanted_len); + + PyBuffer_Release(&py_buf); + tex->PlatformData->Mips[mipmap].BulkData.Unlock(); + Py_BEGIN_ALLOW_THREADS; tex->MarkPackageDirty(); #if WITH_EDITOR tex->PostEditChange(); #endif tex->UpdateResource(); + Py_END_ALLOW_THREADS; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyObject *py_unreal_engine_compress_image_array(PyObject * self, PyObject * args) @@ -241,9 +339,13 @@ PyObject *py_unreal_engine_compress_image_array(PyObject * self, PyObject * args colors.Add(FColor(buf[i], buf[1 + 1], buf[i + 2], buf[i + 3])); } + PyBuffer_Release(&py_buf); + TArray output; + Py_BEGIN_ALLOW_THREADS; FImageUtils::CompressImageArray(width, height, colors, output); + Py_END_ALLOW_THREADS; return PyBytes_FromStringAndSize((char *)output.GetData(), output.Num()); } @@ -266,8 +368,11 @@ PyObject *py_unreal_engine_create_checkerboard_texture(PyObject * self, PyObject if (!color_two) return PyErr_Format(PyExc_Exception, "argument is not a FColor"); - UTexture2D *texture = FImageUtils::CreateCheckerboardTexture(color_one->color, color_two->color, checker_size); + UTexture2D *texture = nullptr; + Py_BEGIN_ALLOW_THREADS; + texture = FImageUtils::CreateCheckerboardTexture(color_one->color, color_two->color, checker_size); + Py_END_ALLOW_THREADS; Py_RETURN_UOBJECT(texture); } @@ -286,7 +391,9 @@ PyObject *py_unreal_engine_create_transient_texture(PyObject * self, PyObject * if (!texture) return PyErr_Format(PyExc_Exception, "unable to create texture"); + Py_BEGIN_ALLOW_THREADS; texture->UpdateResource(); + Py_END_ALLOW_THREADS; Py_RETURN_UOBJECT(texture); } @@ -306,8 +413,9 @@ PyObject *py_unreal_engine_create_transient_texture_render_target2d(PyObject * s if (!texture) return PyErr_Format(PyExc_Exception, "unable to create texture render target"); + Py_BEGIN_ALLOW_THREADS; texture->InitCustomFormat(width, height, (EPixelFormat)format, py_linear && PyObject_IsTrue(py_linear)); - + Py_END_ALLOW_THREADS; Py_RETURN_UOBJECT(texture); } @@ -335,6 +443,7 @@ PyObject *py_unreal_engine_create_texture(PyObject * self, PyObject * args) u_package = ue_py_check_type(py_package); if (!u_package) { + PyBuffer_Release(&py_buf); return PyErr_Format(PyExc_Exception, "argument is not a UPackage"); } } @@ -350,6 +459,8 @@ PyObject *py_unreal_engine_create_texture(PyObject * self, PyObject * args) FMemory::Memcpy(colors.GetData(), py_buf.buf, wanted_len); + PyBuffer_Release(&py_buf); + UTexture2D *texture = FImageUtils::CreateTexture2D(width, height, colors, u_package, UTF8_TO_TCHAR(name), RF_Public | RF_Standalone, params); if (!texture) return PyErr_Format(PyExc_Exception, "unable to create texture"); diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyTexture.h b/Source/UnrealEnginePython/Private/UObject/UEPyTexture.h index 6bdc09f89..54b9f4830 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyTexture.h +++ b/Source/UnrealEnginePython/Private/UObject/UEPyTexture.h @@ -2,7 +2,7 @@ -#include "UnrealEnginePython.h" +#include "UEPyModule.h" PyObject *py_ue_texture_get_data(ue_PyUObject *, PyObject *); PyObject *py_ue_render_target_get_data(ue_PyUObject *, PyObject *); @@ -12,6 +12,8 @@ PyObject *py_ue_texture_set_data(ue_PyUObject *, PyObject *); PyObject *py_ue_texture_get_width(ue_PyUObject *, PyObject *); PyObject *py_ue_texture_get_height(ue_PyUObject *, PyObject *); +PyObject *py_ue_texture_has_alpha_channel(ue_PyUObject *, PyObject *); + PyObject *py_unreal_engine_compress_image_array(PyObject *, PyObject *); PyObject *py_unreal_engine_create_checkerboard_texture(PyObject *, PyObject *); @@ -23,4 +25,5 @@ PyObject *py_ue_texture_update_resource(ue_PyUObject *, PyObject *); #if WITH_EDITOR PyObject *py_unreal_engine_create_texture(PyObject * self, PyObject *); PyObject *py_ue_texture_get_source_data(ue_PyUObject *, PyObject *); +PyObject *py_ue_texture_set_source_data(ue_PyUObject *, PyObject *); #endif diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyTraceAndSweep.cpp b/Source/UnrealEnginePython/Private/UObject/UEPyTraceAndSweep.cpp index 3b399cd3c..053a31fc7 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyTraceAndSweep.cpp +++ b/Source/UnrealEnginePython/Private/UObject/UEPyTraceAndSweep.cpp @@ -1,6 +1,9 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPyTraceAndSweep.h" #include "Kismet/KismetSystemLibrary.h" +#include "Wrappers/UEPyFHitResult.h" +#include "Kismet/GameplayStatics.h" +#include "Engine/World.h" PyObject *py_ue_line_trace_single_by_channel(ue_PyUObject * self, PyObject * args) { diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyTraceAndSweep.h b/Source/UnrealEnginePython/Private/UObject/UEPyTraceAndSweep.h index 4f4c4f0e9..f5f255757 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyTraceAndSweep.h +++ b/Source/UnrealEnginePython/Private/UObject/UEPyTraceAndSweep.h @@ -2,7 +2,7 @@ -#include "UnrealEnginePython.h" +#include "UEPyModule.h" PyObject *py_ue_line_trace_single_by_channel(ue_PyUObject *, PyObject *); PyObject *py_ue_line_trace_multi_by_channel(ue_PyUObject *, PyObject *); diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyTransform.cpp b/Source/UnrealEnginePython/Private/UObject/UEPyTransform.cpp index d6f2041da..34ae1eade 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyTransform.cpp +++ b/Source/UnrealEnginePython/Private/UObject/UEPyTransform.cpp @@ -1,4 +1,7 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPyTransform.h" + +#include "GameFramework/Actor.h" +#include "Wrappers/UEPyFHitResult.h" static bool check_vector_args(PyObject *args, FVector &vec, bool &sweep, bool &teleport_physics) { @@ -231,7 +234,9 @@ PyObject *py_ue_set_actor_location(ue_PyUObject *self, PyObject * args) PyErr_Format(PyExc_Exception, "uobject is not an actor or a component"); FHitResult hit; - bool success = actor->SetActorLocation(vec, sweep, &hit, teleport_physics ? ETeleportType::TeleportPhysics : ETeleportType::None); + bool success = false; + + success = actor->SetActorLocation(vec, sweep, &hit, teleport_physics ? ETeleportType::TeleportPhysics : ETeleportType::None); if (!sweep) { @@ -261,6 +266,7 @@ PyObject *py_ue_add_actor_world_offset(ue_PyUObject *self, PyObject * args) PyErr_Format(PyExc_Exception, "uobject is not an actor or a component"); FHitResult hit; + actor->AddActorWorldOffset(vec, sweep, &hit, teleport_physics ? ETeleportType::TeleportPhysics : ETeleportType::None); if (!sweep) @@ -313,6 +319,7 @@ PyObject *py_ue_add_actor_world_rotation(ue_PyUObject *self, PyObject * args) if (!actor) return PyErr_Format(PyExc_Exception, "uobject is not an actor or a component"); FHitResult hit; + actor->AddActorWorldRotation(quat, sweep, &hit, teleport_physics ? ETeleportType::TeleportPhysics : ETeleportType::None); if (!sweep) @@ -338,6 +345,8 @@ PyObject *py_ue_add_actor_local_rotation(ue_PyUObject *self, PyObject * args) if (!actor) return PyErr_Format(PyExc_Exception, "uobject is not an actor or a component"); FHitResult hit; + + actor->AddActorLocalRotation(quat, sweep, &hit, teleport_physics ? ETeleportType::TeleportPhysics : ETeleportType::None); if (!sweep) @@ -356,16 +365,17 @@ PyObject *py_ue_set_actor_scale(ue_PyUObject *self, PyObject * args) FVector vec; if (!py_ue_vector_arg(args, vec)) - return NULL; + return nullptr; AActor *actor = ue_get_actor(self); if (!actor) PyErr_Format(PyExc_Exception, "uobject is not an actor or a component"); + actor->SetActorScale3D(vec); - Py_INCREF(Py_None); - return Py_None; + + Py_RETURN_NONE; } @@ -382,7 +392,14 @@ PyObject *py_ue_set_actor_rotation(ue_PyUObject *self, PyObject * args) AActor *actor = ue_get_actor(self); if (!actor) return PyErr_Format(PyExc_Exception, "uobject is not an actor or a component"); - if (actor->SetActorRotation(quat, teleport_physics ? ETeleportType::TeleportPhysics : ETeleportType::None)) + + bool success = false; + + + success = actor->SetActorRotation(quat, teleport_physics ? ETeleportType::TeleportPhysics : ETeleportType::None); + + + if (success) { Py_RETURN_TRUE; } @@ -403,8 +420,10 @@ PyObject *py_ue_set_actor_transform(ue_PyUObject *self, PyObject * args) if (!actor) PyErr_Format(PyExc_Exception, "uobject is not an actor or a component"); + actor->SetActorTransform(t); + Py_RETURN_NONE; } @@ -543,7 +562,9 @@ PyObject *py_ue_set_world_location(ue_PyUObject *self, PyObject * args) if (self->ue_object->IsA()) { + ((USceneComponent *)self->ue_object)->SetWorldLocation(vec, sweep, &hit, teleport_physics ? ETeleportType::TeleportPhysics : ETeleportType::None); + if (!sweep) { Py_RETURN_NONE; @@ -561,9 +582,10 @@ PyObject *py_ue_set_world_rotation(ue_PyUObject *self, PyObject * args) return NULL; if (self->ue_object->IsA()) { + ((USceneComponent *)self->ue_object)->SetWorldRotation(rot); - Py_INCREF(Py_None); - return Py_None; + + Py_RETURN_NONE; } return PyErr_Format(PyExc_Exception, "uobject is not a USceneComponent"); } @@ -577,9 +599,9 @@ PyObject *py_ue_set_world_scale(ue_PyUObject *self, PyObject * args) if (self->ue_object->IsA()) { + ((USceneComponent *)self->ue_object)->SetWorldScale3D(vec); - Py_INCREF(Py_None); - return Py_None; + } return PyErr_Format(PyExc_Exception, "uobject is not a USceneComponent"); } @@ -597,7 +619,10 @@ PyObject *py_ue_set_world_transform(ue_PyUObject *self, PyObject * args) if (!component) return PyErr_Format(PyExc_Exception, "uobject is not a USceneComponent"); + component->SetWorldTransform(t); + + Py_RETURN_NONE; } @@ -614,7 +639,9 @@ PyObject *py_ue_set_relative_transform(ue_PyUObject *self, PyObject * args) if (!component) return PyErr_Format(PyExc_Exception, "uobject is not a USceneComponent"); + component->SetRelativeTransform(t); + Py_RETURN_NONE; } @@ -627,9 +654,10 @@ PyObject *py_ue_set_relative_location(ue_PyUObject *self, PyObject * args) if (self->ue_object->IsA()) { + ((USceneComponent *)self->ue_object)->SetRelativeLocation(vec); - Py_INCREF(Py_None); - return Py_None; + + Py_RETURN_NONE; } return PyErr_Format(PyExc_Exception, "uobject is not a USceneComponent"); } @@ -642,9 +670,10 @@ PyObject *py_ue_set_relative_rotation(ue_PyUObject *self, PyObject * args) return NULL; if (self->ue_object->IsA()) { + ((USceneComponent *)self->ue_object)->SetRelativeRotation(rot); - Py_INCREF(Py_None); - return Py_None; + + Py_RETURN_NONE; } return PyErr_Format(PyExc_Exception, "uobject is not a USceneComponent"); } @@ -658,9 +687,10 @@ PyObject *py_ue_set_relative_scale(ue_PyUObject *self, PyObject * args) if (self->ue_object->IsA()) { + ((USceneComponent *)self->ue_object)->SetRelativeScale3D(vec); - Py_INCREF(Py_None); - return Py_None; + + Py_RETURN_NONE; } return PyErr_Format(PyExc_Exception, "uobject is not a USceneComponent"); } diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyTransform.h b/Source/UnrealEnginePython/Private/UObject/UEPyTransform.h index e0d9724c8..3624e5f1a 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyTransform.h +++ b/Source/UnrealEnginePython/Private/UObject/UEPyTransform.h @@ -2,7 +2,7 @@ -#include "UnrealEnginePython.h" +#include "UEPyModule.h" PyObject *py_ue_get_actor_location(ue_PyUObject *, PyObject *); PyObject *py_ue_get_actor_rotation(ue_PyUObject *, PyObject *); diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyUserDefinedStruct.cpp b/Source/UnrealEnginePython/Private/UObject/UEPyUserDefinedStruct.cpp index ddfda0edd..b8066a432 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyUserDefinedStruct.cpp +++ b/Source/UnrealEnginePython/Private/UObject/UEPyUserDefinedStruct.cpp @@ -1,9 +1,10 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPyUserDefinedStruct.h" #if WITH_EDITOR -#include "Classes/UserDefinedStructure/UserDefinedStructEditorData.h" -#include "Public/Kismet2/StructureEditorUtils.h" +#include "Runtime/Engine/Classes/Engine/UserDefinedStruct.h" +#include "Editor/UnrealEd/Classes/UserDefinedStructure/UserDefinedStructEditorData.h" +#include "Editor/UnrealEd/Public/Kismet2/StructureEditorUtils.h" @@ -33,7 +34,7 @@ PyObject *py_ue_struct_add_variable(ue_PyUObject * self, PyObject * args) FStructureEditorUtils::OnStructureChanged(u_struct, FStructureEditorUtils::EStructureEditorChangeInfo::AddedVariable); - return py_ue_new_uscriptstruct(FindObject(ANY_PACKAGE, UTF8_TO_TCHAR((char *)"Guid")), (uint8 *)&var->VarGuid); + return py_ue_new_owned_uscriptstruct(FindObject(ANY_PACKAGE, UTF8_TO_TCHAR((char *)"Guid")), (uint8 *)&var->VarGuid); } PyObject *py_ue_struct_get_variables(ue_PyUObject * self, PyObject * args) @@ -50,7 +51,7 @@ PyObject *py_ue_struct_get_variables(ue_PyUObject * self, PyObject * args) PyObject *py_list = PyList_New(0); for (FStructVariableDescription description : variables) { - PyList_Append(py_list, py_ue_new_uscriptstruct(FStructVariableDescription::StaticStruct(), (uint8*)&description)); + PyList_Append(py_list, py_ue_new_owned_uscriptstruct(FStructVariableDescription::StaticStruct(), (uint8*)&description)); } return py_list; } diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyUserDefinedStruct.h b/Source/UnrealEnginePython/Private/UObject/UEPyUserDefinedStruct.h index 23d7a7d05..9e973ea0e 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyUserDefinedStruct.h +++ b/Source/UnrealEnginePython/Private/UObject/UEPyUserDefinedStruct.h @@ -1,7 +1,7 @@ #pragma once -#include "UnrealEnginePython.h" +#include "UEPyModule.h" PyObject *py_ue_struct_add_variable(ue_PyUObject *, PyObject *); diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyViewport.cpp b/Source/UnrealEnginePython/Private/UObject/UEPyViewport.cpp index 364947cc3..4e7244b63 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyViewport.cpp +++ b/Source/UnrealEnginePython/Private/UObject/UEPyViewport.cpp @@ -1,4 +1,4 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPyViewport.h" #if WITH_EDITOR #include "LevelEditor.h" @@ -6,6 +6,26 @@ #include "Editor/UnrealEd/Public/LevelEditorViewport.h" #endif +#include "Slate/UEPySWidget.h" +#include "Slate/UEPySWindow.h" +// required for GEngine access +#include "Engine/Engine.h" + +PyObject *py_ue_game_viewport_client_get_window(ue_PyUObject *self, PyObject *args) +{ + ue_py_check(self); + + UGameViewportClient *viewport = ue_py_check_type(self); + if (!viewport) + return PyErr_Format(PyExc_Exception, "uobject is not a GameViewportClient"); + + TSharedPtr Window = viewport->GetWindow(); + if (!Window.IsValid()) + return PyErr_Format(PyExc_Exception, "GameViewportClient has no window"); + + return (PyObject *)py_ue_new_swindow(Window.ToSharedRef()); +} + PyObject *py_unreal_engine_get_game_viewport_client(PyObject * self, PyObject * args) { @@ -151,16 +171,13 @@ PyObject *py_ue_add_viewport_widget_content(ue_PyUObject *self, PyObject * args) return PyErr_Format(PyExc_Exception, "cannot retrieve GameViewportClient from UWorld"); } - ue_PySWidget *py_swidget = py_ue_is_swidget(py_widget); - if (!py_swidget) + TSharedPtr content = py_ue_is_swidget(py_widget); + if (!content.IsValid()) { - return PyErr_Format(PyExc_Exception, "argument is not a SWidget"); + return nullptr; } - // Do not increment reference count as it is assumed this function is used in a PyComponent/PyActor/ that can holds reference to - // it in various ways - // Py_INCREF(py_swidget); - viewport->AddViewportWidgetContent(py_swidget->s_widget, z_order); + viewport->AddViewportWidgetContent(content.ToSharedRef()); Py_RETURN_NONE; } @@ -181,14 +198,13 @@ PyObject *py_ue_remove_viewport_widget_content(ue_PyUObject *self, PyObject * ar if (!viewport) return PyErr_Format(PyExc_Exception, "object is not a GameViewportClient"); - ue_PySWidget *py_swidget = py_ue_is_swidget(py_widget); - if (!py_swidget) + TSharedPtr content = py_ue_is_swidget(py_widget); + if (!content.IsValid()) { - return PyErr_Format(PyExc_Exception, "argument is not a SWidget"); + return nullptr; } - Py_DECREF(py_swidget); - viewport->RemoveViewportWidgetContent(py_swidget->s_widget); + viewport->RemoveViewportWidgetContent(content.ToSharedRef()); Py_RETURN_NONE; } @@ -208,3 +224,28 @@ PyObject *py_ue_remove_all_viewport_widgets(ue_PyUObject *self, PyObject * args) Py_RETURN_NONE; } +PyObject *py_ue_game_viewport_client_set_rendering_flag(ue_PyUObject *self, PyObject * args) +{ + + ue_py_check(self); + + PyObject *py_bool; + + if (!PyArg_ParseTuple(args, "O:game_viewport_client_set_rendering_flag", &py_bool)) + { + return nullptr; + } + + bool bEnabled = PyObject_IsTrue(py_bool) ? true : false; + + UGameViewportClient *ViewportClient = ue_py_check_type(self); + if (!ViewportClient) + { + return PyErr_Format(PyExc_Exception, "object is not a UGameViewportClient"); + } + + ViewportClient->EngineShowFlags.Rendering = bEnabled; + + Py_RETURN_NONE; +} + diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyViewport.h b/Source/UnrealEnginePython/Private/UObject/UEPyViewport.h index 2f6a8dc2b..7505fc9de 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyViewport.h +++ b/Source/UnrealEnginePython/Private/UObject/UEPyViewport.h @@ -2,7 +2,7 @@ -#include "UnrealEnginePython.h" +#include "UEPyModule.h" PyObject *py_unreal_engine_get_game_viewport_client(PyObject *, PyObject *); #if WITH_EDITOR @@ -16,3 +16,5 @@ PyObject *py_unreal_engine_editor_set_view_rotation(PyObject *, PyObject *); PyObject *py_ue_add_viewport_widget_content(ue_PyUObject *, PyObject *); PyObject *py_ue_remove_viewport_widget_content(ue_PyUObject *, PyObject *); PyObject *py_ue_remove_all_viewport_widgets(ue_PyUObject *, PyObject *); +PyObject *py_ue_game_viewport_client_set_rendering_flag(ue_PyUObject *, PyObject *); +PyObject *py_ue_game_viewport_client_get_window(ue_PyUObject *, PyObject *); diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyWidget.cpp b/Source/UnrealEnginePython/Private/UObject/UEPyWidget.cpp index bac67a6d8..5c6794c04 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyWidget.cpp +++ b/Source/UnrealEnginePython/Private/UObject/UEPyWidget.cpp @@ -1,7 +1,8 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPyWidget.h" #include "Runtime/UMG/Public/Components/Widget.h" +#include "Slate/UEPySWidget.h" PyObject *py_ue_take_widget(ue_PyUObject * self, PyObject * args) diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyWidget.h b/Source/UnrealEnginePython/Private/UObject/UEPyWidget.h index c08e02e71..d257ef8de 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyWidget.h +++ b/Source/UnrealEnginePython/Private/UObject/UEPyWidget.h @@ -1,7 +1,7 @@ #pragma once -#include "UnrealEnginePython.h" +#include "UEPyModule.h" PyObject *py_ue_take_widget(ue_PyUObject *, PyObject *); diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyWidgetComponent.cpp b/Source/UnrealEnginePython/Private/UObject/UEPyWidgetComponent.cpp index a548be8f6..284223c61 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyWidgetComponent.cpp +++ b/Source/UnrealEnginePython/Private/UObject/UEPyWidgetComponent.cpp @@ -1,8 +1,9 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPyWidgetComponent.h" #include "Runtime/UMG/Public/Components/WidgetComponent.h" #include "PyUserWidget.h" +#include "Slate/UEPySWidget.h" PyObject *py_ue_set_slate_widget(ue_PyUObject * self, PyObject * args) @@ -18,16 +19,16 @@ PyObject *py_ue_set_slate_widget(ue_PyUObject * self, PyObject * args) } UWidgetComponent *widget_component = ue_py_check_type(self); - UPyUserWidget *py_user_widget = ue_py_check_type(self); + UPyUserWidget *py_user_widget = ue_py_check_type(self); if (!widget_component && !py_user_widget) return PyErr_Format(PyExc_Exception, "uobject is not a UWidgetComponent or UPyUserWidget"); - ue_PySWidget *s_widget = py_ue_is_swidget(py_widget); - if (!s_widget) - return PyErr_Format(PyExc_Exception, "argument is not a SWidget"); + TSharedPtr Widget = py_ue_is_swidget(py_widget); + if (!Widget.IsValid()) + return nullptr; - if (widget_component) { widget_component->SetSlateWidget(s_widget->s_widget); } - else { py_user_widget->SetSlateWidget(s_widget->s_widget); } + if (widget_component) { widget_component->SetSlateWidget(Widget); } + else { py_user_widget->SetSlateWidget(Widget.ToSharedRef()); } Py_RETURN_NONE; } diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyWidgetComponent.h b/Source/UnrealEnginePython/Private/UObject/UEPyWidgetComponent.h index f9f3440be..485491478 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyWidgetComponent.h +++ b/Source/UnrealEnginePython/Private/UObject/UEPyWidgetComponent.h @@ -1,7 +1,7 @@ #pragma once -#include "UnrealEnginePython.h" +#include "UEPyModule.h" PyObject *py_ue_set_slate_widget(ue_PyUObject *, PyObject *); \ No newline at end of file diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyWorld.cpp b/Source/UnrealEnginePython/Private/UObject/UEPyWorld.cpp index ce33397d0..19a31299b 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyWorld.cpp +++ b/Source/UnrealEnginePython/Private/UObject/UEPyWorld.cpp @@ -1,8 +1,12 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPyWorld.h" #include "Runtime/Engine/Classes/Kismet/KismetSystemLibrary.h" -#include "Runtime/Foliage/Public/FoliageType.h" -#include "Runtime/Foliage/Public/InstancedFoliageActor.h" +#include "EngineUtils.h" +#include "Kismet/GameplayStatics.h" +#include "Runtime/CoreUObject/Public/UObject/UObjectIterator.h" +#if WITH_EDITOR +#include "Editor/UnrealEd/Public/EditorActorFolders.h" +#endif PyObject *py_ue_world_exec(ue_PyUObject *self, PyObject * args) { @@ -39,7 +43,11 @@ PyObject *py_ue_quit_game(ue_PyUObject *self, PyObject * args) if (!controller) return PyErr_Format(PyExc_Exception, "unable to retrieve the first controller"); +#if ENGINE_MINOR_VERSION > 20 + UKismetSystemLibrary::QuitGame(world, controller, EQuitPreference::Quit, false); +#else UKismetSystemLibrary::QuitGame(world, controller, EQuitPreference::Quit); +#endif Py_RETURN_NONE; } @@ -192,9 +200,12 @@ PyObject *py_ue_get_game_viewport(ue_PyUObject *self, PyObject * args) if (!viewport_client) return PyErr_Format(PyExc_Exception, "world has no GameViewportClient"); - Py_RETURN_UOBJECT(viewport_client); + Py_RETURN_UOBJECT((UObject *)viewport_client); } + + + PyObject *py_ue_has_world(ue_PyUObject *self, PyObject * args) { @@ -305,67 +316,128 @@ PyObject *py_ue_set_current_level(ue_PyUObject *self, PyObject * args) if (!level) return PyErr_Format(PyExc_Exception, "argument is not a ULevel"); +#if WITH_EDITOR || ENGINE_MINOR_VERSION < 22 + if (world->SetCurrentLevel(level)) Py_RETURN_TRUE; +#endif Py_RETURN_FALSE; } -PyObject *py_ue_get_instanced_foliage_actor_for_current_level(ue_PyUObject *self, PyObject * args) +#if WITH_EDITOR +PyObject *py_ue_get_level_script_blueprint(ue_PyUObject *self, PyObject * args) { + ue_py_check(self); + ULevel *level = ue_py_check_type(self); + if (!level) + { + return PyErr_Format(PyExc_Exception, "uobject is not a ULevel"); + } + + Py_RETURN_UOBJECT((UObject*)level->GetLevelScriptBlueprint()); +} + +PyObject *py_ue_world_create_folder(ue_PyUObject *self, PyObject * args) +{ + + ue_py_check(self); + + char *path; + if (!PyArg_ParseTuple(args, "s:world_create_folder", &path)) + return nullptr; + + if (!FActorFolders::IsAvailable()) + return PyErr_Format(PyExc_Exception, "FActorFolders is not available"); + UWorld *world = ue_get_uworld(self); if (!world) return PyErr_Format(PyExc_Exception, "unable to retrieve UWorld from uobject"); - Py_RETURN_UOBJECT(AInstancedFoliageActor::GetInstancedFoliageActorForCurrentLevel(world, true)); + FName FolderPath = FName(UTF8_TO_TCHAR(path)); + + FActorFolders::Get().CreateFolder(*world, FolderPath); + + Py_RETURN_NONE; } -#if WITH_EDITOR -PyObject *py_ue_add_foliage_asset(ue_PyUObject *self, PyObject * args) +PyObject *py_ue_world_delete_folder(ue_PyUObject *self, PyObject * args) { ue_py_check(self); - PyObject *py_uobject; + char *path; + if (!PyArg_ParseTuple(args, "s:world_delete_folder", &path)) + return nullptr; - if (!PyArg_ParseTuple(args, "O:add_foliage_asset", &py_uobject)) - { + if (!FActorFolders::IsAvailable()) + return PyErr_Format(PyExc_Exception, "FActorFolders is not available"); + + UWorld *world = ue_get_uworld(self); + if (!world) + return PyErr_Format(PyExc_Exception, "unable to retrieve UWorld from uobject"); + + FName FolderPath = FName(UTF8_TO_TCHAR(path)); + + FActorFolders::Get().DeleteFolder(*world, FolderPath); + + Py_RETURN_NONE; +} + +PyObject *py_ue_world_rename_folder(ue_PyUObject *self, PyObject * args) +{ + + ue_py_check(self); + + char *path; + char *new_path; + if (!PyArg_ParseTuple(args, "ss:world_rename_folder", &path, &new_path)) return nullptr; - } + + if (!FActorFolders::IsAvailable()) + return PyErr_Format(PyExc_Exception, "FActorFolders is not available"); UWorld *world = ue_get_uworld(self); if (!world) return PyErr_Format(PyExc_Exception, "unable to retrieve UWorld from uobject"); - UObject *u_object = ue_py_check_type(py_uobject); - if (!u_object) - return PyErr_Format(PyExc_Exception, "argument is not a UObject"); + FName FolderPath = FName(UTF8_TO_TCHAR(path)); + FName NewFolderPath = FName(UTF8_TO_TCHAR(new_path)); - UFoliageType *foliage_type = nullptr; + if (FActorFolders::Get().RenameFolderInWorld(*world, FolderPath, NewFolderPath)) + Py_RETURN_TRUE; - AInstancedFoliageActor *ifa = AInstancedFoliageActor::GetInstancedFoliageActorForCurrentLevel(world, true); - if (u_object->IsA()) - { - foliage_type = ifa->GetLocalFoliageTypeForMesh((UStaticMesh *)u_object); - if (!foliage_type) - { - ifa->AddMesh((UStaticMesh *)u_object, &foliage_type); - } - } - else if (u_object->IsA()) - { - foliage_type = (UFoliageType *)u_object; - ifa->AddFoliageType(foliage_type); + Py_RETURN_FALSE; +} - } +PyObject *py_ue_world_folders(ue_PyUObject *self, PyObject * args) +{ + + ue_py_check(self); + + if (!FActorFolders::IsAvailable()) + return PyErr_Format(PyExc_Exception, "FActorFolders is not available"); - if (!foliage_type) - return PyErr_Format(PyExc_Exception, "unable to add foliage asset"); + UWorld *world = ue_get_uworld(self); + if (!world) + return PyErr_Format(PyExc_Exception, "unable to retrieve UWorld from uobject"); + + const TMap &Folders = FActorFolders::Get().GetFolderPropertiesForWorld(*world); - Py_RETURN_UOBJECT(foliage_type); + PyObject *py_list = PyList_New(0); + TArray FolderNames; + Folders.GenerateKeyArray(FolderNames); + + for (FName FolderName : FolderNames) + { + PyObject *py_str = PyUnicode_FromString(TCHAR_TO_UTF8(*FolderName.ToString())); + PyList_Append(py_list, py_str); + Py_DECREF(py_str); + } + + return py_list; } #endif - diff --git a/Source/UnrealEnginePython/Private/UObject/UEPyWorld.h b/Source/UnrealEnginePython/Private/UObject/UEPyWorld.h index 47cde2bfc..16f07ae7e 100644 --- a/Source/UnrealEnginePython/Private/UObject/UEPyWorld.h +++ b/Source/UnrealEnginePython/Private/UObject/UEPyWorld.h @@ -1,8 +1,8 @@ #pragma once +#include "UEPyModule.h" -#include "UnrealEnginePython.h" PyObject *py_ue_quit_game(ue_PyUObject *, PyObject *); PyObject *py_ue_play(ue_PyUObject *, PyObject *); @@ -30,7 +30,11 @@ PyObject *py_ue_set_current_level(ue_PyUObject *, PyObject *); PyObject *py_ue_get_world_type(ue_PyUObject *, PyObject *); -PyObject *py_ue_get_instanced_foliage_actor_for_current_level(ue_PyUObject *, PyObject *); #if WITH_EDITOR -PyObject *py_ue_add_foliage_asset(ue_PyUObject *, PyObject *); -#endif \ No newline at end of file +PyObject *py_ue_world_create_folder(ue_PyUObject *, PyObject *); +PyObject *py_ue_world_delete_folder(ue_PyUObject *, PyObject *); +PyObject *py_ue_world_rename_folder(ue_PyUObject *, PyObject *); +PyObject *py_ue_world_folders(ue_PyUObject *, PyObject *); +PyObject *py_ue_get_level_script_blueprint(ue_PyUObject *, PyObject *); +#endif + diff --git a/Source/UnrealEnginePython/Private/UnrealEnginePython.cpp b/Source/UnrealEnginePython/Private/UnrealEnginePython.cpp index 7357b1504..211124849 100644 --- a/Source/UnrealEnginePython/Private/UnrealEnginePython.cpp +++ b/Source/UnrealEnginePython/Private/UnrealEnginePython.cpp @@ -1,28 +1,56 @@ -// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved. +// Copyright 20Tab S.r.l. -#include "UnrealEnginePythonPrivatePCH.h" +#include "UnrealEnginePython.h" +#include "UEPyModule.h" #include "PythonBlueprintFunctionLibrary.h" #include "HAL/IConsoleManager.h" +#include "HAL/PlatformFilemanager.h" #if ENGINE_MINOR_VERSION < 13 #include "ClassIconFinder.h" #endif +#include "Styling/SlateStyleRegistry.h" +#if WITH_EDITOR +#include "Interfaces/IPluginManager.h" +#endif + #if ENGINE_MINOR_VERSION >= 18 #define PROJECT_CONTENT_DIR FPaths::ProjectContentDir() #else #define PROJECT_CONTENT_DIR FPaths::GameContentDir() #endif +#if PLATFORM_MAC +#include "Runtime/Core/Public/Mac/CocoaThread.h" +#endif + void unreal_engine_init_py_module(); void init_unreal_engine_builtin(); -#if defined(UNREAL_ENGINE_PYTHON_ON_LINUX) +#if PLATFORM_LINUX const char *ue4_module_options = "linux_global_symbols"; #endif -#if PY_MAJOR_VERSION < 3 -char *PyUnicode_AsUTF8(PyObject *py_str) +#include "Runtime/Core/Public/Misc/CommandLine.h" +#include "Runtime/Core/Public/Misc/ConfigCacheIni.h" +#include "Runtime/Core/Public/GenericPlatform/GenericPlatformFile.h" +#include "Runtime/Core/Public/GenericPlatform/GenericPlatformMisc.h" + +#include "Runtime/Core/Public/HAL/FileManagerGeneric.h" + +#if PLATFORM_WINDOWS +#include +#endif + +#if PLATFORM_ANDROID +#include "Android/AndroidJNI.h" +#include "Android/AndroidApplication.h" +#endif + + +const char *UEPyUnicode_AsUTF8(PyObject *py_str) { +#if PY_MAJOR_VERSION < 3 if (PyUnicode_Check(py_str)) { PyObject *unicode = PyUnicode_AsUTF8String(py_str); @@ -33,9 +61,15 @@ char *PyUnicode_AsUTF8(PyObject *py_str) // just a hack to avoid crashes return (char *)""; } - return PyString_AsString(py_str); + return (const char *)PyString_AsString(py_str); +#elif PY_MINOR_VERSION < 7 + return (const char *)PyUnicode_AsUTF8(py_str); +#else + return PyUnicode_AsUTF8(py_str); +#endif } +#if PY_MAJOR_VERSION < 3 int PyGILState_Check() { PyThreadState * tstate = _PyThreadState_Current; @@ -60,39 +94,44 @@ bool PyUnicodeOrString_Check(PyObject *py_obj) #define LOCTEXT_NAMESPACE "FUnrealEnginePythonModule" - -void FUnrealEnginePythonModule::PythonGILRelease() +void FUnrealEnginePythonModule::UESetupPythonInterpreter(bool verbose) { -#if defined(UEPY_THREADING) - if (PyGILState_Check() == 1) - { - ue_python_gil = PyEval_SaveThread(); - } -#endif -} + const TCHAR* CommandLine = FCommandLine::GetOriginal(); + const SIZE_T CommandLineSize = FCString::Strlen(CommandLine) + 1; + TCHAR* CommandLineCopy = new TCHAR[CommandLineSize]; + FCString::Strcpy(CommandLineCopy, CommandLineSize, CommandLine); + const TCHAR* ParsedCmdLine = CommandLineCopy; -bool FUnrealEnginePythonModule::PythonGILAcquire() -{ -#if defined(UEPY_THREADING) - if (PyGILState_Check() == 0) + TArray Args; + for (;;) { - PyEval_RestoreThread((PyThreadState *)ue_python_gil); - return true; - } - return false; -#endif - return true; + FString Arg = FParse::Token(ParsedCmdLine, 0); + if (Arg.Len() <= 0) + break; + Args.Add(Arg); } -void FUnrealEnginePythonModule::UESetupPythonInterpreter(bool verbose) -{ +#if PY_MAJOR_VERSION >= 3 + wchar_t **argv = (wchar_t **)FMemory::Malloc(sizeof(wchar_t *) * (Args.Num() + 1)); +#else + char **argv = (char **)FMemory::Malloc(sizeof(char *) * (Args.Num() + 1)); +#endif + argv[Args.Num()] = nullptr; + for (int32 i = 0; i < Args.Num(); i++) + { #if PY_MAJOR_VERSION >= 3 - wchar_t *argv[] = { UTF8_TO_TCHAR("UnrealEngine"), NULL }; + #if ENGINE_MINOR_VERSION >= 20 + argv[i] = (wchar_t *)(TCHAR_TO_WCHAR(*Args[i])); + #else + argv[i] = (wchar_t *)(*Args[i]); + #endif #else - char *argv[] = { (char *)"UnrealEngine", NULL }; + argv[i] = TCHAR_TO_UTF8(*Args[i]); #endif - PySys_SetArgv(1, argv); + } + + PySys_SetArgv(Args.Num(), argv); unreal_engine_init_py_module(); @@ -105,9 +144,18 @@ void FUnrealEnginePythonModule::UESetupPythonInterpreter(bool verbose) PyObject *py_zip_path = PyUnicode_FromString(zip_path); PyList_Insert(py_path, 0, py_zip_path); - char *scripts_path = TCHAR_TO_UTF8(*ScriptsPath); - PyObject *py_scripts_path = PyUnicode_FromString(scripts_path); - PyList_Insert(py_path, 0, py_scripts_path); + + int i = 0; + for (FString ScriptsPath : ScriptsPaths) + { + char *scripts_path = TCHAR_TO_UTF8(*ScriptsPath); + PyObject *py_scripts_path = PyUnicode_FromString(scripts_path); + PyList_Insert(py_path, i++, py_scripts_path); + if (verbose) + { + UE_LOG(LogPython, Log, TEXT("Python Scripts search path: %s"), UTF8_TO_TCHAR(scripts_path)); + } + } char *additional_modules_path = TCHAR_TO_UTF8(*AdditionalModulesPath); PyObject *py_additional_modules_path = PyUnicode_FromString(additional_modules_path); @@ -116,7 +164,6 @@ void FUnrealEnginePythonModule::UESetupPythonInterpreter(bool verbose) if (verbose) { UE_LOG(LogPython, Log, TEXT("Python VM initialized: %s"), UTF8_TO_TCHAR(Py_GetVersion())); - UE_LOG(LogPython, Log, TEXT("Python Scripts search path: %s"), UTF8_TO_TCHAR(scripts_path)); } } @@ -177,7 +224,6 @@ namespace { cmdString += argStr.TrimQuotes() + '\n'; } - UPythonBlueprintFunctionLibrary::ExecutePythonString(cmdString); } } @@ -193,9 +239,9 @@ FAutoConsoleCommand ExecPythonStringCommand( *NSLOCTEXT("UnrealEnginePython", "CommandText_Cmd", "Execute python string").ToString(), FConsoleCommandWithArgsDelegate::CreateStatic(consoleExecString)); + void FUnrealEnginePythonModule::StartupModule() { - BrutalFinalize = false; // This code will execute after your module is loaded into memory; the exact timing is specified in the .uplugin file per-module @@ -209,7 +255,7 @@ void FUnrealEnginePythonModule::StartupModule() #endif FPlatformMisc::SetEnvironmentVar(TEXT("PYTHONHOME"), *PythonHome); Py_SetPythonHome(home); -} + } if (GConfig->GetString(UTF8_TO_TCHAR("Python"), UTF8_TO_TCHAR("RelativeHome"), PythonHome, GEngineIni)) { @@ -223,7 +269,9 @@ void FUnrealEnginePythonModule::StartupModule() #endif Py_SetPythonHome(home); -} + } + + TArray ImportModules; FString IniValue; if (GConfig->GetString(UTF8_TO_TCHAR("Python"), UTF8_TO_TCHAR("ProgramName"), IniValue, GEngineIni)) @@ -251,12 +299,12 @@ void FUnrealEnginePythonModule::StartupModule() if (GConfig->GetString(UTF8_TO_TCHAR("Python"), UTF8_TO_TCHAR("ScriptsPath"), IniValue, GEngineIni)) { - ScriptsPath = IniValue; + ScriptsPaths.Add(IniValue); } if (GConfig->GetString(UTF8_TO_TCHAR("Python"), UTF8_TO_TCHAR("RelativeScriptsPath"), IniValue, GEngineIni)) { - ScriptsPath = FPaths::Combine(*PROJECT_CONTENT_DIR, *IniValue); + ScriptsPaths.Add(FPaths::Combine(*PROJECT_CONTENT_DIR, *IniValue)); } if (GConfig->GetString(UTF8_TO_TCHAR("Python"), UTF8_TO_TCHAR("AdditionalModulesPath"), IniValue, GEngineIni)) @@ -279,20 +327,39 @@ void FUnrealEnginePythonModule::StartupModule() ZipPath = FPaths::Combine(*PROJECT_CONTENT_DIR, *IniValue); } - if (ScriptsPath.IsEmpty()) + if (GConfig->GetString(UTF8_TO_TCHAR("Python"), UTF8_TO_TCHAR("ImportModules"), IniValue, GEngineIni)) { - ScriptsPath = FPaths::Combine(*PROJECT_CONTENT_DIR, UTF8_TO_TCHAR("Scripts")); + const TCHAR* separators[] = { TEXT(" "), TEXT(";"), TEXT(",") }; + IniValue.ParseIntoArray(ImportModules, separators, 3); } - if (ZipPath.IsEmpty()) + FString ProjectScriptsPath = FPaths::Combine(*PROJECT_CONTENT_DIR, UTF8_TO_TCHAR("Scripts")); + if (!FPaths::DirectoryExists(ProjectScriptsPath)) { - ZipPath = FPaths::Combine(*PROJECT_CONTENT_DIR, UTF8_TO_TCHAR("ue_python.zip")); + FPlatformFileManager::Get().GetPlatformFile().CreateDirectory(*ProjectScriptsPath); } + ScriptsPaths.Add(ProjectScriptsPath); - if (!FPaths::DirectoryExists(ScriptsPath)) +#if WITH_EDITOR + for (TSharedRefplugin : IPluginManager::Get().GetEnabledPlugins()) { - IPlatformFile& PlatformFile = FPlatformFileManager::Get().GetPlatformFile(); - PlatformFile.CreateDirectory(*ScriptsPath); + FString PluginScriptsPath = FPaths::Combine(plugin->GetContentDir(), UTF8_TO_TCHAR("Scripts")); + if (FPaths::DirectoryExists(PluginScriptsPath)) + { + ScriptsPaths.Add(PluginScriptsPath); + } + + // allows third parties to include their code in the main plugin directory + if (plugin->GetName() == "UnrealEnginePython") + { + ScriptsPaths.Add(plugin->GetBaseDir()); + } + } +#endif + + if (ZipPath.IsEmpty()) + { + ZipPath = FPaths::Combine(*PROJECT_CONTENT_DIR, UTF8_TO_TCHAR("ue_python.zip")); } // To ensure there are no path conflicts, if we have a valid python home at this point, @@ -304,7 +371,11 @@ void FUnrealEnginePythonModule::StartupModule() const int32 MaxPathVarLen = 32768; FString OrigPathVar = FString::ChrN(MaxPathVarLen, TEXT('\0')); +#if ENGINE_MINOR_VERSION >= 21 + OrigPathVar = FPlatformMisc::GetEnvironmentVariable(TEXT("PATH")); +#else FPlatformMisc::GetEnvironmentVariable(TEXT("PATH"), OrigPathVar.GetCharArray().GetData(), MaxPathVarLen); +#endif // Get the current path and remove elements with python in them, we don't want any conflicts const TCHAR* PathDelimiter = FPlatformMisc::GetPathVarDelimiter(); @@ -332,14 +403,79 @@ void FUnrealEnginePythonModule::StartupModule() PathVars.Append(OurPythonPaths); FString ModifiedPath = FString::Join(PathVars, PathDelimiter); FPlatformMisc::SetEnvironmentVar(TEXT("PATH"), *ModifiedPath); - } + } + + #if PY_MAJOR_VERSION >= 3 init_unreal_engine_builtin(); +#if PLATFORM_ANDROID + extern FString GOBBFilePathBase; + extern FString GFilePathBase; + extern FString GExternalFilePath; + extern FString GPackageName; + extern int32 GAndroidPackageVersion; + FString OBBDir1 = GOBBFilePathBase + FString(TEXT("/Android/obb/") + GPackageName); + FString OBBDir2 = GOBBFilePathBase + FString(TEXT("/obb/") + GPackageName); + FString MainOBBName = FString::Printf(TEXT("main.%d.%s.obb"), GAndroidPackageVersion, *GPackageName); + FString PatchOBBName = FString::Printf(TEXT("patch.%d.%s.obb"), GAndroidPackageVersion, *GPackageName); + FString UnrealEnginePython_OBBPath; + if (FPaths::FileExists(*(OBBDir1 / MainOBBName))) + { + UnrealEnginePython_OBBPath = OBBDir1 / MainOBBName / FApp::GetProjectName() / FString(TEXT("Content/Scripts")); + } + else if (FPaths::FileExists(*(OBBDir2 / MainOBBName))) + { + UnrealEnginePython_OBBPath = OBBDir2 / MainOBBName / FApp::GetProjectName() / FString(TEXT("Content/Scripts")); + } + if (FPaths::FileExists(*(OBBDir1 / PatchOBBName))) + { + UnrealEnginePython_OBBPath = OBBDir1 / PatchOBBName / FApp::GetProjectName() / FString(TEXT("Content/Scripts")); + } + else if (FPaths::FileExists(*(OBBDir2 / PatchOBBName))) + { + UnrealEnginePython_OBBPath = OBBDir1 / PatchOBBName / FApp::GetProjectName() / FString(TEXT("Content/Scripts")); + } + + if (!UnrealEnginePython_OBBPath.IsEmpty()) + { + ScriptsPaths.Add(UnrealEnginePython_OBBPath); + } + + FString FinalPath = GFilePathBase / FString("UE4Game") / FApp::GetProjectName() / FApp::GetProjectName() / FString(TEXT("Content/Scripts")); + ScriptsPaths.Add(FinalPath); + + FString BasePythonPath = FinalPath / FString(TEXT("stdlib.zip")) + FString(":") + FinalPath; + + if (!UnrealEnginePython_OBBPath.IsEmpty()) + { + BasePythonPath += FString(":") + UnrealEnginePython_OBBPath; + } + + UE_LOG(LogPython, Warning, TEXT("Setting Base Path to %s"), *BasePythonPath); + + Py_SetPath(Py_DecodeLocale(TCHAR_TO_UTF8(*BasePythonPath), NULL)); +#endif #endif Py_Initialize(); +#if PLATFORM_WINDOWS + // Restore stdio state after Py_Initialize set it to O_BINARY, otherwise + // everything that the engine will output is going to be encoded in UTF-16. + // The behaviour is described here: https://bugs.python.org/issue16587 + _setmode(_fileno(stdin), O_TEXT); + _setmode(_fileno(stdout), O_TEXT); + _setmode(_fileno(stderr), O_TEXT); + + // Also restore the user-requested UTF-8 flag if relevant (behaviour copied + // from LaunchEngineLoop.cpp). + if (FParse::Param(FCommandLine::Get(), TEXT("UTF8Output"))) + { + FPlatformMisc::SetUTF8Output(); + } +#endif + PyEval_InitThreads(); #if WITH_EDITOR @@ -366,15 +502,38 @@ void FUnrealEnginePythonModule::StartupModule() } else { - // TODO gracefully manage the error +#if PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 6 + if (PyErr_ExceptionMatches(PyExc_ModuleNotFoundError)) + { + UE_LOG(LogPython, Log, TEXT("ue_site Python module not found")); + PyErr_Clear(); + } + else + { + unreal_engine_py_log_error(); + } +#else unreal_engine_py_log_error(); +#endif } - // release the GIL - PythonGILRelease(); + for (FString ImportModule : ImportModules) + { + if (PyImport_ImportModule(TCHAR_TO_UTF8(*ImportModule))) + { + UE_LOG(LogPython, Log, TEXT("%s Python module successfully imported"), *ImportModule); + } + else + { + unreal_engine_py_log_error(); + } } + // release the GIL + PyThreadState *UEPyGlobalState = PyEval_SaveThread(); +} + void FUnrealEnginePythonModule::ShutdownModule() { // This function may be called during shutdown to clean up your module. For modules that support dynamic reloading, @@ -383,7 +542,7 @@ void FUnrealEnginePythonModule::ShutdownModule() UE_LOG(LogPython, Log, TEXT("Goodbye Python")); if (!BrutalFinalize) { - PythonGILAcquire(); + PyGILState_Ensure(); Py_Finalize(); } } @@ -391,17 +550,41 @@ void FUnrealEnginePythonModule::ShutdownModule() void FUnrealEnginePythonModule::RunString(char *str) { FScopePythonGIL gil; + PyObject *eval_ret = PyRun_String(str, Py_file_input, (PyObject *)main_dict, (PyObject *)local_dict); if (!eval_ret) { + if (PyErr_ExceptionMatches(PyExc_SystemExit)) + { + PyErr_Clear(); + return; + } unreal_engine_py_log_error(); return; } Py_DECREF(eval_ret); } +#if PLATFORM_MAC +void FUnrealEnginePythonModule::RunStringInMainThread(char *str) +{ + MainThreadCall(^{ + RunString(str); + }); +} + +void FUnrealEnginePythonModule::RunFileInMainThread(char *filename) +{ + MainThreadCall(^{ + RunFile(filename); + }); +} +#endif + FString FUnrealEnginePythonModule::Pep8ize(FString Code) { + FScopePythonGIL gil; + PyObject *pep8izer_module = PyImport_ImportModule("autopep8"); if (!pep8izer_module) { @@ -428,103 +611,92 @@ FString FUnrealEnginePythonModule::Pep8ize(FString Code) return Code; } - if (!PyUnicode_Check(ret)) + if (!PyUnicodeOrString_Check(ret)) { UE_LOG(LogPython, Error, TEXT("returned value is not a string")); // return the original string to avoid losing data return Code; } - char *pep8ized = PyUnicode_AsUTF8(ret); + const char *pep8ized = UEPyUnicode_AsUTF8(ret); FString NewCode = FString(pep8ized); Py_DECREF(ret); return NewCode; } -// run a python string in a new sub interpreter -void FUnrealEnginePythonModule::RunStringSandboxed(char *str) + +void FUnrealEnginePythonModule::RunFile(char *filename) { FScopePythonGIL gil; - - PyThreadState *_main = PyThreadState_Get(); - - PyThreadState *py_new_state = Py_NewInterpreter(); - if (!py_new_state) + FString full_path = UTF8_TO_TCHAR(filename); + FString original_path = full_path; + bool foundFile = false; + if (!FPaths::FileExists(filename)) { - UE_LOG(LogPython, Error, TEXT("Unable to create new Python interpreter")); - return; + for (FString ScriptsPath : ScriptsPaths) + { + full_path = FPaths::Combine(*ScriptsPath, original_path); + if (FPaths::FileExists(full_path)) + { + foundFile = true; + break; + } + } } - PyThreadState_Swap(nullptr); - PyThreadState_Swap(py_new_state); - - UESetupPythonInterpreter(false); - - setup_stdout_stderr(); - - PyObject *m = PyImport_AddModule("__main__"); - if (m == NULL) + else { - UE_LOG(LogPython, Error, TEXT("Unable to create new global dict")); - Py_EndInterpreter(py_new_state); - PyThreadState_Swap(_main); - return; -} - PyObject *global_dict = PyModule_GetDict(m); + foundFile = true; + } - PyObject *eval_ret = PyRun_String(str, Py_file_input, global_dict, global_dict); - if (!eval_ret) + if (!foundFile) { - unreal_engine_py_log_error(); - Py_EndInterpreter(py_new_state); - PyThreadState_Swap(_main); + UE_LOG(LogPython, Error, TEXT("Unable to find file %s"), UTF8_TO_TCHAR(filename)); return; } - Py_EndInterpreter(py_new_state); - PyThreadState_Swap(_main); -} - -void FUnrealEnginePythonModule::RunFile(char *filename) -{ - FScopePythonGIL gil; - char *full_path = filename; - if (!FPaths::FileExists(filename)) - { - full_path = TCHAR_TO_UTF8(*FPaths::Combine(*ScriptsPath, UTF8_TO_TCHAR(filename))); - } #if PY_MAJOR_VERSION >= 3 FILE *fd = nullptr; #if PLATFORM_WINDOWS - if (fopen_s(&fd, full_path, "r") != 0) + if (fopen_s(&fd, TCHAR_TO_UTF8(*full_path), "r") != 0) { - UE_LOG(LogPython, Error, TEXT("Unable to open file %s"), UTF8_TO_TCHAR(full_path)); + UE_LOG(LogPython, Error, TEXT("Unable to open file %s"), *full_path); return; } #else - fd = fopen(full_path, "r"); + fd = fopen(TCHAR_TO_UTF8(*full_path), "r"); if (!fd) { - UE_LOG(LogPython, Error, TEXT("Unable to open file %s"), UTF8_TO_TCHAR(full_path)); + UE_LOG(LogPython, Error, TEXT("Unable to open file %s"), *full_path); return; } #endif - PyObject *eval_ret = PyRun_File(fd, full_path, Py_file_input, (PyObject *)main_dict, (PyObject *)local_dict); + PyObject *eval_ret = PyRun_File(fd, TCHAR_TO_UTF8(*full_path), Py_file_input, (PyObject *)main_dict, (PyObject *)local_dict); fclose(fd); if (!eval_ret) { + if (PyErr_ExceptionMatches(PyExc_SystemExit)) + { + PyErr_Clear(); + return; + } unreal_engine_py_log_error(); return; } Py_DECREF(eval_ret); #else // damn, this is horrible, but it is the only way i found to avoid the CRT error :( - FString command = FString::Printf(TEXT("execfile(\"%s\")"), UTF8_TO_TCHAR(full_path)); + FString command = FString::Printf(TEXT("execfile(\"%s\")"), *full_path); PyObject *eval_ret = PyRun_String(TCHAR_TO_UTF8(*command), Py_file_input, (PyObject *)main_dict, (PyObject *)local_dict); if (!eval_ret) { + if (PyErr_ExceptionMatches(PyExc_SystemExit)) + { + PyErr_Clear(); + return; + } unreal_engine_py_log_error(); return; } @@ -532,90 +704,23 @@ void FUnrealEnginePythonModule::RunFile(char *filename) } -// run a python script in a new sub interpreter (useful for unit tests) -void FUnrealEnginePythonModule::RunFileSandboxed(char *filename, void(*callback)(void *arg), void *arg) -{ - FScopePythonGIL gil; - char *full_path = filename; - if (!FPaths::FileExists(filename)) - { - full_path = TCHAR_TO_UTF8(*FPaths::Combine(*ScriptsPath, UTF8_TO_TCHAR(filename))); - } - - PyThreadState *_main = PyThreadState_Get(); - - PyThreadState *py_new_state = Py_NewInterpreter(); - if (!py_new_state) - { - UE_LOG(LogPython, Error, TEXT("Unable to create new Python interpreter")); - return; - } - PyThreadState_Swap(nullptr); - PyThreadState_Swap(py_new_state); - - UESetupPythonInterpreter(false); - - setup_stdout_stderr(); - - PyObject *m = PyImport_AddModule("__main__"); - if (m == NULL) - { - UE_LOG(LogPython, Error, TEXT("Unable to create new global dict")); - Py_EndInterpreter(py_new_state); - PyThreadState_Swap(_main); - return; - } - PyObject *global_dict = PyModule_GetDict(m); - -#if PY_MAJOR_VERSION >= 3 - FILE *fd = nullptr; - -#if PLATFORM_WINDOWS - if (fopen_s(&fd, full_path, "r") != 0) - { - UE_LOG(LogPython, Error, TEXT("Unable to open file %s"), UTF8_TO_TCHAR(full_path)); - return; - } -#else - fd = fopen(full_path, "r"); - if (!fd) - { - UE_LOG(LogPython, Error, TEXT("Unable to open file %s"), UTF8_TO_TCHAR(full_path)); - return; - } -#endif - PyObject *eval_ret = PyRun_File(fd, full_path, Py_file_input, global_dict, global_dict); - fclose(fd); - if (!eval_ret) - { - unreal_engine_py_log_error(); - Py_EndInterpreter(py_new_state); - PyThreadState_Swap(_main); - return; - } - Py_DECREF(eval_ret); -#else - // damn, this is horrible, but it is the only way i found to avoid the CRT error :( - FString command = FString::Printf(TEXT("execfile(\"%s\")"), UTF8_TO_TCHAR(full_path)); - PyObject *eval_ret = PyRun_String(TCHAR_TO_UTF8(*command), Py_file_input, global_dict, global_dict); - if (!eval_ret) - { - unreal_engine_py_log_error(); - Py_EndInterpreter(py_new_state); - PyThreadState_Swap(_main); - return; - } -#endif +void ue_py_register_magic_module(char *name, PyObject *(*func)()) +{ + PyObject *py_sys = PyImport_ImportModule("sys"); + PyObject *py_sys_dict = PyModule_GetDict(py_sys); - if (callback) - callback(arg); + PyObject *py_sys_modules = PyDict_GetItemString(py_sys_dict, "modules"); + PyObject *u_module = func(); + Py_INCREF(u_module); + PyDict_SetItemString(py_sys_modules, name, u_module); +} - Py_EndInterpreter(py_new_state); - PyThreadState_Swap(_main); +PyObject *ue_py_register_module(const char *name) +{ + return PyImport_AddModule(name); } #undef LOCTEXT_NAMESPACE IMPLEMENT_MODULE(FUnrealEnginePythonModule, UnrealEnginePython) - diff --git a/Source/UnrealEnginePython/Private/UnrealEnginePythonPrivatePCH.h b/Source/UnrealEnginePython/Private/UnrealEnginePythonPrivatePCH.h deleted file mode 100644 index 6bd720b0a..000000000 --- a/Source/UnrealEnginePython/Private/UnrealEnginePythonPrivatePCH.h +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright 20Tab S.r.l. - -#pragma once - -//#define UEPY_MEMORY_DEBUG 1 -//#define UEPY_THREADING 1 - -#include "UnrealEnginePython.h" - -// You should place include statements to your module's private header files here. You only need to -// add includes for headers that are used in most of your module's source files though. - -#include "Engine.h" -#if WITH_EDITOR -#include "Editor.h" -#endif - -#include "Runtime/Launch/Resources/Version.h" - - -#if defined(UNREAL_ENGINE_PYTHON_ON_MAC) -#include -#include -#elif defined(UNREAL_ENGINE_PYTHON_ON_LINUX) -#include -#include -#else -#include -#include -#endif - -#include "UEPyModule.h" - -#include "Wrappers/UEPyESlateEnums.h" - -#include "Wrappers/UEPyFVector.h" -#include "Wrappers/UEPyFHitResult.h" -#include "Wrappers/UEPyFRotator.h" -#include "Wrappers/UEPyFTransform.h" -#include "Wrappers/UEPyFColor.h" -#include "Wrappers/UEPyFLinearColor.h" -#include "Wrappers/UEPyFSocket.h" -#include "Wrappers/UEPyFQuat.h" - -#include "Wrappers/UEPyFRawAnimSequenceTrack.h" - -#include "Wrappers/UEPyFRandomStream.h" - -#include "Wrappers/UEPyFPythonOutputDevice.h" -#include "Wrappers/UEPyFSoftSkinVertex.h" -#include "Wrappers/UEPyFMorphTargetDelta.h" -#include "Wrappers/UEPyFObjectThumbnail.h" - -#include "Wrappers/UEPyFViewportClient.h" -#if WITH_EDITOR -#include "Wrappers/UEPyFEditorViewportClient.h" -#endif - -#include "UEPyCallable.h" -#include "UEPyUClassesImporter.h" -#include "UEPyEnumsImporter.h" -#include "UEPyUStructsImporter.h" - -#include "UEPyUScriptStruct.h" - -#if WITH_EDITOR -#include "Wrappers/UEPyFAssetData.h" -#include "Wrappers/UEPyFARFilter.h" -#include "Wrappers/UEPyFRawMesh.h" -#include "Wrappers/UEPyFStringAssetReference.h" -#include "UObject/UEPyAnimSequence.h" -#include "Blueprint/UEPyEdGraphPin.h" -#include "UEPyIPlugin.h" -#include "CollectionManager/UEPyICollectionManager.h" -#include "MaterialEditorUtilities/UEPyFMaterialEditorUtilities.h" -#endif - -#include "Slate/UEPySlate.h" -#include "Http/UEPyIHttp.h" -#include "ConsoleManager/UEPyIConsoleManager.h" -#include "SlateApplication/UEPyFSlateApplication.h" -#include "Voice/UEPyIVoiceCapture.h" - -#include "PythonHouseKeeper.h" - - -#define ue_py_check(py_u) if (!FUnrealEnginePythonHouseKeeper::Get()->IsValidPyUObject(py_u))\ - return PyErr_Format(PyExc_Exception, "PyUObject is in invalid state") - -#define ue_py_check_int(py_u) if (!FUnrealEnginePythonHouseKeeper::Get()->IsValidPyUObject(py_u))\ - {\ - PyErr_SetString(PyExc_Exception, "PyUObject is in invalid state");\ - return -1;\ - } - -#if PY_MAJOR_VERSION < 3 -char *PyUnicode_AsUTF8(PyObject *py_str); -int PyGILState_Check(); -#endif -bool PyUnicodeOrString_Check(PyObject *py_obj); - -#define Py_RETURN_UOBJECT(py_uobj) ue_PyUObject *ret = ue_get_python_uobject_inc(py_uobj);\ - if (!ret)\ - return PyErr_Format(PyExc_Exception, "uobject is in invalid state");\ - return (PyObject *)ret; - -#define Py_RETURN_UOBJECT_NOINC(py_uobj) ue_PyUObject *ret = ue_get_python_uobject(py_uobj);\ - if (!ret)\ - return PyErr_Format(PyExc_Exception, "uobject is in invalid state");\ - return (PyObject *)ret; - -#if ENGINE_MINOR_VERSION < 16 -template -struct TStructOpsTypeTraitsBase2 : TStructOpsTypeTraitsBase -{ - -}; -#endif diff --git a/Source/UnrealEnginePython/Private/Voice/UEPyIVoiceCapture.cpp b/Source/UnrealEnginePython/Private/Voice/UEPyIVoiceCapture.cpp index 16233dbc1..6bba831b1 100644 --- a/Source/UnrealEnginePython/Private/Voice/UEPyIVoiceCapture.cpp +++ b/Source/UnrealEnginePython/Private/Voice/UEPyIVoiceCapture.cpp @@ -1,6 +1,4 @@ -#include "UnrealEnginePythonPrivatePCH.h" - #include "UEPyIVoiceCapture.h" diff --git a/Source/UnrealEnginePython/Private/Wrappers/UEPyESlateEnums.cpp b/Source/UnrealEnginePython/Private/Wrappers/UEPyESlateEnums.cpp index 71113bd09..7ffa2d05e 100644 --- a/Source/UnrealEnginePython/Private/Wrappers/UEPyESlateEnums.cpp +++ b/Source/UnrealEnginePython/Private/Wrappers/UEPyESlateEnums.cpp @@ -1,18 +1,20 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPyESlateEnums.h" + +#include "Runtime/Slate/Public/Framework/Commands/UICommandInfo.h" static PyObject *py_ue_eslate_enums_get(ue_PyESlateEnums *self, void *closure) { - return PyLong_FromLong(self->val); + return PyLong_FromLong(self->val); } static PyGetSetDef ue_PyESlateEnums_getseters[] = { - { (char*)"val", (getter)py_ue_eslate_enums_get, 0, (char *)"", NULL }, - { NULL } /* Sentinel */ + { (char*)"val", (getter)py_ue_eslate_enums_get, 0, (char *)"", NULL }, + { NULL } /* Sentinel */ }; static PyObject *ue_PyESlateEnums_str(ue_PyESlateEnums *self) { - return PyUnicode_FromFormat("", PyLong_FromLong(self->val)); + return PyUnicode_FromFormat("", PyLong_FromLong(self->val)); } static PyTypeObject ue_PyESlateEnumsType = { @@ -35,7 +37,7 @@ static PyTypeObject ue_PyESlateEnumsType = { 0, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ "Unreal Engine ESlateEnums", /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ @@ -45,54 +47,59 @@ static PyTypeObject ue_PyESlateEnumsType = { 0, /* tp_iternext */ 0, /* tp_methods */ 0, - ue_PyESlateEnums_getseters, + ue_PyESlateEnums_getseters, }; -static int ue_py_eslate_enums_init(ue_PyESlateEnums *self, PyObject *args, PyObject *kwargs) { - int val = 0; - if (!PyArg_ParseTuple(args, "i", &val)) - return -1; +static int ue_py_eslate_enums_init(ue_PyESlateEnums *self, PyObject *args, PyObject *kwargs) +{ + int val = 0; + if (!PyArg_ParseTuple(args, "i", &val)) + return -1; - self->val = val; - return 0; + self->val = val; + return 0; } void ue_python_init_eslate_enums(PyObject *ue_module) { - ue_PyESlateEnumsType.tp_new = PyType_GenericNew; + ue_PyESlateEnumsType.tp_new = PyType_GenericNew; - ue_PyESlateEnumsType.tp_init = (initproc)ue_py_eslate_enums_init; + ue_PyESlateEnumsType.tp_init = (initproc)ue_py_eslate_enums_init; - if (PyType_Ready(&ue_PyESlateEnumsType) < 0) - return; + if (PyType_Ready(&ue_PyESlateEnumsType) < 0) + return; - Py_INCREF(&ue_PyESlateEnumsType); - PyModule_AddObject(ue_module, "ESlateEnums", (PyObject *)&ue_PyESlateEnumsType); + Py_INCREF(&ue_PyESlateEnumsType); + PyModule_AddObject(ue_module, "ESlateEnums", (PyObject *)&ue_PyESlateEnumsType); - auto add_native_enum = [](const char *enum_name, uint8 val) - { - ue_PyESlateEnums* native_enum = (ue_PyESlateEnums *)PyObject_New(ue_PyESlateEnums, &ue_PyESlateEnumsType); - native_enum->val = val; - PyDict_SetItemString(ue_PyESlateEnumsType.tp_dict, enum_name, (PyObject *)native_enum); - }; + auto add_native_enum = [](const char *enum_name, uint8 val) + { + ue_PyESlateEnums* native_enum = (ue_PyESlateEnums *)PyObject_New(ue_PyESlateEnums, &ue_PyESlateEnumsType); + native_enum->val = val; + PyDict_SetItemString(ue_PyESlateEnumsType.tp_dict, enum_name, (PyObject *)native_enum); + }; #if ENGINE_MINOR_VERSION > 15 +#if ENGINE_MINOR_VERSION >= 23 +#define ADD_NATIVE_ENUM(EnumType, EnumVal) add_native_enum(#EnumType "." #EnumVal, (uint8)EnumType::EnumVal) +#else #define ADD_NATIVE_ENUM(EnumType, EnumVal) add_native_enum(#EnumType "." #EnumVal, (uint8)EnumType::Type::EnumVal) - ADD_NATIVE_ENUM(EUserInterfaceActionType, None ); - ADD_NATIVE_ENUM(EUserInterfaceActionType, Button ); - ADD_NATIVE_ENUM(EUserInterfaceActionType, ToggleButton ); - ADD_NATIVE_ENUM(EUserInterfaceActionType, RadioButton ); - ADD_NATIVE_ENUM(EUserInterfaceActionType, Check ); - ADD_NATIVE_ENUM(EUserInterfaceActionType, CollapsedButton); +#endif + ADD_NATIVE_ENUM(EUserInterfaceActionType, None); + ADD_NATIVE_ENUM(EUserInterfaceActionType, Button); + ADD_NATIVE_ENUM(EUserInterfaceActionType, ToggleButton); + ADD_NATIVE_ENUM(EUserInterfaceActionType, RadioButton); + ADD_NATIVE_ENUM(EUserInterfaceActionType, Check); + ADD_NATIVE_ENUM(EUserInterfaceActionType, CollapsedButton); #undef ADD_NATIVE_ENUM #endif - + } ue_PyESlateEnums *py_ue_is_eslate_enums(PyObject *obj) { - if (!PyObject_IsInstance(obj, (PyObject *)&ue_PyESlateEnumsType)) - return nullptr; - return (ue_PyESlateEnums *)obj; + if (!PyObject_IsInstance(obj, (PyObject *)&ue_PyESlateEnumsType)) + return nullptr; + return (ue_PyESlateEnums *)obj; } diff --git a/Source/UnrealEnginePython/Private/Wrappers/UEPyFARFilter.cpp b/Source/UnrealEnginePython/Private/Wrappers/UEPyFARFilter.cpp index c9d8e00d0..bbdc82b2d 100644 --- a/Source/UnrealEnginePython/Private/Wrappers/UEPyFARFilter.cpp +++ b/Source/UnrealEnginePython/Private/Wrappers/UEPyFARFilter.cpp @@ -1,4 +1,4 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPyFARFilter.h" #if WITH_EDITOR @@ -125,6 +125,8 @@ static int ue_py_farfilter_init(ue_PyFARFilter *self, PyObject *args, PyObject * static void ue_py_farfilter_dealloc(ue_PyFARFilter *self) { + self->filter.~FARFilter(); + Py_XDECREF(self->class_names); Py_XDECREF(self->object_paths); Py_XDECREF(self->package_names); @@ -132,11 +134,8 @@ static void ue_py_farfilter_dealloc(ue_PyFARFilter *self) Py_XDECREF(self->recursive_classes_exclusion_set); Py_XDECREF(self->tags_and_values); -#if PY_MAJOR_VERSION < 3 - self->ob_type->tp_free((PyObject*)self); -#else + Py_TYPE(self)->tp_free((PyObject*)self); -#endif } static PyObject * ue_py_farfilter_new(PyTypeObject *type, PyObject *args, PyObject *kwds) @@ -146,6 +145,9 @@ static PyObject * ue_py_farfilter_new(PyTypeObject *type, PyObject *args, PyObje self = (ue_PyFARFilter *)type->tp_alloc(type, 0); if (self != NULL) { + + new(&self->filter) FARFilter(); + self->class_names = PyList_New(0); if (self->class_names == NULL) { @@ -174,7 +176,7 @@ static PyObject * ue_py_farfilter_new(PyTypeObject *type, PyObject *args, PyObje return NULL; } - self->recursive_classes_exclusion_set = PySet_New(0); + self->recursive_classes_exclusion_set = PySet_New(NULL); if (self->recursive_classes_exclusion_set == NULL) { Py_DECREF(self); @@ -182,26 +184,41 @@ static PyObject * ue_py_farfilter_new(PyTypeObject *type, PyObject *args, PyObje } PyObject *collections = PyImport_ImportModule("collections"); + if (!collections) + { + unreal_engine_py_log_error(); + Py_DECREF(self); + return NULL; + } PyObject *collections_module_dict = PyModule_GetDict(collections); PyObject *defaultdict_cls = PyDict_GetItemString(collections_module_dict, "defaultdict"); - PyObject *main_module = PyImport_ImportModule("__main__"); - PyObject *main_dict = PyModule_GetDict(main_module); - PyObject *builtins_module = PyDict_GetItemString(main_dict, "__builtins__"); + + PyObject *builtins_module = PyImport_ImportModule("builtins"); + if (!builtins_module) + { + unreal_engine_py_log_error(); + Py_DECREF(self); + return NULL; + } PyObject *builtins_dict = PyModule_GetDict(builtins_module); PyObject *set_cls = PyDict_GetItemString(builtins_dict, "set"); + // required because PyTuple_SetItem below will steal a reference + Py_INCREF(set_cls); + PyObject *py_args = PyTuple_New(1); PyTuple_SetItem(py_args, 0, set_cls); PyObject *default_dict = PyObject_CallObject(defaultdict_cls, py_args); - Py_XDECREF(py_args); - - self->tags_and_values = default_dict; - if (self->tags_and_values == NULL) + Py_DECREF(py_args); + if (!default_dict) { + unreal_engine_py_log_error(); Py_DECREF(self); return NULL; } + + self->tags_and_values = default_dict; } return (PyObject *)self; @@ -297,7 +314,7 @@ void ue_sync_farfilter_name_array(PyObject *pylist, TArray &uelist) for (int i = 0; i < (int)pylist_len; i++) { PyObject *py_item = PyList_GetItem(pylist, i); - uelist.Add(FName(UTF8_TO_TCHAR(PyUnicode_AsUTF8(py_item)))); + uelist.Add(FName(UTF8_TO_TCHAR(UEPyUnicode_AsUTF8(py_item)))); } } @@ -316,7 +333,7 @@ void py_ue_sync_farfilter(PyObject *pyobj) for (int i = 0; i < (int)pyset_len; i++) { py_item = PyList_GetItem(pyset, i); - pyfilter->filter.RecursiveClassesExclusionSet.Add(FName(UTF8_TO_TCHAR(PyUnicode_AsUTF8(py_item)))); + pyfilter->filter.RecursiveClassesExclusionSet.Add(FName(UTF8_TO_TCHAR(UEPyUnicode_AsUTF8(py_item)))); } PyObject *pykey, *pyvalue; @@ -325,12 +342,16 @@ void py_ue_sync_farfilter(PyObject *pyobj) pyfilter->filter.TagsAndValues.Reset(); while (PyDict_Next(pyfilter->tags_and_values, &pypos, &pykey, &pyvalue)) { - ukey = UTF8_TO_TCHAR(PyUnicode_AsUTF8(pykey)); + ukey = UTF8_TO_TCHAR(UEPyUnicode_AsUTF8(pykey)); pyset_len = PySet_Size(pyvalue); for (int i = 0; i < (int)pyset_len; i++) { py_item = PyList_GetItem(pyset, i); - pyfilter->filter.TagsAndValues.AddUnique(ukey, UTF8_TO_TCHAR(PyUnicode_AsUTF8(py_item))); +#if ENGINE_MINOR_VERSION < 20 + pyfilter->filter.TagsAndValues.AddUnique(ukey, UTF8_TO_TCHAR(UEPyUnicode_AsUTF8(py_item))); +#else + pyfilter->filter.TagsAndValues.AddUnique(ukey, FString(UTF8_TO_TCHAR(UEPyUnicode_AsUTF8(py_item)))); +#endif } } } diff --git a/Source/UnrealEnginePython/Private/Wrappers/UEPyFARFilter.h b/Source/UnrealEnginePython/Private/Wrappers/UEPyFARFilter.h index 3f237af14..bd8a525a6 100644 --- a/Source/UnrealEnginePython/Private/Wrappers/UEPyFARFilter.h +++ b/Source/UnrealEnginePython/Private/Wrappers/UEPyFARFilter.h @@ -1,15 +1,16 @@ #pragma once -#include "UnrealEnginePython.h" +#include "UEPyModule.h" #if WITH_EDITOR #include "AssetRegistryModule.h" #include "Runtime/AssetRegistry/Public/ARFilter.h" -typedef struct { +typedef struct +{ PyObject_HEAD - /* Type-specific fields go here. */ - FARFilter filter; + /* Type-specific fields go here. */ + FARFilter filter; PyObject *class_names; PyObject *object_paths; PyObject *package_names; diff --git a/Source/UnrealEnginePython/Private/Wrappers/UEPyFAssetData.cpp b/Source/UnrealEnginePython/Private/Wrappers/UEPyFAssetData.cpp index ea4251cc0..6cb186f8b 100644 --- a/Source/UnrealEnginePython/Private/Wrappers/UEPyFAssetData.cpp +++ b/Source/UnrealEnginePython/Private/Wrappers/UEPyFAssetData.cpp @@ -1,8 +1,9 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPyFAssetData.h" #if WITH_EDITOR #include "ObjectTools.h" +#include "Wrappers/UEPyFObjectThumbnail.h" static PyObject *py_ue_fassetdata_get_asset(ue_PyFAssetData *self, PyObject * args) { diff --git a/Source/UnrealEnginePython/Private/Wrappers/UEPyFAssetData.h b/Source/UnrealEnginePython/Private/Wrappers/UEPyFAssetData.h index 32bccc070..76837892a 100644 --- a/Source/UnrealEnginePython/Private/Wrappers/UEPyFAssetData.h +++ b/Source/UnrealEnginePython/Private/Wrappers/UEPyFAssetData.h @@ -1,12 +1,14 @@ #pragma once -#include "UnrealEnginePython.h" + +#include "UEPyModule.h" #if WITH_EDITOR -struct ue_PyFAssetData { +struct ue_PyFAssetData +{ PyObject_HEAD - /* Type-specific fields go here. */ - FAssetData asset_data; + /* Type-specific fields go here. */ + FAssetData asset_data; }; PyObject *py_ue_new_fassetdata(FAssetData); diff --git a/Source/UnrealEnginePython/Private/Wrappers/UEPyFColor.cpp b/Source/UnrealEnginePython/Private/Wrappers/UEPyFColor.cpp index f57609c41..0105dd254 100644 --- a/Source/UnrealEnginePython/Private/Wrappers/UEPyFColor.cpp +++ b/Source/UnrealEnginePython/Private/Wrappers/UEPyFColor.cpp @@ -1,4 +1,4 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPyFColor.h" static PyObject *py_ue_fcolor_to_hex(ue_PyFColor *self, PyObject * args) { @@ -103,7 +103,7 @@ static PyObject *ue_PyFColor_str(ue_PyFColor *self) self->color.R, self->color.G, self->color.B, self->color.A); } -static PyTypeObject ue_PyFColorType = { +PyTypeObject ue_PyFColorType = { PyVarObject_HEAD_INIT(NULL, 0) "unreal_engine.FColor", /* tp_name */ sizeof(ue_PyFColor), /* tp_basicsize */ diff --git a/Source/UnrealEnginePython/Private/Wrappers/UEPyFColor.h b/Source/UnrealEnginePython/Private/Wrappers/UEPyFColor.h index 51b5c5c56..d3a1013e7 100644 --- a/Source/UnrealEnginePython/Private/Wrappers/UEPyFColor.h +++ b/Source/UnrealEnginePython/Private/Wrappers/UEPyFColor.h @@ -2,14 +2,17 @@ -#include "UnrealEnginePython.h" +#include "UEPyModule.h" -typedef struct { +typedef struct +{ PyObject_HEAD - /* Type-specific fields go here. */ - FColor color; + /* Type-specific fields go here. */ + FColor color; } ue_PyFColor; +extern PyTypeObject ue_PyFColorType; + PyObject *py_ue_new_fcolor(FColor); ue_PyFColor *py_ue_is_fcolor(PyObject *); @@ -17,4 +20,4 @@ void ue_python_init_fcolor(PyObject *); bool py_ue_color_arg(PyObject *, FColor &); -bool py_ue_get_fcolor(PyObject *, FColor &); \ No newline at end of file +bool py_ue_get_fcolor(PyObject *, FColor &); diff --git a/Source/UnrealEnginePython/Private/Wrappers/UEPyFEditorViewportClient.cpp b/Source/UnrealEnginePython/Private/Wrappers/UEPyFEditorViewportClient.cpp index 6a30692df..43aff5748 100644 --- a/Source/UnrealEnginePython/Private/Wrappers/UEPyFEditorViewportClient.cpp +++ b/Source/UnrealEnginePython/Private/Wrappers/UEPyFEditorViewportClient.cpp @@ -1,7 +1,8 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPyFEditorViewportClient.h" #if WITH_EDITOR + static PyObject *py_ue_feditor_viewport_client_take_high_res_screen_shot(ue_PyFEditorViewportClient *self, PyObject * args) { self->editor_viewport_client->TakeHighResScreenShot(); @@ -36,6 +37,11 @@ static PyObject *py_ue_feditor_viewport_client_get_view_location(ue_PyFEditorVie return py_ue_new_fvector(self->editor_viewport_client->GetViewLocation()); } +static PyObject *py_ue_feditor_viewport_client_get_view_rotation(ue_PyFEditorViewportClient *self, PyObject * args) +{ + return py_ue_new_frotator(self->editor_viewport_client->GetViewRotation()); +} + static PyObject *py_ue_feditor_viewport_client_get_camera_speed(ue_PyFEditorViewportClient *self, PyObject * args) { return PyFloat_FromDouble(self->editor_viewport_client->GetCameraSpeed()); @@ -83,16 +89,25 @@ static PyObject *py_ue_feditor_viewport_client_set_view_location(ue_PyFEditorVie Py_RETURN_NONE; } +static PyObject *py_ue_feditor_viewport_client_set_view_rotation(ue_PyFEditorViewportClient *self, PyObject * args) +{ + FRotator rot; + if (!py_ue_rotator_arg(args, rot)) + return PyErr_Format(PyExc_Exception, "argument is not a FRotator"); + self->editor_viewport_client->SetViewRotation(rot); + Py_RETURN_NONE; +} + static PyObject *py_ue_feditor_viewport_client_set_realtime(ue_PyFEditorViewportClient *self, PyObject * args) { - PyObject* bInRealtime; - PyObject* bStoreCurrentValue; - if (!PyArg_ParseTuple(args, "OO", &bInRealtime, &bStoreCurrentValue)) - return nullptr; + PyObject* bInRealtime; + PyObject* bStoreCurrentValue; + if (!PyArg_ParseTuple(args, "OO", &bInRealtime, &bStoreCurrentValue)) + return nullptr; - self->editor_viewport_client->SetRealtime(PyObject_IsTrue(bInRealtime) ? true : false, - PyObject_IsTrue(bStoreCurrentValue) ? true : false); - Py_RETURN_NONE; + self->editor_viewport_client->SetRealtime(PyObject_IsTrue(bInRealtime) ? true : false, + PyObject_IsTrue(bStoreCurrentValue) ? true : false); + Py_RETURN_NONE; } static PyMethodDef ue_PyFEditorViewportClient_methods[] = { @@ -100,13 +115,15 @@ static PyMethodDef ue_PyFEditorViewportClient_methods[] = { { "tick", (PyCFunction)py_ue_feditor_viewport_client_tick, METH_VARARGS, "" }, { "get_look_at_location", (PyCFunction)py_ue_feditor_viewport_client_get_look_at_location, METH_VARARGS, "" }, { "get_view_location", (PyCFunction)py_ue_feditor_viewport_client_get_view_location, METH_VARARGS, "" }, + { "get_view_rotation", (PyCFunction)py_ue_feditor_viewport_client_get_view_location, METH_VARARGS, "" }, { "get_camera_speed", (PyCFunction)py_ue_feditor_viewport_client_get_camera_speed, METH_VARARGS, "" }, { "get_viewport_dimensions", (PyCFunction)py_ue_feditor_viewport_client_get_viewport_dimensions, METH_VARARGS, "" }, { "is_visible", (PyCFunction)py_ue_feditor_viewport_client_is_visible, METH_VARARGS, "" }, { "get_scene_depth_at_location", (PyCFunction)py_ue_feditor_viewport_client_get_scene_depth_at_location, METH_VARARGS, "" }, { "set_look_at_location", (PyCFunction)py_ue_feditor_viewport_client_set_look_at_location, METH_VARARGS, "" }, { "set_view_location", (PyCFunction)py_ue_feditor_viewport_client_set_view_location, METH_VARARGS, "" }, - { "set_realtime", (PyCFunction)py_ue_feditor_viewport_client_set_realtime, METH_VARARGS, "" }, + { "set_view_rotation", (PyCFunction)py_ue_feditor_viewport_client_set_view_rotation, METH_VARARGS, "" }, + { "set_realtime", (PyCFunction)py_ue_feditor_viewport_client_set_realtime, METH_VARARGS, "" }, { nullptr } /* Sentinel */ }; diff --git a/Source/UnrealEnginePython/Private/Wrappers/UEPyFEditorViewportClient.h b/Source/UnrealEnginePython/Private/Wrappers/UEPyFEditorViewportClient.h index e36a9afa5..86efd709b 100644 --- a/Source/UnrealEnginePython/Private/Wrappers/UEPyFEditorViewportClient.h +++ b/Source/UnrealEnginePython/Private/Wrappers/UEPyFEditorViewportClient.h @@ -1,7 +1,15 @@ #pragma once #include "UnrealEnginePython.h" -struct ue_PyFEditorViewportClient { +#if WITH_EDITOR + +#include "Wrappers/UEPyFViewportClient.h" + + +#include "Editor/UnrealEd/Public/EditorViewportClient.h" + +struct ue_PyFEditorViewportClient +{ ue_PyFViewportClient viewport_client; /* Type-specific fields go here. */ TSharedRef editor_viewport_client;; @@ -12,3 +20,5 @@ void ue_python_init_feditor_viewport_client(PyObject *); PyObject *py_ue_new_feditor_viewport_client(TSharedRef); ue_PyFEditorViewportClient *py_ue_is_feditor_viewport_client(PyObject *); + +#endif \ No newline at end of file diff --git a/Source/UnrealEnginePython/Private/Wrappers/UEPyFFoliageInstance.cpp b/Source/UnrealEnginePython/Private/Wrappers/UEPyFFoliageInstance.cpp new file mode 100644 index 000000000..2ed7ffa2d --- /dev/null +++ b/Source/UnrealEnginePython/Private/Wrappers/UEPyFFoliageInstance.cpp @@ -0,0 +1,280 @@ +#include "UEPyFFoliageInstance.h" + +#include "Wrappers/UEPyFVector.h" +#include "Wrappers/UEPyFRotator.h" +#include "Wrappers/UEPyFTransform.h" +#include "Components/ActorComponent.h" +#include "Runtime/Foliage/Public/InstancedFoliageActor.h" + +#if WITH_EDITOR + +#define get_instance(x) FFoliageInstance *instance = get_foliage_instance(x);\ + if (!instance)\ + return nullptr; + +#define set_instance(x) FFoliageInstance *instance = get_foliage_instance(x);\ + if (!instance)\ + return -1; + + + +static FFoliageInstance* get_foliage_instance(ue_PyFFoliageInstance* self) +{ + if (!self->foliage_actor.IsValid()) + { + PyErr_SetString(PyExc_Exception, "AInstancedFoliageActor is in invalid state"); + return nullptr; + } + + if (!self->foliage_type.IsValid()) + { + PyErr_SetString(PyExc_Exception, "UFoliageType is in invalid state"); + return nullptr; + } + +#if ENGINE_MINOR_VERSION >= 23 + FFoliageInfo& info = self->foliage_actor->FoliageInfos[self->foliage_type.Get()].Get(); +#else + + FFoliageMeshInfo& info = self->foliage_actor->FoliageMeshes[self->foliage_type.Get()].Get(); +#endif + + if (self->instance_id >= 0 && self->instance_id < info.Instances.Num()) + { + return &info.Instances[self->instance_id]; + } + + PyErr_SetString(PyExc_Exception, "invalid foliage instance id"); + return nullptr; +} + +static PyObject* ue_PyFFoliageInstance_str(ue_PyFFoliageInstance* self) +{ + return PyUnicode_FromFormat("", + self->instance_id); +} + + +static PyObject* py_ue_ffoliage_instance_get_location(ue_PyFFoliageInstance* self, void* closure) +{ + get_instance(self); + return py_ue_new_fvector(instance->Location); +} + +static int py_ue_ffoliage_instance_set_location(ue_PyFFoliageInstance* self, PyObject* value, void* closure) +{ + set_instance(self); + if (value) + { + ue_PyFVector* vec = py_ue_is_fvector(value); + if (vec) + { + TArray instances; + instances.Add(self->instance_id); +#if ENGINE_MINOR_VERSION >= 23 + FFoliageInfo& info = self->foliage_actor->FoliageInfos[self->foliage_type.Get()].Get(); +#else + FFoliageMeshInfo& info = self->foliage_actor->FoliageMeshes[self->foliage_type.Get()].Get(); +#endif + info.PreMoveInstances(self->foliage_actor.Get(), instances); + instance->Location = vec->vec; + info.PostMoveInstances(self->foliage_actor.Get(), instances); + return 0; + } + } + PyErr_SetString(PyExc_TypeError, "value is not an FVector"); + return -1; +} + +static int py_ue_ffoliage_instance_set_rotation(ue_PyFFoliageInstance* self, PyObject* value, void* closure) +{ + set_instance(self); + if (value) + { + ue_PyFRotator* rot = py_ue_is_frotator(value); + if (rot) + { + TArray instances; + instances.Add(self->instance_id); +#if ENGINE_MINOR_VERSION >= 23 + FFoliageInfo& info = self->foliage_actor->FoliageInfos[self->foliage_type.Get()].Get(); +#else + FFoliageMeshInfo& info = self->foliage_actor->FoliageMeshes[self->foliage_type.Get()].Get(); +#endif + info.PreMoveInstances(self->foliage_actor.Get(), instances); + instance->Rotation = rot->rot; + info.PostMoveInstances(self->foliage_actor.Get(), instances); + return 0; + } + } + PyErr_SetString(PyExc_TypeError, "value is not an FRotator"); + return -1; +} + +static PyObject* py_ue_ffoliage_instance_get_draw_scale3d(ue_PyFFoliageInstance* self, void* closure) +{ + get_instance(self); + return py_ue_new_fvector(instance->DrawScale3D); +} + +static PyObject* py_ue_ffoliage_instance_get_flags(ue_PyFFoliageInstance* self, void* closure) +{ + get_instance(self); + return PyLong_FromUnsignedLong(instance->Flags); +} + +static PyObject* py_ue_ffoliage_instance_get_pre_align_rotation(ue_PyFFoliageInstance* self, void* closure) +{ + get_instance(self); + return py_ue_new_frotator(instance->PreAlignRotation); +} + +static PyObject* py_ue_ffoliage_instance_get_rotation(ue_PyFFoliageInstance* self, void* closure) +{ + get_instance(self); + return py_ue_new_frotator(instance->Rotation); +} + +static PyObject* py_ue_ffoliage_instance_get_zoffset(ue_PyFFoliageInstance* self, void* closure) +{ + get_instance(self); + return PyFloat_FromDouble(instance->ZOffset); +} + +static PyObject* py_ue_ffoliage_instance_get_procedural_guid(ue_PyFFoliageInstance* self, void* closure) +{ + get_instance(self); + FGuid guid = instance->ProceduralGuid; + return py_ue_new_owned_uscriptstruct(FindObject(ANY_PACKAGE, UTF8_TO_TCHAR((char*)"Guid")), (uint8*)& guid); +} + +static PyObject* py_ue_ffoliage_instance_get_base_id(ue_PyFFoliageInstance* self, void* closure) +{ + get_instance(self); + return PyLong_FromLong(instance->BaseId); +} + +static PyObject* py_ue_ffoliage_instance_get_instance_id(ue_PyFFoliageInstance* self, void* closure) +{ + return PyLong_FromLong(self->instance_id); +} + +#if ENGINE_MINOR_VERSION > 19 +static PyObject * py_ue_ffoliage_instance_get_base_component(ue_PyFFoliageInstance * self, void* closure) +{ + get_instance(self); + Py_RETURN_UOBJECT(instance->BaseComponent); +} +#endif + + + +static PyGetSetDef ue_PyFFoliageInstance_getseters[] = { + { (char*)"location", (getter)py_ue_ffoliage_instance_get_location, (setter)py_ue_ffoliage_instance_set_location, (char*)"", NULL }, + { (char*)"draw_scale3d", (getter)py_ue_ffoliage_instance_get_draw_scale3d, nullptr, (char*)"", NULL }, + { (char*)"flags", (getter)py_ue_ffoliage_instance_get_flags, nullptr, (char*)"", NULL }, + { (char*)"pre_align_rotation", (getter)py_ue_ffoliage_instance_get_pre_align_rotation, nullptr, (char*)"", NULL }, + { (char*)"rotation", (getter)py_ue_ffoliage_instance_get_rotation, (setter)py_ue_ffoliage_instance_set_rotation, (char*)"", NULL }, + { (char*)"zoffset", (getter)py_ue_ffoliage_instance_get_zoffset, nullptr, (char*)"", NULL }, + { (char*)"procedural_guid", (getter)py_ue_ffoliage_instance_get_procedural_guid, nullptr, (char*)"", NULL }, + { (char*)"guid", (getter)py_ue_ffoliage_instance_get_procedural_guid, nullptr, (char*)"", NULL }, + { (char*)"base_id", (getter)py_ue_ffoliage_instance_get_base_id, nullptr, (char*)"", NULL }, + { (char*)"instance_id", (getter)py_ue_ffoliage_instance_get_instance_id, nullptr, (char*)"", NULL }, +#if ENGINE_MINOR_VERSION > 19 + { (char*)"base_component", (getter)py_ue_ffoliage_instance_get_base_component, nullptr, (char*)"", NULL }, +#endif + { NULL } /* Sentinel */ +}; + +static PyObject* py_ue_ffoliage_instance_get_instance_world_transform(ue_PyFFoliageInstance* self, PyObject* args) +{ + get_instance(self); + return py_ue_new_ftransform(instance->GetInstanceWorldTransform()); +} + +static PyObject* py_ue_ffoliage_instance_align_to_normal(ue_PyFFoliageInstance* self, PyObject* args) +{ + get_instance(self); + + PyObject* py_vec; + float align_max_angle = 0; + + if (!PyArg_ParseTuple(args, "O|f:align_to_normal", &py_vec, &align_max_angle)) + return nullptr; + + ue_PyFVector* vec = py_ue_is_fvector(py_vec); + if (!vec) + { + return PyErr_Format(PyExc_Exception, "argument is not an FVector"); + } + + instance->AlignToNormal(vec->vec, align_max_angle); + + Py_RETURN_NONE; +} + + +static PyMethodDef ue_PyFFoliageInstance_methods[] = { + { "get_instance_world_transform", (PyCFunction)py_ue_ffoliage_instance_get_instance_world_transform, METH_VARARGS, "" }, + { "align_to_normal", (PyCFunction)py_ue_ffoliage_instance_align_to_normal, METH_VARARGS, "" }, + { NULL } /* Sentinel */ +}; + +static PyTypeObject ue_PyFFoliageInstanceType = { + PyVarObject_HEAD_INIT(NULL, 0) + "unreal_engine.FFoliageInstance", /* tp_name */ + sizeof(ue_PyFFoliageInstance), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc)ue_PyFFoliageInstance_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ +#if PY_MAJOR_VERSION < 3 + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_CHECKTYPES, /* tp_flags */ +#else + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ +#endif + "Unreal Engine FFoliageInstance", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + ue_PyFFoliageInstance_methods, /* tp_methods */ + 0, + ue_PyFFoliageInstance_getseters, +}; + +void ue_python_init_ffoliage_instance(PyObject* ue_module) +{ + ue_PyFFoliageInstanceType.tp_new = PyType_GenericNew; + + if (PyType_Ready(&ue_PyFFoliageInstanceType) < 0) + return; + + Py_INCREF(&ue_PyFFoliageInstanceType); + PyModule_AddObject(ue_module, "FoliageInstance", (PyObject*)& ue_PyFFoliageInstanceType); +} + +PyObject* py_ue_new_ffoliage_instance(AInstancedFoliageActor* foliage_actor, UFoliageType* foliage_type, int32 instance_id) +{ + ue_PyFFoliageInstance* ret = (ue_PyFFoliageInstance*)PyObject_New(ue_PyFFoliageInstance, &ue_PyFFoliageInstanceType); + ret->foliage_actor = TWeakObjectPtr(foliage_actor); + ret->foliage_type = TWeakObjectPtr(foliage_type); + ret->instance_id = instance_id; + return (PyObject*)ret; +} + +#endif \ No newline at end of file diff --git a/Source/UnrealEnginePython/Private/Wrappers/UEPyFFoliageInstance.h b/Source/UnrealEnginePython/Private/Wrappers/UEPyFFoliageInstance.h new file mode 100644 index 000000000..ab65fc3c8 --- /dev/null +++ b/Source/UnrealEnginePython/Private/Wrappers/UEPyFFoliageInstance.h @@ -0,0 +1,18 @@ +#pragma once +#include "UnrealEnginePython.h" + +#if WITH_EDITOR +#include "InstancedFoliage.h" + +typedef struct +{ + PyObject_HEAD + TWeakObjectPtr foliage_actor; + TWeakObjectPtr foliage_type; + int32 instance_id; +} ue_PyFFoliageInstance; + +void ue_python_init_ffoliage_instance(PyObject *); + +PyObject *py_ue_new_ffoliage_instance(AInstancedFoliageActor *foliage_actor, UFoliageType *foliage_type, int32 instance_id); +#endif diff --git a/Source/UnrealEnginePython/Private/Wrappers/UEPyFFrameNumber.cpp b/Source/UnrealEnginePython/Private/Wrappers/UEPyFFrameNumber.cpp new file mode 100644 index 000000000..b2dc0a0df --- /dev/null +++ b/Source/UnrealEnginePython/Private/Wrappers/UEPyFFrameNumber.cpp @@ -0,0 +1,83 @@ +#include "UEPyFFrameNumber.h" + +#if ENGINE_MINOR_VERSION >= 20 + +static PyObject *ue_PyFFrameNumber_str(ue_PyFFrameNumber *self) +{ + return PyUnicode_FromFormat("", + self->frame_number.Value); +} + +static PyTypeObject ue_PyFFrameNumberType = { + PyVarObject_HEAD_INIT(NULL, 0) + "unreal_engine.FFrameNumber", /* tp_name */ + sizeof(ue_PyFFrameNumber), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc)ue_PyFFrameNumber_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ +#if PY_MAJOR_VERSION < 3 + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES, /* tp_flags */ +#else + Py_TPFLAGS_DEFAULT, /* tp_flags */ +#endif + "Unreal Engine FFrameNumber", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + 0, + 0, +}; + +static int py_ue_fframe_number_init(ue_PyFFrameNumber *self, PyObject * args) +{ + int value = 0; + if (!PyArg_ParseTuple(args, "i", &value)) + return -1; + new(&self->frame_number) FFrameNumber(value); + return 0; +} + +void ue_python_init_fframe_number(PyObject *ue_module) +{ + ue_PyFFrameNumberType.tp_new = PyType_GenericNew; + ue_PyFFrameNumberType.tp_init = (initproc)py_ue_fframe_number_init; + + if (PyType_Ready(&ue_PyFFrameNumberType) < 0) + return; + + Py_INCREF(&ue_PyFFrameNumberType); + PyModule_AddObject(ue_module, "FFrameNumber", (PyObject *)&ue_PyFFrameNumberType); +} + +ue_PyFFrameNumber *py_ue_is_fframe_number(PyObject *obj) +{ + if (!PyObject_IsInstance(obj, (PyObject *)&ue_PyFFrameNumberType)) + return nullptr; + return (ue_PyFFrameNumber *)obj; +} + +PyObject *py_ue_new_fframe_number(FFrameNumber frame_number) +{ + ue_PyFFrameNumber *ret = (ue_PyFFrameNumber *)PyObject_New(ue_PyFFrameNumber, &ue_PyFFrameNumberType); + new(&ret->frame_number) FFrameNumber(frame_number); + return (PyObject *)ret; +} + +#endif diff --git a/Source/UnrealEnginePython/Private/Wrappers/UEPyFFrameNumber.h b/Source/UnrealEnginePython/Private/Wrappers/UEPyFFrameNumber.h new file mode 100644 index 000000000..33bb29b1a --- /dev/null +++ b/Source/UnrealEnginePython/Private/Wrappers/UEPyFFrameNumber.h @@ -0,0 +1,19 @@ +#pragma once +#include "UnrealEnginePython.h" + +#if ENGINE_MINOR_VERSION >= 20 + +#include "Runtime/Core/Public/Misc/FrameNumber.h" + +struct ue_PyFFrameNumber { + PyObject_HEAD + /* Type-specific fields go here. */ + FFrameNumber frame_number; +}; + +void ue_python_init_fframe_number(PyObject *); + +PyObject *py_ue_new_fframe_number(FFrameNumber); + +ue_PyFFrameNumber *py_ue_is_fframe_number(PyObject *); +#endif diff --git a/Source/UnrealEnginePython/Private/Wrappers/UEPyFHitResult.cpp b/Source/UnrealEnginePython/Private/Wrappers/UEPyFHitResult.cpp index 6aeb0ce83..0ca0277e5 100644 --- a/Source/UnrealEnginePython/Private/Wrappers/UEPyFHitResult.cpp +++ b/Source/UnrealEnginePython/Private/Wrappers/UEPyFHitResult.cpp @@ -1,5 +1,6 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPyFHitResult.h" +#include "GameFramework/Actor.h" static PyObject *py_ue_fhitresult_get_reversed_hit(ue_PyFHitResult *self, PyObject * args) { diff --git a/Source/UnrealEnginePython/Private/Wrappers/UEPyFHitResult.h b/Source/UnrealEnginePython/Private/Wrappers/UEPyFHitResult.h index c3180d244..0ab274626 100644 --- a/Source/UnrealEnginePython/Private/Wrappers/UEPyFHitResult.h +++ b/Source/UnrealEnginePython/Private/Wrappers/UEPyFHitResult.h @@ -2,12 +2,15 @@ -#include "UnrealEnginePython.h" +#include "UEPyModule.h" -typedef struct { +#include "Engine/EngineTypes.h" + +typedef struct +{ PyObject_HEAD - /* Type-specific fields go here. */ - FHitResult hit; + /* Type-specific fields go here. */ + FHitResult hit; } ue_PyFHitResult; PyObject *py_ue_new_fhitresult(FHitResult); diff --git a/Source/UnrealEnginePython/Private/Wrappers/UEPyFLinearColor.cpp b/Source/UnrealEnginePython/Private/Wrappers/UEPyFLinearColor.cpp index d9537a0bd..5ca0eb83a 100644 --- a/Source/UnrealEnginePython/Private/Wrappers/UEPyFLinearColor.cpp +++ b/Source/UnrealEnginePython/Private/Wrappers/UEPyFLinearColor.cpp @@ -1,4 +1,4 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPyFLinearColor.h" static PyObject *py_ue_flinearcolor_to_fcolor(ue_PyFLinearColor *self, PyObject * args) { @@ -106,7 +106,7 @@ static PyObject *ue_PyFLinearColor_str(ue_PyFLinearColor *self) PyFloat_FromDouble(self->color.A)); } -static PyTypeObject ue_PyFLinearColorType = { +PyTypeObject ue_PyFLinearColorType = { PyVarObject_HEAD_INIT(NULL, 0) "unreal_engine.FLinearColor", /* tp_name */ sizeof(ue_PyFLinearColor), /* tp_basicsize */ diff --git a/Source/UnrealEnginePython/Private/Wrappers/UEPyFLinearColor.h b/Source/UnrealEnginePython/Private/Wrappers/UEPyFLinearColor.h index f1185b745..2ade8c420 100644 --- a/Source/UnrealEnginePython/Private/Wrappers/UEPyFLinearColor.h +++ b/Source/UnrealEnginePython/Private/Wrappers/UEPyFLinearColor.h @@ -2,14 +2,17 @@ -#include "UnrealEnginePython.h" +#include "UEPyModule.h" -typedef struct { +typedef struct +{ PyObject_HEAD - /* Type-specific fields go here. */ - FLinearColor color; + /* Type-specific fields go here. */ + FLinearColor color; } ue_PyFLinearColor; +extern PyTypeObject ue_PyFLinearColorType; + PyObject *py_ue_new_flinearcolor(FLinearColor); ue_PyFLinearColor *py_ue_is_flinearcolor(PyObject *); @@ -17,4 +20,4 @@ void ue_python_init_flinearcolor(PyObject *); bool py_ue_linearcolor_arg(PyObject *, FLinearColor &); -bool py_ue_get_flinearcolor(PyObject *, FLinearColor &); \ No newline at end of file +bool py_ue_get_flinearcolor(PyObject *, FLinearColor &); diff --git a/Source/UnrealEnginePython/Private/Wrappers/UEPyFMorphTargetDelta.cpp b/Source/UnrealEnginePython/Private/Wrappers/UEPyFMorphTargetDelta.cpp index 0b39d4073..1c697717a 100644 --- a/Source/UnrealEnginePython/Private/Wrappers/UEPyFMorphTargetDelta.cpp +++ b/Source/UnrealEnginePython/Private/Wrappers/UEPyFMorphTargetDelta.cpp @@ -1,4 +1,4 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPyFMorphTargetDelta.h" static PyObject *py_ue_fmorph_target_delta_get_position_delta(ue_PyFMorphTargetDelta *self, void *closure) { @@ -73,7 +73,7 @@ static PyObject *ue_PyFMorphTargetDelta_str(ue_PyFMorphTargetDelta *self) static PyTypeObject ue_PyFMorphTargetDeltaType = { PyVarObject_HEAD_INIT(NULL, 0) "unreal_engine.FMorphTargetDelta", /* tp_name */ - sizeof(ue_PyFSoftSkinVertex), /* tp_basicsize */ + sizeof(ue_PyFMorphTargetDelta), /* tp_basicsize */ 0, /* tp_itemsize */ 0, /* tp_dealloc */ 0, /* tp_print */ diff --git a/Source/UnrealEnginePython/Private/Wrappers/UEPyFMorphTargetDelta.h b/Source/UnrealEnginePython/Private/Wrappers/UEPyFMorphTargetDelta.h index 4b0c81788..77ce41314 100644 --- a/Source/UnrealEnginePython/Private/Wrappers/UEPyFMorphTargetDelta.h +++ b/Source/UnrealEnginePython/Private/Wrappers/UEPyFMorphTargetDelta.h @@ -1,6 +1,8 @@ #pragma once #include "UnrealEnginePython.h" +#include "Wrappers/UEPyFVector.h" + #if ENGINE_MINOR_VERSION > 12 #include "Runtime/Engine/Classes/Animation/MorphTarget.h" diff --git a/Source/UnrealEnginePython/Private/Wrappers/UEPyFObjectThumbnail.cpp b/Source/UnrealEnginePython/Private/Wrappers/UEPyFObjectThumbnail.cpp index 6a41265a5..fd82cbbb8 100644 --- a/Source/UnrealEnginePython/Private/Wrappers/UEPyFObjectThumbnail.cpp +++ b/Source/UnrealEnginePython/Private/Wrappers/UEPyFObjectThumbnail.cpp @@ -1,4 +1,4 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPyFObjectThumbnail.h" static PyObject *py_ue_fobject_thumbnail_get_image_width(ue_PyFObjectThumbnail *self, PyObject * args) diff --git a/Source/UnrealEnginePython/Private/Wrappers/UEPyFPythonOutputDevice.cpp b/Source/UnrealEnginePython/Private/Wrappers/UEPyFPythonOutputDevice.cpp index 08ad98052..56919c354 100644 --- a/Source/UnrealEnginePython/Private/Wrappers/UEPyFPythonOutputDevice.cpp +++ b/Source/UnrealEnginePython/Private/Wrappers/UEPyFPythonOutputDevice.cpp @@ -1,4 +1,4 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPyFPythonOutputDevice.h" static PyMethodDef ue_PyFPythonOutputDevice_methods[] = { @@ -11,7 +11,8 @@ static PyObject *ue_PyFPythonOutputDevice_str(ue_PyFPythonOutputDevice *self) self->device); } -static void ue_PyFPythonOutputDevice_dealloc(ue_PyFPythonOutputDevice *self) { +static void ue_PyFPythonOutputDevice_dealloc(ue_PyFPythonOutputDevice *self) +{ delete(self->device); #if PY_MAJOR_VERSION < 3 self->ob_type->tp_free((PyObject*)self); @@ -53,13 +54,16 @@ static PyTypeObject ue_PyFPythonOutputDeviceType = { 0, }; -static int ue_py_fpython_output_device_init(ue_PyFPythonOutputDevice *self, PyObject *args, PyObject *kwargs) { +static int ue_py_fpython_output_device_init(ue_PyFPythonOutputDevice *self, PyObject *args, PyObject *kwargs) +{ PyObject *py_serialize; - if (!PyArg_ParseTuple(args, "O", &py_serialize)) { + if (!PyArg_ParseTuple(args, "O", &py_serialize)) + { return -1; } - if (!PyCallable_Check(py_serialize)) { + if (!PyCallable_Check(py_serialize)) + { PyErr_SetString(PyExc_TypeError, "argument is not a callable"); return -1; } @@ -69,7 +73,8 @@ static int ue_py_fpython_output_device_init(ue_PyFPythonOutputDevice *self, PyOb return 0; } -void ue_python_init_fpython_output_device(PyObject *ue_module) { +void ue_python_init_fpython_output_device(PyObject *ue_module) +{ ue_PyFPythonOutputDeviceType.tp_new = PyType_GenericNew; ue_PyFPythonOutputDeviceType.tp_init = (initproc)ue_py_fpython_output_device_init; diff --git a/Source/UnrealEnginePython/Private/Wrappers/UEPyFPythonOutputDevice.h b/Source/UnrealEnginePython/Private/Wrappers/UEPyFPythonOutputDevice.h index 02a57e3e9..d38cedfb1 100644 --- a/Source/UnrealEnginePython/Private/Wrappers/UEPyFPythonOutputDevice.h +++ b/Source/UnrealEnginePython/Private/Wrappers/UEPyFPythonOutputDevice.h @@ -1,48 +1,56 @@ #pragma once -#include "UnrealEnginePython.h" +#include "UEPyModule.h" #include "Runtime/Core/Public/Misc/OutputDevice.h" -class FPythonOutputDevice : FOutputDevice { +class FPythonOutputDevice : FOutputDevice +{ public: - FPythonOutputDevice() { + FPythonOutputDevice() + { GLog->AddOutputDevice(this); GLog->SerializeBacklog(this); } - ~FPythonOutputDevice() { - if (GLog) { + ~FPythonOutputDevice() + { + if (GLog) + { GLog->RemoveOutputDevice(this); } Py_XDECREF(py_serialize); } - void SetPySerialize(PyObject *py_callable) { + void SetPySerialize(PyObject *py_callable) + { py_serialize = py_callable; Py_INCREF(py_serialize); } protected: - virtual void Serialize(const TCHAR * V, ELogVerbosity::Type Verbosity, const class FName& Category) override { + virtual void Serialize(const TCHAR * V, ELogVerbosity::Type Verbosity, const class FName& Category) override + { if (!py_serialize) return; PyObject *ret = PyObject_CallFunction(py_serialize, (char *)"sis", TCHAR_TO_UTF8(V), Verbosity, TCHAR_TO_UTF8(*Category.ToString())); - if (!ret) { + if (!ret) + { unreal_engine_py_log_error(); } Py_XDECREF(ret); } private: - PyObject *py_serialize; + PyObject * py_serialize; }; -typedef struct { +typedef struct +{ PyObject_HEAD - /* Type-specific fields go here. */ - FPythonOutputDevice *device; + /* Type-specific fields go here. */ + FPythonOutputDevice *device; } ue_PyFPythonOutputDevice; void ue_python_init_fpython_output_device(PyObject *); \ No newline at end of file diff --git a/Source/UnrealEnginePython/Private/Wrappers/UEPyFQuat.cpp b/Source/UnrealEnginePython/Private/Wrappers/UEPyFQuat.cpp index 843e9cb78..41faf7383 100644 --- a/Source/UnrealEnginePython/Private/Wrappers/UEPyFQuat.cpp +++ b/Source/UnrealEnginePython/Private/Wrappers/UEPyFQuat.cpp @@ -1,9 +1,11 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPyFQuat.h" #if ENGINE_MINOR_VERSION > 12 -static PyObject *py_ue_fquat_angular_distance(ue_PyFQuat *self, PyObject * args) { +static PyObject *py_ue_fquat_angular_distance(ue_PyFQuat *self, PyObject * args) +{ FQuat q; - if (!py_ue_quat_arg(args, q)) { + if (!py_ue_quat_arg(args, q)) + { return nullptr; } @@ -11,31 +13,38 @@ static PyObject *py_ue_fquat_angular_distance(ue_PyFQuat *self, PyObject * args) } #endif -static PyObject *py_ue_fquat_euler(ue_PyFQuat *self, PyObject * args) { +static PyObject *py_ue_fquat_euler(ue_PyFQuat *self, PyObject * args) +{ return py_ue_new_fvector(self->quat.Euler()); } -static PyObject *py_ue_fquat_get_axis_x(ue_PyFQuat *self, PyObject * args) { +static PyObject *py_ue_fquat_get_axis_x(ue_PyFQuat *self, PyObject * args) +{ return py_ue_new_fvector(self->quat.GetAxisX()); } -static PyObject *py_ue_fquat_get_axis_y(ue_PyFQuat *self, PyObject * args) { +static PyObject *py_ue_fquat_get_axis_y(ue_PyFQuat *self, PyObject * args) +{ return py_ue_new_fvector(self->quat.GetAxisY()); } -static PyObject *py_ue_fquat_get_axis_z(ue_PyFQuat *self, PyObject * args) { +static PyObject *py_ue_fquat_get_axis_z(ue_PyFQuat *self, PyObject * args) +{ return py_ue_new_fvector(self->quat.GetAxisZ()); } -static PyObject *py_ue_fquat_inverse(ue_PyFQuat *self, PyObject * args) { +static PyObject *py_ue_fquat_inverse(ue_PyFQuat *self, PyObject * args) +{ return py_ue_new_fquat(self->quat.Inverse()); } -static PyObject *py_ue_fquat_get_normalized(ue_PyFQuat *self, PyObject * args) { +static PyObject *py_ue_fquat_get_normalized(ue_PyFQuat *self, PyObject * args) +{ return py_ue_new_fquat(self->quat.GetNormalized()); } -static PyObject *py_ue_fquat_vector(ue_PyFQuat *self, PyObject * args) { +static PyObject *py_ue_fquat_vector(ue_PyFQuat *self, PyObject * args) +{ return py_ue_new_fvector(self->quat.Vector()); } @@ -57,12 +66,15 @@ static PyMethodDef ue_PyFQuat_methods[] = { { NULL } /* Sentinel */ }; -static PyObject *py_ue_fquat_get_x(ue_PyFQuat *self, void *closure) { +static PyObject *py_ue_fquat_get_x(ue_PyFQuat *self, void *closure) +{ return PyFloat_FromDouble(self->quat.X); } -static int py_ue_fquat_set_x(ue_PyFQuat *self, PyObject *value, void *closure) { - if (value && PyNumber_Check(value)) { +static int py_ue_fquat_set_x(ue_PyFQuat *self, PyObject *value, void *closure) +{ + if (value && PyNumber_Check(value)) + { PyObject *f_value = PyNumber_Float(value); self->quat.X = PyFloat_AsDouble(f_value); Py_DECREF(f_value); @@ -72,12 +84,15 @@ static int py_ue_fquat_set_x(ue_PyFQuat *self, PyObject *value, void *closure) { return -1; } -static PyObject *py_ue_fquat_get_y(ue_PyFQuat *self, void *closure) { +static PyObject *py_ue_fquat_get_y(ue_PyFQuat *self, void *closure) +{ return PyFloat_FromDouble(self->quat.Y); } -static int py_ue_fquat_set_y(ue_PyFQuat *self, PyObject *value, void *closure) { - if (value && PyNumber_Check(value)) { +static int py_ue_fquat_set_y(ue_PyFQuat *self, PyObject *value, void *closure) +{ + if (value && PyNumber_Check(value)) + { PyObject *f_value = PyNumber_Float(value); self->quat.Y = PyFloat_AsDouble(f_value); Py_DECREF(f_value); @@ -87,12 +102,15 @@ static int py_ue_fquat_set_y(ue_PyFQuat *self, PyObject *value, void *closure) { return -1; } -static PyObject *py_ue_fquat_get_z(ue_PyFQuat *self, void *closure) { +static PyObject *py_ue_fquat_get_z(ue_PyFQuat *self, void *closure) +{ return PyFloat_FromDouble(self->quat.Z); } -static int py_ue_fquat_set_z(ue_PyFQuat *self, PyObject *value, void *closure) { - if (value && PyNumber_Check(value)) { +static int py_ue_fquat_set_z(ue_PyFQuat *self, PyObject *value, void *closure) +{ + if (value && PyNumber_Check(value)) + { PyObject *f_value = PyNumber_Float(value); self->quat.Z = PyFloat_AsDouble(f_value); Py_DECREF(f_value); @@ -102,12 +120,15 @@ static int py_ue_fquat_set_z(ue_PyFQuat *self, PyObject *value, void *closure) { return -1; } -static PyObject *py_ue_fquat_get_w(ue_PyFQuat *self, void *closure) { +static PyObject *py_ue_fquat_get_w(ue_PyFQuat *self, void *closure) +{ return PyFloat_FromDouble(self->quat.W); } -static int py_ue_fquat_set_w(ue_PyFQuat *self, PyObject *value, void *closure) { - if (value && PyNumber_Check(value)) { +static int py_ue_fquat_set_w(ue_PyFQuat *self, PyObject *value, void *closure) +{ + if (value && PyNumber_Check(value)) + { PyObject *f_value = PyNumber_Float(value); self->quat.W = PyFloat_AsDouble(f_value); Py_DECREF(f_value); @@ -131,7 +152,7 @@ static PyObject *ue_PyFQuat_str(ue_PyFQuat *self) PyFloat_FromDouble(self->quat.X), PyFloat_FromDouble(self->quat.Y), PyFloat_FromDouble(self->quat.Z), PyFloat_FromDouble(self->quat.W)); } -static PyTypeObject ue_PyFQuatType = { +PyTypeObject ue_PyFQuatType = { PyVarObject_HEAD_INIT(NULL, 0) "unreal_engine.FQuat", /* tp_name */ sizeof(ue_PyFQuat), /* tp_basicsize */ @@ -169,34 +190,42 @@ static PyTypeObject ue_PyFQuatType = { }; -static PyObject *ue_py_fquat_add(ue_PyFQuat *self, PyObject *value) { +static PyObject *ue_py_fquat_add(ue_PyFQuat *self, PyObject *value) +{ FQuat quat = self->quat; ue_PyFQuat *py_quat = py_ue_is_fquat(value); - if (py_quat) { + if (py_quat) + { quat += py_quat->quat; } return py_ue_new_fquat(quat); } -static PyObject *ue_py_fquat_sub(ue_PyFQuat *self, PyObject *value) { +static PyObject *ue_py_fquat_sub(ue_PyFQuat *self, PyObject *value) +{ FQuat quat = self->quat; ue_PyFQuat *py_quat = py_ue_is_fquat(value); - if (py_quat) { + if (py_quat) + { quat -= py_quat->quat; } return py_ue_new_fquat(quat); } -static PyObject *ue_py_fquat_mul(ue_PyFQuat *self, PyObject *value) { - if (ue_PyFVector *py_vec = py_ue_is_fvector(value)) { +static PyObject *ue_py_fquat_mul(ue_PyFQuat *self, PyObject *value) +{ + if (ue_PyFVector *py_vec = py_ue_is_fvector(value)) + { FVector vec = self->quat * py_vec->vec; return py_ue_new_fvector(vec); } - if (ue_PyFQuat *py_quat = py_ue_is_fquat(value)) { + if (ue_PyFQuat *py_quat = py_ue_is_fquat(value)) + { FQuat quat = self->quat * py_quat->quat; return py_ue_new_fquat(quat); } - else if (PyNumber_Check(value)) { + else if (PyNumber_Check(value)) + { FQuat quat = self->quat; PyObject *f_value = PyNumber_Float(value); float f = PyFloat_AsDouble(f_value); @@ -207,10 +236,12 @@ static PyObject *ue_py_fquat_mul(ue_PyFQuat *self, PyObject *value) { return PyErr_Format(PyExc_TypeError, "unsupported argument type"); } -static PyObject *ue_py_fquat_div(ue_PyFQuat *self, PyObject *value) { +static PyObject *ue_py_fquat_div(ue_PyFQuat *self, PyObject *value) +{ FQuat quat = self->quat; - if (PyNumber_Check(value)) { + if (PyNumber_Check(value)) + { PyObject *f_value = PyNumber_Float(value); float f = PyFloat_AsDouble(f_value); if (f == 0) @@ -225,12 +256,15 @@ static PyObject *ue_py_fquat_div(ue_PyFQuat *self, PyObject *value) { PyNumberMethods ue_PyFQuat_number_methods; -static Py_ssize_t ue_py_fquat_seq_length(ue_PyFQuat *self) { +static Py_ssize_t ue_py_fquat_seq_length(ue_PyFQuat *self) +{ return 4; } -static PyObject *ue_py_fquat_seq_item(ue_PyFQuat *self, Py_ssize_t i) { - switch (i) { +static PyObject *ue_py_fquat_seq_item(ue_PyFQuat *self, Py_ssize_t i) +{ + switch (i) + { case 0: return PyFloat_FromDouble(self->quat.X); case 1: @@ -245,7 +279,8 @@ static PyObject *ue_py_fquat_seq_item(ue_PyFQuat *self, Py_ssize_t i) { PySequenceMethods ue_PyFQuat_sequence_methods; -static int ue_py_fquat_init(ue_PyFQuat *self, PyObject *args, PyObject *kwargs) { +static int ue_py_fquat_init(ue_PyFQuat *self, PyObject *args, PyObject *kwargs) +{ float x = 0, y = 0, z = 0, w = 1; if (!PyArg_ParseTuple(args, "|ffff", &x, &y, &z, &w)) return -1; @@ -258,7 +293,8 @@ static int ue_py_fquat_init(ue_PyFQuat *self, PyObject *args, PyObject *kwargs) return 0; } -void ue_python_init_fquat(PyObject *ue_module) { +void ue_python_init_fquat(PyObject *ue_module) +{ ue_PyFQuatType.tp_new = PyType_GenericNew; ue_PyFQuatType.tp_init = (initproc)ue_py_fquat_init; @@ -282,24 +318,29 @@ void ue_python_init_fquat(PyObject *ue_module) { PyModule_AddObject(ue_module, "FQuat", (PyObject *)&ue_PyFQuatType); } -PyObject *py_ue_new_fquat(FQuat quat) { +PyObject *py_ue_new_fquat(FQuat quat) +{ ue_PyFQuat *ret = (ue_PyFQuat *)PyObject_New(ue_PyFQuat, &ue_PyFQuatType); ret->quat = quat; return (PyObject *)ret; } -ue_PyFQuat *py_ue_is_fquat(PyObject *obj) { +ue_PyFQuat *py_ue_is_fquat(PyObject *obj) +{ if (!PyObject_IsInstance(obj, (PyObject *)&ue_PyFQuatType)) return nullptr; return (ue_PyFQuat *)obj; } -bool py_ue_quat_arg(PyObject *args, FQuat &quat) { +bool py_ue_quat_arg(PyObject *args, FQuat &quat) +{ - if (PyTuple_Size(args) == 1) { + if (PyTuple_Size(args) == 1) + { PyObject *arg = PyTuple_GetItem(args, 0); ue_PyFQuat *py_quat = py_ue_is_fquat(arg); - if (!py_quat) { + if (!py_quat) + { PyErr_Format(PyExc_TypeError, "argument is not a FQuat"); return false; } diff --git a/Source/UnrealEnginePython/Private/Wrappers/UEPyFQuat.h b/Source/UnrealEnginePython/Private/Wrappers/UEPyFQuat.h index 531417e65..94bd2cf9e 100644 --- a/Source/UnrealEnginePython/Private/Wrappers/UEPyFQuat.h +++ b/Source/UnrealEnginePython/Private/Wrappers/UEPyFQuat.h @@ -1,18 +1,21 @@ #pragma once -#include "UnrealEnginePython.h" +#include "UEPyModule.h" #include "Runtime/Core/Public/Math/Quat.h" -typedef struct { +typedef struct +{ PyObject_HEAD - /* Type-specific fields go here. */ - FQuat quat; + /* Type-specific fields go here. */ + FQuat quat; } ue_PyFQuat; +extern PyTypeObject ue_PyFQuatType; + PyObject *py_ue_new_fquat(FQuat); ue_PyFQuat *py_ue_is_fquat(PyObject *); void ue_python_init_fquat(PyObject *); -bool py_ue_quat_arg(PyObject *, FQuat &); \ No newline at end of file +bool py_ue_quat_arg(PyObject *, FQuat &); diff --git a/Source/UnrealEnginePython/Private/Wrappers/UEPyFRandomStream.cpp b/Source/UnrealEnginePython/Private/Wrappers/UEPyFRandomStream.cpp index a61509f18..d315dd2f0 100644 --- a/Source/UnrealEnginePython/Private/Wrappers/UEPyFRandomStream.cpp +++ b/Source/UnrealEnginePython/Private/Wrappers/UEPyFRandomStream.cpp @@ -1,4 +1,4 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPyFRandomStream.h" static PyObject *py_ue_frandomstream_frand(ue_PyFRandomStream *self, PyObject * args) { return PyFloat_FromDouble(self->rstream.FRand()); diff --git a/Source/UnrealEnginePython/Private/Wrappers/UEPyFRandomStream.h b/Source/UnrealEnginePython/Private/Wrappers/UEPyFRandomStream.h index 935ee2751..3dd27d19d 100644 --- a/Source/UnrealEnginePython/Private/Wrappers/UEPyFRandomStream.h +++ b/Source/UnrealEnginePython/Private/Wrappers/UEPyFRandomStream.h @@ -2,12 +2,13 @@ -#include "UnrealEnginePython.h" +#include "UEPyModule.h" -typedef struct { +typedef struct +{ PyObject_HEAD - /* Type-specific fields go here. */ - FRandomStream rstream; + /* Type-specific fields go here. */ + FRandomStream rstream; } ue_PyFRandomStream; void ue_python_init_frandomstream(PyObject *); \ No newline at end of file diff --git a/Source/UnrealEnginePython/Private/Wrappers/UEPyFRawAnimSequenceTrack.cpp b/Source/UnrealEnginePython/Private/Wrappers/UEPyFRawAnimSequenceTrack.cpp index 300608cc9..af69b254c 100644 --- a/Source/UnrealEnginePython/Private/Wrappers/UEPyFRawAnimSequenceTrack.cpp +++ b/Source/UnrealEnginePython/Private/Wrappers/UEPyFRawAnimSequenceTrack.cpp @@ -1,8 +1,10 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPyFRawAnimSequenceTrack.h" -static PyObject *py_ue_fraw_anim_sequence_track_get_pos_keys(ue_PyFRawAnimSequenceTrack *self, void *closure) { +static PyObject *py_ue_fraw_anim_sequence_track_get_pos_keys(ue_PyFRawAnimSequenceTrack *self, void *closure) +{ PyObject *py_list = PyList_New(0); - for (FVector vec : self->raw_anim_sequence_track.PosKeys) { + for (FVector vec : self->raw_anim_sequence_track.PosKeys) + { PyObject *py_vec = py_ue_new_fvector(vec); PyList_Append(py_list, py_vec); Py_DECREF(py_vec); @@ -10,9 +12,11 @@ static PyObject *py_ue_fraw_anim_sequence_track_get_pos_keys(ue_PyFRawAnimSequen return py_list; } -static PyObject *py_ue_fraw_anim_sequence_track_get_scale_keys(ue_PyFRawAnimSequenceTrack *self, void *closure) { +static PyObject *py_ue_fraw_anim_sequence_track_get_scale_keys(ue_PyFRawAnimSequenceTrack *self, void *closure) +{ PyObject *py_list = PyList_New(0); - for (FVector vec : self->raw_anim_sequence_track.ScaleKeys) { + for (FVector vec : self->raw_anim_sequence_track.ScaleKeys) + { PyObject *py_vec = py_ue_new_fvector(vec); PyList_Append(py_list, py_vec); Py_DECREF(py_vec); @@ -20,9 +24,11 @@ static PyObject *py_ue_fraw_anim_sequence_track_get_scale_keys(ue_PyFRawAnimSequ return py_list; } -static PyObject *py_ue_fraw_anim_sequence_track_get_rot_keys(ue_PyFRawAnimSequenceTrack *self, void *closure) { +static PyObject *py_ue_fraw_anim_sequence_track_get_rot_keys(ue_PyFRawAnimSequenceTrack *self, void *closure) +{ PyObject *py_list = PyList_New(0); - for (FQuat quat : self->raw_anim_sequence_track.RotKeys) { + for (FQuat quat : self->raw_anim_sequence_track.RotKeys) + { PyObject *py_quat = py_ue_new_fquat(quat); PyList_Append(py_list, py_quat); Py_DECREF(py_quat); @@ -30,22 +36,28 @@ static PyObject *py_ue_fraw_anim_sequence_track_get_rot_keys(ue_PyFRawAnimSequen return py_list; } -static int py_ue_fraw_anim_sequence_track_set_pos_keys(ue_PyFRawAnimSequenceTrack *self, PyObject *value, void *closure) { +static int py_ue_fraw_anim_sequence_track_set_pos_keys(ue_PyFRawAnimSequenceTrack *self, PyObject *value, void *closure) +{ TArray pos; - if (value) { + if (value) + { PyObject *py_iter = PyObject_GetIter(value); - if (py_iter) { + if (py_iter) + { bool failed = false; - while (PyObject *py_item = PyIter_Next(py_iter)) { + while (PyObject *py_item = PyIter_Next(py_iter)) + { ue_PyFVector *py_vec = py_ue_is_fvector(py_item); - if (!py_vec) { + if (!py_vec) + { failed = true; break; } pos.Add(py_vec->vec); } Py_DECREF(py_iter); - if (!failed) { + if (!failed) + { self->raw_anim_sequence_track.PosKeys = pos; return 0; } @@ -55,22 +67,28 @@ static int py_ue_fraw_anim_sequence_track_set_pos_keys(ue_PyFRawAnimSequenceTrac return -1; } -static int py_ue_fraw_anim_sequence_track_set_scale_keys(ue_PyFRawAnimSequenceTrack *self, PyObject *value, void *closure) { +static int py_ue_fraw_anim_sequence_track_set_scale_keys(ue_PyFRawAnimSequenceTrack *self, PyObject *value, void *closure) +{ TArray scale; - if (value) { + if (value) + { PyObject *py_iter = PyObject_GetIter(value); - if (py_iter) { + if (py_iter) + { bool failed = false; - while (PyObject *py_item = PyIter_Next(py_iter)) { + while (PyObject *py_item = PyIter_Next(py_iter)) + { ue_PyFVector *py_vec = py_ue_is_fvector(py_item); - if (!py_vec) { + if (!py_vec) + { failed = true; break; } scale.Add(py_vec->vec); } Py_DECREF(py_iter); - if (!failed) { + if (!failed) + { self->raw_anim_sequence_track.ScaleKeys = scale; return 0; } @@ -80,22 +98,28 @@ static int py_ue_fraw_anim_sequence_track_set_scale_keys(ue_PyFRawAnimSequenceTr return -1; } -static int py_ue_fraw_anim_sequence_track_set_rot_keys(ue_PyFRawAnimSequenceTrack *self, PyObject *value, void *closure) { +static int py_ue_fraw_anim_sequence_track_set_rot_keys(ue_PyFRawAnimSequenceTrack *self, PyObject *value, void *closure) +{ TArray rot; - if (value) { + if (value) + { PyObject *py_iter = PyObject_GetIter(value); - if (py_iter) { + if (py_iter) + { bool failed = false; - while (PyObject *py_item = PyIter_Next(py_iter)) { + while (PyObject *py_item = PyIter_Next(py_iter)) + { ue_PyFQuat *py_quat = py_ue_is_fquat(py_item); - if (!py_quat) { + if (!py_quat) + { failed = true; break; } rot.Add(py_quat->quat); } Py_DECREF(py_iter); - if (!failed) { + if (!failed) + { self->raw_anim_sequence_track.RotKeys = rot; return 0; } @@ -158,7 +182,8 @@ static PyTypeObject ue_PyFRawAnimSequenceTrackType = { -void ue_python_init_fraw_anim_sequence_track(PyObject *ue_module) { +void ue_python_init_fraw_anim_sequence_track(PyObject *ue_module) +{ ue_PyFRawAnimSequenceTrackType.tp_new = PyType_GenericNew; if (PyType_Ready(&ue_PyFRawAnimSequenceTrackType) < 0) @@ -168,13 +193,15 @@ void ue_python_init_fraw_anim_sequence_track(PyObject *ue_module) { PyModule_AddObject(ue_module, "FRawAnimSequenceTrack", (PyObject *)&ue_PyFRawAnimSequenceTrackType); } -ue_PyFRawAnimSequenceTrack *py_ue_is_fraw_anim_sequence_track(PyObject *obj) { +ue_PyFRawAnimSequenceTrack *py_ue_is_fraw_anim_sequence_track(PyObject *obj) +{ if (!PyObject_IsInstance(obj, (PyObject *)&ue_PyFRawAnimSequenceTrackType)) return nullptr; return (ue_PyFRawAnimSequenceTrack *)obj; } -PyObject *py_ue_new_fraw_anim_sequence_track(FRawAnimSequenceTrack raw_anim_sequence_track) { +PyObject *py_ue_new_fraw_anim_sequence_track(FRawAnimSequenceTrack raw_anim_sequence_track) +{ ue_PyFRawAnimSequenceTrack *ret = (ue_PyFRawAnimSequenceTrack *)PyObject_New(ue_PyFRawAnimSequenceTrack, &ue_PyFRawAnimSequenceTrackType); new(&ret->raw_anim_sequence_track) FRawAnimSequenceTrack(raw_anim_sequence_track); return (PyObject *)ret; diff --git a/Source/UnrealEnginePython/Private/Wrappers/UEPyFRawAnimSequenceTrack.h b/Source/UnrealEnginePython/Private/Wrappers/UEPyFRawAnimSequenceTrack.h index 9c194c98d..199429cfe 100644 --- a/Source/UnrealEnginePython/Private/Wrappers/UEPyFRawAnimSequenceTrack.h +++ b/Source/UnrealEnginePython/Private/Wrappers/UEPyFRawAnimSequenceTrack.h @@ -1,13 +1,14 @@ #pragma once -#include "UnrealEnginePython.h" +#include "UEPyModule.h" #include "Runtime/Engine/Classes/Animation/AnimSequence.h" -typedef struct { +typedef struct +{ PyObject_HEAD - /* Type-specific fields go here. */ - FRawAnimSequenceTrack raw_anim_sequence_track; + /* Type-specific fields go here. */ + FRawAnimSequenceTrack raw_anim_sequence_track; } ue_PyFRawAnimSequenceTrack; PyObject *py_ue_new_fraw_anim_sequence_track(FRawAnimSequenceTrack); diff --git a/Source/UnrealEnginePython/Private/Wrappers/UEPyFRawMesh.cpp b/Source/UnrealEnginePython/Private/Wrappers/UEPyFRawMesh.cpp index 04164b490..d6f8f24d2 100644 --- a/Source/UnrealEnginePython/Private/Wrappers/UEPyFRawMesh.cpp +++ b/Source/UnrealEnginePython/Private/Wrappers/UEPyFRawMesh.cpp @@ -1,9 +1,11 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPyFRawMesh.h" #if WITH_EDITOR #if ENGINE_MINOR_VERSION > 13 +#include "Engine/StaticMesh.h" + static PyObject *py_ue_fraw_mesh_set_vertex_positions(ue_PyFRawMesh *self, PyObject * args) { PyObject *data; diff --git a/Source/UnrealEnginePython/Private/Wrappers/UEPyFRawMesh.h b/Source/UnrealEnginePython/Private/Wrappers/UEPyFRawMesh.h index a004a128a..ba6ad8a90 100644 --- a/Source/UnrealEnginePython/Private/Wrappers/UEPyFRawMesh.h +++ b/Source/UnrealEnginePython/Private/Wrappers/UEPyFRawMesh.h @@ -1,5 +1,5 @@ #pragma once -#include "UnrealEnginePython.h" +#include "UEPyModule.h" #if WITH_EDITOR @@ -7,10 +7,11 @@ #include "Developer/RawMesh/Public/RawMesh.h" -struct ue_PyFRawMesh { +struct ue_PyFRawMesh +{ PyObject_HEAD - /* Type-specific fields go here. */ - FRawMesh raw_mesh; + /* Type-specific fields go here. */ + FRawMesh raw_mesh; }; diff --git a/Source/UnrealEnginePython/Private/Wrappers/UEPyFRotator.cpp b/Source/UnrealEnginePython/Private/Wrappers/UEPyFRotator.cpp index 896a49f66..3558faa5b 100644 --- a/Source/UnrealEnginePython/Private/Wrappers/UEPyFRotator.cpp +++ b/Source/UnrealEnginePython/Private/Wrappers/UEPyFRotator.cpp @@ -1,4 +1,4 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPyFRotator.h" static PyObject *py_ue_frotator_get_vector(ue_PyFRotator *self, PyObject * args) { FVector vec = self->rot.Vector(); @@ -29,7 +29,7 @@ static PyMethodDef ue_PyFRotator_methods[] = { { "get_vector", (PyCFunction)py_ue_frotator_get_vector, METH_VARARGS, "" }, { "get_euler", (PyCFunction)py_ue_frotator_get_euler, METH_VARARGS, "" }, { "normalized", (PyCFunction)py_ue_frotator_normalized, METH_VARARGS, "" }, - { "inversed", (PyCFunction)py_ue_frotator_normalized, METH_VARARGS, "" }, + { "inversed", (PyCFunction)py_ue_frotator_inversed, METH_VARARGS, "" }, { "quaternion", (PyCFunction)py_ue_frotator_quaternion, METH_VARARGS, "" }, { NULL } /* Sentinel */ }; @@ -93,7 +93,7 @@ static PyObject *ue_PyFRotator_str(ue_PyFRotator *self) PyFloat_FromDouble(self->rot.Roll), PyFloat_FromDouble(self->rot.Pitch), PyFloat_FromDouble(self->rot.Yaw)); } -static PyTypeObject ue_PyFRotatorType = { +PyTypeObject ue_PyFRotatorType = { PyVarObject_HEAD_INIT(NULL, 0) "unreal_engine.FRotator", /* tp_name */ sizeof(ue_PyFRotator), /* tp_basicsize */ diff --git a/Source/UnrealEnginePython/Private/Wrappers/UEPyFRotator.h b/Source/UnrealEnginePython/Private/Wrappers/UEPyFRotator.h index 02db8f74f..2d3f6df4c 100644 --- a/Source/UnrealEnginePython/Private/Wrappers/UEPyFRotator.h +++ b/Source/UnrealEnginePython/Private/Wrappers/UEPyFRotator.h @@ -1,8 +1,8 @@ #pragma once - - #include "UnrealEnginePython.h" +#include "UEPyFVector.h" +#include "UEPyFQuat.h" typedef struct { PyObject_HEAD @@ -10,9 +10,11 @@ typedef struct { FRotator rot; } ue_PyFRotator; +extern PyTypeObject ue_PyFRotatorType; + PyObject *py_ue_new_frotator(FRotator); ue_PyFRotator *py_ue_is_frotator(PyObject *); void ue_python_init_frotator(PyObject *); -bool py_ue_rotator_arg(PyObject *, FRotator &); \ No newline at end of file +bool py_ue_rotator_arg(PyObject *, FRotator &); diff --git a/Source/UnrealEnginePython/Private/Wrappers/UEPyFSlowTask.cpp b/Source/UnrealEnginePython/Private/Wrappers/UEPyFSlowTask.cpp new file mode 100644 index 000000000..71669f418 --- /dev/null +++ b/Source/UnrealEnginePython/Private/Wrappers/UEPyFSlowTask.cpp @@ -0,0 +1,192 @@ +#include "UEPyFSlowTask.h" + +#include "Misc/FeedbackContext.h" + +#if WITH_EDITOR + +static PyObject *py_ue_fslowtask_initialize(ue_PyFSlowTask *self, PyObject * args) +{ + self->slowtask.Initialize(); + + Py_RETURN_NONE; +} + +static PyObject *py_ue_fslowtask_destroy(ue_PyFSlowTask *self, PyObject * args) +{ + self->slowtask.Destroy(); + + Py_RETURN_NONE; +} + +static PyObject *py_ue_fslowtask_make_dialog_delayed(ue_PyFSlowTask *self, PyObject * args) +{ + float threshold; + PyObject *py_show_cancel_button = nullptr; + PyObject *py_allow_in_pie = nullptr; + if(!PyArg_ParseTuple(args, "f|OO:make_dialog_delayed", &threshold, &py_show_cancel_button, &py_allow_in_pie)) + { + return nullptr; + } + + bool show_cancel_button = false; + if (nullptr != py_show_cancel_button && PyObject_IsTrue(py_show_cancel_button)) + { + show_cancel_button = true; + } + + bool allow_in_pie = false; + if (nullptr != py_allow_in_pie && PyObject_IsTrue(py_allow_in_pie)) + { + allow_in_pie = true; + } + + self->slowtask.MakeDialogDelayed(threshold, show_cancel_button, allow_in_pie); + + Py_RETURN_NONE; +} + +static PyObject *py_ue_fslowtask_make_dialog(ue_PyFSlowTask *self, PyObject * args) +{ + PyObject *py_show_cancel_button = nullptr; + PyObject *py_allow_in_pie = nullptr; + if(!PyArg_ParseTuple(args, "|OO:make_dialog", &py_show_cancel_button, &py_allow_in_pie)) + { + return nullptr; + } + + bool show_cancel_button = false; + if (nullptr != py_show_cancel_button && PyObject_IsTrue(py_show_cancel_button)) + { + show_cancel_button = true; + } + + bool allow_in_pie = false; + if (nullptr != py_allow_in_pie && PyObject_IsTrue(py_allow_in_pie)) + { + allow_in_pie = true; + } + + self->slowtask.MakeDialog(show_cancel_button, allow_in_pie); + + Py_RETURN_NONE; +} + +static PyObject *py_ue_fslowtask_enter_progress_frame(ue_PyFSlowTask *self, PyObject * args) +{ + float expected_work_this_frame = 1.0; + char *text = (char *)""; + if(!PyArg_ParseTuple(args, "|fs:enter_progress_frame", &expected_work_this_frame, &text)) + { + return nullptr; + } + + self->slowtask.EnterProgressFrame(expected_work_this_frame, FText::FromString(UTF8_TO_TCHAR(text))); + + Py_RETURN_NONE; +} + +static PyObject *py_ue_fslowtask_get_current_message(ue_PyFSlowTask *self, PyObject * args) +{ + FText current_message = self->slowtask.GetCurrentMessage(); + return PyUnicode_FromString(TCHAR_TO_UTF8(*current_message.ToString())); +} + +static PyObject *py_ue_fslowtask_received_user_cancel(ue_PyFSlowTask *self, PyObject * args ) +{ + if(GWarn->ReceivedUserCancel()) + { + Py_INCREF(Py_True); + return Py_True; + } + Py_INCREF(Py_False); + return Py_False; +} + +static PyMethodDef ue_PyFSlowTask_methods[] = { + { "initialize", (PyCFunction)py_ue_fslowtask_initialize, METH_VARARGS, "" }, + { "destroy", (PyCFunction)py_ue_fslowtask_destroy, METH_VARARGS, "" }, + { "make_dialog_delayed", (PyCFunction)py_ue_fslowtask_make_dialog_delayed, METH_VARARGS, "" }, + { "make_dialog", (PyCFunction)py_ue_fslowtask_make_dialog, METH_VARARGS, "" }, + { "enter_progress_frame", (PyCFunction)py_ue_fslowtask_enter_progress_frame, METH_VARARGS, "" }, + { "get_current_message", (PyCFunction)py_ue_fslowtask_get_current_message, METH_VARARGS, "" }, + { "received_user_cancel", (PyCFunction)py_ue_fslowtask_received_user_cancel, METH_VARARGS, "" }, + { NULL } /* Sentinel */ +}; + +static PyTypeObject ue_PyFSlowTaskType = { + PyVarObject_HEAD_INIT(NULL, 0) + "unreal_engine.FSlowTask", /* tp_name */ + sizeof(ue_PyFSlowTask), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ +#if PY_MAJOR_VERSION < 3 + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES, /* tp_flags */ +#else + Py_TPFLAGS_DEFAULT, /* tp_flags */ +#endif + "Unreal Engine FSlowTask", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + ue_PyFSlowTask_methods, /* tp_methods */ + 0, + 0, +}; + +static int py_ue_fslowtask_init(ue_PyFSlowTask *self, PyObject * args) +{ + float amount_of_work; + char *default_message = (char *)""; + PyObject *py_enabled = nullptr; + if(!PyArg_ParseTuple(args, "f|sO:__init__", &amount_of_work, &default_message, &py_enabled)) + { + return -1; + } + + bool enabled = true; + if (nullptr != py_enabled && !PyObject_IsTrue(py_enabled)) + { + enabled = false; + } + + new(&self->slowtask) FSlowTask(amount_of_work, FText::FromString(UTF8_TO_TCHAR(default_message)), enabled); + return 0; +} + +void ue_python_init_fslowtask(PyObject *ue_module) +{ + ue_PyFSlowTaskType.tp_new = PyType_GenericNew; + ue_PyFSlowTaskType.tp_init = (initproc)py_ue_fslowtask_init; + + if (PyType_Ready(&ue_PyFSlowTaskType) < 0) + return; + + Py_INCREF(&ue_PyFSlowTaskType); + PyModule_AddObject(ue_module, "FSlowTask", (PyObject *)&ue_PyFSlowTaskType); +} + +ue_PyFSlowTask *py_ue_is_fslowtask(PyObject *obj) +{ + if (!PyObject_IsInstance(obj, (PyObject *)&ue_PyFSlowTaskType)) + return nullptr; + return (ue_PyFSlowTask *)obj; +} + +#endif diff --git a/Source/UnrealEnginePython/Private/Wrappers/UEPyFSlowTask.h b/Source/UnrealEnginePython/Private/Wrappers/UEPyFSlowTask.h new file mode 100644 index 000000000..8abd0693f --- /dev/null +++ b/Source/UnrealEnginePython/Private/Wrappers/UEPyFSlowTask.h @@ -0,0 +1,18 @@ +#pragma once +#include "UnrealEnginePython.h" +#include "Misc/SlowTask.h" + +#if WITH_EDITOR + +typedef struct { + PyObject_HEAD + /* Type-specific fields go here. */ + + FSlowTask slowtask; +} ue_PyFSlowTask; + +void ue_python_init_fslowtask(PyObject *); + +ue_PyFSlowTask *py_ue_is_fslowtask(PyObject *); + +#endif diff --git a/Source/UnrealEnginePython/Private/Wrappers/UEPyFSocket.cpp b/Source/UnrealEnginePython/Private/Wrappers/UEPyFSocket.cpp index 1c47cfbce..4f6066342 100644 --- a/Source/UnrealEnginePython/Private/Wrappers/UEPyFSocket.cpp +++ b/Source/UnrealEnginePython/Private/Wrappers/UEPyFSocket.cpp @@ -1,9 +1,11 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPyFSocket.h" -static PyObject *py_ue_fsocket_start_receiver(ue_PyFSocket *self, PyObject * args) { +static PyObject *py_ue_fsocket_start_receiver(ue_PyFSocket *self, PyObject * args) +{ - if (self->udp_receiver) { + if (self->udp_receiver) + { return PyErr_Format(PyExc_Exception, "receiver already started"); } @@ -15,24 +17,30 @@ static PyObject *py_ue_fsocket_start_receiver(ue_PyFSocket *self, PyObject * arg return Py_None; } -static void sock_close(ue_PyFSocket *self) { - if (self->sock) { +static void sock_close(ue_PyFSocket *self) +{ + if (self->sock) + { self->sock->Close(); ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM)->DestroySocket(self->sock); self->sock = nullptr; } } -static void sock_stop_receiver(ue_PyFSocket *self) { - if (self->udp_receiver) { +static void sock_stop_receiver(ue_PyFSocket *self) +{ + if (self->udp_receiver) + { self->udp_receiver->Stop(); delete(self->udp_receiver); self->udp_receiver = nullptr; } } -static PyObject *py_ue_fsocket_stop_receiver(ue_PyFSocket *self, PyObject * args) { - if (!self->udp_receiver) { +static PyObject *py_ue_fsocket_stop_receiver(ue_PyFSocket *self, PyObject * args) +{ + if (!self->udp_receiver) + { return PyErr_Format(PyExc_Exception, "receiver not started"); } @@ -42,9 +50,11 @@ static PyObject *py_ue_fsocket_stop_receiver(ue_PyFSocket *self, PyObject * args return Py_None; } -static PyObject *py_ue_fsocket_close(ue_PyFSocket *self, PyObject * args) { +static PyObject *py_ue_fsocket_close(ue_PyFSocket *self, PyObject * args) +{ - if (self->udp_receiver) { + if (self->udp_receiver) + { return PyErr_Format(PyExc_Exception, "you have to stop its receiver before closing a socket"); } @@ -71,11 +81,12 @@ static PyObject *ue_PyFSocket_str(ue_PyFSocket *self) TCHAR_TO_UTF8(*self->sock->GetDescription())); } -static void ue_py_fsocket_dealloc(ue_PyFSocket *self) { - +static void ue_py_fsocket_dealloc(ue_PyFSocket *self) +{ + sock_stop_receiver(self); sock_close(self); - + } static PyTypeObject ue_PyFSocketType = { @@ -111,7 +122,8 @@ static PyTypeObject ue_PyFSocketType = { 0, }; -static int ue_py_fsocket_init(ue_PyFSocket *self, PyObject *args, PyObject *kwargs) { +static int ue_py_fsocket_init(ue_PyFSocket *self, PyObject *args, PyObject *kwargs) +{ char *socket_desc; char *socket_addr; int port_number; @@ -128,7 +140,8 @@ static int ue_py_fsocket_init(ue_PyFSocket *self, PyObject *args, PyObject *kwar return 0; } -void ue_python_init_fsocket(PyObject *ue_module) { +void ue_python_init_fsocket(PyObject *ue_module) +{ ue_PyFSocketType.tp_new = PyType_GenericNew; ue_PyFSocketType.tp_init = (initproc)ue_py_fsocket_init; diff --git a/Source/UnrealEnginePython/Private/Wrappers/UEPyFSoftSkinVertex.cpp b/Source/UnrealEnginePython/Private/Wrappers/UEPyFSoftSkinVertex.cpp index 1cce29b12..64e168222 100644 --- a/Source/UnrealEnginePython/Private/Wrappers/UEPyFSoftSkinVertex.cpp +++ b/Source/UnrealEnginePython/Private/Wrappers/UEPyFSoftSkinVertex.cpp @@ -1,4 +1,6 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPyFSoftSkinVertex.h" + +#if WITH_EDITOR static PyObject *py_ue_fsoft_skin_vertex_get_color(ue_PyFSoftSkinVertex *self, void *closure) { @@ -361,4 +363,6 @@ PyObject *py_ue_new_fsoft_skin_vertex(FSoftSkinVertex ss_vertex) ue_PyFSoftSkinVertex *ret = (ue_PyFSoftSkinVertex *)PyObject_New(ue_PyFSoftSkinVertex, &ue_PyFSoftSkinVertexType); new(&ret->ss_vertex) FSoftSkinVertex(ss_vertex); return (PyObject *)ret; -} \ No newline at end of file +} + +#endif \ No newline at end of file diff --git a/Source/UnrealEnginePython/Private/Wrappers/UEPyFSoftSkinVertex.h b/Source/UnrealEnginePython/Private/Wrappers/UEPyFSoftSkinVertex.h index edc386582..4355f1887 100644 --- a/Source/UnrealEnginePython/Private/Wrappers/UEPyFSoftSkinVertex.h +++ b/Source/UnrealEnginePython/Private/Wrappers/UEPyFSoftSkinVertex.h @@ -1,6 +1,8 @@ #pragma once #include "UnrealEnginePython.h" +#if WITH_EDITOR + #include "Runtime/Engine/Public/SkeletalMeshTypes.h" #if ENGINE_MINOR_VERSION > 18 @@ -9,10 +11,14 @@ #endif +#include "Wrappers/UEPyFColor.h" + struct ue_PyFSoftSkinVertex { PyObject_HEAD /* Type-specific fields go here. */ + FSoftSkinVertex ss_vertex; + uint16 material_index; uint32 smoothing_group; }; @@ -22,3 +28,5 @@ void ue_python_init_fsoft_skin_vertex(PyObject *); PyObject *py_ue_new_fsoft_skin_vertex(FSoftSkinVertex); ue_PyFSoftSkinVertex *py_ue_is_fsoft_skin_vertex(PyObject *); + +#endif diff --git a/Source/UnrealEnginePython/Private/Wrappers/UEPyFStringAssetReference.cpp b/Source/UnrealEnginePython/Private/Wrappers/UEPyFStringAssetReference.cpp index ec600856d..ac48249fc 100644 --- a/Source/UnrealEnginePython/Private/Wrappers/UEPyFStringAssetReference.cpp +++ b/Source/UnrealEnginePython/Private/Wrappers/UEPyFStringAssetReference.cpp @@ -1,4 +1,3 @@ -#include "UnrealEnginePythonPrivatePCH.h" #include "UEPyFStringAssetReference.h" @@ -72,9 +71,9 @@ static int ue_py_fstring_asset_reference_init(ue_PyFStringAssetReference *self, if (!PyArg_ParseTuple(args, "O", &py_object)) return -1; - if (PyUnicode_Check(py_object)) + if (PyUnicodeOrString_Check(py_object)) { - char *value = PyUnicode_AsUTF8(py_object); + const char *value = UEPyUnicode_AsUTF8(py_object); self->fstring_asset_reference = FStringAssetReference(FString(UTF8_TO_TCHAR(value))); return 0; } diff --git a/Source/UnrealEnginePython/Private/Wrappers/UEPyFStringAssetReference.h b/Source/UnrealEnginePython/Private/Wrappers/UEPyFStringAssetReference.h index f70e84329..02fb7c8cc 100644 --- a/Source/UnrealEnginePython/Private/Wrappers/UEPyFStringAssetReference.h +++ b/Source/UnrealEnginePython/Private/Wrappers/UEPyFStringAssetReference.h @@ -2,16 +2,17 @@ -#include "UnrealEnginePython.h" +#include "UEPyModule.h" #if ENGINE_MINOR_VERSION < 18 #include "Runtime/CoreUObject/Public/Misc/StringAssetReference.h" #endif -typedef struct { +typedef struct +{ PyObject_HEAD - /* Type-specific fields go here. */ - FStringAssetReference fstring_asset_reference; + /* Type-specific fields go here. */ + FStringAssetReference fstring_asset_reference; } ue_PyFStringAssetReference; PyObject *py_ue_new_fstring_asset_reference(FStringAssetReference); diff --git a/Source/UnrealEnginePython/Private/Wrappers/UEPyFTransform.cpp b/Source/UnrealEnginePython/Private/Wrappers/UEPyFTransform.cpp index b76be90a8..b3a6b654a 100644 --- a/Source/UnrealEnginePython/Private/Wrappers/UEPyFTransform.cpp +++ b/Source/UnrealEnginePython/Private/Wrappers/UEPyFTransform.cpp @@ -1,4 +1,4 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPyFTransform.h" static PyObject *py_ue_ftransform_inverse(ue_PyFTransform *self, PyObject * args) { @@ -26,10 +26,103 @@ static PyObject *py_ue_ftransform_get_relative_transform(ue_PyFTransform *self, return py_ue_new_ftransform(self->transform.GetRelativeTransform(py_transform->transform)); } +static PyObject *py_ue_ftransform_transform_vector(ue_PyFTransform *self, PyObject * args) +{ + PyObject *py_obj; + if (!PyArg_ParseTuple(args, "O", &py_obj)) + { + return nullptr; + } + + ue_PyFVector *py_vec = py_ue_is_fvector(py_obj); + if (!py_vec) + return PyErr_Format(PyExc_Exception, "argument is not a FVector"); + return py_ue_new_fvector(self->transform.TransformVector(py_vec->vec)); +} + +static PyObject *py_ue_ftransform_transform_vector_no_scale(ue_PyFTransform *self, PyObject * args) +{ + PyObject *py_obj; + if (!PyArg_ParseTuple(args, "O", &py_obj)) + { + return nullptr; + } + + ue_PyFVector *py_vec = py_ue_is_fvector(py_obj); + if (!py_vec) + return PyErr_Format(PyExc_Exception, "argument is not a FVector"); + return py_ue_new_fvector(self->transform.TransformVectorNoScale(py_vec->vec)); +} + +static PyObject *py_ue_ftransform_transform_position(ue_PyFTransform *self, PyObject * args) +{ + PyObject *py_obj; + if (!PyArg_ParseTuple(args, "O", &py_obj)) + { + return nullptr; + } + + ue_PyFVector *py_vec = py_ue_is_fvector(py_obj); + if (!py_vec) + return PyErr_Format(PyExc_Exception, "argument is not a FVector"); + return py_ue_new_fvector(self->transform.TransformPosition(py_vec->vec)); +} + +static PyObject *py_ue_ftransform_transform_position_no_scale(ue_PyFTransform *self, PyObject * args) +{ + PyObject *py_obj; + if (!PyArg_ParseTuple(args, "O", &py_obj)) + { + return nullptr; + } + + ue_PyFVector *py_vec = py_ue_is_fvector(py_obj); + if (!py_vec) + return PyErr_Format(PyExc_Exception, "argument is not a FVector"); + return py_ue_new_fvector(self->transform.TransformPositionNoScale(py_vec->vec)); +} + +#if ENGINE_MINOR_VERSION > 17 +static PyObject *py_ue_ftransform_transform_rotation(ue_PyFTransform *self, PyObject * args) +{ + PyObject *py_obj; + if (!PyArg_ParseTuple(args, "O", &py_obj)) + { + return nullptr; + } + + ue_PyFQuat *py_quat = py_ue_is_fquat(py_obj); + if (!py_quat) + return PyErr_Format(PyExc_Exception, "argument is not a FQuat"); + return py_ue_new_fquat(self->transform.TransformRotation(py_quat->quat)); +} +#endif + +static PyObject *py_ue_ftransform_get_matrix(ue_PyFTransform *self, PyObject * args) +{ + FTransform transform = self->transform; + transform.NormalizeRotation(); + FMatrix matrix = transform.ToMatrixWithScale(); + UScriptStruct *u_struct = FindObject(ANY_PACKAGE, UTF8_TO_TCHAR("Matrix")); + if (!u_struct) + { + return PyErr_Format(PyExc_Exception, "unable to get Matrix struct"); + } + return py_ue_new_owned_uscriptstruct(u_struct, (uint8 *)&matrix); +} + static PyMethodDef ue_PyFTransform_methods[] = { { "inverse", (PyCFunction)py_ue_ftransform_inverse, METH_VARARGS, "" }, { "get_relative_transform", (PyCFunction)py_ue_ftransform_get_relative_transform, METH_VARARGS, "" }, { "normalize_rotation", (PyCFunction)py_ue_ftransform_normalize_rotation, METH_VARARGS, "" }, + { "get_matrix", (PyCFunction)py_ue_ftransform_get_matrix, METH_VARARGS, "" }, + { "transform_vector", (PyCFunction)py_ue_ftransform_transform_vector, METH_VARARGS, "" }, + { "transform_vector_no_scale", (PyCFunction)py_ue_ftransform_transform_vector_no_scale, METH_VARARGS, "" }, + { "transform_position", (PyCFunction)py_ue_ftransform_transform_position, METH_VARARGS, "" }, + { "transform_position_no_scale", (PyCFunction)py_ue_ftransform_transform_position_no_scale, METH_VARARGS, "" }, +#if ENGINE_MINOR_VERSION > 17 + { "transform_rotation", (PyCFunction)py_ue_ftransform_transform_rotation, METH_VARARGS, "" }, +#endif { NULL } /* Sentinel */ }; @@ -127,7 +220,7 @@ static PyObject *ue_PyFTransform_str(ue_PyFTransform *self) } -static PyTypeObject ue_PyFTransformType = { +PyTypeObject ue_PyFTransformType = { PyVarObject_HEAD_INIT(NULL, 0) "unreal_engine.FTransform", /* tp_name */ sizeof(ue_PyFTransform), /* tp_basicsize */ @@ -342,4 +435,4 @@ bool py_ue_transform_arg(PyObject *args, FTransform &t) t.SetRotation(FRotator(pitch, yaw, roll).Quaternion()); t.SetScale3D(FVector(sx, sy, sz)); return true; -} \ No newline at end of file +} diff --git a/Source/UnrealEnginePython/Private/Wrappers/UEPyFTransform.h b/Source/UnrealEnginePython/Private/Wrappers/UEPyFTransform.h index 74c23f214..86f58e0f9 100644 --- a/Source/UnrealEnginePython/Private/Wrappers/UEPyFTransform.h +++ b/Source/UnrealEnginePython/Private/Wrappers/UEPyFTransform.h @@ -2,7 +2,7 @@ -#include "UnrealEnginePython.h" +#include "UEPyModule.h" typedef struct { PyObject_HEAD @@ -10,8 +10,10 @@ typedef struct { FTransform transform; } ue_PyFTransform; +extern PyTypeObject ue_PyFTransformType; + PyObject *py_ue_new_ftransform(FTransform); ue_PyFTransform *py_ue_is_ftransform(PyObject *); void ue_python_init_ftransform(PyObject *); -bool py_ue_transform_arg(PyObject *, FTransform &); \ No newline at end of file +bool py_ue_transform_arg(PyObject *, FTransform &); diff --git a/Source/UnrealEnginePython/Private/Wrappers/UEPyFVector.cpp b/Source/UnrealEnginePython/Private/Wrappers/UEPyFVector.cpp index ba9ffa9ef..113c3bb62 100644 --- a/Source/UnrealEnginePython/Private/Wrappers/UEPyFVector.cpp +++ b/Source/UnrealEnginePython/Private/Wrappers/UEPyFVector.cpp @@ -1,4 +1,4 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPyFVector.h" static PyObject *py_ue_fvector_length(ue_PyFVector *self, PyObject * args) { @@ -151,7 +151,7 @@ static PyObject *ue_PyFVector_str(ue_PyFVector *self) PyFloat_FromDouble(self->vec.X), PyFloat_FromDouble(self->vec.Y), PyFloat_FromDouble(self->vec.Z)); } -static PyTypeObject ue_PyFVectorType = { +PyTypeObject ue_PyFVectorType = { PyVarObject_HEAD_INIT(NULL, 0) "unreal_engine.FVector", /* tp_name */ sizeof(ue_PyFVector), /* tp_basicsize */ @@ -277,6 +277,24 @@ static PyObject *ue_py_fvector_div(ue_PyFVector *self, PyObject *value) return py_ue_new_fvector(vec); } +static PyObject *ue_py_fvector_floor_div(ue_PyFVector *self, PyObject *value) +{ + FVector vec = self->vec; + if (PyNumber_Check(value)) + { + PyObject *f_value = PyNumber_Float(value); + float f = PyFloat_AsDouble(f_value); + if (f == 0) + return PyErr_Format(PyExc_ZeroDivisionError, "division by zero"); + vec.X = floor(vec.X / f); + vec.Y = floor(vec.Y / f); + vec.Z = floor(vec.Z / f); + Py_DECREF(f_value); + return py_ue_new_fvector(vec); + } + return PyErr_Format(PyExc_TypeError, "value is not numeric"); +} + PyNumberMethods ue_PyFVector_number_methods; static Py_ssize_t ue_py_fvector_seq_length(ue_PyFVector *self) @@ -363,7 +381,8 @@ void ue_python_init_fvector(PyObject *ue_module) ue_PyFVector_number_methods.nb_add = (binaryfunc)ue_py_fvector_add; ue_PyFVector_number_methods.nb_subtract = (binaryfunc)ue_py_fvector_sub; ue_PyFVector_number_methods.nb_multiply = (binaryfunc)ue_py_fvector_mul; - ue_PyFVector_number_methods.nb_divmod = (binaryfunc)ue_py_fvector_div; + ue_PyFVector_number_methods.nb_true_divide = (binaryfunc)ue_py_fvector_div; + ue_PyFVector_number_methods.nb_floor_divide = (binaryfunc)ue_py_fvector_floor_div; memset(&ue_PyFVector_sequence_methods, 0, sizeof(PySequenceMethods)); ue_PyFVectorType.tp_as_sequence = &ue_PyFVector_sequence_methods; diff --git a/Source/UnrealEnginePython/Private/Wrappers/UEPyFVector.h b/Source/UnrealEnginePython/Private/Wrappers/UEPyFVector.h index bdc9df770..b7b0853e8 100644 --- a/Source/UnrealEnginePython/Private/Wrappers/UEPyFVector.h +++ b/Source/UnrealEnginePython/Private/Wrappers/UEPyFVector.h @@ -2,17 +2,20 @@ -#include "UnrealEnginePython.h" +#include "UEPyModule.h" -typedef struct { +typedef struct +{ PyObject_HEAD - /* Type-specific fields go here. */ - FVector vec; + /* Type-specific fields go here. */ + FVector vec; } ue_PyFVector; +extern PyTypeObject ue_PyFVectorType; + PyObject *py_ue_new_fvector(FVector); ue_PyFVector *py_ue_is_fvector(PyObject *); void ue_python_init_fvector(PyObject *); -bool py_ue_vector_arg(PyObject *, FVector &); \ No newline at end of file +bool py_ue_vector_arg(PyObject *, FVector &); diff --git a/Source/UnrealEnginePython/Private/Wrappers/UEPyFVector2D.cpp b/Source/UnrealEnginePython/Private/Wrappers/UEPyFVector2D.cpp new file mode 100644 index 000000000..20855cf56 --- /dev/null +++ b/Source/UnrealEnginePython/Private/Wrappers/UEPyFVector2D.cpp @@ -0,0 +1,368 @@ +#include "UEPyFVector2D.h" + +static PyObject *py_ue_fvector2d_length(ue_PyFVector2D *self, PyObject * args) +{ + return PyFloat_FromDouble(self->vec.Size()); +} + +static PyObject *py_ue_fvector2d_length_squared(ue_PyFVector2D *self, PyObject * args) +{ + return PyFloat_FromDouble(self->vec.SizeSquared()); +} + +static PyObject *py_ue_fvector2d_normalized(ue_PyFVector2D *self, PyObject * args) +{ + FVector2D vec = self->vec; + vec.Normalize(); + return py_ue_new_fvector2d(vec); +} + +static PyObject *py_ue_fvector2d_dot(ue_PyFVector2D *self, PyObject * args) +{ + PyObject *py_obj; + if (!PyArg_ParseTuple(args, "O:dot", &py_obj)) + return NULL; + ue_PyFVector2D *py_vec = py_ue_is_fvector2d(py_obj); + if (!py_vec) + return PyErr_Format(PyExc_TypeError, "argument is not a FVector2D"); + return PyFloat_FromDouble(FVector2D::DotProduct(self->vec, py_vec->vec)); +} + +static PyObject *py_ue_fvector2d_cross(ue_PyFVector2D *self, PyObject * args) +{ + PyObject *py_obj; + if (!PyArg_ParseTuple(args, "O:cross", &py_obj)) + return NULL; + ue_PyFVector2D *py_vec = py_ue_is_fvector2d(py_obj); + if (!py_vec) + return PyErr_Format(PyExc_TypeError, "argument is not a FVector2D"); + return PyFloat_FromDouble(FVector2D::CrossProduct(self->vec, py_vec->vec)); +} + +static PyMethodDef ue_PyFVector2D_methods[] = { + + { "length", (PyCFunction)py_ue_fvector2d_length, METH_VARARGS, "" }, + { "size", (PyCFunction)py_ue_fvector2d_length, METH_VARARGS, "" }, + { "size_squared", (PyCFunction)py_ue_fvector2d_length_squared, METH_VARARGS, "" }, + { "length_squared", (PyCFunction)py_ue_fvector2d_length_squared, METH_VARARGS, "" }, + { "normalized", (PyCFunction)py_ue_fvector2d_normalized, METH_VARARGS, "" }, + { "dot", (PyCFunction)py_ue_fvector2d_dot, METH_VARARGS, "" }, + { "cross", (PyCFunction)py_ue_fvector2d_cross, METH_VARARGS, "" }, + { NULL } /* Sentinel */ +}; + +static PyObject *py_ue_fvector2d_get_x(ue_PyFVector2D *self, void *closure) +{ + return PyFloat_FromDouble(self->vec.X); +} + +static int py_ue_fvector2d_set_x(ue_PyFVector2D *self, PyObject *value, void *closure) +{ + if (value && PyNumber_Check(value)) + { + PyObject *f_value = PyNumber_Float(value); + self->vec.X = PyFloat_AsDouble(f_value); + Py_DECREF(f_value); + return 0; + } + PyErr_SetString(PyExc_TypeError, "value is not numeric"); + return -1; +} + +static PyObject *py_ue_fvector2d_get_y(ue_PyFVector2D *self, void *closure) +{ + return PyFloat_FromDouble(self->vec.Y); +} + +static int py_ue_fvector2d_set_y(ue_PyFVector2D *self, PyObject *value, void *closure) +{ + if (value && PyNumber_Check(value)) + { + PyObject *f_value = PyNumber_Float(value); + self->vec.Y = PyFloat_AsDouble(f_value); + Py_DECREF(f_value); + return 0; + } + PyErr_SetString(PyExc_TypeError, "value is not numeric"); + return -1; +} + + +static PyGetSetDef ue_PyFVector2D_getseters[] = { + {(char *) "x", (getter)py_ue_fvector2d_get_x, (setter)py_ue_fvector2d_set_x, (char *)"", NULL }, + {(char *) "y", (getter)py_ue_fvector2d_get_y, (setter)py_ue_fvector2d_set_y, (char *)"", NULL }, + { NULL } /* Sentinel */ +}; + +static PyObject *ue_PyFVector2D_str(ue_PyFVector2D *self) +{ + return PyUnicode_FromFormat("", + PyFloat_FromDouble(self->vec.X), PyFloat_FromDouble(self->vec.Y)); +} + +PyTypeObject ue_PyFVector2DType = { + PyVarObject_HEAD_INIT(NULL, 0) + "unreal_engine.FVector2D", /* tp_name */ + sizeof(ue_PyFVector2D), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc)ue_PyFVector2D_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ +#if PY_MAJOR_VERSION < 3 + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_CHECKTYPES, /* tp_flags */ +#else + Py_TPFLAGS_DEFAULT, /* tp_flags */ +#endif + "Unreal Engine FVector2D", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + ue_PyFVector2D_methods, /* tp_methods */ + 0, + ue_PyFVector2D_getseters, +}; + + +static PyObject *ue_py_fvector2d_add(ue_PyFVector2D *self, PyObject *value) +{ + FVector2D vec = self->vec; + ue_PyFVector2D *py_vec = py_ue_is_fvector2d(value); + if (py_vec) + { + vec += py_vec->vec; + } + else if (PyNumber_Check(value)) + { + PyObject *f_value = PyNumber_Float(value); + float f = PyFloat_AsDouble(f_value); + vec.X += f; + vec.Y += f; + Py_DECREF(f_value); + } + return py_ue_new_fvector2d(vec); +} + +static PyObject *ue_py_fvector2d_sub(ue_PyFVector2D *self, PyObject *value) +{ + FVector2D vec = self->vec; + ue_PyFVector2D *py_vec = py_ue_is_fvector2d(value); + if (py_vec) + { + vec -= py_vec->vec; + } + else if (PyNumber_Check(value)) + { + PyObject *f_value = PyNumber_Float(value); + float f = PyFloat_AsDouble(f_value); + vec.X -= f; + vec.Y -= f; + Py_DECREF(f_value); + } + return py_ue_new_fvector2d(vec); +} + +static PyObject *ue_py_fvector2d_mul(ue_PyFVector2D *self, PyObject *value) +{ + FVector2D vec = self->vec; + ue_PyFVector2D *py_vec = py_ue_is_fvector2d(value); + if (py_vec) + { + vec *= py_vec->vec; + } + else if (PyNumber_Check(value)) + { + PyObject *f_value = PyNumber_Float(value); + float f = PyFloat_AsDouble(f_value); + vec *= f; + Py_DECREF(f_value); + } + return py_ue_new_fvector2d(vec); +} + +static PyObject *ue_py_fvector2d_div(ue_PyFVector2D *self, PyObject *value) +{ + FVector2D vec = self->vec; + ue_PyFVector2D *py_vec = py_ue_is_fvector2d(value); + if (py_vec) + { + if (py_vec->vec.X == 0 || py_vec->vec.Y == 0) + return PyErr_Format(PyExc_ZeroDivisionError, "division by zero"); + vec /= py_vec->vec; + } + else if (PyNumber_Check(value)) + { + PyObject *f_value = PyNumber_Float(value); + float f = PyFloat_AsDouble(f_value); + if (f == 0) + return PyErr_Format(PyExc_ZeroDivisionError, "division by zero"); + vec /= f; + Py_DECREF(f_value); + } + return py_ue_new_fvector2d(vec); +} + +static PyObject *ue_py_fvector2d_floor_div(ue_PyFVector2D *self, PyObject *value) +{ + FVector2D vec = self->vec; + if (PyNumber_Check(value)) + { + PyObject *f_value = PyNumber_Float(value); + float f = PyFloat_AsDouble(f_value); + if (f == 0) + return PyErr_Format(PyExc_ZeroDivisionError, "division by zero"); + vec.X = floor(vec.X / f); + vec.Y = floor(vec.Y / f); + Py_DECREF(f_value); + return py_ue_new_fvector2d(vec); + } + return PyErr_Format(PyExc_TypeError, "value is not numeric"); +} + +PyNumberMethods ue_PyFVector2D_number_methods; + +static Py_ssize_t ue_py_fvector2d_seq_length(ue_PyFVector2D *self) +{ + return 2; +} + +static PyObject *ue_py_fvector2d_seq_item(ue_PyFVector2D *self, Py_ssize_t i) +{ + switch (i) + { + case 0: + return PyFloat_FromDouble(self->vec.X); + case 1: + return PyFloat_FromDouble(self->vec.Y); + } + return PyErr_Format(PyExc_IndexError, "FVector2D has only 2 items"); +} + +PySequenceMethods ue_PyFVector2D_sequence_methods; + +static int ue_py_fvector2d_init(ue_PyFVector2D *self, PyObject *args, PyObject *kwargs) +{ + float x = 0, y = 0; + if (!PyArg_ParseTuple(args, "|ff", &x, &y)) + return -1; + + if (PyTuple_Size(args) == 1) + { + y = x; + } + + self->vec.X = x; + self->vec.Y = y; + + return 0; +} + +static PyObject *ue_py_fvector2d_richcompare(ue_PyFVector2D *vec1, PyObject *b, int op) +{ + ue_PyFVector2D *vec2 = py_ue_is_fvector2d(b); + if (!vec2 || (op != Py_EQ && op != Py_NE)) + { + return PyErr_Format(PyExc_NotImplementedError, "can only compare with another FVector2D"); + } + + if (op == Py_EQ) + { + if (vec1->vec.X == vec2->vec.X && + vec1->vec.Y == vec2->vec.Y) + { + Py_INCREF(Py_True); + return Py_True; + } + Py_INCREF(Py_False); + return Py_False; + } + + if (vec1->vec.X == vec2->vec.X && + vec1->vec.Y == vec2->vec.Y) + { + Py_INCREF(Py_False); + return Py_False; + } + Py_INCREF(Py_True); + return Py_True; +} + +void ue_python_init_fvector2d(PyObject *ue_module) +{ + ue_PyFVector2DType.tp_new = PyType_GenericNew; + + ue_PyFVector2DType.tp_init = (initproc)ue_py_fvector2d_init; + ue_PyFVector2DType.tp_richcompare = (richcmpfunc)ue_py_fvector2d_richcompare; + + memset(&ue_PyFVector2D_number_methods, 0, sizeof(PyNumberMethods)); + ue_PyFVector2DType.tp_as_number = &ue_PyFVector2D_number_methods; + ue_PyFVector2D_number_methods.nb_add = (binaryfunc)ue_py_fvector2d_add; + ue_PyFVector2D_number_methods.nb_subtract = (binaryfunc)ue_py_fvector2d_sub; + ue_PyFVector2D_number_methods.nb_multiply = (binaryfunc)ue_py_fvector2d_mul; + ue_PyFVector2D_number_methods.nb_true_divide = (binaryfunc)ue_py_fvector2d_div; + ue_PyFVector2D_number_methods.nb_floor_divide = (binaryfunc)ue_py_fvector2d_floor_div; + + memset(&ue_PyFVector2D_sequence_methods, 0, sizeof(PySequenceMethods)); + ue_PyFVector2DType.tp_as_sequence = &ue_PyFVector2D_sequence_methods; + ue_PyFVector2D_sequence_methods.sq_length = (lenfunc)ue_py_fvector2d_seq_length; + ue_PyFVector2D_sequence_methods.sq_item = (ssizeargfunc)ue_py_fvector2d_seq_item; + + if (PyType_Ready(&ue_PyFVector2DType) < 0) + return; + + Py_INCREF(&ue_PyFVector2DType); + PyModule_AddObject(ue_module, "FVector2D", (PyObject *)&ue_PyFVector2DType); +} + +PyObject *py_ue_new_fvector2d(FVector2D vec) +{ + ue_PyFVector2D *ret = (ue_PyFVector2D *)PyObject_New(ue_PyFVector2D, &ue_PyFVector2DType); + ret->vec = vec; + return (PyObject *)ret; +} + +ue_PyFVector2D *py_ue_is_fvector2d(PyObject *obj) +{ + if (!PyObject_IsInstance(obj, (PyObject *)&ue_PyFVector2DType)) + return nullptr; + return (ue_PyFVector2D *)obj; +} + +bool py_ue_vector2d_arg(PyObject *args, FVector2D &vec) +{ + + if (PyTuple_Size(args) == 1) + { + PyObject *arg = PyTuple_GetItem(args, 0); + ue_PyFVector2D *py_vec = py_ue_is_fvector2d(arg); + if (!py_vec) + { + PyErr_Format(PyExc_TypeError, "argument is not a FVector2D"); + return false; + } + vec = py_vec->vec; + return true; + } + + float x, y; + if (!PyArg_ParseTuple(args, "ff", &x, &y)) + return false; + vec.X = x; + vec.Y = y; + return true; +} + diff --git a/Source/UnrealEnginePython/Private/Wrappers/UEPyFVector2D.h b/Source/UnrealEnginePython/Private/Wrappers/UEPyFVector2D.h new file mode 100644 index 000000000..b9c2f4d73 --- /dev/null +++ b/Source/UnrealEnginePython/Private/Wrappers/UEPyFVector2D.h @@ -0,0 +1,21 @@ +#pragma once + + + +#include "UEPyModule.h" + +typedef struct +{ + PyObject_HEAD + /* Type-specific fields go here. */ + FVector2D vec; +} ue_PyFVector2D; + +extern PyTypeObject ue_PyFVector2DType; + +PyObject *py_ue_new_fvector2d(FVector2D); +ue_PyFVector2D *py_ue_is_fvector2d(PyObject *); + +void ue_python_init_fvector2d(PyObject *); + +bool py_ue_vector2d_arg(PyObject *, FVector2D &); diff --git a/Source/UnrealEnginePython/Private/Wrappers/UEPyFViewportClient.cpp b/Source/UnrealEnginePython/Private/Wrappers/UEPyFViewportClient.cpp index 9b2dfe9fd..31bd02496 100644 --- a/Source/UnrealEnginePython/Private/Wrappers/UEPyFViewportClient.cpp +++ b/Source/UnrealEnginePython/Private/Wrappers/UEPyFViewportClient.cpp @@ -1,4 +1,6 @@ -#include "UnrealEnginePythonPrivatePCH.h" +#include "UEPyFViewportClient.h" + +#include "Engine/World.h" static PyObject *py_ue_fviewport_client_get_world(ue_PyFViewportClient *self, PyObject * args) { diff --git a/Source/UnrealEnginePython/Private/Wrappers/UEPyFViewportClient.h b/Source/UnrealEnginePython/Private/Wrappers/UEPyFViewportClient.h index 1e13913b9..f15877bca 100644 --- a/Source/UnrealEnginePython/Private/Wrappers/UEPyFViewportClient.h +++ b/Source/UnrealEnginePython/Private/Wrappers/UEPyFViewportClient.h @@ -1,12 +1,15 @@ #pragma once -#include "UnrealEnginePython.h" + +#include "UEPyModule.h" +#include "UnrealClient.h" extern PyTypeObject ue_PyFViewportClientType; -struct ue_PyFViewportClient { +struct ue_PyFViewportClient +{ PyObject_HEAD - /* Type-specific fields go here. */ - TSharedRef viewport_client;; + /* Type-specific fields go here. */ + TSharedRef viewport_client;; }; void ue_python_init_fviewport_client(PyObject *); diff --git a/Source/UnrealEnginePython/Private/Wrappers/UEPyIAssetEditorInstance.cpp b/Source/UnrealEnginePython/Private/Wrappers/UEPyIAssetEditorInstance.cpp new file mode 100644 index 000000000..47bd92fbd --- /dev/null +++ b/Source/UnrealEnginePython/Private/Wrappers/UEPyIAssetEditorInstance.cpp @@ -0,0 +1,103 @@ +#include "UEPyIAssetEditorInstance.h" + +#if WITH_EDITOR + + + +static PyObject *py_ue_iasset_editor_instance_close_window(ue_PyIAssetEditorInstance *self, PyObject * args) +{ + self->editor_instance->CloseWindow(); + Py_RETURN_NONE; +} + +static PyObject *py_ue_iasset_editor_instance_focus_window(ue_PyIAssetEditorInstance *self, PyObject * args) +{ + self->editor_instance->FocusWindow(); + Py_RETURN_NONE; +} + +static PyObject *py_ue_iasset_editor_instance_get_editor_name(ue_PyIAssetEditorInstance *self, PyObject * args) +{ + return PyUnicode_FromString(TCHAR_TO_UTF8(*self->editor_instance->GetEditorName().ToString())); +} + +static PyObject *py_ue_iasset_editor_instance_get_last_activation_time(ue_PyIAssetEditorInstance *self, PyObject * args) +{ + return PyFloat_FromDouble(self->editor_instance->GetLastActivationTime()); +} + +static PyMethodDef ue_PyIAssetEditorInstance_methods[] = { + { "close_window", (PyCFunction)py_ue_iasset_editor_instance_close_window, METH_VARARGS, "" }, + { "focus_window", (PyCFunction)py_ue_iasset_editor_instance_focus_window, METH_VARARGS, "" }, + { "get_editor_name", (PyCFunction)py_ue_iasset_editor_instance_get_editor_name, METH_VARARGS, "" }, + { "get_last_activation_time", (PyCFunction)py_ue_iasset_editor_instance_get_last_activation_time, METH_VARARGS, "" }, + { nullptr } /* Sentinel */ +}; + +static PyObject *ue_PyIAssetEditorInstance_str(ue_PyIAssetEditorInstance *self) +{ + return PyUnicode_FromFormat("", + &self->editor_instance); +} + +static PyTypeObject ue_PyIAssetEditorInstanceType = { + PyVarObject_HEAD_INIT(NULL, 0) + "unreal_engine.IAssetEditorInstance", /* tp_name */ + sizeof(ue_PyIAssetEditorInstance), /* tp_basicsize */ + 0, /* tp_itemsize */ + 0, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_reserved */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc)ue_PyIAssetEditorInstance_str, /* tp_str */ + 0, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ +#if PY_MAJOR_VERSION < 3 + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_CHECKTYPES, /* tp_flags */ +#else + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ +#endif + "Unreal Engine IAssetEditorInstance", /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + ue_PyIAssetEditorInstance_methods, /* tp_methods */ + 0, +}; + +void ue_python_init_iasset_editor_instance(PyObject *ue_module) +{ + ue_PyIAssetEditorInstanceType.tp_new = PyType_GenericNew; + + if (PyType_Ready(&ue_PyIAssetEditorInstanceType) < 0) + return; + + Py_INCREF(&ue_PyIAssetEditorInstanceType); + PyModule_AddObject(ue_module, "IAssetEditorInstance", (PyObject *)&ue_PyIAssetEditorInstanceType); +} + +ue_PyIAssetEditorInstance *py_ue_is_iasset_editor_instance(PyObject *obj) +{ + if (!PyObject_IsInstance(obj, (PyObject *)&ue_PyIAssetEditorInstanceType)) + return nullptr; + return (ue_PyIAssetEditorInstance *)obj; +} + +PyObject *py_ue_new_iasset_editor_instance(IAssetEditorInstance *editor_instance) +{ + ue_PyIAssetEditorInstance *ret = (ue_PyIAssetEditorInstance *)PyObject_New(ue_PyIAssetEditorInstance, &ue_PyIAssetEditorInstanceType); + ret->editor_instance = editor_instance; + return (PyObject *)ret; +} +#endif \ No newline at end of file diff --git a/Source/UnrealEnginePython/Private/Wrappers/UEPyIAssetEditorInstance.h b/Source/UnrealEnginePython/Private/Wrappers/UEPyIAssetEditorInstance.h new file mode 100644 index 000000000..a2d04496d --- /dev/null +++ b/Source/UnrealEnginePython/Private/Wrappers/UEPyIAssetEditorInstance.h @@ -0,0 +1,21 @@ +#pragma once +#include "UnrealEnginePython.h" + +#if WITH_EDITOR + +#include "Editor/UnrealEd/Public/Toolkits/AssetEditorManager.h" + +struct ue_PyIAssetEditorInstance +{ + PyObject_HEAD + /* Type-specific fields go here. */ + IAssetEditorInstance *editor_instance; +}; + +void ue_python_init_iasset_editor_instance(PyObject *); + +PyObject *py_ue_new_iasset_editor_instance(IAssetEditorInstance *); + +ue_PyIAssetEditorInstance *py_ue_is_iasset_editor_instance(PyObject *); + +#endif \ No newline at end of file diff --git a/Source/UnrealEnginePython/Public/PyActor.h b/Source/UnrealEnginePython/Public/PyActor.h index dcc03fbde..e2bfe95ae 100644 --- a/Source/UnrealEnginePython/Public/PyActor.h +++ b/Source/UnrealEnginePython/Public/PyActor.h @@ -2,7 +2,7 @@ #include "GameFramework/Actor.h" - +#include "UnrealEnginePython.h" #include "PyActor.generated.h" diff --git a/Source/UnrealEnginePython/Public/PyCharacter.h b/Source/UnrealEnginePython/Public/PyCharacter.h index f1136c9cf..675cd810f 100644 --- a/Source/UnrealEnginePython/Public/PyCharacter.h +++ b/Source/UnrealEnginePython/Public/PyCharacter.h @@ -1,7 +1,7 @@ #pragma once #include "GameFramework/Character.h" - +#include "UnrealEnginePython.h" #include "PyCharacter.generated.h" @@ -31,53 +31,53 @@ class UNREALENGINEPYTHON_API APyCharacter : public ACharacter virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override; - UPROPERTY(EditAnywhere , Category = "Python") - FString PythonModule; + UPROPERTY(EditAnywhere, Category = "Python") + FString PythonModule; UPROPERTY(EditAnywhere, Category = "Python") - FString PythonClass; + FString PythonClass; UPROPERTY(EditAnywhere, Category = "Python") - bool PythonTickForceDisabled; + bool PythonTickForceDisabled; UPROPERTY(EditAnywhere, Category = "Python") - bool PythonDisableAutoBinding; + bool PythonDisableAutoBinding; UFUNCTION(BlueprintCallable, Category = "Python") - void CallPyCharacterMethod(FString method_name, FString args); + void CallPyCharacterMethod(FString method_name, FString args); UFUNCTION(BlueprintCallable, Category = "Python") - bool CallPyCharacterMethodBool(FString method_name, FString args); + bool CallPyCharacterMethodBool(FString method_name, FString args); UFUNCTION(BlueprintCallable, Category = "Python") - FString CallPyCharacterMethodString(FString method_name, FString args); + FString CallPyCharacterMethodString(FString method_name, FString args); UFUNCTION(BlueprintCallable, Category = "Python") - float CallPyCharacterMethodFloat(FString method_name, FString args); + float CallPyCharacterMethodFloat(FString method_name, FString args); UFUNCTION(BlueprintCallable, Category = "Python") - void SetPythonAttrInt(FString attr, int Integer); + void SetPythonAttrInt(FString attr, int Integer); UFUNCTION(BlueprintCallable, Category = "Python") - void SetPythonAttrFloat(FString attr, float Float); + void SetPythonAttrFloat(FString attr, float Float); UFUNCTION(BlueprintCallable, Category = "Python") - void SetPythonAttrString(FString attr, FString String); + void SetPythonAttrString(FString attr, FString String); UFUNCTION(BlueprintCallable, Category = "Python") - void SetPythonAttrBool(FString attr, bool Boolean); + void SetPythonAttrBool(FString attr, bool Boolean); UFUNCTION(BlueprintCallable, Category = "Python") - void SetPythonAttrVector(FString attr, FVector Vector); + void SetPythonAttrVector(FString attr, FVector Vector); UFUNCTION(BlueprintCallable, Category = "Python") - void SetPythonAttrRotator(FString attr, FRotator Rotator); + void SetPythonAttrRotator(FString attr, FRotator Rotator); UFUNCTION(BlueprintCallable, Category = "Python") - void SetPythonAttrObject(FString attr, UObject *Object); + void SetPythonAttrObject(FString attr, UObject *Object); private: - PyObject *py_character_instance; + PyObject * py_character_instance; // mapped uobject, required for debug and advanced reflection ue_PyUObject *py_uobject; }; diff --git a/Source/UnrealEnginePython/Public/PyHUD.h b/Source/UnrealEnginePython/Public/PyHUD.h index de5ffdd40..8948cdcbf 100644 --- a/Source/UnrealEnginePython/Public/PyHUD.h +++ b/Source/UnrealEnginePython/Public/PyHUD.h @@ -2,7 +2,7 @@ #include "GameFramework/HUD.h" - +#include "UnrealEnginePython.h" #include "PyHUD.generated.h" diff --git a/Source/UnrealEnginePython/Public/PyNativeWidgetHost.h b/Source/UnrealEnginePython/Public/PyNativeWidgetHost.h index fa20c574f..756ac9b0e 100644 --- a/Source/UnrealEnginePython/Public/PyNativeWidgetHost.h +++ b/Source/UnrealEnginePython/Public/PyNativeWidgetHost.h @@ -3,7 +3,7 @@ #pragma once #include "UObject/Class.h" - +#include "UnrealEnginePython.h" #include "Components/NativeWidgetHost.h" #include "PyNativeWidgetHost.generated.h" @@ -12,34 +12,34 @@ USTRUCT(BlueprintType) struct UNREALENGINEPYTHON_API FPythonSWidgetWrapper { - GENERATED_USTRUCT_BODY() + GENERATED_USTRUCT_BODY() - TSharedPtr Widget; + TSharedPtr Widget; }; template<> struct TStructOpsTypeTraits : public TStructOpsTypeTraitsBase2 { - enum + enum { WithCopy = true, }; }; /** - * + * */ UCLASS() class UNREALENGINEPYTHON_API UPyNativeWidgetHost : public UNativeWidgetHost { - GENERATED_BODY() + GENERATED_BODY() - UPyNativeWidgetHost(const FObjectInitializer& ObjectInitializer); + UPyNativeWidgetHost(const FObjectInitializer& ObjectInitializer); #if WITH_EDITOR - virtual const FText GetPaletteCategory() override; + virtual const FText GetPaletteCategory() override; #endif - + }; diff --git a/Source/UnrealEnginePython/Public/PyPawn.h b/Source/UnrealEnginePython/Public/PyPawn.h index 974c930a2..513a2cc24 100644 --- a/Source/UnrealEnginePython/Public/PyPawn.h +++ b/Source/UnrealEnginePython/Public/PyPawn.h @@ -2,7 +2,7 @@ #include "GameFramework/Pawn.h" - +#include "UnrealEnginePython.h" #include "PyPawn.generated.h" diff --git a/Source/UnrealEnginePython/Public/PyUserWidget.h b/Source/UnrealEnginePython/Public/PyUserWidget.h index 20b856f32..fb4a3d143 100644 --- a/Source/UnrealEnginePython/Public/PyUserWidget.h +++ b/Source/UnrealEnginePython/Public/PyUserWidget.h @@ -1,10 +1,17 @@ #pragma once #include "Runtime/UMG/Public/Blueprint/UserWidget.h" - +#include "UnrealEnginePython.h" +#include "Runtime/Launch/Resources/Version.h" #include "PyUserWidget.generated.h" - +#if ENGINE_MINOR_VERSION < 20 +#define NativePaintArgs FPaintContext & InContext +#define NativePaintRetValue void +#else +#define NativePaintArgs const FPaintArgs& Args, const FGeometry& AllottedGeometry, const FSlateRect& MyCullingRect, FSlateWindowElementList& OutDrawElements, int32 LayerId, const FWidgetStyle& InWidgetStyle, bool bParentEnabled +#define NativePaintRetValue int32 +#endif UCLASS(BlueprintType, Blueprintable) class UNREALENGINEPYTHON_API UPyUserWidget : public UUserWidget @@ -12,7 +19,7 @@ class UNREALENGINEPYTHON_API UPyUserWidget : public UUserWidget GENERATED_BODY() public: - UPyUserWidget(const FObjectInitializer& ObjectInitializer); + UPyUserWidget(const FObjectInitializer& ObjectInitializer); ~UPyUserWidget(); virtual void NativeConstruct() override; @@ -21,7 +28,7 @@ class UNREALENGINEPYTHON_API UPyUserWidget : public UUserWidget // Called every frame virtual void NativeTick(const FGeometry & MyGeometry, float InDeltaTime) override; - virtual void NativePaint(FPaintContext & InContext) const override; + virtual NativePaintRetValue NativePaint(NativePaintArgs) const override; virtual bool NativeIsInteractable() const override; @@ -33,37 +40,37 @@ class UNREALENGINEPYTHON_API UPyUserWidget : public UUserWidget virtual FReply NativeOnKeyDown(const FGeometry & InGeometry, const FKeyEvent & InKeyEvent) override; UPROPERTY(EditAnywhere, Category = "Python", BlueprintReadWrite, meta = (ExposeOnSpawn = true)) - FString PythonModule; + FString PythonModule; UPROPERTY(EditAnywhere, Category = "Python", BlueprintReadWrite, meta = (ExposeOnSpawn = true)) - FString PythonClass; + FString PythonClass; UPROPERTY(EditAnywhere, Category = "Python", BlueprintReadWrite, meta = (ExposeOnSpawn = true)) - bool PythonTickForceDisabled; + bool PythonTickForceDisabled; UPROPERTY(EditAnywhere, Category = "Python", BlueprintReadWrite, meta = (ExposeOnSpawn = true)) - bool PythonPaintForceDisabled; + bool PythonPaintForceDisabled; UFUNCTION(BlueprintCallable, Category = "Python") - void CallPythonUserWidgetMethod(FString method_name, FString args); + void CallPythonUserWidgetMethod(FString method_name, FString args); - UPROPERTY(EditAnywhere, Category = "Python", BlueprintReadWrite) - TWeakObjectPtr PyNativeWidgetHost; + UPROPERTY(EditAnywhere, Category = "Python", BlueprintReadWrite) + TWeakObjectPtr PyNativeWidgetHost; #if WITH_EDITOR - virtual const FText GetPaletteCategory() override; + virtual const FText GetPaletteCategory() override; #endif - void SetSlateWidget(TSharedRef InContent); - virtual void ReleaseSlateResources(bool bReleaseChildren) override; + void SetSlateWidget(TSharedRef InContent); + virtual void ReleaseSlateResources(bool bReleaseChildren) override; protected: - // UWidget interface - virtual TSharedRef RebuildWidget() override; - // End of UWidget interface + // UWidget interface + virtual TSharedRef RebuildWidget() override; + // End of UWidget interface private: - PyObject *py_user_widget_instance; + PyObject * py_user_widget_instance; // mapped uobject, required for debug and advanced reflection ue_PyUObject *py_uobject; }; diff --git a/Source/UnrealEnginePython/Public/PythonBlueprintFunctionLibrary.h b/Source/UnrealEnginePython/Public/PythonBlueprintFunctionLibrary.h index c8f5cad7c..51acdc180 100644 --- a/Source/UnrealEnginePython/Public/PythonBlueprintFunctionLibrary.h +++ b/Source/UnrealEnginePython/Public/PythonBlueprintFunctionLibrary.h @@ -2,6 +2,7 @@ #include "Kismet/BlueprintFunctionLibrary.h" +#include "UnrealEnginePython.h" #include "PythonBlueprintFunctionLibrary.generated.h" @@ -12,9 +13,9 @@ class UNREALENGINEPYTHON_API UPythonBlueprintFunctionLibrary : public UBlueprint public: UFUNCTION(BlueprintCallable, Exec, Category = "Python") - static void ExecutePythonScript(FString script); + static void ExecutePythonScript(FString script); - UFUNCTION(BlueprintCallable, Exec, Category = "Python") - static void ExecutePythonString(const FString& PythonCmd); + UFUNCTION(BlueprintCallable, Exec, Category = "Python") + static void ExecutePythonString(const FString& PythonCmd); }; diff --git a/Source/UnrealEnginePython/Public/PythonClass.h b/Source/UnrealEnginePython/Public/PythonClass.h index f1d448aa7..c814cd7ad 100644 --- a/Source/UnrealEnginePython/Public/PythonClass.h +++ b/Source/UnrealEnginePython/Public/PythonClass.h @@ -1,8 +1,10 @@ #pragma once - +#include "UnrealEnginePython.h" #include "PythonClass.generated.h" +void unreal_engine_py_log_error(); + UCLASS() class UPythonClass : public UClass { @@ -10,16 +12,19 @@ class UPythonClass : public UClass public: - void SetPyConstructor(PyObject *callable) { + void SetPyConstructor(PyObject *callable) + { py_constructor = callable; Py_INCREF(py_constructor); } - void CallPyConstructor(ue_PyUObject *self) { + void CallPyConstructor(ue_PyUObject *self) + { if (!py_constructor) return; PyObject *ret = PyObject_CallObject(py_constructor, Py_BuildValue("(O)", self)); - if (!ret) { + if (!ret) + { unreal_engine_py_log_error(); return; } @@ -31,6 +36,6 @@ class UPythonClass : public UClass private: - PyObject *py_constructor; + PyObject * py_constructor; }; diff --git a/Source/UnrealEnginePython/Public/PythonComponent.h b/Source/UnrealEnginePython/Public/PythonComponent.h index aa08c70af..1f8a13dc1 100644 --- a/Source/UnrealEnginePython/Public/PythonComponent.h +++ b/Source/UnrealEnginePython/Public/PythonComponent.h @@ -1,7 +1,7 @@ #pragma once #include "Components/ActorComponent.h" - +#include "UnrealEnginePython.h" #include "PythonComponent.generated.h" @@ -26,68 +26,73 @@ class UNREALENGINEPYTHON_API UPythonComponent : public UActorComponent virtual void InitializeComponent() override; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Python") - FString PythonModule; + FString PythonModule; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Python") + FString PythonClass; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Python") - FString PythonClass; + bool PythonTickForceDisabled; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Python") - bool PythonTickForceDisabled; + bool PythonDisableAutoBinding; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Python") - bool PythonDisableAutoBinding; + bool PythonTickEnableGenerator; UFUNCTION(BlueprintCallable, Category = "Python") - void InitializePythonComponent(); + void InitializePythonComponent(); UFUNCTION(BlueprintCallable, Category = "Python") - void CallPythonComponentMethod(FString method_name, FString args); + void CallPythonComponentMethod(FString method_name, FString args); UFUNCTION(BlueprintCallable, Category = "Python") - bool CallPythonComponentMethodBool(FString method_name, FString args); + bool CallPythonComponentMethodBool(FString method_name, FString args); UFUNCTION(BlueprintCallable, Category = "Python") - FString CallPythonComponentMethodString(FString method_name, FString args); + FString CallPythonComponentMethodString(FString method_name, FString args); UFUNCTION(BlueprintCallable, Category = "Python") - TMap CallPythonComponentMethodMap(FString method_name, FString args); + TMap CallPythonComponentMethodMap(FString method_name, FString args); UFUNCTION(BlueprintCallable, Category = "Python") - void CallPythonComponentMethodStringArray(FString method_name, FString args, TArray &output_strings); + void CallPythonComponentMethodStringArray(FString method_name, FString args, TArray &output_strings); UFUNCTION(BlueprintCallable, Category = "Python") - float CallPythonComponentMethodFloat(FString method_name, FString args); + float CallPythonComponentMethodFloat(FString method_name, FString args); UFUNCTION(BlueprintCallable, Category = "Python") - int CallPythonComponentMethodInt(FString method_name, FString args); + int CallPythonComponentMethodInt(FString method_name, FString args); UFUNCTION(BlueprintCallable, Category = "Python") - UObject *CallPythonComponentMethodObject(FString method_name, UObject *arg); + UObject *CallPythonComponentMethodObject(FString method_name, UObject *arg); UFUNCTION(BlueprintCallable, Category = "Python") - void SetPythonAttrInt(FString attr, int Integer); + void SetPythonAttrInt(FString attr, int Integer); UFUNCTION(BlueprintCallable, Category = "Python") - void SetPythonAttrFloat(FString attr, float Float); + void SetPythonAttrFloat(FString attr, float Float); UFUNCTION(BlueprintCallable, Category = "Python") - void SetPythonAttrString(FString attr, FString String); + void SetPythonAttrString(FString attr, FString String); UFUNCTION(BlueprintCallable, Category = "Python") - void SetPythonAttrBool(FString attr, bool Boolean); + void SetPythonAttrBool(FString attr, bool Boolean); UFUNCTION(BlueprintCallable, Category = "Python") - void SetPythonAttrVector(FString attr, FVector Vector); + void SetPythonAttrVector(FString attr, FVector Vector); UFUNCTION(BlueprintCallable, Category = "Python") - void SetPythonAttrRotator(FString attr, FRotator Rotator); + void SetPythonAttrRotator(FString attr, FRotator Rotator); UFUNCTION(BlueprintCallable, Category = "Python") - void SetPythonAttrObject(FString attr, UObject *Object); + void SetPythonAttrObject(FString attr, UObject *Object); private: - PyObject *py_component_instance; + PyObject * py_component_instance; // mapped uobject, required for debug and advanced reflection ue_PyUObject *py_uobject; + + PyObject *py_generator; }; diff --git a/Source/UnrealEnginePython/Public/PythonDelegate.h b/Source/UnrealEnginePython/Public/PythonDelegate.h index 2a80205c6..be46aa511 100644 --- a/Source/UnrealEnginePython/Public/PythonDelegate.h +++ b/Source/UnrealEnginePython/Public/PythonDelegate.h @@ -1,6 +1,6 @@ #pragma once - +#include "UnrealEnginePython.h" #include "PythonDelegate.generated.h" UCLASS() @@ -13,17 +13,18 @@ class UPythonDelegate : public UObject ~UPythonDelegate(); virtual void ProcessEvent(UFunction *function, void *Parms) override; void SetPyCallable(PyObject *callable); + bool UsesPyCallable(PyObject *callable); void SetSignature(UFunction *original_signature); void PyInputHandler(); void PyInputAxisHandler(float value); protected: - UFunction *signature; + UFunction * signature; bool signature_set; UFUNCTION() - void PyFakeCallable(); + void PyFakeCallable(); PyObject *py_callable; diff --git a/Source/UnrealEnginePython/Public/PythonFunction.h b/Source/UnrealEnginePython/Public/PythonFunction.h index 4db68c686..162b70950 100644 --- a/Source/UnrealEnginePython/Public/PythonFunction.h +++ b/Source/UnrealEnginePython/Public/PythonFunction.h @@ -1,6 +1,6 @@ #pragma once - +#include "UnrealEnginePython.h" #include "PythonFunction.generated.h" UCLASS() diff --git a/Source/UnrealEnginePython/Public/PythonHouseKeeper.h b/Source/UnrealEnginePython/Public/PythonHouseKeeper.h index 3b1c1ad1a..ccd9edb01 100644 --- a/Source/UnrealEnginePython/Public/PythonHouseKeeper.h +++ b/Source/UnrealEnginePython/Public/PythonHouseKeeper.h @@ -1,243 +1,89 @@ #pragma once -#include "UnrealEnginePythonPrivatePCH.h" - -class FUnrealEnginePythonHouseKeeper +#include "UnrealEnginePython.h" +#include "UObject/UObjectGlobals.h" +#include "UObject/WeakObjectPtr.h" +#include "Widgets/SWidget.h" +#include "Slate/UEPySlateDelegate.h" +#include "Runtime/CoreUObject/Public/UObject/GCObject.h" +#include "PythonDelegate.h" +#include "PythonSmartDelegate.h" + +class FUnrealEnginePythonHouseKeeper : public FGCObject { - - struct FPythonUOjectTracker - { - FWeakObjectPtr Owner; - ue_PyUObject *PyUObject; - - FPythonUOjectTracker(UObject *Object, ue_PyUObject *InPyUObject) - { - Owner = FWeakObjectPtr(Object); - PyUObject = InPyUObject; - } - }; - - struct FPythonDelegateTracker - { - FWeakObjectPtr Owner; - UPythonDelegate *Delegate; - - FPythonDelegateTracker(UPythonDelegate *DelegateToTrack, UObject *DelegateOwner) : Owner(DelegateOwner), Delegate(DelegateToTrack) - { - } - - ~FPythonDelegateTracker() - { - } - }; - - struct FPythonSWidgetTracker - { - TWeakPtr Owner; - ue_PySWidget *PySWidget; - - FPythonSWidgetTracker(TSharedRef InOwner, ue_PySWidget *InPySWidget) - { - Owner = InOwner; - PySWidget = InPySWidget; - } - }; - - struct FPythonSWidgetDelegateTracker - { - TWeakPtr Owner; - TSharedPtr Delegate; - - FPythonSWidgetDelegateTracker(TSharedRef DelegateToTrack, TSharedRef DelegateOwner) : Owner(DelegateOwner), Delegate(DelegateToTrack) - { - } - - ~FPythonSWidgetDelegateTracker() - { - } - }; + struct FPythonUOjectTracker + { + FWeakObjectPtr Owner; + ue_PyUObject *PyUObject; + bool bPythonOwned; + + FPythonUOjectTracker(UObject *Object, ue_PyUObject *InPyUObject) + { + Owner = FWeakObjectPtr(Object); + PyUObject = InPyUObject; + bPythonOwned = false; + } + }; + + struct FPythonDelegateTracker + { + FWeakObjectPtr Owner; + UPythonDelegate *Delegate; + + FPythonDelegateTracker(UPythonDelegate *DelegateToTrack, UObject *DelegateOwner) : Owner(DelegateOwner), Delegate(DelegateToTrack) + { + } + + ~FPythonDelegateTracker() + { + } + }; + + struct FPythonSWidgetDelegateTracker + { + TWeakPtr Owner; + TSharedPtr Delegate; + + FPythonSWidgetDelegateTracker(TSharedRef DelegateToTrack, TSharedRef DelegateOwner) : Owner(DelegateOwner), Delegate(DelegateToTrack) + { + } + + ~FPythonSWidgetDelegateTracker() + { + } + }; public: - static FUnrealEnginePythonHouseKeeper *Get() - { - static FUnrealEnginePythonHouseKeeper *Singleton; - if (!Singleton) - { - Singleton = new FUnrealEnginePythonHouseKeeper(); - // register a new delegate for the GC -#if ENGINE_MINOR_VERSION >= 18 - FCoreUObjectDelegates::GetPostGarbageCollect().AddRaw(Singleton, &FUnrealEnginePythonHouseKeeper::RunGCDelegate); -#else - FCoreUObjectDelegates::PostGarbageCollect.AddRaw(Singleton, &FUnrealEnginePythonHouseKeeper::RunGCDelegate); -#endif - } - return Singleton; - } - - void RunGCDelegate() - { - FScopePythonGIL gil; - RunGC(); - } - - int32 RunGC() - { - int32 Garbaged = PyUObjectsGC(); - Garbaged += DelegatesGC(); - return Garbaged; - } - - bool IsValidPyUObject(ue_PyUObject *PyUObject) - { - if (!PyUObject) - return false; - - UObject *Object = PyUObject->ue_object; - FPythonUOjectTracker *Tracker = UObjectPyMapping.Find(Object); - if (!Tracker) - { - return false; - } - - if (!Tracker->Owner.IsValid()) - return false; - - return true; - - } - - void RegisterPyUObject(UObject *Object, ue_PyUObject *InPyUObject) - { - UObjectPyMapping.Add(Object, FPythonUOjectTracker(Object, InPyUObject)); - } - - void UnregisterPyUObject(UObject *Object) - { - UObjectPyMapping.Remove(Object); - } - - ue_PyUObject *GetPyUObject(UObject *Object) - { - FPythonUOjectTracker *Tracker = UObjectPyMapping.Find(Object); - if (!Tracker) - { - return nullptr; - } - - if (!Tracker->Owner.IsValid(true)) - { -#if defined(UEPY_MEMORY_DEBUG) - UE_LOG(LogPython, Warning, TEXT("DEFREF'ing UObject at %p (refcnt: %d)"), Object, Tracker->PyUObject->ob_base.ob_refcnt); -#endif - Py_DECREF((PyObject *)Tracker->PyUObject); - UnregisterPyUObject(Object); - return nullptr; - } - - return Tracker->PyUObject; - } - - uint32 PyUObjectsGC() - { - uint32 Garbaged = 0; - TArray BrokenList; - for (auto &UObjectPyItem : UObjectPyMapping) - { - UObject *Object = UObjectPyItem.Key; - FPythonUOjectTracker &Tracker = UObjectPyItem.Value; -#if defined(UEPY_MEMORY_DEBUG) - UE_LOG(LogPython, Warning, TEXT("Checking for UObject at %p"), Object); -#endif - if (!Tracker.Owner.IsValid(true)) - { -#if defined(UEPY_MEMORY_DEBUG) - UE_LOG(LogPython, Warning, TEXT("Removing UObject at %p (refcnt: %d)"), Object, Tracker.PyUObject->ob_base.ob_refcnt); -#endif - BrokenList.Add(Object); - Garbaged++; - } - else - { -#if defined(UEPY_MEMORY_DEBUG) - UE_LOG(LogPython, Error, TEXT("UObject at %p %s is in use"), Object, *Object->GetName()); -#endif - } - } - - for (UObject *Object : BrokenList) - { - FPythonUOjectTracker &Tracker = UObjectPyMapping[Object]; - Py_DECREF((PyObject *)Tracker.PyUObject); - UnregisterPyUObject(Object); - } - - return Garbaged; - - } - - - int32 DelegatesGC() - { - int32 Garbaged = 0; -#if defined(UEPY_MEMORY_DEBUG) - UE_LOG(LogPython, Error, TEXT("Checking %d delegates"), PyDelegatesTracker.Num()); -#endif - for (int32 i = PyDelegatesTracker.Num() - 1; i >= 0; --i) - { - FPythonDelegateTracker &Tracker = PyDelegatesTracker[i]; - if (!Tracker.Owner.IsValid(true)) - { - Tracker.Delegate->RemoveFromRoot(); - PyDelegatesTracker.RemoveAt(i); - Garbaged++; - } - - } - return Garbaged; - } - - UPythonDelegate *NewDelegate(UObject *Owner, PyObject *PyCallable, UFunction *Signature) - { - UPythonDelegate *Delegate = NewObject(); - - Delegate->AddToRoot(); - Delegate->SetPyCallable(PyCallable); - Delegate->SetSignature(Signature); - - FPythonDelegateTracker Tracker(Delegate, Owner); - PyDelegatesTracker.Add(Tracker); - - return Delegate; - } - - TSharedRef NewSlateDelegate(TSharedRef Owner, PyObject *PyCallable) - { - TSharedRef Delegate = MakeShareable(new FPythonSlateDelegate()); - Delegate->SetPyCallable(PyCallable); - - FPythonSWidgetDelegateTracker Tracker(Delegate, Owner); - PySlateDelegatesTracker.Add(Tracker); - - return Delegate; - } - - TSharedRef NewStaticSlateDelegate(PyObject *PyCallable) - { - TSharedRef Delegate = MakeShareable(new FPythonSlateDelegate()); - Delegate->SetPyCallable(PyCallable); - - PyStaticSlateDelegatesTracker.Add(Delegate); - - return Delegate; - } + virtual void AddReferencedObjects(FReferenceCollector& InCollector) override; + static FUnrealEnginePythonHouseKeeper *Get(); + int32 RunGC(); + bool IsValidPyUObject(ue_PyUObject *PyUObject); + void TrackUObject(UObject *Object); + void UntrackUObject(UObject *Object); + void RegisterPyUObject(UObject *Object, ue_PyUObject *InPyUObject); + void UnregisterPyUObject(UObject *Object); + ue_PyUObject *GetPyUObject(UObject *Object); + UPythonDelegate *FindDelegate(UObject *Owner, PyObject *PyCallable); + UPythonDelegate *NewDelegate(UObject *Owner, PyObject *PyCallable, UFunction *Signature); + TSharedRef NewSlateDelegate(TSharedRef Owner, PyObject *PyCallable); + TSharedRef NewDeferredSlateDelegate(PyObject *PyCallable); + TSharedRef NewPythonSmartDelegate(PyObject *PyCallable); + void TrackDeferredSlateDelegate(TSharedRef Delegate, TSharedRef Owner); + TSharedRef NewStaticSlateDelegate(PyObject *PyCallable); private: + void RunGCDelegate(); + uint32 PyUObjectsGC(); + int32 DelegatesGC(); + TMap UObjectPyMapping; TArray PyDelegatesTracker; - - TArray PySlateTracker; TArray PySlateDelegatesTracker; TArray> PyStaticSlateDelegatesTracker; + + TArray> PyStaticSmartDelegatesTracker; + + TArray PythonTrackedObjects; }; diff --git a/Source/UnrealEnginePython/Public/PythonScript.h b/Source/UnrealEnginePython/Public/PythonScript.h index 15ecaa284..4203cd26e 100644 --- a/Source/UnrealEnginePython/Public/PythonScript.h +++ b/Source/UnrealEnginePython/Public/PythonScript.h @@ -1,7 +1,7 @@ #pragma once -#include "UnrealEnginePython.h" #include "UObject/Object.h" +#include "UObject/ScriptMacros.h" #include "PythonScript.generated.h" UCLASS(MinimalAPI) @@ -12,19 +12,16 @@ class UPythonScript : public UObject public: UPROPERTY(EditAnywhere, Category = "Python") - FString ScriptPath; + FString ScriptPath; UPROPERTY(EditAnywhere, Category = "Python") - FString FunctionToCall; + FString FunctionToCall; UPROPERTY(EditAnywhere, Category = "Python") - TArray FunctionArgs; + TArray FunctionArgs; UFUNCTION() - void Run(); - - UFUNCTION() - void RunSandboxed(); + void Run(); void CallSpecificFunctionWithArgs(); }; diff --git a/Source/UnrealEnginePython/Public/PythonSmartDelegate.h b/Source/UnrealEnginePython/Public/PythonSmartDelegate.h index 22296a298..3a1047835 100644 --- a/Source/UnrealEnginePython/Public/PythonSmartDelegate.h +++ b/Source/UnrealEnginePython/Public/PythonSmartDelegate.h @@ -1,6 +1,10 @@ #pragma once -#include "UnrealEnginePythonPrivatePCH.h" +#include "UnrealEnginePython.h" +#if WITH_EDITOR +#include "Factories/Factory.h" +#include "Runtime/SlateCore/Public/Widgets/SWindow.h" +#endif class FPythonSmartDelegate : public TSharedFromThis { @@ -18,11 +22,12 @@ class FPythonSmartDelegate : public TSharedFromThis #if WITH_EDITOR void PyFOnAssetPostImport(UFactory *factory, UObject *u_object); + void PyFOnMainFrameCreationFinished(TSharedPtr InRootWindow, bool bIsNewProjectWindow); #endif protected: - PyObject *py_callable; + PyObject * py_callable; }; diff --git a/Source/UnrealEnginePython/Public/UnrealEnginePython.h b/Source/UnrealEnginePython/Public/UnrealEnginePython.h index 35ef5031b..1806609f0 100644 --- a/Source/UnrealEnginePython/Public/UnrealEnginePython.h +++ b/Source/UnrealEnginePython/Public/UnrealEnginePython.h @@ -1,4 +1,4 @@ -// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved. +// Copyright 20Tab S.r.l. #pragma once @@ -6,20 +6,94 @@ #pragma clang diagnostic ignored "-Wdelete-non-virtual-dtor" #endif -#include "ModuleManager.h" -#include "Engine.h" -#include "Runtime/Launch/Resources/Version.h" -#include "Runtime/SlateCore/Public/Styling/ISlateStyle.h" +//#define UEPY_MEMORY_DEBUG 1 + +#include "CoreMinimal.h" +#include "Runtime/Core/Public/Modules/ModuleManager.h" #include "Runtime/SlateCore/Public/Styling/SlateStyle.h" +#include "UObject/ScriptMacros.h" +#include "Runtime/Launch/Resources/Version.h" + +#if PLATFORM_MAC +#include +#include +#elif PLATFORM_LINUX +#include +#include +#elif PLATFORM_ANDROID +#include +#include +#elif PLATFORM_WINDOWS +#include +#ifndef SIZEOF_PID_T +#define SIZEOF_PID_T 4 +#endif +#include +#include +#endif -// We need to make sure reference structs do not mistaken for callable -#define PyCalllable_Check_Extended(value) PyCallable_Check(value) && py_ue_is_uscriptstruct(value) == nullptr +typedef struct +{ + PyObject_HEAD + /* Type-specific fields go here. */ + UObject *ue_object; + // reference to proxy class (can be null) + PyObject *py_proxy; + // the __dict__ + PyObject *py_dict; + // if true RemoveFromRoot will be called at object destruction time + int auto_rooted; + // if owned the life of the UObject is related to the life of PyObject + int owned; +} ue_PyUObject; + +UNREALENGINEPYTHON_API void ue_py_register_magic_module(char *name, PyObject *(*)()); +UNREALENGINEPYTHON_API PyObject *ue_py_register_module(const char *); #if ENGINE_MINOR_VERSION >= 18 #define FStringAssetReference FSoftObjectPath #endif +#define ue_py_check(py_u) if (!FUnrealEnginePythonHouseKeeper::Get()->IsValidPyUObject(py_u))\ + return PyErr_Format(PyExc_Exception, "PyUObject is in invalid state") + +#define ue_py_check_int(py_u) if (!FUnrealEnginePythonHouseKeeper::Get()->IsValidPyUObject(py_u))\ + {\ + PyErr_SetString(PyExc_Exception, "PyUObject is in invalid state");\ + return -1;\ + } + + +const char *UEPyUnicode_AsUTF8(PyObject *py_str); + +#if PY_MAJOR_VERSION < 3 +int PyGILState_Check(); +#endif +bool PyUnicodeOrString_Check(PyObject *py_obj); + +UNREALENGINEPYTHON_API void unreal_engine_py_log_error(); +UNREALENGINEPYTHON_API ue_PyUObject *ue_get_python_uobject(UObject *); +UNREALENGINEPYTHON_API ue_PyUObject *ue_get_python_uobject_inc(UObject *); + +#define Py_RETURN_UOBJECT(py_uobj) ue_PyUObject *ret = ue_get_python_uobject_inc(py_uobj);\ + if (!ret)\ + return PyErr_Format(PyExc_Exception, "uobject is in invalid state");\ + return (PyObject *)ret; + +#define Py_RETURN_UOBJECT_NOINC(py_uobj) ue_PyUObject *ret = ue_get_python_uobject(py_uobj);\ + if (!ret)\ + return PyErr_Format(PyExc_Exception, "uobject is in invalid state");\ + return (PyObject *)ret; + +#if ENGINE_MINOR_VERSION < 16 +template +struct TStructOpsTypeTraitsBase2 : TStructOpsTypeTraitsBase +{ + +}; +#endif + DECLARE_LOG_CATEGORY_EXTERN(LogPython, Log, All); @@ -27,20 +101,20 @@ class UNREALENGINEPYTHON_API FUnrealEnginePythonModule : public IModuleInterface { public: - bool PythonGILAcquire(); - void PythonGILRelease(); - virtual void StartupModule() override; virtual void ShutdownModule() override; void RunString(char *); - void RunStringSandboxed(char *); void RunFile(char *); - void RunFileSandboxed(char *, void(*callback)(void *arg), void *arg); + +#if PLATFORM_MAC + void RunStringInMainThread(char *); + void RunFileInMainThread(char *); +#endif void UESetupPythonInterpreter(bool); - FString ScriptsPath; + TArray ScriptsPaths; FString ZipPath; FString AdditionalModulesPath; @@ -59,30 +133,20 @@ class UNREALENGINEPYTHON_API FUnrealEnginePythonModule : public IModuleInterface TSharedPtr StyleSet; }; - - struct FScopePythonGIL { + + PyGILState_STATE state; + FScopePythonGIL() { -#if defined(UEPY_THREADING) - UnrealEnginePythonModule = FModuleManager::LoadModuleChecked("UnrealEnginePython"); - safeForRelease = UnrealEnginePythonModule.PythonGILAcquire(); -#endif + state = PyGILState_Ensure(); } ~FScopePythonGIL() { -#if defined(UEPY_THREADING) - if (safeForRelease) - { - UnrealEnginePythonModule.PythonGILRelease(); - } -#endif + PyGILState_Release(state); } - - FUnrealEnginePythonModule UnrealEnginePythonModule; - bool safeForRelease; }; diff --git a/Source/UnrealEnginePython/UnrealEnginePython.Build.cs b/Source/UnrealEnginePython/UnrealEnginePython.Build.cs index 09ec39aad..a6fe71946 100644 --- a/Source/UnrealEnginePython/UnrealEnginePython.Build.cs +++ b/Source/UnrealEnginePython/UnrealEnginePython.Build.cs @@ -11,13 +11,14 @@ public class UnrealEnginePython : ModuleRules private string pythonHome = ""; // otherwise specify the path of your python installation //private string pythonHome = "C:/Program Files/Python36"; - // this is an example for Homebrew on Mac + // this is an example for Homebrew on Mac //private string pythonHome = "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/"; // on Linux an include;libs syntax is expected: - //private string pythonHome = "/usr/local/include/python3.6;/usr/local/lib/libpython3.6.so" + //private string pythonHome = "/usr/local/include/python3.6;/usr/local/lib/libpython3.6.so"; private string[] windowsKnownPaths = { + // "C:/Program Files/Python37", "C:/Program Files/Python36", "C:/Program Files/Python35", "C:/Python27", @@ -26,9 +27,11 @@ public class UnrealEnginePython : ModuleRules private string[] macKnownPaths = { + "/Library/Frameworks/Python.framework/Versions/3.7", "/Library/Frameworks/Python.framework/Versions/3.6", "/Library/Frameworks/Python.framework/Versions/3.5", "/Library/Frameworks/Python.framework/Versions/2.7", + "/System/Library/Frameworks/Python.framework/Versions/3.7", "/System/Library/Frameworks/Python.framework/Versions/3.6", "/System/Library/Frameworks/Python.framework/Versions/3.5", "/System/Library/Frameworks/Python.framework/Versions/2.7" @@ -36,11 +39,15 @@ public class UnrealEnginePython : ModuleRules private string[] linuxKnownIncludesPaths = { + "/usr/local/include/python3.7", + "/usr/local/include/python3.7m", "/usr/local/include/python3.6", "/usr/local/include/python3.6m", "/usr/local/include/python3.5", "/usr/local/include/python3.5m", "/usr/local/include/python2.7", + "/usr/include/python3.7", + "/usr/include/python3.7m", "/usr/include/python3.6", "/usr/include/python3.6m", "/usr/include/python3.5", @@ -50,6 +57,10 @@ public class UnrealEnginePython : ModuleRules private string[] linuxKnownLibsPaths = { + "/usr/local/lib/libpython3.7.so", + "/usr/local/lib/libpython3.7m.so", + "/usr/local/lib/x86_64-linux-gnu/libpython3.7.so", + "/usr/local/lib/x86_64-linux-gnu/libpython3.7m.so", "/usr/local/lib/libpython3.6.so", "/usr/local/lib/libpython3.6m.so", "/usr/local/lib/x86_64-linux-gnu/libpython3.6.so", @@ -60,6 +71,10 @@ public class UnrealEnginePython : ModuleRules "/usr/local/lib/x86_64-linux-gnu/libpython3.5m.so", "/usr/local/lib/libpython2.7.so", "/usr/local/lib/x86_64-linux-gnu/libpython2.7.so", + "/usr/lib/libpython3.7.so", + "/usr/lib/libpython3.7m.so", + "/usr/lib/x86_64-linux-gnu/libpython3.7.so", + "/usr/lib/x86_64-linux-gnu/libpython3.7m.so", "/usr/lib/libpython3.6.so", "/usr/lib/libpython3.6m.so", "/usr/lib/x86_64-linux-gnu/libpython3.6.so", @@ -79,10 +94,12 @@ public UnrealEnginePython(TargetInfo Target) #endif { + PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs; + string enableUnityBuild = System.Environment.GetEnvironmentVariable("UEP_ENABLE_UNITY_BUILD"); + bFasterWithoutUnity = string.IsNullOrEmpty(enableUnityBuild); PublicIncludePaths.AddRange( new string[] { - "UnrealEnginePython/Public", // ... add public include paths required here ... } ); @@ -90,7 +107,6 @@ public UnrealEnginePython(TargetInfo Target) PrivateIncludePaths.AddRange( new string[] { - "UnrealEnginePython/Private", // ... add other private include paths required here ... } ); @@ -125,12 +141,25 @@ public UnrealEnginePython(TargetInfo Target) "RenderCore", "MovieSceneCapture", "Landscape", - "Foliage" + "Foliage", + "AIModule" // ... add private dependencies that you statically link with here ... } ); +#if WITH_FORWARDED_MODULE_RULES_CTOR + BuildVersion Version; + if (BuildVersion.TryRead(BuildVersion.GetDefaultFileName(), out Version)) + { + if (Version.MinorVersion >= 18) + { + PrivateDependencyModuleNames.Add("ApplicationCore"); + } + } +#endif + + DynamicallyLoadedModuleNames.AddRange( new string[] { @@ -175,7 +204,7 @@ public UnrealEnginePython(TargetInfo Target) { if (pythonHome == "") { - pythonHome = DiscoverPythonPath(windowsKnownPaths); + pythonHome = DiscoverPythonPath(windowsKnownPaths, "Win64"); if (pythonHome == "") { throw new System.Exception("Unable to find Python installation"); @@ -191,7 +220,7 @@ public UnrealEnginePython(TargetInfo Target) { if (pythonHome == "") { - pythonHome = DiscoverPythonPath(macKnownPaths); + pythonHome = DiscoverPythonPath(macKnownPaths, "Mac"); if (pythonHome == "") { throw new System.Exception("Unable to find Python installation"); @@ -202,7 +231,6 @@ public UnrealEnginePython(TargetInfo Target) string libPath = GetMacPythonLibFile(pythonHome); PublicLibraryPaths.Add(Path.GetDirectoryName(libPath)); PublicDelayLoadDLLs.Add(libPath); - Definitions.Add(string.Format("UNREAL_ENGINE_PYTHON_ON_MAC")); } else if (Target.Platform == UnrealTargetPlatform.Linux) { @@ -220,6 +248,7 @@ public UnrealEnginePython(TargetInfo Target) } PublicIncludePaths.Add(includesPath); PublicAdditionalLibraries.Add(libsPath); + } else { @@ -227,35 +256,45 @@ public UnrealEnginePython(TargetInfo Target) PublicIncludePaths.Add(items[0]); PublicAdditionalLibraries.Add(items[1]); } - Definitions.Add(string.Format("UNREAL_ENGINE_PYTHON_ON_LINUX")); } - - string enableThreads = System.Environment.GetEnvironmentVariable("UEP_ENABLE_THREADS"); - if (!string.IsNullOrEmpty(enableThreads)) +#if WITH_FORWARDED_MODULE_RULES_CTOR + else if (Target.Platform == UnrealTargetPlatform.Android) { - Definitions.Add("UEPY_THREADING"); - System.Console.WriteLine("*** Enabled Python Threads support ***"); + PublicIncludePaths.Add(System.IO.Path.Combine(ModuleDirectory, "../../android/python35/include")); + PublicLibraryPaths.Add(System.IO.Path.Combine(ModuleDirectory, "../../android/armeabi-v7a")); + PublicAdditionalLibraries.Add("python3.5m"); + + string APLName = "UnrealEnginePython_APL.xml"; + string RelAPLPath = Utils.MakePathRelativeTo(System.IO.Path.Combine(ModuleDirectory, APLName), Target.RelativeEnginePath); + AdditionalPropertiesForReceipt.Add(new ReceiptProperty("AndroidPlugin", RelAPLPath)); } +#endif } private bool IsPathRelative(string Path) { bool IsRooted = Path.StartsWith("\\", System.StringComparison.Ordinal) || // Root of the current directory on Windows. Also covers "\\" for UNC or "network" paths. - Path.StartsWith("/", System.StringComparison.Ordinal) || // Root of the current directory on Windows, root on UNIX-likes. - // Also covers "\\", considering normalization replaces "\\" with "//". + Path.StartsWith("/", System.StringComparison.Ordinal) || // Root of the current directory on Windows, root on UNIX-likes. + // Also covers "\\", considering normalization replaces "\\" with "//". (Path.Length >= 2 && char.IsLetter(Path[0]) && Path[1] == ':'); // Starts with ":" return !IsRooted; } - private string DiscoverPythonPath(string[] knownPaths) + private string DiscoverPythonPath(string[] knownPaths, string binaryPath) { // insert the PYTHONHOME content as the first known path List paths = new List(knownPaths); + paths.Insert(0, Path.Combine(ModuleDirectory, "../../Binaries", binaryPath)); string environmentPath = System.Environment.GetEnvironmentVariable("PYTHONHOME"); if (!string.IsNullOrEmpty(environmentPath)) paths.Insert(0, environmentPath); + // look in an alternate custom location + environmentPath = System.Environment.GetEnvironmentVariable("UNREALENGINEPYTHONHOME"); + if (!string.IsNullOrEmpty(environmentPath)) + paths.Insert(0, environmentPath); + foreach (string path in paths) { string actualPath = path; @@ -282,7 +321,9 @@ private string DiscoverPythonPath(string[] knownPaths) private string DiscoverLinuxPythonIncludesPath() { - foreach (string path in linuxKnownIncludesPaths) + List paths = new List(linuxKnownIncludesPaths); + paths.Insert(0, Path.Combine(ModuleDirectory, "../../Binaries", "Linux", "include")); + foreach (string path in paths) { string headerFile = Path.Combine(path, "Python.h"); if (File.Exists(headerFile)) @@ -295,7 +336,10 @@ private string DiscoverLinuxPythonIncludesPath() private string DiscoverLinuxPythonLibsPath() { - foreach (string path in linuxKnownLibsPaths) + List paths = new List(linuxKnownLibsPaths); + paths.Insert(0, Path.Combine(ModuleDirectory, "../../Binaries", "Linux", "lib")); + paths.Insert(0, Path.Combine(ModuleDirectory, "../../Binaries", "Linux", "lib64")); + foreach (string path in paths) { if (File.Exists(path)) { diff --git a/Source/UnrealEnginePython/UnrealEnginePython_APL.xml b/Source/UnrealEnginePython/UnrealEnginePython_APL.xml new file mode 100644 index 000000000..9145ba7c0 --- /dev/null +++ b/Source/UnrealEnginePython/UnrealEnginePython_APL.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/UnrealEnginePython.uplugin b/UnrealEnginePython.uplugin index a7ed3dabb..f07e0ffb9 100644 --- a/UnrealEnginePython.uplugin +++ b/UnrealEnginePython.uplugin @@ -14,22 +14,27 @@ "CanContainContent": true, "IsBetaVersion": true, "Installed": false, - "Modules": [ + "Modules": [ { "Name": "UnrealEnginePython", "Type": "Runtime", "LoadingPhase": "Default" }, - { - "Name": "PythonConsole", - "Type": "Editor", - "LoadingPhase": "PostDefault" - }, - { - "Name" : "PythonEditor", - "Type" : "Editor", - "LoadingPhase": "PostDefault" - } + { + "Name": "PythonAutomation", + "Type": "Editor", + "LoadingPhase": "PostDefault" + }, + { + "Name": "PythonConsole", + "Type": "Editor", + "LoadingPhase": "PostDefault" + }, + { + "Name": "PythonEditor", + "Type": "Editor", + "LoadingPhase": "PostDefault" + } ], "Plugins": [ { diff --git a/android/armeabi-v7a/libcrystax.so b/android/armeabi-v7a/libcrystax.so new file mode 100644 index 000000000..aea07cb5d Binary files /dev/null and b/android/armeabi-v7a/libcrystax.so differ diff --git a/android/armeabi-v7a/libpython2.7.so b/android/armeabi-v7a/libpython2.7.so new file mode 100644 index 000000000..72f72465d Binary files /dev/null and b/android/armeabi-v7a/libpython2.7.so differ diff --git a/android/armeabi-v7a/libpython3.5m.so b/android/armeabi-v7a/libpython3.5m.so new file mode 100644 index 000000000..e8e3aedec Binary files /dev/null and b/android/armeabi-v7a/libpython3.5m.so differ diff --git a/android/python27/include/Python-ast.h b/android/python27/include/Python-ast.h new file mode 100644 index 000000000..3f35bbb63 --- /dev/null +++ b/android/python27/include/Python-ast.h @@ -0,0 +1,535 @@ +/* File automatically generated by Parser/asdl_c.py. */ + +#include "asdl.h" + +typedef struct _mod *mod_ty; + +typedef struct _stmt *stmt_ty; + +typedef struct _expr *expr_ty; + +typedef enum _expr_context { Load=1, Store=2, Del=3, AugLoad=4, AugStore=5, + Param=6 } expr_context_ty; + +typedef struct _slice *slice_ty; + +typedef enum _boolop { And=1, Or=2 } boolop_ty; + +typedef enum _operator { Add=1, Sub=2, Mult=3, Div=4, Mod=5, Pow=6, LShift=7, + RShift=8, BitOr=9, BitXor=10, BitAnd=11, FloorDiv=12 } + operator_ty; + +typedef enum _unaryop { Invert=1, Not=2, UAdd=3, USub=4 } unaryop_ty; + +typedef enum _cmpop { Eq=1, NotEq=2, Lt=3, LtE=4, Gt=5, GtE=6, Is=7, IsNot=8, + In=9, NotIn=10 } cmpop_ty; + +typedef struct _comprehension *comprehension_ty; + +typedef struct _excepthandler *excepthandler_ty; + +typedef struct _arguments *arguments_ty; + +typedef struct _keyword *keyword_ty; + +typedef struct _alias *alias_ty; + + +enum _mod_kind {Module_kind=1, Interactive_kind=2, Expression_kind=3, + Suite_kind=4}; +struct _mod { + enum _mod_kind kind; + union { + struct { + asdl_seq *body; + } Module; + + struct { + asdl_seq *body; + } Interactive; + + struct { + expr_ty body; + } Expression; + + struct { + asdl_seq *body; + } Suite; + + } v; +}; + +enum _stmt_kind {FunctionDef_kind=1, ClassDef_kind=2, Return_kind=3, + Delete_kind=4, Assign_kind=5, AugAssign_kind=6, Print_kind=7, + For_kind=8, While_kind=9, If_kind=10, With_kind=11, + Raise_kind=12, TryExcept_kind=13, TryFinally_kind=14, + Assert_kind=15, Import_kind=16, ImportFrom_kind=17, + Exec_kind=18, Global_kind=19, Expr_kind=20, Pass_kind=21, + Break_kind=22, Continue_kind=23}; +struct _stmt { + enum _stmt_kind kind; + union { + struct { + identifier name; + arguments_ty args; + asdl_seq *body; + asdl_seq *decorator_list; + } FunctionDef; + + struct { + identifier name; + asdl_seq *bases; + asdl_seq *body; + asdl_seq *decorator_list; + } ClassDef; + + struct { + expr_ty value; + } Return; + + struct { + asdl_seq *targets; + } Delete; + + struct { + asdl_seq *targets; + expr_ty value; + } Assign; + + struct { + expr_ty target; + operator_ty op; + expr_ty value; + } AugAssign; + + struct { + expr_ty dest; + asdl_seq *values; + bool nl; + } Print; + + struct { + expr_ty target; + expr_ty iter; + asdl_seq *body; + asdl_seq *orelse; + } For; + + struct { + expr_ty test; + asdl_seq *body; + asdl_seq *orelse; + } While; + + struct { + expr_ty test; + asdl_seq *body; + asdl_seq *orelse; + } If; + + struct { + expr_ty context_expr; + expr_ty optional_vars; + asdl_seq *body; + } With; + + struct { + expr_ty type; + expr_ty inst; + expr_ty tback; + } Raise; + + struct { + asdl_seq *body; + asdl_seq *handlers; + asdl_seq *orelse; + } TryExcept; + + struct { + asdl_seq *body; + asdl_seq *finalbody; + } TryFinally; + + struct { + expr_ty test; + expr_ty msg; + } Assert; + + struct { + asdl_seq *names; + } Import; + + struct { + identifier module; + asdl_seq *names; + int level; + } ImportFrom; + + struct { + expr_ty body; + expr_ty globals; + expr_ty locals; + } Exec; + + struct { + asdl_seq *names; + } Global; + + struct { + expr_ty value; + } Expr; + + } v; + int lineno; + int col_offset; +}; + +enum _expr_kind {BoolOp_kind=1, BinOp_kind=2, UnaryOp_kind=3, Lambda_kind=4, + IfExp_kind=5, Dict_kind=6, Set_kind=7, ListComp_kind=8, + SetComp_kind=9, DictComp_kind=10, GeneratorExp_kind=11, + Yield_kind=12, Compare_kind=13, Call_kind=14, Repr_kind=15, + Num_kind=16, Str_kind=17, Attribute_kind=18, + Subscript_kind=19, Name_kind=20, List_kind=21, Tuple_kind=22}; +struct _expr { + enum _expr_kind kind; + union { + struct { + boolop_ty op; + asdl_seq *values; + } BoolOp; + + struct { + expr_ty left; + operator_ty op; + expr_ty right; + } BinOp; + + struct { + unaryop_ty op; + expr_ty operand; + } UnaryOp; + + struct { + arguments_ty args; + expr_ty body; + } Lambda; + + struct { + expr_ty test; + expr_ty body; + expr_ty orelse; + } IfExp; + + struct { + asdl_seq *keys; + asdl_seq *values; + } Dict; + + struct { + asdl_seq *elts; + } Set; + + struct { + expr_ty elt; + asdl_seq *generators; + } ListComp; + + struct { + expr_ty elt; + asdl_seq *generators; + } SetComp; + + struct { + expr_ty key; + expr_ty value; + asdl_seq *generators; + } DictComp; + + struct { + expr_ty elt; + asdl_seq *generators; + } GeneratorExp; + + struct { + expr_ty value; + } Yield; + + struct { + expr_ty left; + asdl_int_seq *ops; + asdl_seq *comparators; + } Compare; + + struct { + expr_ty func; + asdl_seq *args; + asdl_seq *keywords; + expr_ty starargs; + expr_ty kwargs; + } Call; + + struct { + expr_ty value; + } Repr; + + struct { + object n; + } Num; + + struct { + string s; + } Str; + + struct { + expr_ty value; + identifier attr; + expr_context_ty ctx; + } Attribute; + + struct { + expr_ty value; + slice_ty slice; + expr_context_ty ctx; + } Subscript; + + struct { + identifier id; + expr_context_ty ctx; + } Name; + + struct { + asdl_seq *elts; + expr_context_ty ctx; + } List; + + struct { + asdl_seq *elts; + expr_context_ty ctx; + } Tuple; + + } v; + int lineno; + int col_offset; +}; + +enum _slice_kind {Ellipsis_kind=1, Slice_kind=2, ExtSlice_kind=3, Index_kind=4}; +struct _slice { + enum _slice_kind kind; + union { + struct { + expr_ty lower; + expr_ty upper; + expr_ty step; + } Slice; + + struct { + asdl_seq *dims; + } ExtSlice; + + struct { + expr_ty value; + } Index; + + } v; +}; + +struct _comprehension { + expr_ty target; + expr_ty iter; + asdl_seq *ifs; +}; + +enum _excepthandler_kind {ExceptHandler_kind=1}; +struct _excepthandler { + enum _excepthandler_kind kind; + union { + struct { + expr_ty type; + expr_ty name; + asdl_seq *body; + } ExceptHandler; + + } v; + int lineno; + int col_offset; +}; + +struct _arguments { + asdl_seq *args; + identifier vararg; + identifier kwarg; + asdl_seq *defaults; +}; + +struct _keyword { + identifier arg; + expr_ty value; +}; + +struct _alias { + identifier name; + identifier asname; +}; + + +#define Module(a0, a1) _Py_Module(a0, a1) +mod_ty _Py_Module(asdl_seq * body, PyArena *arena); +#define Interactive(a0, a1) _Py_Interactive(a0, a1) +mod_ty _Py_Interactive(asdl_seq * body, PyArena *arena); +#define Expression(a0, a1) _Py_Expression(a0, a1) +mod_ty _Py_Expression(expr_ty body, PyArena *arena); +#define Suite(a0, a1) _Py_Suite(a0, a1) +mod_ty _Py_Suite(asdl_seq * body, PyArena *arena); +#define FunctionDef(a0, a1, a2, a3, a4, a5, a6) _Py_FunctionDef(a0, a1, a2, a3, a4, a5, a6) +stmt_ty _Py_FunctionDef(identifier name, arguments_ty args, asdl_seq * body, + asdl_seq * decorator_list, int lineno, int col_offset, + PyArena *arena); +#define ClassDef(a0, a1, a2, a3, a4, a5, a6) _Py_ClassDef(a0, a1, a2, a3, a4, a5, a6) +stmt_ty _Py_ClassDef(identifier name, asdl_seq * bases, asdl_seq * body, + asdl_seq * decorator_list, int lineno, int col_offset, + PyArena *arena); +#define Return(a0, a1, a2, a3) _Py_Return(a0, a1, a2, a3) +stmt_ty _Py_Return(expr_ty value, int lineno, int col_offset, PyArena *arena); +#define Delete(a0, a1, a2, a3) _Py_Delete(a0, a1, a2, a3) +stmt_ty _Py_Delete(asdl_seq * targets, int lineno, int col_offset, PyArena + *arena); +#define Assign(a0, a1, a2, a3, a4) _Py_Assign(a0, a1, a2, a3, a4) +stmt_ty _Py_Assign(asdl_seq * targets, expr_ty value, int lineno, int + col_offset, PyArena *arena); +#define AugAssign(a0, a1, a2, a3, a4, a5) _Py_AugAssign(a0, a1, a2, a3, a4, a5) +stmt_ty _Py_AugAssign(expr_ty target, operator_ty op, expr_ty value, int + lineno, int col_offset, PyArena *arena); +#define Print(a0, a1, a2, a3, a4, a5) _Py_Print(a0, a1, a2, a3, a4, a5) +stmt_ty _Py_Print(expr_ty dest, asdl_seq * values, bool nl, int lineno, int + col_offset, PyArena *arena); +#define For(a0, a1, a2, a3, a4, a5, a6) _Py_For(a0, a1, a2, a3, a4, a5, a6) +stmt_ty _Py_For(expr_ty target, expr_ty iter, asdl_seq * body, asdl_seq * + orelse, int lineno, int col_offset, PyArena *arena); +#define While(a0, a1, a2, a3, a4, a5) _Py_While(a0, a1, a2, a3, a4, a5) +stmt_ty _Py_While(expr_ty test, asdl_seq * body, asdl_seq * orelse, int lineno, + int col_offset, PyArena *arena); +#define If(a0, a1, a2, a3, a4, a5) _Py_If(a0, a1, a2, a3, a4, a5) +stmt_ty _Py_If(expr_ty test, asdl_seq * body, asdl_seq * orelse, int lineno, + int col_offset, PyArena *arena); +#define With(a0, a1, a2, a3, a4, a5) _Py_With(a0, a1, a2, a3, a4, a5) +stmt_ty _Py_With(expr_ty context_expr, expr_ty optional_vars, asdl_seq * body, + int lineno, int col_offset, PyArena *arena); +#define Raise(a0, a1, a2, a3, a4, a5) _Py_Raise(a0, a1, a2, a3, a4, a5) +stmt_ty _Py_Raise(expr_ty type, expr_ty inst, expr_ty tback, int lineno, int + col_offset, PyArena *arena); +#define TryExcept(a0, a1, a2, a3, a4, a5) _Py_TryExcept(a0, a1, a2, a3, a4, a5) +stmt_ty _Py_TryExcept(asdl_seq * body, asdl_seq * handlers, asdl_seq * orelse, + int lineno, int col_offset, PyArena *arena); +#define TryFinally(a0, a1, a2, a3, a4) _Py_TryFinally(a0, a1, a2, a3, a4) +stmt_ty _Py_TryFinally(asdl_seq * body, asdl_seq * finalbody, int lineno, int + col_offset, PyArena *arena); +#define Assert(a0, a1, a2, a3, a4) _Py_Assert(a0, a1, a2, a3, a4) +stmt_ty _Py_Assert(expr_ty test, expr_ty msg, int lineno, int col_offset, + PyArena *arena); +#define Import(a0, a1, a2, a3) _Py_Import(a0, a1, a2, a3) +stmt_ty _Py_Import(asdl_seq * names, int lineno, int col_offset, PyArena + *arena); +#define ImportFrom(a0, a1, a2, a3, a4, a5) _Py_ImportFrom(a0, a1, a2, a3, a4, a5) +stmt_ty _Py_ImportFrom(identifier module, asdl_seq * names, int level, int + lineno, int col_offset, PyArena *arena); +#define Exec(a0, a1, a2, a3, a4, a5) _Py_Exec(a0, a1, a2, a3, a4, a5) +stmt_ty _Py_Exec(expr_ty body, expr_ty globals, expr_ty locals, int lineno, int + col_offset, PyArena *arena); +#define Global(a0, a1, a2, a3) _Py_Global(a0, a1, a2, a3) +stmt_ty _Py_Global(asdl_seq * names, int lineno, int col_offset, PyArena + *arena); +#define Expr(a0, a1, a2, a3) _Py_Expr(a0, a1, a2, a3) +stmt_ty _Py_Expr(expr_ty value, int lineno, int col_offset, PyArena *arena); +#define Pass(a0, a1, a2) _Py_Pass(a0, a1, a2) +stmt_ty _Py_Pass(int lineno, int col_offset, PyArena *arena); +#define Break(a0, a1, a2) _Py_Break(a0, a1, a2) +stmt_ty _Py_Break(int lineno, int col_offset, PyArena *arena); +#define Continue(a0, a1, a2) _Py_Continue(a0, a1, a2) +stmt_ty _Py_Continue(int lineno, int col_offset, PyArena *arena); +#define BoolOp(a0, a1, a2, a3, a4) _Py_BoolOp(a0, a1, a2, a3, a4) +expr_ty _Py_BoolOp(boolop_ty op, asdl_seq * values, int lineno, int col_offset, + PyArena *arena); +#define BinOp(a0, a1, a2, a3, a4, a5) _Py_BinOp(a0, a1, a2, a3, a4, a5) +expr_ty _Py_BinOp(expr_ty left, operator_ty op, expr_ty right, int lineno, int + col_offset, PyArena *arena); +#define UnaryOp(a0, a1, a2, a3, a4) _Py_UnaryOp(a0, a1, a2, a3, a4) +expr_ty _Py_UnaryOp(unaryop_ty op, expr_ty operand, int lineno, int col_offset, + PyArena *arena); +#define Lambda(a0, a1, a2, a3, a4) _Py_Lambda(a0, a1, a2, a3, a4) +expr_ty _Py_Lambda(arguments_ty args, expr_ty body, int lineno, int col_offset, + PyArena *arena); +#define IfExp(a0, a1, a2, a3, a4, a5) _Py_IfExp(a0, a1, a2, a3, a4, a5) +expr_ty _Py_IfExp(expr_ty test, expr_ty body, expr_ty orelse, int lineno, int + col_offset, PyArena *arena); +#define Dict(a0, a1, a2, a3, a4) _Py_Dict(a0, a1, a2, a3, a4) +expr_ty _Py_Dict(asdl_seq * keys, asdl_seq * values, int lineno, int + col_offset, PyArena *arena); +#define Set(a0, a1, a2, a3) _Py_Set(a0, a1, a2, a3) +expr_ty _Py_Set(asdl_seq * elts, int lineno, int col_offset, PyArena *arena); +#define ListComp(a0, a1, a2, a3, a4) _Py_ListComp(a0, a1, a2, a3, a4) +expr_ty _Py_ListComp(expr_ty elt, asdl_seq * generators, int lineno, int + col_offset, PyArena *arena); +#define SetComp(a0, a1, a2, a3, a4) _Py_SetComp(a0, a1, a2, a3, a4) +expr_ty _Py_SetComp(expr_ty elt, asdl_seq * generators, int lineno, int + col_offset, PyArena *arena); +#define DictComp(a0, a1, a2, a3, a4, a5) _Py_DictComp(a0, a1, a2, a3, a4, a5) +expr_ty _Py_DictComp(expr_ty key, expr_ty value, asdl_seq * generators, int + lineno, int col_offset, PyArena *arena); +#define GeneratorExp(a0, a1, a2, a3, a4) _Py_GeneratorExp(a0, a1, a2, a3, a4) +expr_ty _Py_GeneratorExp(expr_ty elt, asdl_seq * generators, int lineno, int + col_offset, PyArena *arena); +#define Yield(a0, a1, a2, a3) _Py_Yield(a0, a1, a2, a3) +expr_ty _Py_Yield(expr_ty value, int lineno, int col_offset, PyArena *arena); +#define Compare(a0, a1, a2, a3, a4, a5) _Py_Compare(a0, a1, a2, a3, a4, a5) +expr_ty _Py_Compare(expr_ty left, asdl_int_seq * ops, asdl_seq * comparators, + int lineno, int col_offset, PyArena *arena); +#define Call(a0, a1, a2, a3, a4, a5, a6, a7) _Py_Call(a0, a1, a2, a3, a4, a5, a6, a7) +expr_ty _Py_Call(expr_ty func, asdl_seq * args, asdl_seq * keywords, expr_ty + starargs, expr_ty kwargs, int lineno, int col_offset, PyArena + *arena); +#define Repr(a0, a1, a2, a3) _Py_Repr(a0, a1, a2, a3) +expr_ty _Py_Repr(expr_ty value, int lineno, int col_offset, PyArena *arena); +#define Num(a0, a1, a2, a3) _Py_Num(a0, a1, a2, a3) +expr_ty _Py_Num(object n, int lineno, int col_offset, PyArena *arena); +#define Str(a0, a1, a2, a3) _Py_Str(a0, a1, a2, a3) +expr_ty _Py_Str(string s, int lineno, int col_offset, PyArena *arena); +#define Attribute(a0, a1, a2, a3, a4, a5) _Py_Attribute(a0, a1, a2, a3, a4, a5) +expr_ty _Py_Attribute(expr_ty value, identifier attr, expr_context_ty ctx, int + lineno, int col_offset, PyArena *arena); +#define Subscript(a0, a1, a2, a3, a4, a5) _Py_Subscript(a0, a1, a2, a3, a4, a5) +expr_ty _Py_Subscript(expr_ty value, slice_ty slice, expr_context_ty ctx, int + lineno, int col_offset, PyArena *arena); +#define Name(a0, a1, a2, a3, a4) _Py_Name(a0, a1, a2, a3, a4) +expr_ty _Py_Name(identifier id, expr_context_ty ctx, int lineno, int + col_offset, PyArena *arena); +#define List(a0, a1, a2, a3, a4) _Py_List(a0, a1, a2, a3, a4) +expr_ty _Py_List(asdl_seq * elts, expr_context_ty ctx, int lineno, int + col_offset, PyArena *arena); +#define Tuple(a0, a1, a2, a3, a4) _Py_Tuple(a0, a1, a2, a3, a4) +expr_ty _Py_Tuple(asdl_seq * elts, expr_context_ty ctx, int lineno, int + col_offset, PyArena *arena); +#define Ellipsis(a0) _Py_Ellipsis(a0) +slice_ty _Py_Ellipsis(PyArena *arena); +#define Slice(a0, a1, a2, a3) _Py_Slice(a0, a1, a2, a3) +slice_ty _Py_Slice(expr_ty lower, expr_ty upper, expr_ty step, PyArena *arena); +#define ExtSlice(a0, a1) _Py_ExtSlice(a0, a1) +slice_ty _Py_ExtSlice(asdl_seq * dims, PyArena *arena); +#define Index(a0, a1) _Py_Index(a0, a1) +slice_ty _Py_Index(expr_ty value, PyArena *arena); +#define comprehension(a0, a1, a2, a3) _Py_comprehension(a0, a1, a2, a3) +comprehension_ty _Py_comprehension(expr_ty target, expr_ty iter, asdl_seq * + ifs, PyArena *arena); +#define ExceptHandler(a0, a1, a2, a3, a4, a5) _Py_ExceptHandler(a0, a1, a2, a3, a4, a5) +excepthandler_ty _Py_ExceptHandler(expr_ty type, expr_ty name, asdl_seq * body, + int lineno, int col_offset, PyArena *arena); +#define arguments(a0, a1, a2, a3, a4) _Py_arguments(a0, a1, a2, a3, a4) +arguments_ty _Py_arguments(asdl_seq * args, identifier vararg, identifier + kwarg, asdl_seq * defaults, PyArena *arena); +#define keyword(a0, a1, a2) _Py_keyword(a0, a1, a2) +keyword_ty _Py_keyword(identifier arg, expr_ty value, PyArena *arena); +#define alias(a0, a1, a2) _Py_alias(a0, a1, a2) +alias_ty _Py_alias(identifier name, identifier asname, PyArena *arena); + +PyObject* PyAST_mod2obj(mod_ty t); +mod_ty PyAST_obj2mod(PyObject* ast, PyArena* arena, int mode); +int PyAST_Check(PyObject* obj); diff --git a/android/python27/include/Python.h b/android/python27/include/Python.h new file mode 100644 index 000000000..775412b8c --- /dev/null +++ b/android/python27/include/Python.h @@ -0,0 +1,178 @@ +#ifndef Py_PYTHON_H +#define Py_PYTHON_H +/* Since this is a "meta-include" file, no #ifdef __cplusplus / extern "C" { */ + +/* Include nearly all Python header files */ + +#include "patchlevel.h" +#include "pyconfig.h" +#include "pymacconfig.h" + +/* Cyclic gc is always enabled, starting with release 2.3a1. Supply the + * old symbol for the benefit of extension modules written before then + * that may be conditionalizing on it. The core doesn't use it anymore. + */ +#ifndef WITH_CYCLE_GC +#define WITH_CYCLE_GC 1 +#endif + +#include + +#ifndef UCHAR_MAX +#error "Something's broken. UCHAR_MAX should be defined in limits.h." +#endif + +#if UCHAR_MAX != 255 +#error "Python's source code assumes C's unsigned char is an 8-bit type." +#endif + +#if defined(__sgi) && defined(WITH_THREAD) && !defined(_SGI_MP_SOURCE) +#define _SGI_MP_SOURCE +#endif + +#include +#ifndef NULL +# error "Python.h requires that stdio.h define NULL." +#endif + +#include +#ifdef HAVE_ERRNO_H +#include +#endif +#include +#ifdef HAVE_UNISTD_H +#include +#endif + +/* For size_t? */ +#ifdef HAVE_STDDEF_H +#include +#endif + +/* CAUTION: Build setups should ensure that NDEBUG is defined on the + * compiler command line when building Python in release mode; else + * assert() calls won't be removed. + */ +#include + +#include "pyport.h" + +/* pyconfig.h or pyport.h may or may not define DL_IMPORT */ +#ifndef DL_IMPORT /* declarations for DLL import/export */ +#define DL_IMPORT(RTYPE) RTYPE +#endif +#ifndef DL_EXPORT /* declarations for DLL import/export */ +#define DL_EXPORT(RTYPE) RTYPE +#endif + +/* Debug-mode build with pymalloc implies PYMALLOC_DEBUG. + * PYMALLOC_DEBUG is in error if pymalloc is not in use. + */ +#if defined(Py_DEBUG) && defined(WITH_PYMALLOC) && !defined(PYMALLOC_DEBUG) +#define PYMALLOC_DEBUG +#endif +#if defined(PYMALLOC_DEBUG) && !defined(WITH_PYMALLOC) +#error "PYMALLOC_DEBUG requires WITH_PYMALLOC" +#endif +#include "pymath.h" +#include "pymem.h" + +#include "object.h" +#include "objimpl.h" + +#include "pydebug.h" + +#include "unicodeobject.h" +#include "intobject.h" +#include "boolobject.h" +#include "longobject.h" +#include "floatobject.h" +#ifndef WITHOUT_COMPLEX +#include "complexobject.h" +#endif +#include "rangeobject.h" +#include "stringobject.h" +#include "memoryobject.h" +#include "bufferobject.h" +#include "bytesobject.h" +#include "bytearrayobject.h" +#include "tupleobject.h" +#include "listobject.h" +#include "dictobject.h" +#include "enumobject.h" +#include "setobject.h" +#include "methodobject.h" +#include "moduleobject.h" +#include "funcobject.h" +#include "classobject.h" +#include "fileobject.h" +#include "cobject.h" +#include "pycapsule.h" +#include "traceback.h" +#include "sliceobject.h" +#include "cellobject.h" +#include "iterobject.h" +#include "genobject.h" +#include "descrobject.h" +#include "warnings.h" +#include "weakrefobject.h" + +#include "codecs.h" +#include "pyerrors.h" + +#include "pystate.h" + +#include "pyarena.h" +#include "modsupport.h" +#include "pythonrun.h" +#include "ceval.h" +#include "sysmodule.h" +#include "intrcheck.h" +#include "import.h" + +#include "abstract.h" + +#include "compile.h" +#include "eval.h" + +#include "pyctype.h" +#include "pystrtod.h" +#include "pystrcmp.h" +#include "dtoa.h" + +/* _Py_Mangle is defined in compile.c */ +PyAPI_FUNC(PyObject*) _Py_Mangle(PyObject *p, PyObject *name); + +/* PyArg_GetInt is deprecated and should not be used, use PyArg_Parse(). */ +#define PyArg_GetInt(v, a) PyArg_Parse((v), "i", (a)) + +/* PyArg_NoArgs should not be necessary. + Set ml_flags in the PyMethodDef to METH_NOARGS. */ +#define PyArg_NoArgs(v) PyArg_Parse(v, "") + +/* Argument must be a char or an int in [-128, 127] or [0, 255]. */ +#define Py_CHARMASK(c) ((unsigned char)((c) & 0xff)) + +#include "pyfpe.h" + +/* These definitions must match corresponding definitions in graminit.h. + There's code in compile.c that checks that they are the same. */ +#define Py_single_input 256 +#define Py_file_input 257 +#define Py_eval_input 258 + +#ifdef HAVE_PTH +/* GNU pth user-space thread support */ +#include +#endif + +/* Define macros for inline documentation. */ +#define PyDoc_VAR(name) static char name[] +#define PyDoc_STRVAR(name,str) PyDoc_VAR(name) = PyDoc_STR(str) +#ifdef WITH_DOC_STRINGS +#define PyDoc_STR(str) str +#else +#define PyDoc_STR(str) "" +#endif + +#endif /* !Py_PYTHON_H */ diff --git a/android/python27/include/abstract.h b/android/python27/include/abstract.h new file mode 100644 index 000000000..78a182548 --- /dev/null +++ b/android/python27/include/abstract.h @@ -0,0 +1,1396 @@ +#ifndef Py_ABSTRACTOBJECT_H +#define Py_ABSTRACTOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef PY_SSIZE_T_CLEAN +#define PyObject_CallFunction _PyObject_CallFunction_SizeT +#define PyObject_CallMethod _PyObject_CallMethod_SizeT +#endif + +/* Abstract Object Interface (many thanks to Jim Fulton) */ + +/* + PROPOSAL: A Generic Python Object Interface for Python C Modules + +Problem + + Python modules written in C that must access Python objects must do + so through routines whose interfaces are described by a set of + include files. Unfortunately, these routines vary according to the + object accessed. To use these routines, the C programmer must check + the type of the object being used and must call a routine based on + the object type. For example, to access an element of a sequence, + the programmer must determine whether the sequence is a list or a + tuple: + + if(is_tupleobject(o)) + e=gettupleitem(o,i) + else if(is_listitem(o)) + e=getlistitem(o,i) + + If the programmer wants to get an item from another type of object + that provides sequence behavior, there is no clear way to do it + correctly. + + The persistent programmer may peruse object.h and find that the + _typeobject structure provides a means of invoking up to (currently + about) 41 special operators. So, for example, a routine can get an + item from any object that provides sequence behavior. However, to + use this mechanism, the programmer must make their code dependent on + the current Python implementation. + + Also, certain semantics, especially memory management semantics, may + differ by the type of object being used. Unfortunately, these + semantics are not clearly described in the current include files. + An abstract interface providing more consistent semantics is needed. + +Proposal + + I propose the creation of a standard interface (with an associated + library of routines and/or macros) for generically obtaining the + services of Python objects. This proposal can be viewed as one + components of a Python C interface consisting of several components. + + From the viewpoint of C access to Python services, we have (as + suggested by Guido in off-line discussions): + + - "Very high level layer": two or three functions that let you exec or + eval arbitrary Python code given as a string in a module whose name is + given, passing C values in and getting C values out using + mkvalue/getargs style format strings. This does not require the user + to declare any variables of type "PyObject *". This should be enough + to write a simple application that gets Python code from the user, + execs it, and returns the output or errors. (Error handling must also + be part of this API.) + + - "Abstract objects layer": which is the subject of this proposal. + It has many functions operating on objects, and lest you do many + things from C that you can also write in Python, without going + through the Python parser. + + - "Concrete objects layer": This is the public type-dependent + interface provided by the standard built-in types, such as floats, + strings, and lists. This interface exists and is currently + documented by the collection of include files provided with the + Python distributions. + + From the point of view of Python accessing services provided by C + modules: + + - "Python module interface": this interface consist of the basic + routines used to define modules and their members. Most of the + current extensions-writing guide deals with this interface. + + - "Built-in object interface": this is the interface that a new + built-in type must provide and the mechanisms and rules that a + developer of a new built-in type must use and follow. + + This proposal is a "first-cut" that is intended to spur + discussion. See especially the lists of notes. + + The Python C object interface will provide four protocols: object, + numeric, sequence, and mapping. Each protocol consists of a + collection of related operations. If an operation that is not + provided by a particular type is invoked, then a standard exception, + NotImplementedError is raised with a operation name as an argument. + In addition, for convenience this interface defines a set of + constructors for building objects of built-in types. This is needed + so new objects can be returned from C functions that otherwise treat + objects generically. + +Memory Management + + For all of the functions described in this proposal, if a function + retains a reference to a Python object passed as an argument, then the + function will increase the reference count of the object. It is + unnecessary for the caller to increase the reference count of an + argument in anticipation of the object's retention. + + All Python objects returned from functions should be treated as new + objects. Functions that return objects assume that the caller will + retain a reference and the reference count of the object has already + been incremented to account for this fact. A caller that does not + retain a reference to an object that is returned from a function + must decrement the reference count of the object (using + DECREF(object)) to prevent memory leaks. + + Note that the behavior mentioned here is different from the current + behavior for some objects (e.g. lists and tuples) when certain + type-specific routines are called directly (e.g. setlistitem). The + proposed abstraction layer will provide a consistent memory + management interface, correcting for inconsistent behavior for some + built-in types. + +Protocols + +xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/ + +/* Object Protocol: */ + + /* Implemented elsewhere: + + int PyObject_Print(PyObject *o, FILE *fp, int flags); + + Print an object, o, on file, fp. Returns -1 on + error. The flags argument is used to enable certain printing + options. The only option currently supported is Py_Print_RAW. + + (What should be said about Py_Print_RAW?) + + */ + + /* Implemented elsewhere: + + int PyObject_HasAttrString(PyObject *o, char *attr_name); + + Returns 1 if o has the attribute attr_name, and 0 otherwise. + This is equivalent to the Python expression: + hasattr(o,attr_name). + + This function always succeeds. + + */ + + /* Implemented elsewhere: + + PyObject* PyObject_GetAttrString(PyObject *o, char *attr_name); + + Retrieve an attributed named attr_name form object o. + Returns the attribute value on success, or NULL on failure. + This is the equivalent of the Python expression: o.attr_name. + + */ + + /* Implemented elsewhere: + + int PyObject_HasAttr(PyObject *o, PyObject *attr_name); + + Returns 1 if o has the attribute attr_name, and 0 otherwise. + This is equivalent to the Python expression: + hasattr(o,attr_name). + + This function always succeeds. + + */ + + /* Implemented elsewhere: + + PyObject* PyObject_GetAttr(PyObject *o, PyObject *attr_name); + + Retrieve an attributed named attr_name form object o. + Returns the attribute value on success, or NULL on failure. + This is the equivalent of the Python expression: o.attr_name. + + */ + + + /* Implemented elsewhere: + + int PyObject_SetAttrString(PyObject *o, char *attr_name, PyObject *v); + + Set the value of the attribute named attr_name, for object o, + to the value, v. Returns -1 on failure. This is + the equivalent of the Python statement: o.attr_name=v. + + */ + + /* Implemented elsewhere: + + int PyObject_SetAttr(PyObject *o, PyObject *attr_name, PyObject *v); + + Set the value of the attribute named attr_name, for object o, + to the value, v. Returns -1 on failure. This is + the equivalent of the Python statement: o.attr_name=v. + + */ + + /* implemented as a macro: + + int PyObject_DelAttrString(PyObject *o, char *attr_name); + + Delete attribute named attr_name, for object o. Returns + -1 on failure. This is the equivalent of the Python + statement: del o.attr_name. + + */ +#define PyObject_DelAttrString(O,A) PyObject_SetAttrString((O),(A),NULL) + + /* implemented as a macro: + + int PyObject_DelAttr(PyObject *o, PyObject *attr_name); + + Delete attribute named attr_name, for object o. Returns -1 + on failure. This is the equivalent of the Python + statement: del o.attr_name. + + */ +#define PyObject_DelAttr(O,A) PyObject_SetAttr((O),(A),NULL) + + PyAPI_FUNC(int) PyObject_Cmp(PyObject *o1, PyObject *o2, int *result); + + /* + Compare the values of o1 and o2 using a routine provided by + o1, if one exists, otherwise with a routine provided by o2. + The result of the comparison is returned in result. Returns + -1 on failure. This is the equivalent of the Python + statement: result=cmp(o1,o2). + + */ + + /* Implemented elsewhere: + + int PyObject_Compare(PyObject *o1, PyObject *o2); + + Compare the values of o1 and o2 using a routine provided by + o1, if one exists, otherwise with a routine provided by o2. + Returns the result of the comparison on success. On error, + the value returned is undefined. This is equivalent to the + Python expression: cmp(o1,o2). + + */ + + /* Implemented elsewhere: + + PyObject *PyObject_Repr(PyObject *o); + + Compute the string representation of object, o. Returns the + string representation on success, NULL on failure. This is + the equivalent of the Python expression: repr(o). + + Called by the repr() built-in function and by reverse quotes. + + */ + + /* Implemented elsewhere: + + PyObject *PyObject_Str(PyObject *o); + + Compute the string representation of object, o. Returns the + string representation on success, NULL on failure. This is + the equivalent of the Python expression: str(o).) + + Called by the str() built-in function and by the print + statement. + + */ + + /* Implemented elsewhere: + + PyObject *PyObject_Unicode(PyObject *o); + + Compute the unicode representation of object, o. Returns the + unicode representation on success, NULL on failure. This is + the equivalent of the Python expression: unistr(o).) + + Called by the unistr() built-in function. + + */ + + /* Declared elsewhere + + PyAPI_FUNC(int) PyCallable_Check(PyObject *o); + + Determine if the object, o, is callable. Return 1 if the + object is callable and 0 otherwise. + + This function always succeeds. + + */ + + + + PyAPI_FUNC(PyObject *) PyObject_Call(PyObject *callable_object, + PyObject *args, PyObject *kw); + + /* + Call a callable Python object, callable_object, with + arguments and keywords arguments. The 'args' argument can not be + NULL, but the 'kw' argument can be NULL. + + */ + + PyAPI_FUNC(PyObject *) PyObject_CallObject(PyObject *callable_object, + PyObject *args); + + /* + Call a callable Python object, callable_object, with + arguments given by the tuple, args. If no arguments are + needed, then args may be NULL. Returns the result of the + call on success, or NULL on failure. This is the equivalent + of the Python expression: apply(o,args). + + */ + + PyAPI_FUNC(PyObject *) PyObject_CallFunction(PyObject *callable_object, + char *format, ...); + + /* + Call a callable Python object, callable_object, with a + variable number of C arguments. The C arguments are described + using a mkvalue-style format string. The format may be NULL, + indicating that no arguments are provided. Returns the + result of the call on success, or NULL on failure. This is + the equivalent of the Python expression: apply(o,args). + + */ + + + PyAPI_FUNC(PyObject *) PyObject_CallMethod(PyObject *o, char *m, + char *format, ...); + + /* + Call the method named m of object o with a variable number of + C arguments. The C arguments are described by a mkvalue + format string. The format may be NULL, indicating that no + arguments are provided. Returns the result of the call on + success, or NULL on failure. This is the equivalent of the + Python expression: o.method(args). + */ + + PyAPI_FUNC(PyObject *) _PyObject_CallFunction_SizeT(PyObject *callable, + char *format, ...); + PyAPI_FUNC(PyObject *) _PyObject_CallMethod_SizeT(PyObject *o, + char *name, + char *format, ...); + + PyAPI_FUNC(PyObject *) PyObject_CallFunctionObjArgs(PyObject *callable, + ...); + + /* + Call a callable Python object, callable_object, with a + variable number of C arguments. The C arguments are provided + as PyObject * values, terminated by a NULL. Returns the + result of the call on success, or NULL on failure. This is + the equivalent of the Python expression: apply(o,args). + */ + + + PyAPI_FUNC(PyObject *) PyObject_CallMethodObjArgs(PyObject *o, + PyObject *m, ...); + + /* + Call the method named m of object o with a variable number of + C arguments. The C arguments are provided as PyObject * + values, terminated by NULL. Returns the result of the call + on success, or NULL on failure. This is the equivalent of + the Python expression: o.method(args). + */ + + + /* Implemented elsewhere: + + long PyObject_Hash(PyObject *o); + + Compute and return the hash, hash_value, of an object, o. On + failure, return -1. This is the equivalent of the Python + expression: hash(o). + + */ + + + /* Implemented elsewhere: + + int PyObject_IsTrue(PyObject *o); + + Returns 1 if the object, o, is considered to be true, 0 if o is + considered to be false and -1 on failure. This is equivalent to the + Python expression: not not o + + */ + + /* Implemented elsewhere: + + int PyObject_Not(PyObject *o); + + Returns 0 if the object, o, is considered to be true, 1 if o is + considered to be false and -1 on failure. This is equivalent to the + Python expression: not o + + */ + + PyAPI_FUNC(PyObject *) PyObject_Type(PyObject *o); + + /* + On success, returns a type object corresponding to the object + type of object o. On failure, returns NULL. This is + equivalent to the Python expression: type(o). + */ + + PyAPI_FUNC(Py_ssize_t) PyObject_Size(PyObject *o); + + /* + Return the size of object o. If the object, o, provides + both sequence and mapping protocols, the sequence size is + returned. On error, -1 is returned. This is the equivalent + to the Python expression: len(o). + + */ + + /* For DLL compatibility */ +#undef PyObject_Length + PyAPI_FUNC(Py_ssize_t) PyObject_Length(PyObject *o); +#define PyObject_Length PyObject_Size + + PyAPI_FUNC(Py_ssize_t) _PyObject_LengthHint(PyObject *o, Py_ssize_t); + + /* + Guess the size of object o using len(o) or o.__length_hint__(). + If neither of those return a non-negative value, then return the + default value. If one of the calls fails, this function returns -1. + */ + + PyAPI_FUNC(PyObject *) PyObject_GetItem(PyObject *o, PyObject *key); + + /* + Return element of o corresponding to the object, key, or NULL + on failure. This is the equivalent of the Python expression: + o[key]. + + */ + + PyAPI_FUNC(int) PyObject_SetItem(PyObject *o, PyObject *key, PyObject *v); + + /* + Map the object, key, to the value, v. Returns + -1 on failure. This is the equivalent of the Python + statement: o[key]=v. + */ + + PyAPI_FUNC(int) PyObject_DelItemString(PyObject *o, char *key); + + /* + Remove the mapping for object, key, from the object *o. + Returns -1 on failure. This is equivalent to + the Python statement: del o[key]. + */ + + PyAPI_FUNC(int) PyObject_DelItem(PyObject *o, PyObject *key); + + /* + Delete the mapping for key from *o. Returns -1 on failure. + This is the equivalent of the Python statement: del o[key]. + */ + + PyAPI_FUNC(int) PyObject_AsCharBuffer(PyObject *obj, + const char **buffer, + Py_ssize_t *buffer_len); + + /* + Takes an arbitrary object which must support the (character, + single segment) buffer interface and returns a pointer to a + read-only memory location useable as character based input + for subsequent processing. + + 0 is returned on success. buffer and buffer_len are only + set in case no error occurs. Otherwise, -1 is returned and + an exception set. + + */ + + PyAPI_FUNC(int) PyObject_CheckReadBuffer(PyObject *obj); + + /* + Checks whether an arbitrary object supports the (character, + single segment) buffer interface. Returns 1 on success, 0 + on failure. + + */ + + PyAPI_FUNC(int) PyObject_AsReadBuffer(PyObject *obj, + const void **buffer, + Py_ssize_t *buffer_len); + + /* + Same as PyObject_AsCharBuffer() except that this API expects + (readable, single segment) buffer interface and returns a + pointer to a read-only memory location which can contain + arbitrary data. + + 0 is returned on success. buffer and buffer_len are only + set in case no error occurs. Otherwise, -1 is returned and + an exception set. + + */ + + PyAPI_FUNC(int) PyObject_AsWriteBuffer(PyObject *obj, + void **buffer, + Py_ssize_t *buffer_len); + + /* + Takes an arbitrary object which must support the (writeable, + single segment) buffer interface and returns a pointer to a + writeable memory location in buffer of size buffer_len. + + 0 is returned on success. buffer and buffer_len are only + set in case no error occurs. Otherwise, -1 is returned and + an exception set. + + */ + + /* new buffer API */ + +#define PyObject_CheckBuffer(obj) \ + (((obj)->ob_type->tp_as_buffer != NULL) && \ + (PyType_HasFeature((obj)->ob_type, Py_TPFLAGS_HAVE_NEWBUFFER)) && \ + ((obj)->ob_type->tp_as_buffer->bf_getbuffer != NULL)) + + /* Return 1 if the getbuffer function is available, otherwise + return 0 */ + + PyAPI_FUNC(int) PyObject_GetBuffer(PyObject *obj, Py_buffer *view, + int flags); + + /* This is a C-API version of the getbuffer function call. It checks + to make sure object has the required function pointer and issues the + call. Returns -1 and raises an error on failure and returns 0 on + success + */ + + + PyAPI_FUNC(void *) PyBuffer_GetPointer(Py_buffer *view, Py_ssize_t *indices); + + /* Get the memory area pointed to by the indices for the buffer given. + Note that view->ndim is the assumed size of indices + */ + + PyAPI_FUNC(int) PyBuffer_SizeFromFormat(const char *); + + /* Return the implied itemsize of the data-format area from a + struct-style description */ + + + + PyAPI_FUNC(int) PyBuffer_ToContiguous(void *buf, Py_buffer *view, + Py_ssize_t len, char fort); + + PyAPI_FUNC(int) PyBuffer_FromContiguous(Py_buffer *view, void *buf, + Py_ssize_t len, char fort); + + + /* Copy len bytes of data from the contiguous chunk of memory + pointed to by buf into the buffer exported by obj. Return + 0 on success and return -1 and raise a PyBuffer_Error on + error (i.e. the object does not have a buffer interface or + it is not working). + + If fort is 'F' and the object is multi-dimensional, + then the data will be copied into the array in + Fortran-style (first dimension varies the fastest). If + fort is 'C', then the data will be copied into the array + in C-style (last dimension varies the fastest). If fort + is 'A', then it does not matter and the copy will be made + in whatever way is more efficient. + + */ + + PyAPI_FUNC(int) PyObject_CopyData(PyObject *dest, PyObject *src); + + /* Copy the data from the src buffer to the buffer of destination + */ + + PyAPI_FUNC(int) PyBuffer_IsContiguous(Py_buffer *view, char fort); + + + PyAPI_FUNC(void) PyBuffer_FillContiguousStrides(int ndims, + Py_ssize_t *shape, + Py_ssize_t *strides, + int itemsize, + char fort); + + /* Fill the strides array with byte-strides of a contiguous + (Fortran-style if fort is 'F' or C-style otherwise) + array of the given shape with the given number of bytes + per element. + */ + + PyAPI_FUNC(int) PyBuffer_FillInfo(Py_buffer *view, PyObject *o, void *buf, + Py_ssize_t len, int readonly, + int flags); + + /* Fills in a buffer-info structure correctly for an exporter + that can only share a contiguous chunk of memory of + "unsigned bytes" of the given length. Returns 0 on success + and -1 (with raising an error) on error. + */ + + PyAPI_FUNC(void) PyBuffer_Release(Py_buffer *view); + + /* Releases a Py_buffer obtained from getbuffer ParseTuple's s*. + */ + + PyAPI_FUNC(PyObject *) PyObject_Format(PyObject* obj, + PyObject *format_spec); + /* + Takes an arbitrary object and returns the result of + calling obj.__format__(format_spec). + */ + +/* Iterators */ + + PyAPI_FUNC(PyObject *) PyObject_GetIter(PyObject *); + /* Takes an object and returns an iterator for it. + This is typically a new iterator but if the argument + is an iterator, this returns itself. */ + +#define PyIter_Check(obj) \ + (PyType_HasFeature((obj)->ob_type, Py_TPFLAGS_HAVE_ITER) && \ + (obj)->ob_type->tp_iternext != NULL && \ + (obj)->ob_type->tp_iternext != &_PyObject_NextNotImplemented) + + PyAPI_FUNC(PyObject *) PyIter_Next(PyObject *); + /* Takes an iterator object and calls its tp_iternext slot, + returning the next value. If the iterator is exhausted, + this returns NULL without setting an exception. + NULL with an exception means an error occurred. */ + +/* Number Protocol:*/ + + PyAPI_FUNC(int) PyNumber_Check(PyObject *o); + + /* + Returns 1 if the object, o, provides numeric protocols, and + false otherwise. + + This function always succeeds. + + */ + + PyAPI_FUNC(PyObject *) PyNumber_Add(PyObject *o1, PyObject *o2); + + /* + Returns the result of adding o1 and o2, or null on failure. + This is the equivalent of the Python expression: o1+o2. + + + */ + + PyAPI_FUNC(PyObject *) PyNumber_Subtract(PyObject *o1, PyObject *o2); + + /* + Returns the result of subtracting o2 from o1, or null on + failure. This is the equivalent of the Python expression: + o1-o2. + + */ + + PyAPI_FUNC(PyObject *) PyNumber_Multiply(PyObject *o1, PyObject *o2); + + /* + Returns the result of multiplying o1 and o2, or null on + failure. This is the equivalent of the Python expression: + o1*o2. + + + */ + + PyAPI_FUNC(PyObject *) PyNumber_Divide(PyObject *o1, PyObject *o2); + + /* + Returns the result of dividing o1 by o2, or null on failure. + This is the equivalent of the Python expression: o1/o2. + + + */ + + PyAPI_FUNC(PyObject *) PyNumber_FloorDivide(PyObject *o1, PyObject *o2); + + /* + Returns the result of dividing o1 by o2 giving an integral result, + or null on failure. + This is the equivalent of the Python expression: o1//o2. + + + */ + + PyAPI_FUNC(PyObject *) PyNumber_TrueDivide(PyObject *o1, PyObject *o2); + + /* + Returns the result of dividing o1 by o2 giving a float result, + or null on failure. + This is the equivalent of the Python expression: o1/o2. + + + */ + + PyAPI_FUNC(PyObject *) PyNumber_Remainder(PyObject *o1, PyObject *o2); + + /* + Returns the remainder of dividing o1 by o2, or null on + failure. This is the equivalent of the Python expression: + o1%o2. + + + */ + + PyAPI_FUNC(PyObject *) PyNumber_Divmod(PyObject *o1, PyObject *o2); + + /* + See the built-in function divmod. Returns NULL on failure. + This is the equivalent of the Python expression: + divmod(o1,o2). + + + */ + + PyAPI_FUNC(PyObject *) PyNumber_Power(PyObject *o1, PyObject *o2, + PyObject *o3); + + /* + See the built-in function pow. Returns NULL on failure. + This is the equivalent of the Python expression: + pow(o1,o2,o3), where o3 is optional. + + */ + + PyAPI_FUNC(PyObject *) PyNumber_Negative(PyObject *o); + + /* + Returns the negation of o on success, or null on failure. + This is the equivalent of the Python expression: -o. + + */ + + PyAPI_FUNC(PyObject *) PyNumber_Positive(PyObject *o); + + /* + Returns the (what?) of o on success, or NULL on failure. + This is the equivalent of the Python expression: +o. + + */ + + PyAPI_FUNC(PyObject *) PyNumber_Absolute(PyObject *o); + + /* + Returns the absolute value of o, or null on failure. This is + the equivalent of the Python expression: abs(o). + + */ + + PyAPI_FUNC(PyObject *) PyNumber_Invert(PyObject *o); + + /* + Returns the bitwise negation of o on success, or NULL on + failure. This is the equivalent of the Python expression: + ~o. + + + */ + + PyAPI_FUNC(PyObject *) PyNumber_Lshift(PyObject *o1, PyObject *o2); + + /* + Returns the result of left shifting o1 by o2 on success, or + NULL on failure. This is the equivalent of the Python + expression: o1 << o2. + + + */ + + PyAPI_FUNC(PyObject *) PyNumber_Rshift(PyObject *o1, PyObject *o2); + + /* + Returns the result of right shifting o1 by o2 on success, or + NULL on failure. This is the equivalent of the Python + expression: o1 >> o2. + + */ + + PyAPI_FUNC(PyObject *) PyNumber_And(PyObject *o1, PyObject *o2); + + /* + Returns the result of bitwise and of o1 and o2 on success, or + NULL on failure. This is the equivalent of the Python + expression: o1&o2. + + + */ + + PyAPI_FUNC(PyObject *) PyNumber_Xor(PyObject *o1, PyObject *o2); + + /* + Returns the bitwise exclusive or of o1 by o2 on success, or + NULL on failure. This is the equivalent of the Python + expression: o1^o2. + + + */ + + PyAPI_FUNC(PyObject *) PyNumber_Or(PyObject *o1, PyObject *o2); + + /* + Returns the result of bitwise or on o1 and o2 on success, or + NULL on failure. This is the equivalent of the Python + expression: o1|o2. + + */ + + /* Implemented elsewhere: + + int PyNumber_Coerce(PyObject **p1, PyObject **p2); + + This function takes the addresses of two variables of type + PyObject*. + + If the objects pointed to by *p1 and *p2 have the same type, + increment their reference count and return 0 (success). + If the objects can be converted to a common numeric type, + replace *p1 and *p2 by their converted value (with 'new' + reference counts), and return 0. + If no conversion is possible, or if some other error occurs, + return -1 (failure) and don't increment the reference counts. + The call PyNumber_Coerce(&o1, &o2) is equivalent to the Python + statement o1, o2 = coerce(o1, o2). + + */ + +#define PyIndex_Check(obj) \ + ((obj)->ob_type->tp_as_number != NULL && \ + PyType_HasFeature((obj)->ob_type, Py_TPFLAGS_HAVE_INDEX) && \ + (obj)->ob_type->tp_as_number->nb_index != NULL) + + PyAPI_FUNC(PyObject *) PyNumber_Index(PyObject *o); + + /* + Returns the object converted to a Python long or int + or NULL with an error raised on failure. + */ + + PyAPI_FUNC(Py_ssize_t) PyNumber_AsSsize_t(PyObject *o, PyObject *exc); + + /* + Returns the Integral instance converted to an int. The + instance is expected to be int or long or have an __int__ + method. Steals integral's reference. error_format will be + used to create the TypeError if integral isn't actually an + Integral instance. error_format should be a format string + that can accept a char* naming integral's type. + */ + + PyAPI_FUNC(PyObject *) _PyNumber_ConvertIntegralToInt( + PyObject *integral, + const char* error_format); + + /* + Returns the object converted to Py_ssize_t by going through + PyNumber_Index first. If an overflow error occurs while + converting the int-or-long to Py_ssize_t, then the second argument + is the error-type to return. If it is NULL, then the overflow error + is cleared and the value is clipped. + */ + + PyAPI_FUNC(PyObject *) PyNumber_Int(PyObject *o); + + /* + Returns the o converted to an integer object on success, or + NULL on failure. This is the equivalent of the Python + expression: int(o). + + */ + + PyAPI_FUNC(PyObject *) PyNumber_Long(PyObject *o); + + /* + Returns the o converted to a long integer object on success, + or NULL on failure. This is the equivalent of the Python + expression: long(o). + + */ + + PyAPI_FUNC(PyObject *) PyNumber_Float(PyObject *o); + + /* + Returns the o converted to a float object on success, or NULL + on failure. This is the equivalent of the Python expression: + float(o). + */ + +/* In-place variants of (some of) the above number protocol functions */ + + PyAPI_FUNC(PyObject *) PyNumber_InPlaceAdd(PyObject *o1, PyObject *o2); + + /* + Returns the result of adding o2 to o1, possibly in-place, or null + on failure. This is the equivalent of the Python expression: + o1 += o2. + + */ + + PyAPI_FUNC(PyObject *) PyNumber_InPlaceSubtract(PyObject *o1, PyObject *o2); + + /* + Returns the result of subtracting o2 from o1, possibly in-place or + null on failure. This is the equivalent of the Python expression: + o1 -= o2. + + */ + + PyAPI_FUNC(PyObject *) PyNumber_InPlaceMultiply(PyObject *o1, PyObject *o2); + + /* + Returns the result of multiplying o1 by o2, possibly in-place, or + null on failure. This is the equivalent of the Python expression: + o1 *= o2. + + */ + + PyAPI_FUNC(PyObject *) PyNumber_InPlaceDivide(PyObject *o1, PyObject *o2); + + /* + Returns the result of dividing o1 by o2, possibly in-place, or null + on failure. This is the equivalent of the Python expression: + o1 /= o2. + + */ + + PyAPI_FUNC(PyObject *) PyNumber_InPlaceFloorDivide(PyObject *o1, + PyObject *o2); + + /* + Returns the result of dividing o1 by o2 giving an integral result, + possibly in-place, or null on failure. + This is the equivalent of the Python expression: + o1 /= o2. + + */ + + PyAPI_FUNC(PyObject *) PyNumber_InPlaceTrueDivide(PyObject *o1, + PyObject *o2); + + /* + Returns the result of dividing o1 by o2 giving a float result, + possibly in-place, or null on failure. + This is the equivalent of the Python expression: + o1 /= o2. + + */ + + PyAPI_FUNC(PyObject *) PyNumber_InPlaceRemainder(PyObject *o1, PyObject *o2); + + /* + Returns the remainder of dividing o1 by o2, possibly in-place, or + null on failure. This is the equivalent of the Python expression: + o1 %= o2. + + */ + + PyAPI_FUNC(PyObject *) PyNumber_InPlacePower(PyObject *o1, PyObject *o2, + PyObject *o3); + + /* + Returns the result of raising o1 to the power of o2, possibly + in-place, or null on failure. This is the equivalent of the Python + expression: o1 **= o2, or pow(o1, o2, o3) if o3 is present. + + */ + + PyAPI_FUNC(PyObject *) PyNumber_InPlaceLshift(PyObject *o1, PyObject *o2); + + /* + Returns the result of left shifting o1 by o2, possibly in-place, or + null on failure. This is the equivalent of the Python expression: + o1 <<= o2. + + */ + + PyAPI_FUNC(PyObject *) PyNumber_InPlaceRshift(PyObject *o1, PyObject *o2); + + /* + Returns the result of right shifting o1 by o2, possibly in-place or + null on failure. This is the equivalent of the Python expression: + o1 >>= o2. + + */ + + PyAPI_FUNC(PyObject *) PyNumber_InPlaceAnd(PyObject *o1, PyObject *o2); + + /* + Returns the result of bitwise and of o1 and o2, possibly in-place, + or null on failure. This is the equivalent of the Python + expression: o1 &= o2. + + */ + + PyAPI_FUNC(PyObject *) PyNumber_InPlaceXor(PyObject *o1, PyObject *o2); + + /* + Returns the bitwise exclusive or of o1 by o2, possibly in-place, or + null on failure. This is the equivalent of the Python expression: + o1 ^= o2. + + */ + + PyAPI_FUNC(PyObject *) PyNumber_InPlaceOr(PyObject *o1, PyObject *o2); + + /* + Returns the result of bitwise or of o1 and o2, possibly in-place, + or null on failure. This is the equivalent of the Python + expression: o1 |= o2. + + */ + + + PyAPI_FUNC(PyObject *) PyNumber_ToBase(PyObject *n, int base); + + /* + Returns the integer n converted to a string with a base, with a base + marker of 0b, 0o or 0x prefixed if applicable. + If n is not an int object, it is converted with PyNumber_Index first. + */ + + +/* Sequence protocol:*/ + + PyAPI_FUNC(int) PySequence_Check(PyObject *o); + + /* + Return 1 if the object provides sequence protocol, and zero + otherwise. + + This function always succeeds. + + */ + + PyAPI_FUNC(Py_ssize_t) PySequence_Size(PyObject *o); + + /* + Return the size of sequence object o, or -1 on failure. + + */ + + /* For DLL compatibility */ +#undef PySequence_Length + PyAPI_FUNC(Py_ssize_t) PySequence_Length(PyObject *o); +#define PySequence_Length PySequence_Size + + + PyAPI_FUNC(PyObject *) PySequence_Concat(PyObject *o1, PyObject *o2); + + /* + Return the concatenation of o1 and o2 on success, and NULL on + failure. This is the equivalent of the Python + expression: o1+o2. + + */ + + PyAPI_FUNC(PyObject *) PySequence_Repeat(PyObject *o, Py_ssize_t count); + + /* + Return the result of repeating sequence object o count times, + or NULL on failure. This is the equivalent of the Python + expression: o1*count. + + */ + + PyAPI_FUNC(PyObject *) PySequence_GetItem(PyObject *o, Py_ssize_t i); + + /* + Return the ith element of o, or NULL on failure. This is the + equivalent of the Python expression: o[i]. + */ + + PyAPI_FUNC(PyObject *) PySequence_GetSlice(PyObject *o, Py_ssize_t i1, Py_ssize_t i2); + + /* + Return the slice of sequence object o between i1 and i2, or + NULL on failure. This is the equivalent of the Python + expression: o[i1:i2]. + + */ + + PyAPI_FUNC(int) PySequence_SetItem(PyObject *o, Py_ssize_t i, PyObject *v); + + /* + Assign object v to the ith element of o. Returns + -1 on failure. This is the equivalent of the Python + statement: o[i]=v. + + */ + + PyAPI_FUNC(int) PySequence_DelItem(PyObject *o, Py_ssize_t i); + + /* + Delete the ith element of object v. Returns + -1 on failure. This is the equivalent of the Python + statement: del o[i]. + */ + + PyAPI_FUNC(int) PySequence_SetSlice(PyObject *o, Py_ssize_t i1, Py_ssize_t i2, + PyObject *v); + + /* + Assign the sequence object, v, to the slice in sequence + object, o, from i1 to i2. Returns -1 on failure. This is the + equivalent of the Python statement: o[i1:i2]=v. + */ + + PyAPI_FUNC(int) PySequence_DelSlice(PyObject *o, Py_ssize_t i1, Py_ssize_t i2); + + /* + Delete the slice in sequence object, o, from i1 to i2. + Returns -1 on failure. This is the equivalent of the Python + statement: del o[i1:i2]. + */ + + PyAPI_FUNC(PyObject *) PySequence_Tuple(PyObject *o); + + /* + Returns the sequence, o, as a tuple on success, and NULL on failure. + This is equivalent to the Python expression: tuple(o) + */ + + + PyAPI_FUNC(PyObject *) PySequence_List(PyObject *o); + /* + Returns the sequence, o, as a list on success, and NULL on failure. + This is equivalent to the Python expression: list(o) + */ + + PyAPI_FUNC(PyObject *) PySequence_Fast(PyObject *o, const char* m); + /* + Return the sequence, o, as a list, unless it's already a + tuple or list. Use PySequence_Fast_GET_ITEM to access the + members of this list, and PySequence_Fast_GET_SIZE to get its length. + + Returns NULL on failure. If the object does not support iteration, + raises a TypeError exception with m as the message text. + */ + +#define PySequence_Fast_GET_SIZE(o) \ + (PyList_Check(o) ? PyList_GET_SIZE(o) : PyTuple_GET_SIZE(o)) + /* + Return the size of o, assuming that o was returned by + PySequence_Fast and is not NULL. + */ + +#define PySequence_Fast_GET_ITEM(o, i)\ + (PyList_Check(o) ? PyList_GET_ITEM(o, i) : PyTuple_GET_ITEM(o, i)) + /* + Return the ith element of o, assuming that o was returned by + PySequence_Fast, and that i is within bounds. + */ + +#define PySequence_ITEM(o, i)\ + ( Py_TYPE(o)->tp_as_sequence->sq_item(o, i) ) + /* Assume tp_as_sequence and sq_item exist and that i does not + need to be corrected for a negative index + */ + +#define PySequence_Fast_ITEMS(sf) \ + (PyList_Check(sf) ? ((PyListObject *)(sf))->ob_item \ + : ((PyTupleObject *)(sf))->ob_item) + /* Return a pointer to the underlying item array for + an object retured by PySequence_Fast */ + + PyAPI_FUNC(Py_ssize_t) PySequence_Count(PyObject *o, PyObject *value); + + /* + Return the number of occurrences on value on o, that is, + return the number of keys for which o[key]==value. On + failure, return -1. This is equivalent to the Python + expression: o.count(value). + */ + + PyAPI_FUNC(int) PySequence_Contains(PyObject *seq, PyObject *ob); + /* + Return -1 if error; 1 if ob in seq; 0 if ob not in seq. + Use __contains__ if possible, else _PySequence_IterSearch(). + */ + +#define PY_ITERSEARCH_COUNT 1 +#define PY_ITERSEARCH_INDEX 2 +#define PY_ITERSEARCH_CONTAINS 3 + PyAPI_FUNC(Py_ssize_t) _PySequence_IterSearch(PyObject *seq, + PyObject *obj, int operation); + /* + Iterate over seq. Result depends on the operation: + PY_ITERSEARCH_COUNT: return # of times obj appears in seq; -1 if + error. + PY_ITERSEARCH_INDEX: return 0-based index of first occurrence of + obj in seq; set ValueError and return -1 if none found; + also return -1 on error. + PY_ITERSEARCH_CONTAINS: return 1 if obj in seq, else 0; -1 on + error. + */ + +/* For DLL-level backwards compatibility */ +#undef PySequence_In + PyAPI_FUNC(int) PySequence_In(PyObject *o, PyObject *value); + +/* For source-level backwards compatibility */ +#define PySequence_In PySequence_Contains + + /* + Determine if o contains value. If an item in o is equal to + X, return 1, otherwise return 0. On error, return -1. This + is equivalent to the Python expression: value in o. + */ + + PyAPI_FUNC(Py_ssize_t) PySequence_Index(PyObject *o, PyObject *value); + + /* + Return the first index for which o[i]=value. On error, + return -1. This is equivalent to the Python + expression: o.index(value). + */ + +/* In-place versions of some of the above Sequence functions. */ + + PyAPI_FUNC(PyObject *) PySequence_InPlaceConcat(PyObject *o1, PyObject *o2); + + /* + Append o2 to o1, in-place when possible. Return the resulting + object, which could be o1, or NULL on failure. This is the + equivalent of the Python expression: o1 += o2. + + */ + + PyAPI_FUNC(PyObject *) PySequence_InPlaceRepeat(PyObject *o, Py_ssize_t count); + + /* + Repeat o1 by count, in-place when possible. Return the resulting + object, which could be o1, or NULL on failure. This is the + equivalent of the Python expression: o1 *= count. + + */ + +/* Mapping protocol:*/ + + PyAPI_FUNC(int) PyMapping_Check(PyObject *o); + + /* + Return 1 if the object provides mapping protocol, and zero + otherwise. + + This function always succeeds. + */ + + PyAPI_FUNC(Py_ssize_t) PyMapping_Size(PyObject *o); + + /* + Returns the number of keys in object o on success, and -1 on + failure. For objects that do not provide sequence protocol, + this is equivalent to the Python expression: len(o). + */ + + /* For DLL compatibility */ +#undef PyMapping_Length + PyAPI_FUNC(Py_ssize_t) PyMapping_Length(PyObject *o); +#define PyMapping_Length PyMapping_Size + + + /* implemented as a macro: + + int PyMapping_DelItemString(PyObject *o, char *key); + + Remove the mapping for object, key, from the object *o. + Returns -1 on failure. This is equivalent to + the Python statement: del o[key]. + */ +#define PyMapping_DelItemString(O,K) PyObject_DelItemString((O),(K)) + + /* implemented as a macro: + + int PyMapping_DelItem(PyObject *o, PyObject *key); + + Remove the mapping for object, key, from the object *o. + Returns -1 on failure. This is equivalent to + the Python statement: del o[key]. + */ +#define PyMapping_DelItem(O,K) PyObject_DelItem((O),(K)) + + PyAPI_FUNC(int) PyMapping_HasKeyString(PyObject *o, char *key); + + /* + On success, return 1 if the mapping object has the key, key, + and 0 otherwise. This is equivalent to the Python expression: + o.has_key(key). + + This function always succeeds. + */ + + PyAPI_FUNC(int) PyMapping_HasKey(PyObject *o, PyObject *key); + + /* + Return 1 if the mapping object has the key, key, + and 0 otherwise. This is equivalent to the Python expression: + o.has_key(key). + + This function always succeeds. + + */ + + /* Implemented as macro: + + PyObject *PyMapping_Keys(PyObject *o); + + On success, return a list of the keys in object o. On + failure, return NULL. This is equivalent to the Python + expression: o.keys(). + */ +#define PyMapping_Keys(O) PyObject_CallMethod(O,"keys",NULL) + + /* Implemented as macro: + + PyObject *PyMapping_Values(PyObject *o); + + On success, return a list of the values in object o. On + failure, return NULL. This is equivalent to the Python + expression: o.values(). + */ +#define PyMapping_Values(O) PyObject_CallMethod(O,"values",NULL) + + /* Implemented as macro: + + PyObject *PyMapping_Items(PyObject *o); + + On success, return a list of the items in object o, where + each item is a tuple containing a key-value pair. On + failure, return NULL. This is equivalent to the Python + expression: o.items(). + + */ +#define PyMapping_Items(O) PyObject_CallMethod(O,"items",NULL) + + PyAPI_FUNC(PyObject *) PyMapping_GetItemString(PyObject *o, char *key); + + /* + Return element of o corresponding to the object, key, or NULL + on failure. This is the equivalent of the Python expression: + o[key]. + */ + + PyAPI_FUNC(int) PyMapping_SetItemString(PyObject *o, char *key, + PyObject *value); + + /* + Map the object, key, to the value, v. Returns + -1 on failure. This is the equivalent of the Python + statement: o[key]=v. + */ + + +PyAPI_FUNC(int) PyObject_IsInstance(PyObject *object, PyObject *typeorclass); + /* isinstance(object, typeorclass) */ + +PyAPI_FUNC(int) PyObject_IsSubclass(PyObject *object, PyObject *typeorclass); + /* issubclass(object, typeorclass) */ + + +PyAPI_FUNC(int) _PyObject_RealIsInstance(PyObject *inst, PyObject *cls); + +PyAPI_FUNC(int) _PyObject_RealIsSubclass(PyObject *derived, PyObject *cls); + + +/* For internal use by buffer API functions */ +PyAPI_FUNC(void) _Py_add_one_to_index_F(int nd, Py_ssize_t *index, + const Py_ssize_t *shape); +PyAPI_FUNC(void) _Py_add_one_to_index_C(int nd, Py_ssize_t *index, + const Py_ssize_t *shape); + + +#ifdef __cplusplus +} +#endif +#endif /* Py_ABSTRACTOBJECT_H */ diff --git a/android/python27/include/asdl.h b/android/python27/include/asdl.h new file mode 100644 index 000000000..84e837e75 --- /dev/null +++ b/android/python27/include/asdl.h @@ -0,0 +1,45 @@ +#ifndef Py_ASDL_H +#define Py_ASDL_H + +typedef PyObject * identifier; +typedef PyObject * string; +typedef PyObject * object; + +#ifndef __cplusplus +typedef enum {false, true} bool; +#endif + +/* It would be nice if the code generated by asdl_c.py was completely + independent of Python, but it is a goal the requires too much work + at this stage. So, for example, I'll represent identifiers as + interned Python strings. +*/ + +/* XXX A sequence should be typed so that its use can be typechecked. */ + +typedef struct { + int size; + void *elements[1]; +} asdl_seq; + +typedef struct { + int size; + int elements[1]; +} asdl_int_seq; + +asdl_seq *asdl_seq_new(int size, PyArena *arena); +asdl_int_seq *asdl_int_seq_new(int size, PyArena *arena); + +#define asdl_seq_GET(S, I) (S)->elements[(I)] +#define asdl_seq_LEN(S) ((S) == NULL ? 0 : (S)->size) +#ifdef Py_DEBUG +#define asdl_seq_SET(S, I, V) { \ + int _asdl_i = (I); \ + assert((S) && _asdl_i < (S)->size); \ + (S)->elements[_asdl_i] = (V); \ +} +#else +#define asdl_seq_SET(S, I, V) (S)->elements[I] = (V) +#endif + +#endif /* !Py_ASDL_H */ diff --git a/android/python27/include/ast.h b/android/python27/include/ast.h new file mode 100644 index 000000000..cc14b7fd7 --- /dev/null +++ b/android/python27/include/ast.h @@ -0,0 +1,13 @@ +#ifndef Py_AST_H +#define Py_AST_H +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_FUNC(mod_ty) PyAST_FromNode(const node *, PyCompilerFlags *flags, + const char *, PyArena *); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_AST_H */ diff --git a/android/python27/include/bitset.h b/android/python27/include/bitset.h new file mode 100644 index 000000000..faeb41913 --- /dev/null +++ b/android/python27/include/bitset.h @@ -0,0 +1,32 @@ + +#ifndef Py_BITSET_H +#define Py_BITSET_H +#ifdef __cplusplus +extern "C" { +#endif + +/* Bitset interface */ + +#define BYTE char + +typedef BYTE *bitset; + +bitset newbitset(int nbits); +void delbitset(bitset bs); +#define testbit(ss, ibit) (((ss)[BIT2BYTE(ibit)] & BIT2MASK(ibit)) != 0) +int addbit(bitset bs, int ibit); /* Returns 0 if already set */ +int samebitset(bitset bs1, bitset bs2, int nbits); +void mergebitset(bitset bs1, bitset bs2, int nbits); + +#define BITSPERBYTE (8*sizeof(BYTE)) +#define NBYTES(nbits) (((nbits) + BITSPERBYTE - 1) / BITSPERBYTE) + +#define BIT2BYTE(ibit) ((ibit) / BITSPERBYTE) +#define BIT2SHIFT(ibit) ((ibit) % BITSPERBYTE) +#define BIT2MASK(ibit) (1 << BIT2SHIFT(ibit)) +#define BYTE2BIT(ibyte) ((ibyte) * BITSPERBYTE) + +#ifdef __cplusplus +} +#endif +#endif /* !Py_BITSET_H */ diff --git a/android/python27/include/boolobject.h b/android/python27/include/boolobject.h new file mode 100644 index 000000000..74e854f70 --- /dev/null +++ b/android/python27/include/boolobject.h @@ -0,0 +1,36 @@ +/* Boolean object interface */ + +#ifndef Py_BOOLOBJECT_H +#define Py_BOOLOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + + +typedef PyIntObject PyBoolObject; + +PyAPI_DATA(PyTypeObject) PyBool_Type; + +#define PyBool_Check(x) (Py_TYPE(x) == &PyBool_Type) + +/* Py_False and Py_True are the only two bools in existence. +Don't forget to apply Py_INCREF() when returning either!!! */ + +/* Don't use these directly */ +PyAPI_DATA(PyIntObject) _Py_ZeroStruct, _Py_TrueStruct; + +/* Use these macros */ +#define Py_False ((PyObject *) &_Py_ZeroStruct) +#define Py_True ((PyObject *) &_Py_TrueStruct) + +/* Macros for returning Py_True or Py_False, respectively */ +#define Py_RETURN_TRUE return Py_INCREF(Py_True), Py_True +#define Py_RETURN_FALSE return Py_INCREF(Py_False), Py_False + +/* Function to return a bool from a C long */ +PyAPI_FUNC(PyObject *) PyBool_FromLong(long); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_BOOLOBJECT_H */ diff --git a/android/python27/include/bufferobject.h b/android/python27/include/bufferobject.h new file mode 100644 index 000000000..6dd83458c --- /dev/null +++ b/android/python27/include/bufferobject.h @@ -0,0 +1,33 @@ + +/* Buffer object interface */ + +/* Note: the object's structure is private */ + +#ifndef Py_BUFFEROBJECT_H +#define Py_BUFFEROBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + + +PyAPI_DATA(PyTypeObject) PyBuffer_Type; + +#define PyBuffer_Check(op) (Py_TYPE(op) == &PyBuffer_Type) + +#define Py_END_OF_BUFFER (-1) + +PyAPI_FUNC(PyObject *) PyBuffer_FromObject(PyObject *base, + Py_ssize_t offset, Py_ssize_t size); +PyAPI_FUNC(PyObject *) PyBuffer_FromReadWriteObject(PyObject *base, + Py_ssize_t offset, + Py_ssize_t size); + +PyAPI_FUNC(PyObject *) PyBuffer_FromMemory(void *ptr, Py_ssize_t size); +PyAPI_FUNC(PyObject *) PyBuffer_FromReadWriteMemory(void *ptr, Py_ssize_t size); + +PyAPI_FUNC(PyObject *) PyBuffer_New(Py_ssize_t size); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_BUFFEROBJECT_H */ diff --git a/android/python27/include/bytearrayobject.h b/android/python27/include/bytearrayobject.h new file mode 100644 index 000000000..e1281a628 --- /dev/null +++ b/android/python27/include/bytearrayobject.h @@ -0,0 +1,57 @@ +/* ByteArray object interface */ + +#ifndef Py_BYTEARRAYOBJECT_H +#define Py_BYTEARRAYOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/* Type PyByteArrayObject represents a mutable array of bytes. + * The Python API is that of a sequence; + * the bytes are mapped to ints in [0, 256). + * Bytes are not characters; they may be used to encode characters. + * The only way to go between bytes and str/unicode is via encoding + * and decoding. + * For the convenience of C programmers, the bytes type is considered + * to contain a char pointer, not an unsigned char pointer. + */ + +/* Object layout */ +typedef struct { + PyObject_VAR_HEAD + /* XXX(nnorwitz): should ob_exports be Py_ssize_t? */ + int ob_exports; /* how many buffer exports */ + Py_ssize_t ob_alloc; /* How many bytes allocated */ + char *ob_bytes; +} PyByteArrayObject; + +/* Type object */ +PyAPI_DATA(PyTypeObject) PyByteArray_Type; +PyAPI_DATA(PyTypeObject) PyByteArrayIter_Type; + +/* Type check macros */ +#define PyByteArray_Check(self) PyObject_TypeCheck(self, &PyByteArray_Type) +#define PyByteArray_CheckExact(self) (Py_TYPE(self) == &PyByteArray_Type) + +/* Direct API functions */ +PyAPI_FUNC(PyObject *) PyByteArray_FromObject(PyObject *); +PyAPI_FUNC(PyObject *) PyByteArray_Concat(PyObject *, PyObject *); +PyAPI_FUNC(PyObject *) PyByteArray_FromStringAndSize(const char *, Py_ssize_t); +PyAPI_FUNC(Py_ssize_t) PyByteArray_Size(PyObject *); +PyAPI_FUNC(char *) PyByteArray_AsString(PyObject *); +PyAPI_FUNC(int) PyByteArray_Resize(PyObject *, Py_ssize_t); + +/* Macros, trading safety for speed */ +#define PyByteArray_AS_STRING(self) \ + (assert(PyByteArray_Check(self)), \ + Py_SIZE(self) ? ((PyByteArrayObject *)(self))->ob_bytes : _PyByteArray_empty_string) +#define PyByteArray_GET_SIZE(self) (assert(PyByteArray_Check(self)),Py_SIZE(self)) + +PyAPI_DATA(char) _PyByteArray_empty_string[]; + +#ifdef __cplusplus +} +#endif +#endif /* !Py_BYTEARRAYOBJECT_H */ diff --git a/android/python27/include/bytes_methods.h b/android/python27/include/bytes_methods.h new file mode 100644 index 000000000..412566621 --- /dev/null +++ b/android/python27/include/bytes_methods.h @@ -0,0 +1,75 @@ +#ifndef Py_BYTES_CTYPE_H +#define Py_BYTES_CTYPE_H + +/* + * The internal implementation behind PyString (bytes) and PyBytes (buffer) + * methods of the given names, they operate on ASCII byte strings. + */ +extern PyObject* _Py_bytes_isspace(const char *cptr, Py_ssize_t len); +extern PyObject* _Py_bytes_isalpha(const char *cptr, Py_ssize_t len); +extern PyObject* _Py_bytes_isalnum(const char *cptr, Py_ssize_t len); +extern PyObject* _Py_bytes_isdigit(const char *cptr, Py_ssize_t len); +extern PyObject* _Py_bytes_islower(const char *cptr, Py_ssize_t len); +extern PyObject* _Py_bytes_isupper(const char *cptr, Py_ssize_t len); +extern PyObject* _Py_bytes_istitle(const char *cptr, Py_ssize_t len); + +/* These store their len sized answer in the given preallocated *result arg. */ +extern void _Py_bytes_lower(char *result, const char *cptr, Py_ssize_t len); +extern void _Py_bytes_upper(char *result, const char *cptr, Py_ssize_t len); +extern void _Py_bytes_title(char *result, char *s, Py_ssize_t len); +extern void _Py_bytes_capitalize(char *result, char *s, Py_ssize_t len); +extern void _Py_bytes_swapcase(char *result, char *s, Py_ssize_t len); + +/* Shared __doc__ strings. */ +extern const char _Py_isspace__doc__[]; +extern const char _Py_isalpha__doc__[]; +extern const char _Py_isalnum__doc__[]; +extern const char _Py_isdigit__doc__[]; +extern const char _Py_islower__doc__[]; +extern const char _Py_isupper__doc__[]; +extern const char _Py_istitle__doc__[]; +extern const char _Py_lower__doc__[]; +extern const char _Py_upper__doc__[]; +extern const char _Py_title__doc__[]; +extern const char _Py_capitalize__doc__[]; +extern const char _Py_swapcase__doc__[]; + +/* These are left in for backward compatibility and will be removed + in 2.8/3.2 */ +#define ISLOWER(c) Py_ISLOWER(c) +#define ISUPPER(c) Py_ISUPPER(c) +#define ISALPHA(c) Py_ISALPHA(c) +#define ISDIGIT(c) Py_ISDIGIT(c) +#define ISXDIGIT(c) Py_ISXDIGIT(c) +#define ISALNUM(c) Py_ISALNUM(c) +#define ISSPACE(c) Py_ISSPACE(c) + +#undef islower +#define islower(c) undefined_islower(c) +#undef isupper +#define isupper(c) undefined_isupper(c) +#undef isalpha +#define isalpha(c) undefined_isalpha(c) +#undef isdigit +#define isdigit(c) undefined_isdigit(c) +#undef isxdigit +#define isxdigit(c) undefined_isxdigit(c) +#undef isalnum +#define isalnum(c) undefined_isalnum(c) +#undef isspace +#define isspace(c) undefined_isspace(c) + +/* These are left in for backward compatibility and will be removed + in 2.8/3.2 */ +#define TOLOWER(c) Py_TOLOWER(c) +#define TOUPPER(c) Py_TOUPPER(c) + +#undef tolower +#define tolower(c) undefined_tolower(c) +#undef toupper +#define toupper(c) undefined_toupper(c) + +/* this is needed because some docs are shared from the .o, not static */ +#define PyDoc_STRVAR_shared(name,str) const char name[] = PyDoc_STR(str) + +#endif /* !Py_BYTES_CTYPE_H */ diff --git a/android/python27/include/bytesobject.h b/android/python27/include/bytesobject.h new file mode 100644 index 000000000..1083da9c8 --- /dev/null +++ b/android/python27/include/bytesobject.h @@ -0,0 +1,27 @@ +#define PyBytesObject PyStringObject +#define PyBytes_Type PyString_Type + +#define PyBytes_Check PyString_Check +#define PyBytes_CheckExact PyString_CheckExact +#define PyBytes_CHECK_INTERNED PyString_CHECK_INTERNED +#define PyBytes_AS_STRING PyString_AS_STRING +#define PyBytes_GET_SIZE PyString_GET_SIZE +#define Py_TPFLAGS_BYTES_SUBCLASS Py_TPFLAGS_STRING_SUBCLASS + +#define PyBytes_FromStringAndSize PyString_FromStringAndSize +#define PyBytes_FromString PyString_FromString +#define PyBytes_FromFormatV PyString_FromFormatV +#define PyBytes_FromFormat PyString_FromFormat +#define PyBytes_Size PyString_Size +#define PyBytes_AsString PyString_AsString +#define PyBytes_Repr PyString_Repr +#define PyBytes_Concat PyString_Concat +#define PyBytes_ConcatAndDel PyString_ConcatAndDel +#define _PyBytes_Resize _PyString_Resize +#define _PyBytes_Eq _PyString_Eq +#define PyBytes_Format PyString_Format +#define _PyBytes_FormatLong _PyString_FormatLong +#define PyBytes_DecodeEscape PyString_DecodeEscape +#define _PyBytes_Join _PyString_Join +#define PyBytes_AsStringAndSize PyString_AsStringAndSize +#define _PyBytes_InsertThousandsGrouping _PyString_InsertThousandsGrouping diff --git a/android/python27/include/cStringIO.h b/android/python27/include/cStringIO.h new file mode 100644 index 000000000..973a47108 --- /dev/null +++ b/android/python27/include/cStringIO.h @@ -0,0 +1,73 @@ +#ifndef Py_CSTRINGIO_H +#define Py_CSTRINGIO_H +#ifdef __cplusplus +extern "C" { +#endif +/* + + This header provides access to cStringIO objects from C. + Functions are provided for calling cStringIO objects and + macros are provided for testing whether you have cStringIO + objects. + + Before calling any of the functions or macros, you must initialize + the routines with: + + PycString_IMPORT + + This would typically be done in your init function. + +*/ + +#define PycStringIO_CAPSULE_NAME "cStringIO.cStringIO_CAPI" + +#define PycString_IMPORT \ + PycStringIO = ((struct PycStringIO_CAPI*)PyCapsule_Import(\ + PycStringIO_CAPSULE_NAME, 0)) + +/* Basic functions to manipulate cStringIO objects from C */ + +static struct PycStringIO_CAPI { + + /* Read a string from an input object. If the last argument + is -1, the remainder will be read. + */ + int(*cread)(PyObject *, char **, Py_ssize_t); + + /* Read a line from an input object. Returns the length of the read + line as an int and a pointer inside the object buffer as char** (so + the caller doesn't have to provide its own buffer as destination). + */ + int(*creadline)(PyObject *, char **); + + /* Write a string to an output object*/ + int(*cwrite)(PyObject *, const char *, Py_ssize_t); + + /* Get the output object as a Python string (returns new reference). */ + PyObject *(*cgetvalue)(PyObject *); + + /* Create a new output object */ + PyObject *(*NewOutput)(int); + + /* Create an input object from a Python string + (copies the Python string reference). + */ + PyObject *(*NewInput)(PyObject *); + + /* The Python types for cStringIO input and output objects. + Note that you can do input on an output object. + */ + PyTypeObject *InputType, *OutputType; + +} *PycStringIO; + +/* These can be used to test if you have one */ +#define PycStringIO_InputCheck(O) \ + (Py_TYPE(O)==PycStringIO->InputType) +#define PycStringIO_OutputCheck(O) \ + (Py_TYPE(O)==PycStringIO->OutputType) + +#ifdef __cplusplus +} +#endif +#endif /* !Py_CSTRINGIO_H */ diff --git a/android/python27/include/cellobject.h b/android/python27/include/cellobject.h new file mode 100644 index 000000000..c927ee5da --- /dev/null +++ b/android/python27/include/cellobject.h @@ -0,0 +1,28 @@ +/* Cell object interface */ + +#ifndef Py_CELLOBJECT_H +#define Py_CELLOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + PyObject_HEAD + PyObject *ob_ref; /* Content of the cell or NULL when empty */ +} PyCellObject; + +PyAPI_DATA(PyTypeObject) PyCell_Type; + +#define PyCell_Check(op) (Py_TYPE(op) == &PyCell_Type) + +PyAPI_FUNC(PyObject *) PyCell_New(PyObject *); +PyAPI_FUNC(PyObject *) PyCell_Get(PyObject *); +PyAPI_FUNC(int) PyCell_Set(PyObject *, PyObject *); + +#define PyCell_GET(op) (((PyCellObject *)(op))->ob_ref) +#define PyCell_SET(op, v) (((PyCellObject *)(op))->ob_ref = v) + +#ifdef __cplusplus +} +#endif +#endif /* !Py_TUPLEOBJECT_H */ diff --git a/android/python27/include/ceval.h b/android/python27/include/ceval.h new file mode 100644 index 000000000..0e8bd2ab1 --- /dev/null +++ b/android/python27/include/ceval.h @@ -0,0 +1,153 @@ +#ifndef Py_CEVAL_H +#define Py_CEVAL_H +#ifdef __cplusplus +extern "C" { +#endif + + +/* Interface to random parts in ceval.c */ + +PyAPI_FUNC(PyObject *) PyEval_CallObjectWithKeywords( + PyObject *, PyObject *, PyObject *); + +/* Inline this */ +#define PyEval_CallObject(func,arg) \ + PyEval_CallObjectWithKeywords(func, arg, (PyObject *)NULL) + +PyAPI_FUNC(PyObject *) PyEval_CallFunction(PyObject *obj, + const char *format, ...); +PyAPI_FUNC(PyObject *) PyEval_CallMethod(PyObject *obj, + const char *methodname, + const char *format, ...); + +PyAPI_FUNC(void) PyEval_SetProfile(Py_tracefunc, PyObject *); +PyAPI_FUNC(void) PyEval_SetTrace(Py_tracefunc, PyObject *); + +struct _frame; /* Avoid including frameobject.h */ + +PyAPI_FUNC(PyObject *) PyEval_GetBuiltins(void); +PyAPI_FUNC(PyObject *) PyEval_GetGlobals(void); +PyAPI_FUNC(PyObject *) PyEval_GetLocals(void); +PyAPI_FUNC(struct _frame *) PyEval_GetFrame(void); +PyAPI_FUNC(int) PyEval_GetRestricted(void); + +/* Look at the current frame's (if any) code's co_flags, and turn on + the corresponding compiler flags in cf->cf_flags. Return 1 if any + flag was set, else return 0. */ +PyAPI_FUNC(int) PyEval_MergeCompilerFlags(PyCompilerFlags *cf); + +PyAPI_FUNC(int) Py_FlushLine(void); + +PyAPI_FUNC(int) Py_AddPendingCall(int (*func)(void *), void *arg); +PyAPI_FUNC(int) Py_MakePendingCalls(void); + +/* Protection against deeply nested recursive calls */ +PyAPI_FUNC(void) Py_SetRecursionLimit(int); +PyAPI_FUNC(int) Py_GetRecursionLimit(void); + +#define Py_EnterRecursiveCall(where) \ + (_Py_MakeRecCheck(PyThreadState_GET()->recursion_depth) && \ + _Py_CheckRecursiveCall(where)) +#define Py_LeaveRecursiveCall() \ + (--PyThreadState_GET()->recursion_depth) +PyAPI_FUNC(int) _Py_CheckRecursiveCall(char *where); +PyAPI_DATA(int) _Py_CheckRecursionLimit; +#ifdef USE_STACKCHECK +# define _Py_MakeRecCheck(x) (++(x) > --_Py_CheckRecursionLimit) +#else +# define _Py_MakeRecCheck(x) (++(x) > _Py_CheckRecursionLimit) +#endif + +PyAPI_FUNC(const char *) PyEval_GetFuncName(PyObject *); +PyAPI_FUNC(const char *) PyEval_GetFuncDesc(PyObject *); + +PyAPI_FUNC(PyObject *) PyEval_GetCallStats(PyObject *); +PyAPI_FUNC(PyObject *) PyEval_EvalFrame(struct _frame *); +PyAPI_FUNC(PyObject *) PyEval_EvalFrameEx(struct _frame *f, int exc); + +/* this used to be handled on a per-thread basis - now just two globals */ +PyAPI_DATA(volatile int) _Py_Ticker; +PyAPI_DATA(int) _Py_CheckInterval; + +/* Interface for threads. + + A module that plans to do a blocking system call (or something else + that lasts a long time and doesn't touch Python data) can allow other + threads to run as follows: + + ...preparations here... + Py_BEGIN_ALLOW_THREADS + ...blocking system call here... + Py_END_ALLOW_THREADS + ...interpret result here... + + The Py_BEGIN_ALLOW_THREADS/Py_END_ALLOW_THREADS pair expands to a + {}-surrounded block. + To leave the block in the middle (e.g., with return), you must insert + a line containing Py_BLOCK_THREADS before the return, e.g. + + if (...premature_exit...) { + Py_BLOCK_THREADS + PyErr_SetFromErrno(PyExc_IOError); + return NULL; + } + + An alternative is: + + Py_BLOCK_THREADS + if (...premature_exit...) { + PyErr_SetFromErrno(PyExc_IOError); + return NULL; + } + Py_UNBLOCK_THREADS + + For convenience, that the value of 'errno' is restored across + Py_END_ALLOW_THREADS and Py_BLOCK_THREADS. + + WARNING: NEVER NEST CALLS TO Py_BEGIN_ALLOW_THREADS AND + Py_END_ALLOW_THREADS!!! + + The function PyEval_InitThreads() should be called only from + initthread() in "threadmodule.c". + + Note that not yet all candidates have been converted to use this + mechanism! +*/ + +PyAPI_FUNC(PyThreadState *) PyEval_SaveThread(void); +PyAPI_FUNC(void) PyEval_RestoreThread(PyThreadState *); + +#ifdef WITH_THREAD + +PyAPI_FUNC(int) PyEval_ThreadsInitialized(void); +PyAPI_FUNC(void) PyEval_InitThreads(void); +PyAPI_FUNC(void) PyEval_AcquireLock(void); +PyAPI_FUNC(void) PyEval_ReleaseLock(void); +PyAPI_FUNC(void) PyEval_AcquireThread(PyThreadState *tstate); +PyAPI_FUNC(void) PyEval_ReleaseThread(PyThreadState *tstate); +PyAPI_FUNC(void) PyEval_ReInitThreads(void); + +#define Py_BEGIN_ALLOW_THREADS { \ + PyThreadState *_save; \ + _save = PyEval_SaveThread(); +#define Py_BLOCK_THREADS PyEval_RestoreThread(_save); +#define Py_UNBLOCK_THREADS _save = PyEval_SaveThread(); +#define Py_END_ALLOW_THREADS PyEval_RestoreThread(_save); \ + } + +#else /* !WITH_THREAD */ + +#define Py_BEGIN_ALLOW_THREADS { +#define Py_BLOCK_THREADS +#define Py_UNBLOCK_THREADS +#define Py_END_ALLOW_THREADS } + +#endif /* !WITH_THREAD */ + +PyAPI_FUNC(int) _PyEval_SliceIndex(PyObject *, Py_ssize_t *); + + +#ifdef __cplusplus +} +#endif +#endif /* !Py_CEVAL_H */ diff --git a/android/python27/include/classobject.h b/android/python27/include/classobject.h new file mode 100644 index 000000000..bc03e0d02 --- /dev/null +++ b/android/python27/include/classobject.h @@ -0,0 +1,83 @@ + +/* Class object interface */ + +/* Revealing some structures (not for general use) */ + +#ifndef Py_CLASSOBJECT_H +#define Py_CLASSOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + PyObject_HEAD + PyObject *cl_bases; /* A tuple of class objects */ + PyObject *cl_dict; /* A dictionary */ + PyObject *cl_name; /* A string */ + /* The following three are functions or NULL */ + PyObject *cl_getattr; + PyObject *cl_setattr; + PyObject *cl_delattr; + PyObject *cl_weakreflist; /* List of weak references */ +} PyClassObject; + +typedef struct { + PyObject_HEAD + PyClassObject *in_class; /* The class object */ + PyObject *in_dict; /* A dictionary */ + PyObject *in_weakreflist; /* List of weak references */ +} PyInstanceObject; + +typedef struct { + PyObject_HEAD + PyObject *im_func; /* The callable object implementing the method */ + PyObject *im_self; /* The instance it is bound to, or NULL */ + PyObject *im_class; /* The class that asked for the method */ + PyObject *im_weakreflist; /* List of weak references */ +} PyMethodObject; + +PyAPI_DATA(PyTypeObject) PyClass_Type, PyInstance_Type, PyMethod_Type; + +#define PyClass_Check(op) ((op)->ob_type == &PyClass_Type) +#define PyInstance_Check(op) ((op)->ob_type == &PyInstance_Type) +#define PyMethod_Check(op) ((op)->ob_type == &PyMethod_Type) + +PyAPI_FUNC(PyObject *) PyClass_New(PyObject *, PyObject *, PyObject *); +PyAPI_FUNC(PyObject *) PyInstance_New(PyObject *, PyObject *, + PyObject *); +PyAPI_FUNC(PyObject *) PyInstance_NewRaw(PyObject *, PyObject *); +PyAPI_FUNC(PyObject *) PyMethod_New(PyObject *, PyObject *, PyObject *); + +PyAPI_FUNC(PyObject *) PyMethod_Function(PyObject *); +PyAPI_FUNC(PyObject *) PyMethod_Self(PyObject *); +PyAPI_FUNC(PyObject *) PyMethod_Class(PyObject *); + +/* Look up attribute with name (a string) on instance object pinst, using + * only the instance and base class dicts. If a descriptor is found in + * a class dict, the descriptor is returned without calling it. + * Returns NULL if nothing found, else a borrowed reference to the + * value associated with name in the dict in which name was found. + * The point of this routine is that it never calls arbitrary Python + * code, so is always "safe": all it does is dict lookups. The function + * can't fail, never sets an exception, and NULL is not an error (it just + * means "not found"). + */ +PyAPI_FUNC(PyObject *) _PyInstance_Lookup(PyObject *pinst, PyObject *name); + +/* Macros for direct access to these values. Type checks are *not* + done, so use with care. */ +#define PyMethod_GET_FUNCTION(meth) \ + (((PyMethodObject *)meth) -> im_func) +#define PyMethod_GET_SELF(meth) \ + (((PyMethodObject *)meth) -> im_self) +#define PyMethod_GET_CLASS(meth) \ + (((PyMethodObject *)meth) -> im_class) + +PyAPI_FUNC(int) PyClass_IsSubclass(PyObject *, PyObject *); + +PyAPI_FUNC(int) PyMethod_ClearFreeList(void); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_CLASSOBJECT_H */ diff --git a/android/python27/include/cobject.h b/android/python27/include/cobject.h new file mode 100644 index 000000000..ad3cd9c98 --- /dev/null +++ b/android/python27/include/cobject.h @@ -0,0 +1,89 @@ +/* + CObjects are marked Pending Deprecation as of Python 2.7. + The full schedule for 2.x is as follows: + - CObjects are marked Pending Deprecation in Python 2.7. + - CObjects will be marked Deprecated in Python 2.8 + (if there is one). + - CObjects will be removed in Python 2.9 (if there is one). + + Additionally, for the Python 3.x series: + - CObjects were marked Deprecated in Python 3.1. + - CObjects will be removed in Python 3.2. + + You should switch all use of CObjects to capsules. Capsules + have a safer and more consistent API. For more information, + see Include/pycapsule.h, or read the "Capsules" topic in + the "Python/C API Reference Manual". + + Python 2.7 no longer uses CObjects itself; all objects which + were formerly CObjects are now capsules. Note that this change + does not by itself break binary compatibility with extensions + built for previous versions of Python--PyCObject_AsVoidPtr() + has been changed to also understand capsules. + +*/ + +/* original file header comment follows: */ + +/* C objects to be exported from one extension module to another. + + C objects are used for communication between extension modules. + They provide a way for an extension module to export a C interface + to other extension modules, so that extension modules can use the + Python import mechanism to link to one another. + +*/ + +#ifndef Py_COBJECT_H +#define Py_COBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_DATA(PyTypeObject) PyCObject_Type; + +#define PyCObject_Check(op) (Py_TYPE(op) == &PyCObject_Type) + +/* Create a PyCObject from a pointer to a C object and an optional + destructor function. If the second argument is non-null, then it + will be called with the first argument if and when the PyCObject is + destroyed. + +*/ +PyAPI_FUNC(PyObject *) PyCObject_FromVoidPtr( + void *cobj, void (*destruct)(void*)); + + +/* Create a PyCObject from a pointer to a C object, a description object, + and an optional destructor function. If the third argument is non-null, + then it will be called with the first and second arguments if and when + the PyCObject is destroyed. +*/ +PyAPI_FUNC(PyObject *) PyCObject_FromVoidPtrAndDesc( + void *cobj, void *desc, void (*destruct)(void*,void*)); + +/* Retrieve a pointer to a C object from a PyCObject. */ +PyAPI_FUNC(void *) PyCObject_AsVoidPtr(PyObject *); + +/* Retrieve a pointer to a description object from a PyCObject. */ +PyAPI_FUNC(void *) PyCObject_GetDesc(PyObject *); + +/* Import a pointer to a C object from a module using a PyCObject. */ +PyAPI_FUNC(void *) PyCObject_Import(char *module_name, char *cobject_name); + +/* Modify a C object. Fails (==0) if object has a destructor. */ +PyAPI_FUNC(int) PyCObject_SetVoidPtr(PyObject *self, void *cobj); + + +typedef struct { + PyObject_HEAD + void *cobject; + void *desc; + void (*destructor)(void *); +} PyCObject; + + +#ifdef __cplusplus +} +#endif +#endif /* !Py_COBJECT_H */ diff --git a/android/python27/include/code.h b/android/python27/include/code.h new file mode 100644 index 000000000..38b295804 --- /dev/null +++ b/android/python27/include/code.h @@ -0,0 +1,107 @@ +/* Definitions for bytecode */ + +#ifndef Py_CODE_H +#define Py_CODE_H +#ifdef __cplusplus +extern "C" { +#endif + +/* Bytecode object */ +typedef struct { + PyObject_HEAD + int co_argcount; /* #arguments, except *args */ + int co_nlocals; /* #local variables */ + int co_stacksize; /* #entries needed for evaluation stack */ + int co_flags; /* CO_..., see below */ + PyObject *co_code; /* instruction opcodes */ + PyObject *co_consts; /* list (constants used) */ + PyObject *co_names; /* list of strings (names used) */ + PyObject *co_varnames; /* tuple of strings (local variable names) */ + PyObject *co_freevars; /* tuple of strings (free variable names) */ + PyObject *co_cellvars; /* tuple of strings (cell variable names) */ + /* The rest doesn't count for hash/cmp */ + PyObject *co_filename; /* string (where it was loaded from) */ + PyObject *co_name; /* string (name, for reference) */ + int co_firstlineno; /* first source line number */ + PyObject *co_lnotab; /* string (encoding addr<->lineno mapping) See + Objects/lnotab_notes.txt for details. */ + void *co_zombieframe; /* for optimization only (see frameobject.c) */ + PyObject *co_weakreflist; /* to support weakrefs to code objects */ +} PyCodeObject; + +/* Masks for co_flags above */ +#define CO_OPTIMIZED 0x0001 +#define CO_NEWLOCALS 0x0002 +#define CO_VARARGS 0x0004 +#define CO_VARKEYWORDS 0x0008 +#define CO_NESTED 0x0010 +#define CO_GENERATOR 0x0020 +/* The CO_NOFREE flag is set if there are no free or cell variables. + This information is redundant, but it allows a single flag test + to determine whether there is any extra work to be done when the + call frame it setup. +*/ +#define CO_NOFREE 0x0040 + +#if 0 +/* This is no longer used. Stopped defining in 2.5, do not re-use. */ +#define CO_GENERATOR_ALLOWED 0x1000 +#endif +#define CO_FUTURE_DIVISION 0x2000 +#define CO_FUTURE_ABSOLUTE_IMPORT 0x4000 /* do absolute imports by default */ +#define CO_FUTURE_WITH_STATEMENT 0x8000 +#define CO_FUTURE_PRINT_FUNCTION 0x10000 +#define CO_FUTURE_UNICODE_LITERALS 0x20000 + +/* This should be defined if a future statement modifies the syntax. + For example, when a keyword is added. +*/ +#if 1 +#define PY_PARSER_REQUIRES_FUTURE_KEYWORD +#endif + +#define CO_MAXBLOCKS 20 /* Max static block nesting within a function */ + +PyAPI_DATA(PyTypeObject) PyCode_Type; + +#define PyCode_Check(op) (Py_TYPE(op) == &PyCode_Type) +#define PyCode_GetNumFree(op) (PyTuple_GET_SIZE((op)->co_freevars)) + +/* Public interface */ +PyAPI_FUNC(PyCodeObject *) PyCode_New( + int, int, int, int, PyObject *, PyObject *, PyObject *, PyObject *, + PyObject *, PyObject *, PyObject *, PyObject *, int, PyObject *); + /* same as struct above */ + +/* Creates a new empty code object with the specified source location. */ +PyAPI_FUNC(PyCodeObject *) +PyCode_NewEmpty(const char *filename, const char *funcname, int firstlineno); + +/* Return the line number associated with the specified bytecode index + in this code object. If you just need the line number of a frame, + use PyFrame_GetLineNumber() instead. */ +PyAPI_FUNC(int) PyCode_Addr2Line(PyCodeObject *, int); + +/* for internal use only */ +#define _PyCode_GETCODEPTR(co, pp) \ + ((*Py_TYPE((co)->co_code)->tp_as_buffer->bf_getreadbuffer) \ + ((co)->co_code, 0, (void **)(pp))) + +typedef struct _addr_pair { + int ap_lower; + int ap_upper; +} PyAddrPair; + +/* Update *bounds to describe the first and one-past-the-last instructions in the + same line as lasti. Return the number of that line. +*/ +PyAPI_FUNC(int) _PyCode_CheckLineNumber(PyCodeObject* co, + int lasti, PyAddrPair *bounds); + +PyAPI_FUNC(PyObject*) PyCode_Optimize(PyObject *code, PyObject* consts, + PyObject *names, PyObject *lineno_obj); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_CODE_H */ diff --git a/android/python27/include/codecs.h b/android/python27/include/codecs.h new file mode 100644 index 000000000..c038c6a92 --- /dev/null +++ b/android/python27/include/codecs.h @@ -0,0 +1,167 @@ +#ifndef Py_CODECREGISTRY_H +#define Py_CODECREGISTRY_H +#ifdef __cplusplus +extern "C" { +#endif + +/* ------------------------------------------------------------------------ + + Python Codec Registry and support functions + + +Written by Marc-Andre Lemburg (mal@lemburg.com). + +Copyright (c) Corporation for National Research Initiatives. + + ------------------------------------------------------------------------ */ + +/* Register a new codec search function. + + As side effect, this tries to load the encodings package, if not + yet done, to make sure that it is always first in the list of + search functions. + + The search_function's refcount is incremented by this function. */ + +PyAPI_FUNC(int) PyCodec_Register( + PyObject *search_function + ); + +/* Codec register lookup API. + + Looks up the given encoding and returns a CodecInfo object with + function attributes which implement the different aspects of + processing the encoding. + + The encoding string is looked up converted to all lower-case + characters. This makes encodings looked up through this mechanism + effectively case-insensitive. + + If no codec is found, a KeyError is set and NULL returned. + + As side effect, this tries to load the encodings package, if not + yet done. This is part of the lazy load strategy for the encodings + package. + + */ + +PyAPI_FUNC(PyObject *) _PyCodec_Lookup( + const char *encoding + ); + +/* Generic codec based encoding API. + + object is passed through the encoder function found for the given + encoding using the error handling method defined by errors. errors + may be NULL to use the default method defined for the codec. + + Raises a LookupError in case no encoder can be found. + + */ + +PyAPI_FUNC(PyObject *) PyCodec_Encode( + PyObject *object, + const char *encoding, + const char *errors + ); + +/* Generic codec based decoding API. + + object is passed through the decoder function found for the given + encoding using the error handling method defined by errors. errors + may be NULL to use the default method defined for the codec. + + Raises a LookupError in case no encoder can be found. + + */ + +PyAPI_FUNC(PyObject *) PyCodec_Decode( + PyObject *object, + const char *encoding, + const char *errors + ); + +/* --- Codec Lookup APIs -------------------------------------------------- + + All APIs return a codec object with incremented refcount and are + based on _PyCodec_Lookup(). The same comments w/r to the encoding + name also apply to these APIs. + +*/ + +/* Get an encoder function for the given encoding. */ + +PyAPI_FUNC(PyObject *) PyCodec_Encoder( + const char *encoding + ); + +/* Get a decoder function for the given encoding. */ + +PyAPI_FUNC(PyObject *) PyCodec_Decoder( + const char *encoding + ); + +/* Get a IncrementalEncoder object for the given encoding. */ + +PyAPI_FUNC(PyObject *) PyCodec_IncrementalEncoder( + const char *encoding, + const char *errors + ); + +/* Get a IncrementalDecoder object function for the given encoding. */ + +PyAPI_FUNC(PyObject *) PyCodec_IncrementalDecoder( + const char *encoding, + const char *errors + ); + +/* Get a StreamReader factory function for the given encoding. */ + +PyAPI_FUNC(PyObject *) PyCodec_StreamReader( + const char *encoding, + PyObject *stream, + const char *errors + ); + +/* Get a StreamWriter factory function for the given encoding. */ + +PyAPI_FUNC(PyObject *) PyCodec_StreamWriter( + const char *encoding, + PyObject *stream, + const char *errors + ); + +/* Unicode encoding error handling callback registry API */ + +/* Register the error handling callback function error under the given + name. This function will be called by the codec when it encounters + unencodable characters/undecodable bytes and doesn't know the + callback name, when name is specified as the error parameter + in the call to the encode/decode function. + Return 0 on success, -1 on error */ +PyAPI_FUNC(int) PyCodec_RegisterError(const char *name, PyObject *error); + +/* Lookup the error handling callback function registered under the given + name. As a special case NULL can be passed, in which case + the error handling callback for "strict" will be returned. */ +PyAPI_FUNC(PyObject *) PyCodec_LookupError(const char *name); + +/* raise exc as an exception */ +PyAPI_FUNC(PyObject *) PyCodec_StrictErrors(PyObject *exc); + +/* ignore the unicode error, skipping the faulty input */ +PyAPI_FUNC(PyObject *) PyCodec_IgnoreErrors(PyObject *exc); + +/* replace the unicode encode error with ? or U+FFFD */ +PyAPI_FUNC(PyObject *) PyCodec_ReplaceErrors(PyObject *exc); + +/* replace the unicode encode error with XML character references */ +PyAPI_FUNC(PyObject *) PyCodec_XMLCharRefReplaceErrors(PyObject *exc); + +/* replace the unicode encode error with backslash escapes (\x, \u and \U) */ +PyAPI_FUNC(PyObject *) PyCodec_BackslashReplaceErrors(PyObject *exc); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_CODECREGISTRY_H */ diff --git a/android/python27/include/compile.h b/android/python27/include/compile.h new file mode 100644 index 000000000..61001016a --- /dev/null +++ b/android/python27/include/compile.h @@ -0,0 +1,40 @@ + +#ifndef Py_COMPILE_H +#define Py_COMPILE_H + +#include "code.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Public interface */ +struct _node; /* Declare the existence of this type */ +PyAPI_FUNC(PyCodeObject *) PyNode_Compile(struct _node *, const char *); + +/* Future feature support */ + +typedef struct { + int ff_features; /* flags set by future statements */ + int ff_lineno; /* line number of last future statement */ +} PyFutureFeatures; + +#define FUTURE_NESTED_SCOPES "nested_scopes" +#define FUTURE_GENERATORS "generators" +#define FUTURE_DIVISION "division" +#define FUTURE_ABSOLUTE_IMPORT "absolute_import" +#define FUTURE_WITH_STATEMENT "with_statement" +#define FUTURE_PRINT_FUNCTION "print_function" +#define FUTURE_UNICODE_LITERALS "unicode_literals" + + +struct _mod; /* Declare the existence of this type */ +PyAPI_FUNC(PyCodeObject *) PyAST_Compile(struct _mod *, const char *, + PyCompilerFlags *, PyArena *); +PyAPI_FUNC(PyFutureFeatures *) PyFuture_FromAST(struct _mod *, const char *); + + +#ifdef __cplusplus +} +#endif +#endif /* !Py_COMPILE_H */ diff --git a/android/python27/include/complexobject.h b/android/python27/include/complexobject.h new file mode 100644 index 000000000..c9a9500fd --- /dev/null +++ b/android/python27/include/complexobject.h @@ -0,0 +1,66 @@ +/* Complex number structure */ + +#ifndef Py_COMPLEXOBJECT_H +#define Py_COMPLEXOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + double real; + double imag; +} Py_complex; + +/* Operations on complex numbers from complexmodule.c */ + +#define c_sum _Py_c_sum +#define c_diff _Py_c_diff +#define c_neg _Py_c_neg +#define c_prod _Py_c_prod +#define c_quot _Py_c_quot +#define c_pow _Py_c_pow +#define c_abs _Py_c_abs + +PyAPI_FUNC(Py_complex) c_sum(Py_complex, Py_complex); +PyAPI_FUNC(Py_complex) c_diff(Py_complex, Py_complex); +PyAPI_FUNC(Py_complex) c_neg(Py_complex); +PyAPI_FUNC(Py_complex) c_prod(Py_complex, Py_complex); +PyAPI_FUNC(Py_complex) c_quot(Py_complex, Py_complex); +PyAPI_FUNC(Py_complex) c_pow(Py_complex, Py_complex); +PyAPI_FUNC(double) c_abs(Py_complex); + + +/* Complex object interface */ + +/* +PyComplexObject represents a complex number with double-precision +real and imaginary parts. +*/ + +typedef struct { + PyObject_HEAD + Py_complex cval; +} PyComplexObject; + +PyAPI_DATA(PyTypeObject) PyComplex_Type; + +#define PyComplex_Check(op) PyObject_TypeCheck(op, &PyComplex_Type) +#define PyComplex_CheckExact(op) (Py_TYPE(op) == &PyComplex_Type) + +PyAPI_FUNC(PyObject *) PyComplex_FromCComplex(Py_complex); +PyAPI_FUNC(PyObject *) PyComplex_FromDoubles(double real, double imag); + +PyAPI_FUNC(double) PyComplex_RealAsDouble(PyObject *op); +PyAPI_FUNC(double) PyComplex_ImagAsDouble(PyObject *op); +PyAPI_FUNC(Py_complex) PyComplex_AsCComplex(PyObject *op); + +/* Format the object based on the format_spec, as defined in PEP 3101 + (Advanced String Formatting). */ +PyAPI_FUNC(PyObject *) _PyComplex_FormatAdvanced(PyObject *obj, + char *format_spec, + Py_ssize_t format_spec_len); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_COMPLEXOBJECT_H */ diff --git a/android/python27/include/datetime.h b/android/python27/include/datetime.h new file mode 100644 index 000000000..c0e7ffd00 --- /dev/null +++ b/android/python27/include/datetime.h @@ -0,0 +1,239 @@ +/* datetime.h + */ + +#ifndef DATETIME_H +#define DATETIME_H +#ifdef __cplusplus +extern "C" { +#endif + +/* Fields are packed into successive bytes, each viewed as unsigned and + * big-endian, unless otherwise noted: + * + * byte offset + * 0 year 2 bytes, 1-9999 + * 2 month 1 byte, 1-12 + * 3 day 1 byte, 1-31 + * 4 hour 1 byte, 0-23 + * 5 minute 1 byte, 0-59 + * 6 second 1 byte, 0-59 + * 7 usecond 3 bytes, 0-999999 + * 10 + */ + +/* # of bytes for year, month, and day. */ +#define _PyDateTime_DATE_DATASIZE 4 + +/* # of bytes for hour, minute, second, and usecond. */ +#define _PyDateTime_TIME_DATASIZE 6 + +/* # of bytes for year, month, day, hour, minute, second, and usecond. */ +#define _PyDateTime_DATETIME_DATASIZE 10 + + +typedef struct +{ + PyObject_HEAD + long hashcode; /* -1 when unknown */ + int days; /* -MAX_DELTA_DAYS <= days <= MAX_DELTA_DAYS */ + int seconds; /* 0 <= seconds < 24*3600 is invariant */ + int microseconds; /* 0 <= microseconds < 1000000 is invariant */ +} PyDateTime_Delta; + +typedef struct +{ + PyObject_HEAD /* a pure abstract base class */ +} PyDateTime_TZInfo; + + +/* The datetime and time types have hashcodes, and an optional tzinfo member, + * present if and only if hastzinfo is true. + */ +#define _PyTZINFO_HEAD \ + PyObject_HEAD \ + long hashcode; \ + char hastzinfo; /* boolean flag */ + +/* No _PyDateTime_BaseTZInfo is allocated; it's just to have something + * convenient to cast to, when getting at the hastzinfo member of objects + * starting with _PyTZINFO_HEAD. + */ +typedef struct +{ + _PyTZINFO_HEAD +} _PyDateTime_BaseTZInfo; + +/* All time objects are of PyDateTime_TimeType, but that can be allocated + * in two ways, with or without a tzinfo member. Without is the same as + * tzinfo == None, but consumes less memory. _PyDateTime_BaseTime is an + * internal struct used to allocate the right amount of space for the + * "without" case. + */ +#define _PyDateTime_TIMEHEAD \ + _PyTZINFO_HEAD \ + unsigned char data[_PyDateTime_TIME_DATASIZE]; + +typedef struct +{ + _PyDateTime_TIMEHEAD +} _PyDateTime_BaseTime; /* hastzinfo false */ + +typedef struct +{ + _PyDateTime_TIMEHEAD + PyObject *tzinfo; +} PyDateTime_Time; /* hastzinfo true */ + + +/* All datetime objects are of PyDateTime_DateTimeType, but that can be + * allocated in two ways too, just like for time objects above. In addition, + * the plain date type is a base class for datetime, so it must also have + * a hastzinfo member (although it's unused there). + */ +typedef struct +{ + _PyTZINFO_HEAD + unsigned char data[_PyDateTime_DATE_DATASIZE]; +} PyDateTime_Date; + +#define _PyDateTime_DATETIMEHEAD \ + _PyTZINFO_HEAD \ + unsigned char data[_PyDateTime_DATETIME_DATASIZE]; + +typedef struct +{ + _PyDateTime_DATETIMEHEAD +} _PyDateTime_BaseDateTime; /* hastzinfo false */ + +typedef struct +{ + _PyDateTime_DATETIMEHEAD + PyObject *tzinfo; +} PyDateTime_DateTime; /* hastzinfo true */ + + +/* Apply for date and datetime instances. */ +#define PyDateTime_GET_YEAR(o) ((((PyDateTime_Date*)o)->data[0] << 8) | \ + ((PyDateTime_Date*)o)->data[1]) +#define PyDateTime_GET_MONTH(o) (((PyDateTime_Date*)o)->data[2]) +#define PyDateTime_GET_DAY(o) (((PyDateTime_Date*)o)->data[3]) + +#define PyDateTime_DATE_GET_HOUR(o) (((PyDateTime_DateTime*)o)->data[4]) +#define PyDateTime_DATE_GET_MINUTE(o) (((PyDateTime_DateTime*)o)->data[5]) +#define PyDateTime_DATE_GET_SECOND(o) (((PyDateTime_DateTime*)o)->data[6]) +#define PyDateTime_DATE_GET_MICROSECOND(o) \ + ((((PyDateTime_DateTime*)o)->data[7] << 16) | \ + (((PyDateTime_DateTime*)o)->data[8] << 8) | \ + ((PyDateTime_DateTime*)o)->data[9]) + +/* Apply for time instances. */ +#define PyDateTime_TIME_GET_HOUR(o) (((PyDateTime_Time*)o)->data[0]) +#define PyDateTime_TIME_GET_MINUTE(o) (((PyDateTime_Time*)o)->data[1]) +#define PyDateTime_TIME_GET_SECOND(o) (((PyDateTime_Time*)o)->data[2]) +#define PyDateTime_TIME_GET_MICROSECOND(o) \ + ((((PyDateTime_Time*)o)->data[3] << 16) | \ + (((PyDateTime_Time*)o)->data[4] << 8) | \ + ((PyDateTime_Time*)o)->data[5]) + + +/* Define structure for C API. */ +typedef struct { + /* type objects */ + PyTypeObject *DateType; + PyTypeObject *DateTimeType; + PyTypeObject *TimeType; + PyTypeObject *DeltaType; + PyTypeObject *TZInfoType; + + /* constructors */ + PyObject *(*Date_FromDate)(int, int, int, PyTypeObject*); + PyObject *(*DateTime_FromDateAndTime)(int, int, int, int, int, int, int, + PyObject*, PyTypeObject*); + PyObject *(*Time_FromTime)(int, int, int, int, PyObject*, PyTypeObject*); + PyObject *(*Delta_FromDelta)(int, int, int, int, PyTypeObject*); + + /* constructors for the DB API */ + PyObject *(*DateTime_FromTimestamp)(PyObject*, PyObject*, PyObject*); + PyObject *(*Date_FromTimestamp)(PyObject*, PyObject*); + +} PyDateTime_CAPI; + +#define PyDateTime_CAPSULE_NAME "datetime.datetime_CAPI" + + +/* "magic" constant used to partially protect against developer mistakes. */ +#define DATETIME_API_MAGIC 0x414548d5 + +#ifdef Py_BUILD_CORE + +/* Macros for type checking when building the Python core. */ +#define PyDate_Check(op) PyObject_TypeCheck(op, &PyDateTime_DateType) +#define PyDate_CheckExact(op) (Py_TYPE(op) == &PyDateTime_DateType) + +#define PyDateTime_Check(op) PyObject_TypeCheck(op, &PyDateTime_DateTimeType) +#define PyDateTime_CheckExact(op) (Py_TYPE(op) == &PyDateTime_DateTimeType) + +#define PyTime_Check(op) PyObject_TypeCheck(op, &PyDateTime_TimeType) +#define PyTime_CheckExact(op) (Py_TYPE(op) == &PyDateTime_TimeType) + +#define PyDelta_Check(op) PyObject_TypeCheck(op, &PyDateTime_DeltaType) +#define PyDelta_CheckExact(op) (Py_TYPE(op) == &PyDateTime_DeltaType) + +#define PyTZInfo_Check(op) PyObject_TypeCheck(op, &PyDateTime_TZInfoType) +#define PyTZInfo_CheckExact(op) (Py_TYPE(op) == &PyDateTime_TZInfoType) + +#else + +/* Define global variable for the C API and a macro for setting it. */ +static PyDateTime_CAPI *PyDateTimeAPI = NULL; + +#define PyDateTime_IMPORT \ + PyDateTimeAPI = (PyDateTime_CAPI *)PyCapsule_Import(PyDateTime_CAPSULE_NAME, 0) + +/* Macros for type checking when not building the Python core. */ +#define PyDate_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->DateType) +#define PyDate_CheckExact(op) (Py_TYPE(op) == PyDateTimeAPI->DateType) + +#define PyDateTime_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->DateTimeType) +#define PyDateTime_CheckExact(op) (Py_TYPE(op) == PyDateTimeAPI->DateTimeType) + +#define PyTime_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->TimeType) +#define PyTime_CheckExact(op) (Py_TYPE(op) == PyDateTimeAPI->TimeType) + +#define PyDelta_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->DeltaType) +#define PyDelta_CheckExact(op) (Py_TYPE(op) == PyDateTimeAPI->DeltaType) + +#define PyTZInfo_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->TZInfoType) +#define PyTZInfo_CheckExact(op) (Py_TYPE(op) == PyDateTimeAPI->TZInfoType) + +/* Macros for accessing constructors in a simplified fashion. */ +#define PyDate_FromDate(year, month, day) \ + PyDateTimeAPI->Date_FromDate(year, month, day, PyDateTimeAPI->DateType) + +#define PyDateTime_FromDateAndTime(year, month, day, hour, min, sec, usec) \ + PyDateTimeAPI->DateTime_FromDateAndTime(year, month, day, hour, \ + min, sec, usec, Py_None, PyDateTimeAPI->DateTimeType) + +#define PyTime_FromTime(hour, minute, second, usecond) \ + PyDateTimeAPI->Time_FromTime(hour, minute, second, usecond, \ + Py_None, PyDateTimeAPI->TimeType) + +#define PyDelta_FromDSU(days, seconds, useconds) \ + PyDateTimeAPI->Delta_FromDelta(days, seconds, useconds, 1, \ + PyDateTimeAPI->DeltaType) + +/* Macros supporting the DB API. */ +#define PyDateTime_FromTimestamp(args) \ + PyDateTimeAPI->DateTime_FromTimestamp( \ + (PyObject*) (PyDateTimeAPI->DateTimeType), args, NULL) + +#define PyDate_FromTimestamp(args) \ + PyDateTimeAPI->Date_FromTimestamp( \ + (PyObject*) (PyDateTimeAPI->DateType), args) + +#endif /* Py_BUILD_CORE */ + +#ifdef __cplusplus +} +#endif +#endif diff --git a/android/python27/include/descrobject.h b/android/python27/include/descrobject.h new file mode 100644 index 000000000..b542732b1 --- /dev/null +++ b/android/python27/include/descrobject.h @@ -0,0 +1,94 @@ +/* Descriptors */ +#ifndef Py_DESCROBJECT_H +#define Py_DESCROBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +typedef PyObject *(*getter)(PyObject *, void *); +typedef int (*setter)(PyObject *, PyObject *, void *); + +typedef struct PyGetSetDef { + char *name; + getter get; + setter set; + char *doc; + void *closure; +} PyGetSetDef; + +typedef PyObject *(*wrapperfunc)(PyObject *self, PyObject *args, + void *wrapped); + +typedef PyObject *(*wrapperfunc_kwds)(PyObject *self, PyObject *args, + void *wrapped, PyObject *kwds); + +struct wrapperbase { + char *name; + int offset; + void *function; + wrapperfunc wrapper; + char *doc; + int flags; + PyObject *name_strobj; +}; + +/* Flags for above struct */ +#define PyWrapperFlag_KEYWORDS 1 /* wrapper function takes keyword args */ + +/* Various kinds of descriptor objects */ + +#define PyDescr_COMMON \ + PyObject_HEAD \ + PyTypeObject *d_type; \ + PyObject *d_name + +typedef struct { + PyDescr_COMMON; +} PyDescrObject; + +typedef struct { + PyDescr_COMMON; + PyMethodDef *d_method; +} PyMethodDescrObject; + +typedef struct { + PyDescr_COMMON; + struct PyMemberDef *d_member; +} PyMemberDescrObject; + +typedef struct { + PyDescr_COMMON; + PyGetSetDef *d_getset; +} PyGetSetDescrObject; + +typedef struct { + PyDescr_COMMON; + struct wrapperbase *d_base; + void *d_wrapped; /* This can be any function pointer */ +} PyWrapperDescrObject; + +PyAPI_DATA(PyTypeObject) PyWrapperDescr_Type; +PyAPI_DATA(PyTypeObject) PyDictProxy_Type; +PyAPI_DATA(PyTypeObject) PyGetSetDescr_Type; +PyAPI_DATA(PyTypeObject) PyMemberDescr_Type; + +PyAPI_FUNC(PyObject *) PyDescr_NewMethod(PyTypeObject *, PyMethodDef *); +PyAPI_FUNC(PyObject *) PyDescr_NewClassMethod(PyTypeObject *, PyMethodDef *); +PyAPI_FUNC(PyObject *) PyDescr_NewMember(PyTypeObject *, + struct PyMemberDef *); +PyAPI_FUNC(PyObject *) PyDescr_NewGetSet(PyTypeObject *, + struct PyGetSetDef *); +PyAPI_FUNC(PyObject *) PyDescr_NewWrapper(PyTypeObject *, + struct wrapperbase *, void *); +#define PyDescr_IsData(d) (Py_TYPE(d)->tp_descr_set != NULL) + +PyAPI_FUNC(PyObject *) PyDictProxy_New(PyObject *); +PyAPI_FUNC(PyObject *) PyWrapper_New(PyObject *, PyObject *); + + +PyAPI_DATA(PyTypeObject) PyProperty_Type; +#ifdef __cplusplus +} +#endif +#endif /* !Py_DESCROBJECT_H */ + diff --git a/android/python27/include/dictobject.h b/android/python27/include/dictobject.h new file mode 100644 index 000000000..ece01c64d --- /dev/null +++ b/android/python27/include/dictobject.h @@ -0,0 +1,156 @@ +#ifndef Py_DICTOBJECT_H +#define Py_DICTOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + + +/* Dictionary object type -- mapping from hashable object to object */ + +/* The distribution includes a separate file, Objects/dictnotes.txt, + describing explorations into dictionary design and optimization. + It covers typical dictionary use patterns, the parameters for + tuning dictionaries, and several ideas for possible optimizations. +*/ + +/* +There are three kinds of slots in the table: + +1. Unused. me_key == me_value == NULL + Does not hold an active (key, value) pair now and never did. Unused can + transition to Active upon key insertion. This is the only case in which + me_key is NULL, and is each slot's initial state. + +2. Active. me_key != NULL and me_key != dummy and me_value != NULL + Holds an active (key, value) pair. Active can transition to Dummy upon + key deletion. This is the only case in which me_value != NULL. + +3. Dummy. me_key == dummy and me_value == NULL + Previously held an active (key, value) pair, but that was deleted and an + active pair has not yet overwritten the slot. Dummy can transition to + Active upon key insertion. Dummy slots cannot be made Unused again + (cannot have me_key set to NULL), else the probe sequence in case of + collision would have no way to know they were once active. + +Note: .popitem() abuses the me_hash field of an Unused or Dummy slot to +hold a search finger. The me_hash field of Unused or Dummy slots has no +meaning otherwise. +*/ + +/* PyDict_MINSIZE is the minimum size of a dictionary. This many slots are + * allocated directly in the dict object (in the ma_smalltable member). + * It must be a power of 2, and at least 4. 8 allows dicts with no more + * than 5 active entries to live in ma_smalltable (and so avoid an + * additional malloc); instrumentation suggested this suffices for the + * majority of dicts (consisting mostly of usually-small instance dicts and + * usually-small dicts created to pass keyword arguments). + */ +#define PyDict_MINSIZE 8 + +typedef struct { + /* Cached hash code of me_key. Note that hash codes are C longs. + * We have to use Py_ssize_t instead because dict_popitem() abuses + * me_hash to hold a search finger. + */ + Py_ssize_t me_hash; + PyObject *me_key; + PyObject *me_value; +} PyDictEntry; + +/* +To ensure the lookup algorithm terminates, there must be at least one Unused +slot (NULL key) in the table. +The value ma_fill is the number of non-NULL keys (sum of Active and Dummy); +ma_used is the number of non-NULL, non-dummy keys (== the number of non-NULL +values == the number of Active items). +To avoid slowing down lookups on a near-full table, we resize the table when +it's two-thirds full. +*/ +typedef struct _dictobject PyDictObject; +struct _dictobject { + PyObject_HEAD + Py_ssize_t ma_fill; /* # Active + # Dummy */ + Py_ssize_t ma_used; /* # Active */ + + /* The table contains ma_mask + 1 slots, and that's a power of 2. + * We store the mask instead of the size because the mask is more + * frequently needed. + */ + Py_ssize_t ma_mask; + + /* ma_table points to ma_smalltable for small tables, else to + * additional malloc'ed memory. ma_table is never NULL! This rule + * saves repeated runtime null-tests in the workhorse getitem and + * setitem calls. + */ + PyDictEntry *ma_table; + PyDictEntry *(*ma_lookup)(PyDictObject *mp, PyObject *key, long hash); + PyDictEntry ma_smalltable[PyDict_MINSIZE]; +}; + +PyAPI_DATA(PyTypeObject) PyDict_Type; +PyAPI_DATA(PyTypeObject) PyDictIterKey_Type; +PyAPI_DATA(PyTypeObject) PyDictIterValue_Type; +PyAPI_DATA(PyTypeObject) PyDictIterItem_Type; +PyAPI_DATA(PyTypeObject) PyDictKeys_Type; +PyAPI_DATA(PyTypeObject) PyDictItems_Type; +PyAPI_DATA(PyTypeObject) PyDictValues_Type; + +#define PyDict_Check(op) \ + PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_DICT_SUBCLASS) +#define PyDict_CheckExact(op) (Py_TYPE(op) == &PyDict_Type) +#define PyDictKeys_Check(op) (Py_TYPE(op) == &PyDictKeys_Type) +#define PyDictItems_Check(op) (Py_TYPE(op) == &PyDictItems_Type) +#define PyDictValues_Check(op) (Py_TYPE(op) == &PyDictValues_Type) +/* This excludes Values, since they are not sets. */ +# define PyDictViewSet_Check(op) \ + (PyDictKeys_Check(op) || PyDictItems_Check(op)) + +PyAPI_FUNC(PyObject *) PyDict_New(void); +PyAPI_FUNC(PyObject *) PyDict_GetItem(PyObject *mp, PyObject *key); +PyAPI_FUNC(int) PyDict_SetItem(PyObject *mp, PyObject *key, PyObject *item); +PyAPI_FUNC(int) PyDict_DelItem(PyObject *mp, PyObject *key); +PyAPI_FUNC(void) PyDict_Clear(PyObject *mp); +PyAPI_FUNC(int) PyDict_Next( + PyObject *mp, Py_ssize_t *pos, PyObject **key, PyObject **value); +PyAPI_FUNC(int) _PyDict_Next( + PyObject *mp, Py_ssize_t *pos, PyObject **key, PyObject **value, long *hash); +PyAPI_FUNC(PyObject *) PyDict_Keys(PyObject *mp); +PyAPI_FUNC(PyObject *) PyDict_Values(PyObject *mp); +PyAPI_FUNC(PyObject *) PyDict_Items(PyObject *mp); +PyAPI_FUNC(Py_ssize_t) PyDict_Size(PyObject *mp); +PyAPI_FUNC(PyObject *) PyDict_Copy(PyObject *mp); +PyAPI_FUNC(int) PyDict_Contains(PyObject *mp, PyObject *key); +PyAPI_FUNC(int) _PyDict_Contains(PyObject *mp, PyObject *key, long hash); +PyAPI_FUNC(PyObject *) _PyDict_NewPresized(Py_ssize_t minused); +PyAPI_FUNC(void) _PyDict_MaybeUntrack(PyObject *mp); + +/* PyDict_Update(mp, other) is equivalent to PyDict_Merge(mp, other, 1). */ +PyAPI_FUNC(int) PyDict_Update(PyObject *mp, PyObject *other); + +/* PyDict_Merge updates/merges from a mapping object (an object that + supports PyMapping_Keys() and PyObject_GetItem()). If override is true, + the last occurrence of a key wins, else the first. The Python + dict.update(other) is equivalent to PyDict_Merge(dict, other, 1). +*/ +PyAPI_FUNC(int) PyDict_Merge(PyObject *mp, + PyObject *other, + int override); + +/* PyDict_MergeFromSeq2 updates/merges from an iterable object producing + iterable objects of length 2. If override is true, the last occurrence + of a key wins, else the first. The Python dict constructor dict(seq2) + is equivalent to dict={}; PyDict_MergeFromSeq(dict, seq2, 1). +*/ +PyAPI_FUNC(int) PyDict_MergeFromSeq2(PyObject *d, + PyObject *seq2, + int override); + +PyAPI_FUNC(PyObject *) PyDict_GetItemString(PyObject *dp, const char *key); +PyAPI_FUNC(int) PyDict_SetItemString(PyObject *dp, const char *key, PyObject *item); +PyAPI_FUNC(int) PyDict_DelItemString(PyObject *dp, const char *key); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_DICTOBJECT_H */ diff --git a/android/python27/include/dtoa.h b/android/python27/include/dtoa.h new file mode 100644 index 000000000..9b434b77b --- /dev/null +++ b/android/python27/include/dtoa.h @@ -0,0 +1,15 @@ +#ifndef PY_NO_SHORT_FLOAT_REPR +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_FUNC(double) _Py_dg_strtod(const char *str, char **ptr); +PyAPI_FUNC(char *) _Py_dg_dtoa(double d, int mode, int ndigits, + int *decpt, int *sign, char **rve); +PyAPI_FUNC(void) _Py_dg_freedtoa(char *s); + + +#ifdef __cplusplus +} +#endif +#endif diff --git a/android/python27/include/enumobject.h b/android/python27/include/enumobject.h new file mode 100644 index 000000000..c14dbfc8c --- /dev/null +++ b/android/python27/include/enumobject.h @@ -0,0 +1,17 @@ +#ifndef Py_ENUMOBJECT_H +#define Py_ENUMOBJECT_H + +/* Enumerate Object */ + +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_DATA(PyTypeObject) PyEnum_Type; +PyAPI_DATA(PyTypeObject) PyReversed_Type; + +#ifdef __cplusplus +} +#endif + +#endif /* !Py_ENUMOBJECT_H */ diff --git a/android/python27/include/errcode.h b/android/python27/include/errcode.h new file mode 100644 index 000000000..becec80c8 --- /dev/null +++ b/android/python27/include/errcode.h @@ -0,0 +1,36 @@ +#ifndef Py_ERRCODE_H +#define Py_ERRCODE_H +#ifdef __cplusplus +extern "C" { +#endif + + +/* Error codes passed around between file input, tokenizer, parser and + interpreter. This is necessary so we can turn them into Python + exceptions at a higher level. Note that some errors have a + slightly different meaning when passed from the tokenizer to the + parser than when passed from the parser to the interpreter; e.g. + the parser only returns E_EOF when it hits EOF immediately, and it + never returns E_OK. */ + +#define E_OK 10 /* No error */ +#define E_EOF 11 /* End Of File */ +#define E_INTR 12 /* Interrupted */ +#define E_TOKEN 13 /* Bad token */ +#define E_SYNTAX 14 /* Syntax error */ +#define E_NOMEM 15 /* Ran out of memory */ +#define E_DONE 16 /* Parsing complete */ +#define E_ERROR 17 /* Execution error */ +#define E_TABSPACE 18 /* Inconsistent mixing of tabs and spaces */ +#define E_OVERFLOW 19 /* Node had too many children */ +#define E_TOODEEP 20 /* Too many indentation levels */ +#define E_DEDENT 21 /* No matching outer block for dedent */ +#define E_DECODE 22 /* Error in decoding into Unicode */ +#define E_EOFS 23 /* EOF in triple-quoted string */ +#define E_EOLS 24 /* EOL in single-quoted string */ +#define E_LINECONT 25 /* Unexpected characters after a line continuation */ + +#ifdef __cplusplus +} +#endif +#endif /* !Py_ERRCODE_H */ diff --git a/android/python27/include/eval.h b/android/python27/include/eval.h new file mode 100644 index 000000000..b78dfe0fa --- /dev/null +++ b/android/python27/include/eval.h @@ -0,0 +1,25 @@ + +/* Interface to execute compiled code */ + +#ifndef Py_EVAL_H +#define Py_EVAL_H +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_FUNC(PyObject *) PyEval_EvalCode(PyCodeObject *, PyObject *, PyObject *); + +PyAPI_FUNC(PyObject *) PyEval_EvalCodeEx(PyCodeObject *co, + PyObject *globals, + PyObject *locals, + PyObject **args, int argc, + PyObject **kwds, int kwdc, + PyObject **defs, int defc, + PyObject *closure); + +PyAPI_FUNC(PyObject *) _PyEval_CallTracing(PyObject *func, PyObject *args); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_EVAL_H */ diff --git a/android/python27/include/fileobject.h b/android/python27/include/fileobject.h new file mode 100644 index 000000000..1b540f902 --- /dev/null +++ b/android/python27/include/fileobject.h @@ -0,0 +1,97 @@ + +/* File object interface */ + +#ifndef Py_FILEOBJECT_H +#define Py_FILEOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + PyObject_HEAD + FILE *f_fp; + PyObject *f_name; + PyObject *f_mode; + int (*f_close)(FILE *); + int f_softspace; /* Flag used by 'print' command */ + int f_binary; /* Flag which indicates whether the file is + open in binary (1) or text (0) mode */ + char* f_buf; /* Allocated readahead buffer */ + char* f_bufend; /* Points after last occupied position */ + char* f_bufptr; /* Current buffer position */ + char *f_setbuf; /* Buffer for setbuf(3) and setvbuf(3) */ + int f_univ_newline; /* Handle any newline convention */ + int f_newlinetypes; /* Types of newlines seen */ + int f_skipnextlf; /* Skip next \n */ + PyObject *f_encoding; + PyObject *f_errors; + PyObject *weakreflist; /* List of weak references */ + int unlocked_count; /* Num. currently running sections of code + using f_fp with the GIL released. */ + int readable; + int writable; +} PyFileObject; + +PyAPI_DATA(PyTypeObject) PyFile_Type; + +#define PyFile_Check(op) PyObject_TypeCheck(op, &PyFile_Type) +#define PyFile_CheckExact(op) (Py_TYPE(op) == &PyFile_Type) + +PyAPI_FUNC(PyObject *) PyFile_FromString(char *, char *); +PyAPI_FUNC(void) PyFile_SetBufSize(PyObject *, int); +PyAPI_FUNC(int) PyFile_SetEncoding(PyObject *, const char *); +PyAPI_FUNC(int) PyFile_SetEncodingAndErrors(PyObject *, const char *, char *errors); +PyAPI_FUNC(PyObject *) PyFile_FromFile(FILE *, char *, char *, + int (*)(FILE *)); +PyAPI_FUNC(FILE *) PyFile_AsFile(PyObject *); +PyAPI_FUNC(void) PyFile_IncUseCount(PyFileObject *); +PyAPI_FUNC(void) PyFile_DecUseCount(PyFileObject *); +PyAPI_FUNC(PyObject *) PyFile_Name(PyObject *); +PyAPI_FUNC(PyObject *) PyFile_GetLine(PyObject *, int); +PyAPI_FUNC(int) PyFile_WriteObject(PyObject *, PyObject *, int); +PyAPI_FUNC(int) PyFile_SoftSpace(PyObject *, int); +PyAPI_FUNC(int) PyFile_WriteString(const char *, PyObject *); +PyAPI_FUNC(int) PyObject_AsFileDescriptor(PyObject *); + +/* The default encoding used by the platform file system APIs + If non-NULL, this is different than the default encoding for strings +*/ +PyAPI_DATA(const char *) Py_FileSystemDefaultEncoding; + +/* Routines to replace fread() and fgets() which accept any of \r, \n + or \r\n as line terminators. +*/ +#define PY_STDIOTEXTMODE "b" +char *Py_UniversalNewlineFgets(char *, int, FILE*, PyObject *); +size_t Py_UniversalNewlineFread(char *, size_t, FILE *, PyObject *); + +/* A routine to do sanity checking on the file mode string. returns + non-zero on if an exception occurred +*/ +int _PyFile_SanitizeMode(char *mode); + +#if defined _MSC_VER && _MSC_VER >= 1400 +/* A routine to check if a file descriptor is valid on Windows. Returns 0 + * and sets errno to EBADF if it isn't. This is to avoid Assertions + * from various functions in the Windows CRT beginning with + * Visual Studio 2005 + */ +int _PyVerify_fd(int fd); +#elif defined _MSC_VER && _MSC_VER >= 1200 +/* fdopen doesn't set errno EBADF and crashes for large fd on debug build */ +#define _PyVerify_fd(fd) (_get_osfhandle(fd) >= 0) +#else +#define _PyVerify_fd(A) (1) /* dummy */ +#endif + +/* A routine to check if a file descriptor can be select()-ed. */ +#ifdef HAVE_SELECT + #define _PyIsSelectable_fd(FD) (((FD) >= 0) && ((FD) < FD_SETSIZE)) +#else + #define _PyIsSelectable_fd(FD) (1) +#endif /* HAVE_SELECT */ + +#ifdef __cplusplus +} +#endif +#endif /* !Py_FILEOBJECT_H */ diff --git a/android/python27/include/floatobject.h b/android/python27/include/floatobject.h new file mode 100644 index 000000000..54e88256a --- /dev/null +++ b/android/python27/include/floatobject.h @@ -0,0 +1,140 @@ + +/* Float object interface */ + +/* +PyFloatObject represents a (double precision) floating point number. +*/ + +#ifndef Py_FLOATOBJECT_H +#define Py_FLOATOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + PyObject_HEAD + double ob_fval; +} PyFloatObject; + +PyAPI_DATA(PyTypeObject) PyFloat_Type; + +#define PyFloat_Check(op) PyObject_TypeCheck(op, &PyFloat_Type) +#define PyFloat_CheckExact(op) (Py_TYPE(op) == &PyFloat_Type) + +/* The str() precision PyFloat_STR_PRECISION is chosen so that in most cases, + the rounding noise created by various operations is suppressed, while + giving plenty of precision for practical use. */ + +#define PyFloat_STR_PRECISION 12 + +#ifdef Py_NAN +#define Py_RETURN_NAN return PyFloat_FromDouble(Py_NAN) +#endif + +#define Py_RETURN_INF(sign) do \ + if (copysign(1., sign) == 1.) { \ + return PyFloat_FromDouble(Py_HUGE_VAL); \ + } else { \ + return PyFloat_FromDouble(-Py_HUGE_VAL); \ + } while(0) + +PyAPI_FUNC(double) PyFloat_GetMax(void); +PyAPI_FUNC(double) PyFloat_GetMin(void); +PyAPI_FUNC(PyObject *) PyFloat_GetInfo(void); + +/* Return Python float from string PyObject. Second argument ignored on + input, and, if non-NULL, NULL is stored into *junk (this tried to serve a + purpose once but can't be made to work as intended). */ +PyAPI_FUNC(PyObject *) PyFloat_FromString(PyObject*, char** junk); + +/* Return Python float from C double. */ +PyAPI_FUNC(PyObject *) PyFloat_FromDouble(double); + +/* Extract C double from Python float. The macro version trades safety for + speed. */ +PyAPI_FUNC(double) PyFloat_AsDouble(PyObject *); +#define PyFloat_AS_DOUBLE(op) (((PyFloatObject *)(op))->ob_fval) + +/* Write repr(v) into the char buffer argument, followed by null byte. The + buffer must be "big enough"; >= 100 is very safe. + PyFloat_AsReprString(buf, x) strives to print enough digits so that + PyFloat_FromString(buf) then reproduces x exactly. */ +PyAPI_FUNC(void) PyFloat_AsReprString(char*, PyFloatObject *v); + +/* Write str(v) into the char buffer argument, followed by null byte. The + buffer must be "big enough"; >= 100 is very safe. Note that it's + unusual to be able to get back the float you started with from + PyFloat_AsString's result -- use PyFloat_AsReprString() if you want to + preserve precision across conversions. */ +PyAPI_FUNC(void) PyFloat_AsString(char*, PyFloatObject *v); + +/* _PyFloat_{Pack,Unpack}{4,8} + * + * The struct and pickle (at least) modules need an efficient platform- + * independent way to store floating-point values as byte strings. + * The Pack routines produce a string from a C double, and the Unpack + * routines produce a C double from such a string. The suffix (4 or 8) + * specifies the number of bytes in the string. + * + * On platforms that appear to use (see _PyFloat_Init()) IEEE-754 formats + * these functions work by copying bits. On other platforms, the formats the + * 4- byte format is identical to the IEEE-754 single precision format, and + * the 8-byte format to the IEEE-754 double precision format, although the + * packing of INFs and NaNs (if such things exist on the platform) isn't + * handled correctly, and attempting to unpack a string containing an IEEE + * INF or NaN will raise an exception. + * + * On non-IEEE platforms with more precision, or larger dynamic range, than + * 754 supports, not all values can be packed; on non-IEEE platforms with less + * precision, or smaller dynamic range, not all values can be unpacked. What + * happens in such cases is partly accidental (alas). + */ + +/* The pack routines write 4 or 8 bytes, starting at p. le is a bool + * argument, true if you want the string in little-endian format (exponent + * last, at p+3 or p+7), false if you want big-endian format (exponent + * first, at p). + * Return value: 0 if all is OK, -1 if error (and an exception is + * set, most likely OverflowError). + * There are two problems on non-IEEE platforms: + * 1): What this does is undefined if x is a NaN or infinity. + * 2): -0.0 and +0.0 produce the same string. + */ +PyAPI_FUNC(int) _PyFloat_Pack4(double x, unsigned char *p, int le); +PyAPI_FUNC(int) _PyFloat_Pack8(double x, unsigned char *p, int le); + +/* Used to get the important decimal digits of a double */ +PyAPI_FUNC(int) _PyFloat_Digits(char *buf, double v, int *signum); +PyAPI_FUNC(void) _PyFloat_DigitsInit(void); + +/* The unpack routines read 4 or 8 bytes, starting at p. le is a bool + * argument, true if the string is in little-endian format (exponent + * last, at p+3 or p+7), false if big-endian (exponent first, at p). + * Return value: The unpacked double. On error, this is -1.0 and + * PyErr_Occurred() is true (and an exception is set, most likely + * OverflowError). Note that on a non-IEEE platform this will refuse + * to unpack a string that represents a NaN or infinity. + */ +PyAPI_FUNC(double) _PyFloat_Unpack4(const unsigned char *p, int le); +PyAPI_FUNC(double) _PyFloat_Unpack8(const unsigned char *p, int le); + +/* free list api */ +PyAPI_FUNC(int) PyFloat_ClearFreeList(void); + +/* Format the object based on the format_spec, as defined in PEP 3101 + (Advanced String Formatting). */ +PyAPI_FUNC(PyObject *) _PyFloat_FormatAdvanced(PyObject *obj, + char *format_spec, + Py_ssize_t format_spec_len); + +/* Round a C double x to the closest multiple of 10**-ndigits. Returns a + Python float on success, or NULL (with an appropriate exception set) on + failure. Used in builtin_round in bltinmodule.c. */ +PyAPI_FUNC(PyObject *) _Py_double_round(double x, int ndigits); + + + +#ifdef __cplusplus +} +#endif +#endif /* !Py_FLOATOBJECT_H */ diff --git a/android/python27/include/frameobject.h b/android/python27/include/frameobject.h new file mode 100644 index 000000000..17e7679ac --- /dev/null +++ b/android/python27/include/frameobject.h @@ -0,0 +1,89 @@ + +/* Frame object interface */ + +#ifndef Py_FRAMEOBJECT_H +#define Py_FRAMEOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + int b_type; /* what kind of block this is */ + int b_handler; /* where to jump to find handler */ + int b_level; /* value stack level to pop to */ +} PyTryBlock; + +typedef struct _frame { + PyObject_VAR_HEAD + struct _frame *f_back; /* previous frame, or NULL */ + PyCodeObject *f_code; /* code segment */ + PyObject *f_builtins; /* builtin symbol table (PyDictObject) */ + PyObject *f_globals; /* global symbol table (PyDictObject) */ + PyObject *f_locals; /* local symbol table (any mapping) */ + PyObject **f_valuestack; /* points after the last local */ + /* Next free slot in f_valuestack. Frame creation sets to f_valuestack. + Frame evaluation usually NULLs it, but a frame that yields sets it + to the current stack top. */ + PyObject **f_stacktop; + PyObject *f_trace; /* Trace function */ + + /* If an exception is raised in this frame, the next three are used to + * record the exception info (if any) originally in the thread state. See + * comments before set_exc_info() -- it's not obvious. + * Invariant: if _type is NULL, then so are _value and _traceback. + * Desired invariant: all three are NULL, or all three are non-NULL. That + * one isn't currently true, but "should be". + */ + PyObject *f_exc_type, *f_exc_value, *f_exc_traceback; + + PyThreadState *f_tstate; + int f_lasti; /* Last instruction if called */ + /* Call PyFrame_GetLineNumber() instead of reading this field + directly. As of 2.3 f_lineno is only valid when tracing is + active (i.e. when f_trace is set). At other times we use + PyCode_Addr2Line to calculate the line from the current + bytecode index. */ + int f_lineno; /* Current line number */ + int f_iblock; /* index in f_blockstack */ + PyTryBlock f_blockstack[CO_MAXBLOCKS]; /* for try and loop blocks */ + PyObject *f_localsplus[1]; /* locals+stack, dynamically sized */ +} PyFrameObject; + + +/* Standard object interface */ + +PyAPI_DATA(PyTypeObject) PyFrame_Type; + +#define PyFrame_Check(op) ((op)->ob_type == &PyFrame_Type) +#define PyFrame_IsRestricted(f) \ + ((f)->f_builtins != (f)->f_tstate->interp->builtins) + +PyAPI_FUNC(PyFrameObject *) PyFrame_New(PyThreadState *, PyCodeObject *, + PyObject *, PyObject *); + + +/* The rest of the interface is specific for frame objects */ + +/* Block management functions */ + +PyAPI_FUNC(void) PyFrame_BlockSetup(PyFrameObject *, int, int, int); +PyAPI_FUNC(PyTryBlock *) PyFrame_BlockPop(PyFrameObject *); + +/* Extend the value stack */ + +PyAPI_FUNC(PyObject **) PyFrame_ExtendStack(PyFrameObject *, int, int); + +/* Conversions between "fast locals" and locals in dictionary */ + +PyAPI_FUNC(void) PyFrame_LocalsToFast(PyFrameObject *, int); +PyAPI_FUNC(void) PyFrame_FastToLocals(PyFrameObject *); + +PyAPI_FUNC(int) PyFrame_ClearFreeList(void); + +/* Return the line of code the frame is currently executing. */ +PyAPI_FUNC(int) PyFrame_GetLineNumber(PyFrameObject *); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_FRAMEOBJECT_H */ diff --git a/android/python27/include/funcobject.h b/android/python27/include/funcobject.h new file mode 100644 index 000000000..eb19f4c38 --- /dev/null +++ b/android/python27/include/funcobject.h @@ -0,0 +1,76 @@ + +/* Function object interface */ + +#ifndef Py_FUNCOBJECT_H +#define Py_FUNCOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +/* Function objects and code objects should not be confused with each other: + * + * Function objects are created by the execution of the 'def' statement. + * They reference a code object in their func_code attribute, which is a + * purely syntactic object, i.e. nothing more than a compiled version of some + * source code lines. There is one code object per source code "fragment", + * but each code object can be referenced by zero or many function objects + * depending only on how many times the 'def' statement in the source was + * executed so far. + */ + +typedef struct { + PyObject_HEAD + PyObject *func_code; /* A code object */ + PyObject *func_globals; /* A dictionary (other mappings won't do) */ + PyObject *func_defaults; /* NULL or a tuple */ + PyObject *func_closure; /* NULL or a tuple of cell objects */ + PyObject *func_doc; /* The __doc__ attribute, can be anything */ + PyObject *func_name; /* The __name__ attribute, a string object */ + PyObject *func_dict; /* The __dict__ attribute, a dict or NULL */ + PyObject *func_weakreflist; /* List of weak references */ + PyObject *func_module; /* The __module__ attribute, can be anything */ + + /* Invariant: + * func_closure contains the bindings for func_code->co_freevars, so + * PyTuple_Size(func_closure) == PyCode_GetNumFree(func_code) + * (func_closure may be NULL if PyCode_GetNumFree(func_code) == 0). + */ +} PyFunctionObject; + +PyAPI_DATA(PyTypeObject) PyFunction_Type; + +#define PyFunction_Check(op) (Py_TYPE(op) == &PyFunction_Type) + +PyAPI_FUNC(PyObject *) PyFunction_New(PyObject *, PyObject *); +PyAPI_FUNC(PyObject *) PyFunction_GetCode(PyObject *); +PyAPI_FUNC(PyObject *) PyFunction_GetGlobals(PyObject *); +PyAPI_FUNC(PyObject *) PyFunction_GetModule(PyObject *); +PyAPI_FUNC(PyObject *) PyFunction_GetDefaults(PyObject *); +PyAPI_FUNC(int) PyFunction_SetDefaults(PyObject *, PyObject *); +PyAPI_FUNC(PyObject *) PyFunction_GetClosure(PyObject *); +PyAPI_FUNC(int) PyFunction_SetClosure(PyObject *, PyObject *); + +/* Macros for direct access to these values. Type checks are *not* + done, so use with care. */ +#define PyFunction_GET_CODE(func) \ + (((PyFunctionObject *)func) -> func_code) +#define PyFunction_GET_GLOBALS(func) \ + (((PyFunctionObject *)func) -> func_globals) +#define PyFunction_GET_MODULE(func) \ + (((PyFunctionObject *)func) -> func_module) +#define PyFunction_GET_DEFAULTS(func) \ + (((PyFunctionObject *)func) -> func_defaults) +#define PyFunction_GET_CLOSURE(func) \ + (((PyFunctionObject *)func) -> func_closure) + +/* The classmethod and staticmethod types lives here, too */ +PyAPI_DATA(PyTypeObject) PyClassMethod_Type; +PyAPI_DATA(PyTypeObject) PyStaticMethod_Type; + +PyAPI_FUNC(PyObject *) PyClassMethod_New(PyObject *); +PyAPI_FUNC(PyObject *) PyStaticMethod_New(PyObject *); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_FUNCOBJECT_H */ diff --git a/android/python27/include/genobject.h b/android/python27/include/genobject.h new file mode 100644 index 000000000..135561b70 --- /dev/null +++ b/android/python27/include/genobject.h @@ -0,0 +1,40 @@ + +/* Generator object interface */ + +#ifndef Py_GENOBJECT_H +#define Py_GENOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +struct _frame; /* Avoid including frameobject.h */ + +typedef struct { + PyObject_HEAD + /* The gi_ prefix is intended to remind of generator-iterator. */ + + /* Note: gi_frame can be NULL if the generator is "finished" */ + struct _frame *gi_frame; + + /* True if generator is being executed. */ + int gi_running; + + /* The code object backing the generator */ + PyObject *gi_code; + + /* List of weak reference. */ + PyObject *gi_weakreflist; +} PyGenObject; + +PyAPI_DATA(PyTypeObject) PyGen_Type; + +#define PyGen_Check(op) PyObject_TypeCheck(op, &PyGen_Type) +#define PyGen_CheckExact(op) (Py_TYPE(op) == &PyGen_Type) + +PyAPI_FUNC(PyObject *) PyGen_New(struct _frame *); +PyAPI_FUNC(int) PyGen_NeedsFinalizing(PyGenObject *); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_GENOBJECT_H */ diff --git a/android/python27/include/graminit.h b/android/python27/include/graminit.h new file mode 100644 index 000000000..40d531e8a --- /dev/null +++ b/android/python27/include/graminit.h @@ -0,0 +1,87 @@ +/* Generated by Parser/pgen */ + +#define single_input 256 +#define file_input 257 +#define eval_input 258 +#define decorator 259 +#define decorators 260 +#define decorated 261 +#define funcdef 262 +#define parameters 263 +#define varargslist 264 +#define fpdef 265 +#define fplist 266 +#define stmt 267 +#define simple_stmt 268 +#define small_stmt 269 +#define expr_stmt 270 +#define augassign 271 +#define print_stmt 272 +#define del_stmt 273 +#define pass_stmt 274 +#define flow_stmt 275 +#define break_stmt 276 +#define continue_stmt 277 +#define return_stmt 278 +#define yield_stmt 279 +#define raise_stmt 280 +#define import_stmt 281 +#define import_name 282 +#define import_from 283 +#define import_as_name 284 +#define dotted_as_name 285 +#define import_as_names 286 +#define dotted_as_names 287 +#define dotted_name 288 +#define global_stmt 289 +#define exec_stmt 290 +#define assert_stmt 291 +#define compound_stmt 292 +#define if_stmt 293 +#define while_stmt 294 +#define for_stmt 295 +#define try_stmt 296 +#define with_stmt 297 +#define with_item 298 +#define except_clause 299 +#define suite 300 +#define testlist_safe 301 +#define old_test 302 +#define old_lambdef 303 +#define test 304 +#define or_test 305 +#define and_test 306 +#define not_test 307 +#define comparison 308 +#define comp_op 309 +#define expr 310 +#define xor_expr 311 +#define and_expr 312 +#define shift_expr 313 +#define arith_expr 314 +#define term 315 +#define factor 316 +#define power 317 +#define atom 318 +#define listmaker 319 +#define testlist_comp 320 +#define lambdef 321 +#define trailer 322 +#define subscriptlist 323 +#define subscript 324 +#define sliceop 325 +#define exprlist 326 +#define testlist 327 +#define dictorsetmaker 328 +#define classdef 329 +#define arglist 330 +#define argument 331 +#define list_iter 332 +#define list_for 333 +#define list_if 334 +#define comp_iter 335 +#define comp_for 336 +#define comp_if 337 +#define testlist1 338 +#define encoding_decl 339 +#define yield_expr 340 diff --git a/android/python27/include/grammar.h b/android/python27/include/grammar.h new file mode 100644 index 000000000..8426da30d --- /dev/null +++ b/android/python27/include/grammar.h @@ -0,0 +1,93 @@ + +/* Grammar interface */ + +#ifndef Py_GRAMMAR_H +#define Py_GRAMMAR_H +#ifdef __cplusplus +extern "C" { +#endif + +#include "bitset.h" /* Sigh... */ + +/* A label of an arc */ + +typedef struct { + int lb_type; + char *lb_str; +} label; + +#define EMPTY 0 /* Label number 0 is by definition the empty label */ + +/* A list of labels */ + +typedef struct { + int ll_nlabels; + label *ll_label; +} labellist; + +/* An arc from one state to another */ + +typedef struct { + short a_lbl; /* Label of this arc */ + short a_arrow; /* State where this arc goes to */ +} arc; + +/* A state in a DFA */ + +typedef struct { + int s_narcs; + arc *s_arc; /* Array of arcs */ + + /* Optional accelerators */ + int s_lower; /* Lowest label index */ + int s_upper; /* Highest label index */ + int *s_accel; /* Accelerator */ + int s_accept; /* Nonzero for accepting state */ +} state; + +/* A DFA */ + +typedef struct { + int d_type; /* Non-terminal this represents */ + char *d_name; /* For printing */ + int d_initial; /* Initial state */ + int d_nstates; + state *d_state; /* Array of states */ + bitset d_first; +} dfa; + +/* A grammar */ + +typedef struct { + int g_ndfas; + dfa *g_dfa; /* Array of DFAs */ + labellist g_ll; + int g_start; /* Start symbol of the grammar */ + int g_accel; /* Set if accelerators present */ +} grammar; + +/* FUNCTIONS */ + +grammar *newgrammar(int start); +dfa *adddfa(grammar *g, int type, char *name); +int addstate(dfa *d); +void addarc(dfa *d, int from, int to, int lbl); +dfa *PyGrammar_FindDFA(grammar *g, int type); + +int addlabel(labellist *ll, int type, char *str); +int findlabel(labellist *ll, int type, char *str); +char *PyGrammar_LabelRepr(label *lb); +void translatelabels(grammar *g); + +void addfirstsets(grammar *g); + +void PyGrammar_AddAccelerators(grammar *g); +void PyGrammar_RemoveAccelerators(grammar *); + +void printgrammar(grammar *g, FILE *fp); +void printnonterminals(grammar *g, FILE *fp); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_GRAMMAR_H */ diff --git a/android/python27/include/import.h b/android/python27/include/import.h new file mode 100644 index 000000000..89f51b55d --- /dev/null +++ b/android/python27/include/import.h @@ -0,0 +1,71 @@ + +/* Module definition and import interface */ + +#ifndef Py_IMPORT_H +#define Py_IMPORT_H +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_FUNC(long) PyImport_GetMagicNumber(void); +PyAPI_FUNC(PyObject *) PyImport_ExecCodeModule(char *name, PyObject *co); +PyAPI_FUNC(PyObject *) PyImport_ExecCodeModuleEx( + char *name, PyObject *co, char *pathname); +PyAPI_FUNC(PyObject *) PyImport_GetModuleDict(void); +PyAPI_FUNC(PyObject *) PyImport_AddModule(const char *name); +PyAPI_FUNC(PyObject *) PyImport_ImportModule(const char *name); +PyAPI_FUNC(PyObject *) PyImport_ImportModuleNoBlock(const char *); +PyAPI_FUNC(PyObject *) PyImport_ImportModuleLevel(char *name, + PyObject *globals, PyObject *locals, PyObject *fromlist, int level); + +#define PyImport_ImportModuleEx(n, g, l, f) \ + PyImport_ImportModuleLevel(n, g, l, f, -1) + +PyAPI_FUNC(PyObject *) PyImport_GetImporter(PyObject *path); +PyAPI_FUNC(PyObject *) PyImport_Import(PyObject *name); +PyAPI_FUNC(PyObject *) PyImport_ReloadModule(PyObject *m); +PyAPI_FUNC(void) PyImport_Cleanup(void); +PyAPI_FUNC(int) PyImport_ImportFrozenModule(char *); + +#ifdef WITH_THREAD +PyAPI_FUNC(void) _PyImport_AcquireLock(void); +PyAPI_FUNC(int) _PyImport_ReleaseLock(void); +#else +#define _PyImport_AcquireLock() +#define _PyImport_ReleaseLock() 1 +#endif + +PyAPI_FUNC(struct filedescr *) _PyImport_FindModule( + const char *, PyObject *, char *, size_t, FILE **, PyObject **); +PyAPI_FUNC(int) _PyImport_IsScript(struct filedescr *); +PyAPI_FUNC(void) _PyImport_ReInitLock(void); + +PyAPI_FUNC(PyObject *) _PyImport_FindExtension(char *, char *); +PyAPI_FUNC(PyObject *) _PyImport_FixupExtension(char *, char *); + +struct _inittab { + char *name; + void (*initfunc)(void); +}; + +PyAPI_DATA(PyTypeObject) PyNullImporter_Type; +PyAPI_DATA(struct _inittab *) PyImport_Inittab; + +PyAPI_FUNC(int) PyImport_AppendInittab(const char *name, void (*initfunc)(void)); +PyAPI_FUNC(int) PyImport_ExtendInittab(struct _inittab *newtab); + +struct _frozen { + char *name; + unsigned char *code; + int size; +}; + +/* Embedding apps may change this pointer to point to their favorite + collection of frozen modules: */ + +PyAPI_DATA(struct _frozen *) PyImport_FrozenModules; + +#ifdef __cplusplus +} +#endif +#endif /* !Py_IMPORT_H */ diff --git a/android/python27/include/intobject.h b/android/python27/include/intobject.h new file mode 100644 index 000000000..252eea9fd --- /dev/null +++ b/android/python27/include/intobject.h @@ -0,0 +1,81 @@ + +/* Integer object interface */ + +/* +PyIntObject represents a (long) integer. This is an immutable object; +an integer cannot change its value after creation. + +There are functions to create new integer objects, to test an object +for integer-ness, and to get the integer value. The latter functions +returns -1 and sets errno to EBADF if the object is not an PyIntObject. +None of the functions should be applied to nil objects. + +The type PyIntObject is (unfortunately) exposed here so we can declare +_Py_TrueStruct and _Py_ZeroStruct in boolobject.h; don't use this. +*/ + +#ifndef Py_INTOBJECT_H +#define Py_INTOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + PyObject_HEAD + long ob_ival; +} PyIntObject; + +PyAPI_DATA(PyTypeObject) PyInt_Type; + +#define PyInt_Check(op) \ + PyType_FastSubclass((op)->ob_type, Py_TPFLAGS_INT_SUBCLASS) +#define PyInt_CheckExact(op) ((op)->ob_type == &PyInt_Type) + +PyAPI_FUNC(PyObject *) PyInt_FromString(char*, char**, int); +#ifdef Py_USING_UNICODE +PyAPI_FUNC(PyObject *) PyInt_FromUnicode(Py_UNICODE*, Py_ssize_t, int); +#endif +PyAPI_FUNC(PyObject *) PyInt_FromLong(long); +PyAPI_FUNC(PyObject *) PyInt_FromSize_t(size_t); +PyAPI_FUNC(PyObject *) PyInt_FromSsize_t(Py_ssize_t); +PyAPI_FUNC(long) PyInt_AsLong(PyObject *); +PyAPI_FUNC(Py_ssize_t) PyInt_AsSsize_t(PyObject *); +PyAPI_FUNC(int) _PyInt_AsInt(PyObject *); +PyAPI_FUNC(unsigned long) PyInt_AsUnsignedLongMask(PyObject *); +#ifdef HAVE_LONG_LONG +PyAPI_FUNC(unsigned PY_LONG_LONG) PyInt_AsUnsignedLongLongMask(PyObject *); +#endif + +PyAPI_FUNC(long) PyInt_GetMax(void); + +/* Macro, trading safety for speed */ +#define PyInt_AS_LONG(op) (((PyIntObject *)(op))->ob_ival) + +/* These aren't really part of the Int object, but they're handy; the protos + * are necessary for systems that need the magic of PyAPI_FUNC and that want + * to have stropmodule as a dynamically loaded module instead of building it + * into the main Python shared library/DLL. Guido thinks I'm weird for + * building it this way. :-) [cjh] + */ +PyAPI_FUNC(unsigned long) PyOS_strtoul(char *, char **, int); +PyAPI_FUNC(long) PyOS_strtol(char *, char **, int); + +/* free list api */ +PyAPI_FUNC(int) PyInt_ClearFreeList(void); + +/* Convert an integer to the given base. Returns a string. + If base is 2, 8 or 16, add the proper prefix '0b', '0o' or '0x'. + If newstyle is zero, then use the pre-2.6 behavior of octal having + a leading "0" */ +PyAPI_FUNC(PyObject*) _PyInt_Format(PyIntObject* v, int base, int newstyle); + +/* Format the object based on the format_spec, as defined in PEP 3101 + (Advanced String Formatting). */ +PyAPI_FUNC(PyObject *) _PyInt_FormatAdvanced(PyObject *obj, + char *format_spec, + Py_ssize_t format_spec_len); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTOBJECT_H */ diff --git a/android/python27/include/intrcheck.h b/android/python27/include/intrcheck.h new file mode 100644 index 000000000..3b67ed0d5 --- /dev/null +++ b/android/python27/include/intrcheck.h @@ -0,0 +1,15 @@ + +#ifndef Py_INTRCHECK_H +#define Py_INTRCHECK_H +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_FUNC(int) PyOS_InterruptOccurred(void); +PyAPI_FUNC(void) PyOS_InitInterrupts(void); +PyAPI_FUNC(void) PyOS_AfterFork(void); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTRCHECK_H */ diff --git a/android/python27/include/iterobject.h b/android/python27/include/iterobject.h new file mode 100644 index 000000000..4bd19c290 --- /dev/null +++ b/android/python27/include/iterobject.h @@ -0,0 +1,23 @@ +#ifndef Py_ITEROBJECT_H +#define Py_ITEROBJECT_H +/* Iterators (the basic kind, over a sequence) */ +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_DATA(PyTypeObject) PySeqIter_Type; + +#define PySeqIter_Check(op) (Py_TYPE(op) == &PySeqIter_Type) + +PyAPI_FUNC(PyObject *) PySeqIter_New(PyObject *); + +PyAPI_DATA(PyTypeObject) PyCallIter_Type; + +#define PyCallIter_Check(op) (Py_TYPE(op) == &PyCallIter_Type) + +PyAPI_FUNC(PyObject *) PyCallIter_New(PyObject *, PyObject *); +#ifdef __cplusplus +} +#endif +#endif /* !Py_ITEROBJECT_H */ + diff --git a/android/python27/include/listobject.h b/android/python27/include/listobject.h new file mode 100644 index 000000000..7cd616ba0 --- /dev/null +++ b/android/python27/include/listobject.h @@ -0,0 +1,68 @@ + +/* List object interface */ + +/* +Another generally useful object type is an list of object pointers. +This is a mutable type: the list items can be changed, and items can be +added or removed. Out-of-range indices or non-list objects are ignored. + +*** WARNING *** PyList_SetItem does not increment the new item's reference +count, but does decrement the reference count of the item it replaces, +if not nil. It does *decrement* the reference count if it is *not* +inserted in the list. Similarly, PyList_GetItem does not increment the +returned item's reference count. +*/ + +#ifndef Py_LISTOBJECT_H +#define Py_LISTOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + PyObject_VAR_HEAD + /* Vector of pointers to list elements. list[0] is ob_item[0], etc. */ + PyObject **ob_item; + + /* ob_item contains space for 'allocated' elements. The number + * currently in use is ob_size. + * Invariants: + * 0 <= ob_size <= allocated + * len(list) == ob_size + * ob_item == NULL implies ob_size == allocated == 0 + * list.sort() temporarily sets allocated to -1 to detect mutations. + * + * Items must normally not be NULL, except during construction when + * the list is not yet visible outside the function that builds it. + */ + Py_ssize_t allocated; +} PyListObject; + +PyAPI_DATA(PyTypeObject) PyList_Type; + +#define PyList_Check(op) \ + PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_LIST_SUBCLASS) +#define PyList_CheckExact(op) (Py_TYPE(op) == &PyList_Type) + +PyAPI_FUNC(PyObject *) PyList_New(Py_ssize_t size); +PyAPI_FUNC(Py_ssize_t) PyList_Size(PyObject *); +PyAPI_FUNC(PyObject *) PyList_GetItem(PyObject *, Py_ssize_t); +PyAPI_FUNC(int) PyList_SetItem(PyObject *, Py_ssize_t, PyObject *); +PyAPI_FUNC(int) PyList_Insert(PyObject *, Py_ssize_t, PyObject *); +PyAPI_FUNC(int) PyList_Append(PyObject *, PyObject *); +PyAPI_FUNC(PyObject *) PyList_GetSlice(PyObject *, Py_ssize_t, Py_ssize_t); +PyAPI_FUNC(int) PyList_SetSlice(PyObject *, Py_ssize_t, Py_ssize_t, PyObject *); +PyAPI_FUNC(int) PyList_Sort(PyObject *); +PyAPI_FUNC(int) PyList_Reverse(PyObject *); +PyAPI_FUNC(PyObject *) PyList_AsTuple(PyObject *); +PyAPI_FUNC(PyObject *) _PyList_Extend(PyListObject *, PyObject *); + +/* Macro, trading safety for speed */ +#define PyList_GET_ITEM(op, i) (((PyListObject *)(op))->ob_item[i]) +#define PyList_SET_ITEM(op, i, v) (((PyListObject *)(op))->ob_item[i] = (v)) +#define PyList_GET_SIZE(op) Py_SIZE(op) + +#ifdef __cplusplus +} +#endif +#endif /* !Py_LISTOBJECT_H */ diff --git a/android/python27/include/longintrepr.h b/android/python27/include/longintrepr.h new file mode 100644 index 000000000..6425c30f3 --- /dev/null +++ b/android/python27/include/longintrepr.h @@ -0,0 +1,103 @@ +#ifndef Py_LONGINTREPR_H +#define Py_LONGINTREPR_H +#ifdef __cplusplus +extern "C" { +#endif + + +/* This is published for the benefit of "friend" marshal.c only. */ + +/* Parameters of the long integer representation. There are two different + sets of parameters: one set for 30-bit digits, stored in an unsigned 32-bit + integer type, and one set for 15-bit digits with each digit stored in an + unsigned short. The value of PYLONG_BITS_IN_DIGIT, defined either at + configure time or in pyport.h, is used to decide which digit size to use. + + Type 'digit' should be able to hold 2*PyLong_BASE-1, and type 'twodigits' + should be an unsigned integer type able to hold all integers up to + PyLong_BASE*PyLong_BASE-1. x_sub assumes that 'digit' is an unsigned type, + and that overflow is handled by taking the result modulo 2**N for some N > + PyLong_SHIFT. The majority of the code doesn't care about the precise + value of PyLong_SHIFT, but there are some notable exceptions: + + - long_pow() requires that PyLong_SHIFT be divisible by 5 + + - PyLong_{As,From}ByteArray require that PyLong_SHIFT be at least 8 + + - long_hash() requires that PyLong_SHIFT is *strictly* less than the number + of bits in an unsigned long, as do the PyLong <-> long (or unsigned long) + conversion functions + + - the long <-> size_t/Py_ssize_t conversion functions expect that + PyLong_SHIFT is strictly less than the number of bits in a size_t + + - the marshal code currently expects that PyLong_SHIFT is a multiple of 15 + + The values 15 and 30 should fit all of the above requirements, on any + platform. +*/ + +#if PYLONG_BITS_IN_DIGIT == 30 +#if !(defined HAVE_UINT64_T && defined HAVE_UINT32_T && \ + defined HAVE_INT64_T && defined HAVE_INT32_T) +#error "30-bit long digits requested, but the necessary types are not available on this platform" +#endif +typedef PY_UINT32_T digit; +typedef PY_INT32_T sdigit; /* signed variant of digit */ +typedef PY_UINT64_T twodigits; +typedef PY_INT64_T stwodigits; /* signed variant of twodigits */ +#define PyLong_SHIFT 30 +#define _PyLong_DECIMAL_SHIFT 9 /* max(e such that 10**e fits in a digit) */ +#define _PyLong_DECIMAL_BASE ((digit)1000000000) /* 10 ** DECIMAL_SHIFT */ +#elif PYLONG_BITS_IN_DIGIT == 15 +typedef unsigned short digit; +typedef short sdigit; /* signed variant of digit */ +typedef unsigned long twodigits; +typedef long stwodigits; /* signed variant of twodigits */ +#define PyLong_SHIFT 15 +#define _PyLong_DECIMAL_SHIFT 4 /* max(e such that 10**e fits in a digit) */ +#define _PyLong_DECIMAL_BASE ((digit)10000) /* 10 ** DECIMAL_SHIFT */ +#else +#error "PYLONG_BITS_IN_DIGIT should be 15 or 30" +#endif +#define PyLong_BASE ((digit)1 << PyLong_SHIFT) +#define PyLong_MASK ((digit)(PyLong_BASE - 1)) + +/* b/w compatibility with Python 2.5 */ +#define SHIFT PyLong_SHIFT +#define BASE PyLong_BASE +#define MASK PyLong_MASK + +#if PyLong_SHIFT % 5 != 0 +#error "longobject.c requires that PyLong_SHIFT be divisible by 5" +#endif + +/* Long integer representation. + The absolute value of a number is equal to + SUM(for i=0 through abs(ob_size)-1) ob_digit[i] * 2**(SHIFT*i) + Negative numbers are represented with ob_size < 0; + zero is represented by ob_size == 0. + In a normalized number, ob_digit[abs(ob_size)-1] (the most significant + digit) is never zero. Also, in all cases, for all valid i, + 0 <= ob_digit[i] <= MASK. + The allocation function takes care of allocating extra memory + so that ob_digit[0] ... ob_digit[abs(ob_size)-1] are actually available. + + CAUTION: Generic code manipulating subtypes of PyVarObject has to + aware that longs abuse ob_size's sign bit. +*/ + +struct _longobject { + PyObject_VAR_HEAD + digit ob_digit[1]; +}; + +PyAPI_FUNC(PyLongObject *) _PyLong_New(Py_ssize_t); + +/* Return a copy of src. */ +PyAPI_FUNC(PyObject *) _PyLong_Copy(PyLongObject *src); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_LONGINTREPR_H */ diff --git a/android/python27/include/longobject.h b/android/python27/include/longobject.h new file mode 100644 index 000000000..8be2345a4 --- /dev/null +++ b/android/python27/include/longobject.h @@ -0,0 +1,135 @@ +#ifndef Py_LONGOBJECT_H +#define Py_LONGOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + + +/* Long (arbitrary precision) integer object interface */ + +typedef struct _longobject PyLongObject; /* Revealed in longintrepr.h */ + +PyAPI_DATA(PyTypeObject) PyLong_Type; + +#define PyLong_Check(op) \ + PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_LONG_SUBCLASS) +#define PyLong_CheckExact(op) (Py_TYPE(op) == &PyLong_Type) + +PyAPI_FUNC(PyObject *) PyLong_FromLong(long); +PyAPI_FUNC(PyObject *) PyLong_FromUnsignedLong(unsigned long); +PyAPI_FUNC(PyObject *) PyLong_FromDouble(double); +PyAPI_FUNC(PyObject *) PyLong_FromSize_t(size_t); +PyAPI_FUNC(PyObject *) PyLong_FromSsize_t(Py_ssize_t); +PyAPI_FUNC(long) PyLong_AsLong(PyObject *); +PyAPI_FUNC(long) PyLong_AsLongAndOverflow(PyObject *, int *); +PyAPI_FUNC(unsigned long) PyLong_AsUnsignedLong(PyObject *); +PyAPI_FUNC(unsigned long) PyLong_AsUnsignedLongMask(PyObject *); +PyAPI_FUNC(Py_ssize_t) PyLong_AsSsize_t(PyObject *); +PyAPI_FUNC(int) _PyLong_AsInt(PyObject *); +PyAPI_FUNC(PyObject *) PyLong_GetInfo(void); + +/* For use by intobject.c only */ +#define _PyLong_AsSsize_t PyLong_AsSsize_t +#define _PyLong_FromSize_t PyLong_FromSize_t +#define _PyLong_FromSsize_t PyLong_FromSsize_t +PyAPI_DATA(int) _PyLong_DigitValue[256]; + +/* _PyLong_Frexp returns a double x and an exponent e such that the + true value is approximately equal to x * 2**e. e is >= 0. x is + 0.0 if and only if the input is 0 (in which case, e and x are both + zeroes); otherwise, 0.5 <= abs(x) < 1.0. On overflow, which is + possible if the number of bits doesn't fit into a Py_ssize_t, sets + OverflowError and returns -1.0 for x, 0 for e. */ +PyAPI_FUNC(double) _PyLong_Frexp(PyLongObject *a, Py_ssize_t *e); + +PyAPI_FUNC(double) PyLong_AsDouble(PyObject *); +PyAPI_FUNC(PyObject *) PyLong_FromVoidPtr(void *); +PyAPI_FUNC(void *) PyLong_AsVoidPtr(PyObject *); + +#ifdef HAVE_LONG_LONG +PyAPI_FUNC(PyObject *) PyLong_FromLongLong(PY_LONG_LONG); +PyAPI_FUNC(PyObject *) PyLong_FromUnsignedLongLong(unsigned PY_LONG_LONG); +PyAPI_FUNC(PY_LONG_LONG) PyLong_AsLongLong(PyObject *); +PyAPI_FUNC(unsigned PY_LONG_LONG) PyLong_AsUnsignedLongLong(PyObject *); +PyAPI_FUNC(unsigned PY_LONG_LONG) PyLong_AsUnsignedLongLongMask(PyObject *); +PyAPI_FUNC(PY_LONG_LONG) PyLong_AsLongLongAndOverflow(PyObject *, int *); +#endif /* HAVE_LONG_LONG */ + +PyAPI_FUNC(PyObject *) PyLong_FromString(char *, char **, int); +#ifdef Py_USING_UNICODE +PyAPI_FUNC(PyObject *) PyLong_FromUnicode(Py_UNICODE*, Py_ssize_t, int); +#endif + +/* _PyLong_Sign. Return 0 if v is 0, -1 if v < 0, +1 if v > 0. + v must not be NULL, and must be a normalized long. + There are no error cases. +*/ +PyAPI_FUNC(int) _PyLong_Sign(PyObject *v); + + +/* _PyLong_NumBits. Return the number of bits needed to represent the + absolute value of a long. For example, this returns 1 for 1 and -1, 2 + for 2 and -2, and 2 for 3 and -3. It returns 0 for 0. + v must not be NULL, and must be a normalized long. + (size_t)-1 is returned and OverflowError set if the true result doesn't + fit in a size_t. +*/ +PyAPI_FUNC(size_t) _PyLong_NumBits(PyObject *v); + +/* _PyLong_FromByteArray: View the n unsigned bytes as a binary integer in + base 256, and return a Python long with the same numeric value. + If n is 0, the integer is 0. Else: + If little_endian is 1/true, bytes[n-1] is the MSB and bytes[0] the LSB; + else (little_endian is 0/false) bytes[0] is the MSB and bytes[n-1] the + LSB. + If is_signed is 0/false, view the bytes as a non-negative integer. + If is_signed is 1/true, view the bytes as a 2's-complement integer, + non-negative if bit 0x80 of the MSB is clear, negative if set. + Error returns: + + Return NULL with the appropriate exception set if there's not + enough memory to create the Python long. +*/ +PyAPI_FUNC(PyObject *) _PyLong_FromByteArray( + const unsigned char* bytes, size_t n, + int little_endian, int is_signed); + +/* _PyLong_AsByteArray: Convert the least-significant 8*n bits of long + v to a base-256 integer, stored in array bytes. Normally return 0, + return -1 on error. + If little_endian is 1/true, store the MSB at bytes[n-1] and the LSB at + bytes[0]; else (little_endian is 0/false) store the MSB at bytes[0] and + the LSB at bytes[n-1]. + If is_signed is 0/false, it's an error if v < 0; else (v >= 0) n bytes + are filled and there's nothing special about bit 0x80 of the MSB. + If is_signed is 1/true, bytes is filled with the 2's-complement + representation of v's value. Bit 0x80 of the MSB is the sign bit. + Error returns (-1): + + is_signed is 0 and v < 0. TypeError is set in this case, and bytes + isn't altered. + + n isn't big enough to hold the full mathematical value of v. For + example, if is_signed is 0 and there are more digits in the v than + fit in n; or if is_signed is 1, v < 0, and n is just 1 bit shy of + being large enough to hold a sign bit. OverflowError is set in this + case, but bytes holds the least-signficant n bytes of the true value. +*/ +PyAPI_FUNC(int) _PyLong_AsByteArray(PyLongObject* v, + unsigned char* bytes, size_t n, + int little_endian, int is_signed); + +/* _PyLong_Format: Convert the long to a string object with given base, + appending a base prefix of 0[box] if base is 2, 8 or 16. + Add a trailing "L" if addL is non-zero. + If newstyle is zero, then use the pre-2.6 behavior of octal having + a leading "0", instead of the prefix "0o" */ +PyAPI_FUNC(PyObject *) _PyLong_Format(PyObject *aa, int base, int addL, int newstyle); + +/* Format the object based on the format_spec, as defined in PEP 3101 + (Advanced String Formatting). */ +PyAPI_FUNC(PyObject *) _PyLong_FormatAdvanced(PyObject *obj, + char *format_spec, + Py_ssize_t format_spec_len); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_LONGOBJECT_H */ diff --git a/android/python27/include/marshal.h b/android/python27/include/marshal.h new file mode 100644 index 000000000..411fdca36 --- /dev/null +++ b/android/python27/include/marshal.h @@ -0,0 +1,25 @@ + +/* Interface for marshal.c */ + +#ifndef Py_MARSHAL_H +#define Py_MARSHAL_H +#ifdef __cplusplus +extern "C" { +#endif + +#define Py_MARSHAL_VERSION 2 + +PyAPI_FUNC(void) PyMarshal_WriteLongToFile(long, FILE *, int); +PyAPI_FUNC(void) PyMarshal_WriteObjectToFile(PyObject *, FILE *, int); +PyAPI_FUNC(PyObject *) PyMarshal_WriteObjectToString(PyObject *, int); + +PyAPI_FUNC(long) PyMarshal_ReadLongFromFile(FILE *); +PyAPI_FUNC(int) PyMarshal_ReadShortFromFile(FILE *); +PyAPI_FUNC(PyObject *) PyMarshal_ReadObjectFromFile(FILE *); +PyAPI_FUNC(PyObject *) PyMarshal_ReadLastObjectFromFile(FILE *); +PyAPI_FUNC(PyObject *) PyMarshal_ReadObjectFromString(char *, Py_ssize_t); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_MARSHAL_H */ diff --git a/android/python27/include/memoryobject.h b/android/python27/include/memoryobject.h new file mode 100644 index 000000000..bf0b621ab --- /dev/null +++ b/android/python27/include/memoryobject.h @@ -0,0 +1,74 @@ +/* Memory view object. In Python this is available as "memoryview". */ + +#ifndef Py_MEMORYOBJECT_H +#define Py_MEMORYOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_DATA(PyTypeObject) PyMemoryView_Type; + +#define PyMemoryView_Check(op) (Py_TYPE(op) == &PyMemoryView_Type) + +/* Get a pointer to the underlying Py_buffer of a memoryview object. */ +#define PyMemoryView_GET_BUFFER(op) (&((PyMemoryViewObject *)(op))->view) +/* Get a pointer to the PyObject from which originates a memoryview object. */ +#define PyMemoryView_GET_BASE(op) (((PyMemoryViewObject *)(op))->view.obj) + + +PyAPI_FUNC(PyObject *) PyMemoryView_GetContiguous(PyObject *base, + int buffertype, + char fort); + + /* Return a contiguous chunk of memory representing the buffer + from an object in a memory view object. If a copy is made then the + base object for the memory view will be a *new* bytes object. + + Otherwise, the base-object will be the object itself and no + data-copying will be done. + + The buffertype argument can be PyBUF_READ, PyBUF_WRITE, + PyBUF_SHADOW to determine whether the returned buffer + should be READONLY, WRITABLE, or set to update the + original buffer if a copy must be made. If buffertype is + PyBUF_WRITE and the buffer is not contiguous an error will + be raised. In this circumstance, the user can use + PyBUF_SHADOW to ensure that a a writable temporary + contiguous buffer is returned. The contents of this + contiguous buffer will be copied back into the original + object after the memoryview object is deleted as long as + the original object is writable and allows setting an + exclusive write lock. If this is not allowed by the + original object, then a BufferError is raised. + + If the object is multi-dimensional and if fortran is 'F', + the first dimension of the underlying array will vary the + fastest in the buffer. If fortran is 'C', then the last + dimension will vary the fastest (C-style contiguous). If + fortran is 'A', then it does not matter and you will get + whatever the object decides is more efficient. + + A new reference is returned that must be DECREF'd when finished. + */ + +PyAPI_FUNC(PyObject *) PyMemoryView_FromObject(PyObject *base); + +PyAPI_FUNC(PyObject *) PyMemoryView_FromBuffer(Py_buffer *info); + /* create new if bufptr is NULL + will be a new bytesobject in base */ + + +/* The struct is declared here so that macros can work, but it shouldn't + be considered public. Don't access those fields directly, use the macros + and functions instead! */ +typedef struct { + PyObject_HEAD + PyObject *base; + Py_buffer view; +} PyMemoryViewObject; + + +#ifdef __cplusplus +} +#endif +#endif /* !Py_MEMORYOBJECT_H */ diff --git a/android/python27/include/metagrammar.h b/android/python27/include/metagrammar.h new file mode 100644 index 000000000..15c8ef8f3 --- /dev/null +++ b/android/python27/include/metagrammar.h @@ -0,0 +1,18 @@ +#ifndef Py_METAGRAMMAR_H +#define Py_METAGRAMMAR_H +#ifdef __cplusplus +extern "C" { +#endif + + +#define MSTART 256 +#define RULE 257 +#define RHS 258 +#define ALT 259 +#define ITEM 260 +#define ATOM 261 + +#ifdef __cplusplus +} +#endif +#endif /* !Py_METAGRAMMAR_H */ diff --git a/android/python27/include/methodobject.h b/android/python27/include/methodobject.h new file mode 100644 index 000000000..6e160b639 --- /dev/null +++ b/android/python27/include/methodobject.h @@ -0,0 +1,93 @@ + +/* Method object interface */ + +#ifndef Py_METHODOBJECT_H +#define Py_METHODOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +/* This is about the type 'builtin_function_or_method', + not Python methods in user-defined classes. See classobject.h + for the latter. */ + +PyAPI_DATA(PyTypeObject) PyCFunction_Type; + +#define PyCFunction_Check(op) (Py_TYPE(op) == &PyCFunction_Type) + +typedef PyObject *(*PyCFunction)(PyObject *, PyObject *); +typedef PyObject *(*PyCFunctionWithKeywords)(PyObject *, PyObject *, + PyObject *); +typedef PyObject *(*PyNoArgsFunction)(PyObject *); + +PyAPI_FUNC(PyCFunction) PyCFunction_GetFunction(PyObject *); +PyAPI_FUNC(PyObject *) PyCFunction_GetSelf(PyObject *); +PyAPI_FUNC(int) PyCFunction_GetFlags(PyObject *); + +/* Macros for direct access to these values. Type checks are *not* + done, so use with care. */ +#define PyCFunction_GET_FUNCTION(func) \ + (((PyCFunctionObject *)func) -> m_ml -> ml_meth) +#define PyCFunction_GET_SELF(func) \ + (((PyCFunctionObject *)func) -> m_self) +#define PyCFunction_GET_FLAGS(func) \ + (((PyCFunctionObject *)func) -> m_ml -> ml_flags) +PyAPI_FUNC(PyObject *) PyCFunction_Call(PyObject *, PyObject *, PyObject *); + +struct PyMethodDef { + const char *ml_name; /* The name of the built-in function/method */ + PyCFunction ml_meth; /* The C function that implements it */ + int ml_flags; /* Combination of METH_xxx flags, which mostly + describe the args expected by the C func */ + const char *ml_doc; /* The __doc__ attribute, or NULL */ +}; +typedef struct PyMethodDef PyMethodDef; + +PyAPI_FUNC(PyObject *) Py_FindMethod(PyMethodDef[], PyObject *, const char *); + +#define PyCFunction_New(ML, SELF) PyCFunction_NewEx((ML), (SELF), NULL) +PyAPI_FUNC(PyObject *) PyCFunction_NewEx(PyMethodDef *, PyObject *, + PyObject *); + +/* Flag passed to newmethodobject */ +#define METH_OLDARGS 0x0000 +#define METH_VARARGS 0x0001 +#define METH_KEYWORDS 0x0002 +/* METH_NOARGS and METH_O must not be combined with the flags above. */ +#define METH_NOARGS 0x0004 +#define METH_O 0x0008 + +/* METH_CLASS and METH_STATIC are a little different; these control + the construction of methods for a class. These cannot be used for + functions in modules. */ +#define METH_CLASS 0x0010 +#define METH_STATIC 0x0020 + +/* METH_COEXIST allows a method to be entered eventhough a slot has + already filled the entry. When defined, the flag allows a separate + method, "__contains__" for example, to coexist with a defined + slot like sq_contains. */ + +#define METH_COEXIST 0x0040 + +typedef struct PyMethodChain { + PyMethodDef *methods; /* Methods of this type */ + struct PyMethodChain *link; /* NULL or base type */ +} PyMethodChain; + +PyAPI_FUNC(PyObject *) Py_FindMethodInChain(PyMethodChain *, PyObject *, + const char *); + +typedef struct { + PyObject_HEAD + PyMethodDef *m_ml; /* Description of the C function to call */ + PyObject *m_self; /* Passed as 'self' arg to the C func, can be NULL */ + PyObject *m_module; /* The __module__ attribute, can be anything */ +} PyCFunctionObject; + +PyAPI_FUNC(int) PyCFunction_ClearFreeList(void); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_METHODOBJECT_H */ diff --git a/android/python27/include/modsupport.h b/android/python27/include/modsupport.h new file mode 100644 index 000000000..d4dddef0b --- /dev/null +++ b/android/python27/include/modsupport.h @@ -0,0 +1,134 @@ + +#ifndef Py_MODSUPPORT_H +#define Py_MODSUPPORT_H +#ifdef __cplusplus +extern "C" { +#endif + +/* Module support interface */ + +#include + +/* If PY_SSIZE_T_CLEAN is defined, each functions treats #-specifier + to mean Py_ssize_t */ +#ifdef PY_SSIZE_T_CLEAN +#define PyArg_Parse _PyArg_Parse_SizeT +#define PyArg_ParseTuple _PyArg_ParseTuple_SizeT +#define PyArg_ParseTupleAndKeywords _PyArg_ParseTupleAndKeywords_SizeT +#define PyArg_VaParse _PyArg_VaParse_SizeT +#define PyArg_VaParseTupleAndKeywords _PyArg_VaParseTupleAndKeywords_SizeT +#define Py_BuildValue _Py_BuildValue_SizeT +#define Py_VaBuildValue _Py_VaBuildValue_SizeT +#else +PyAPI_FUNC(PyObject *) _Py_VaBuildValue_SizeT(const char *, va_list); +#endif + +PyAPI_FUNC(int) PyArg_Parse(PyObject *, const char *, ...); +PyAPI_FUNC(int) PyArg_ParseTuple(PyObject *, const char *, ...) Py_FORMAT_PARSETUPLE(PyArg_ParseTuple, 2, 3); +PyAPI_FUNC(int) PyArg_ParseTupleAndKeywords(PyObject *, PyObject *, + const char *, char **, ...); +PyAPI_FUNC(int) PyArg_UnpackTuple(PyObject *, const char *, Py_ssize_t, Py_ssize_t, ...); +PyAPI_FUNC(PyObject *) Py_BuildValue(const char *, ...); +PyAPI_FUNC(PyObject *) _Py_BuildValue_SizeT(const char *, ...); +PyAPI_FUNC(int) _PyArg_NoKeywords(const char *funcname, PyObject *kw); + +PyAPI_FUNC(int) PyArg_VaParse(PyObject *, const char *, va_list); +PyAPI_FUNC(int) PyArg_VaParseTupleAndKeywords(PyObject *, PyObject *, + const char *, char **, va_list); +PyAPI_FUNC(PyObject *) Py_VaBuildValue(const char *, va_list); + +PyAPI_FUNC(int) PyModule_AddObject(PyObject *, const char *, PyObject *); +PyAPI_FUNC(int) PyModule_AddIntConstant(PyObject *, const char *, long); +PyAPI_FUNC(int) PyModule_AddStringConstant(PyObject *, const char *, const char *); +#define PyModule_AddIntMacro(m, c) PyModule_AddIntConstant(m, #c, c) +#define PyModule_AddStringMacro(m, c) PyModule_AddStringConstant(m, #c, c) + +#define PYTHON_API_VERSION 1013 +#define PYTHON_API_STRING "1013" +/* The API version is maintained (independently from the Python version) + so we can detect mismatches between the interpreter and dynamically + loaded modules. These are diagnosed by an error message but + the module is still loaded (because the mismatch can only be tested + after loading the module). The error message is intended to + explain the core dump a few seconds later. + + The symbol PYTHON_API_STRING defines the same value as a string + literal. *** PLEASE MAKE SURE THE DEFINITIONS MATCH. *** + + Please add a line or two to the top of this log for each API + version change: + + 22-Feb-2006 MvL 1013 PEP 353 - long indices for sequence lengths + + 19-Aug-2002 GvR 1012 Changes to string object struct for + interning changes, saving 3 bytes. + + 17-Jul-2001 GvR 1011 Descr-branch, just to be on the safe side + + 25-Jan-2001 FLD 1010 Parameters added to PyCode_New() and + PyFrame_New(); Python 2.1a2 + + 14-Mar-2000 GvR 1009 Unicode API added + + 3-Jan-1999 GvR 1007 Decided to change back! (Don't reuse 1008!) + + 3-Dec-1998 GvR 1008 Python 1.5.2b1 + + 18-Jan-1997 GvR 1007 string interning and other speedups + + 11-Oct-1996 GvR renamed Py_Ellipses to Py_Ellipsis :-( + + 30-Jul-1996 GvR Slice and ellipses syntax added + + 23-Jul-1996 GvR For 1.4 -- better safe than sorry this time :-) + + 7-Nov-1995 GvR Keyword arguments (should've been done at 1.3 :-( ) + + 10-Jan-1995 GvR Renamed globals to new naming scheme + + 9-Jan-1995 GvR Initial version (incompatible with older API) +*/ + +#ifdef MS_WINDOWS +/* Special defines for Windows versions used to live here. Things + have changed, and the "Version" is now in a global string variable. + Reason for this is that this for easier branding of a "custom DLL" + without actually needing a recompile. */ +#endif /* MS_WINDOWS */ + +#if SIZEOF_SIZE_T != SIZEOF_INT +/* On a 64-bit system, rename the Py_InitModule4 so that 2.4 + modules cannot get loaded into a 2.5 interpreter */ +#define Py_InitModule4 Py_InitModule4_64 +#endif + +#ifdef Py_TRACE_REFS + /* When we are tracing reference counts, rename Py_InitModule4 so + modules compiled with incompatible settings will generate a + link-time error. */ + #if SIZEOF_SIZE_T != SIZEOF_INT + #undef Py_InitModule4 + #define Py_InitModule4 Py_InitModule4TraceRefs_64 + #else + #define Py_InitModule4 Py_InitModule4TraceRefs + #endif +#endif + +PyAPI_FUNC(PyObject *) Py_InitModule4(const char *name, PyMethodDef *methods, + const char *doc, PyObject *self, + int apiver); + +#define Py_InitModule(name, methods) \ + Py_InitModule4(name, methods, (char *)NULL, (PyObject *)NULL, \ + PYTHON_API_VERSION) + +#define Py_InitModule3(name, methods, doc) \ + Py_InitModule4(name, methods, doc, (PyObject *)NULL, \ + PYTHON_API_VERSION) + +PyAPI_DATA(char *) _Py_PackageContext; + +#ifdef __cplusplus +} +#endif +#endif /* !Py_MODSUPPORT_H */ diff --git a/android/python27/include/moduleobject.h b/android/python27/include/moduleobject.h new file mode 100644 index 000000000..b387f5bfd --- /dev/null +++ b/android/python27/include/moduleobject.h @@ -0,0 +1,24 @@ + +/* Module object interface */ + +#ifndef Py_MODULEOBJECT_H +#define Py_MODULEOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_DATA(PyTypeObject) PyModule_Type; + +#define PyModule_Check(op) PyObject_TypeCheck(op, &PyModule_Type) +#define PyModule_CheckExact(op) (Py_TYPE(op) == &PyModule_Type) + +PyAPI_FUNC(PyObject *) PyModule_New(const char *); +PyAPI_FUNC(PyObject *) PyModule_GetDict(PyObject *); +PyAPI_FUNC(char *) PyModule_GetName(PyObject *); +PyAPI_FUNC(char *) PyModule_GetFilename(PyObject *); +PyAPI_FUNC(void) _PyModule_Clear(PyObject *); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_MODULEOBJECT_H */ diff --git a/android/python27/include/node.h b/android/python27/include/node.h new file mode 100644 index 000000000..517c3dc43 --- /dev/null +++ b/android/python27/include/node.h @@ -0,0 +1,41 @@ + +/* Parse tree node interface */ + +#ifndef Py_NODE_H +#define Py_NODE_H +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct _node { + short n_type; + char *n_str; + int n_lineno; + int n_col_offset; + int n_nchildren; + struct _node *n_child; +} node; + +PyAPI_FUNC(node *) PyNode_New(int type); +PyAPI_FUNC(int) PyNode_AddChild(node *n, int type, + char *str, int lineno, int col_offset); +PyAPI_FUNC(void) PyNode_Free(node *n); +PyAPI_FUNC(Py_ssize_t) _PyNode_SizeOf(node *n); + +/* Node access functions */ +#define NCH(n) ((n)->n_nchildren) + +#define CHILD(n, i) (&(n)->n_child[i]) +#define RCHILD(n, i) (CHILD(n, NCH(n) + i)) +#define TYPE(n) ((n)->n_type) +#define STR(n) ((n)->n_str) + +/* Assert that the type of a node is what we expect */ +#define REQ(n, type) assert(TYPE(n) == (type)) + +PyAPI_FUNC(void) PyNode_ListTree(node *); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_NODE_H */ diff --git a/android/python27/include/object.h b/android/python27/include/object.h new file mode 100644 index 000000000..4ee1f8e6f --- /dev/null +++ b/android/python27/include/object.h @@ -0,0 +1,1013 @@ +#ifndef Py_OBJECT_H +#define Py_OBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + + +/* Object and type object interface */ + +/* +Objects are structures allocated on the heap. Special rules apply to +the use of objects to ensure they are properly garbage-collected. +Objects are never allocated statically or on the stack; they must be +accessed through special macros and functions only. (Type objects are +exceptions to the first rule; the standard types are represented by +statically initialized type objects, although work on type/class unification +for Python 2.2 made it possible to have heap-allocated type objects too). + +An object has a 'reference count' that is increased or decreased when a +pointer to the object is copied or deleted; when the reference count +reaches zero there are no references to the object left and it can be +removed from the heap. + +An object has a 'type' that determines what it represents and what kind +of data it contains. An object's type is fixed when it is created. +Types themselves are represented as objects; an object contains a +pointer to the corresponding type object. The type itself has a type +pointer pointing to the object representing the type 'type', which +contains a pointer to itself!). + +Objects do not float around in memory; once allocated an object keeps +the same size and address. Objects that must hold variable-size data +can contain pointers to variable-size parts of the object. Not all +objects of the same type have the same size; but the size cannot change +after allocation. (These restrictions are made so a reference to an +object can be simply a pointer -- moving an object would require +updating all the pointers, and changing an object's size would require +moving it if there was another object right next to it.) + +Objects are always accessed through pointers of the type 'PyObject *'. +The type 'PyObject' is a structure that only contains the reference count +and the type pointer. The actual memory allocated for an object +contains other data that can only be accessed after casting the pointer +to a pointer to a longer structure type. This longer type must start +with the reference count and type fields; the macro PyObject_HEAD should be +used for this (to accommodate for future changes). The implementation +of a particular object type can cast the object pointer to the proper +type and back. + +A standard interface exists for objects that contain an array of items +whose size is determined when the object is allocated. +*/ + +/* Py_DEBUG implies Py_TRACE_REFS. */ +#if defined(Py_DEBUG) && !defined(Py_TRACE_REFS) +#define Py_TRACE_REFS +#endif + +/* Py_TRACE_REFS implies Py_REF_DEBUG. */ +#if defined(Py_TRACE_REFS) && !defined(Py_REF_DEBUG) +#define Py_REF_DEBUG +#endif + +#ifdef Py_TRACE_REFS +/* Define pointers to support a doubly-linked list of all live heap objects. */ +#define _PyObject_HEAD_EXTRA \ + struct _object *_ob_next; \ + struct _object *_ob_prev; + +#define _PyObject_EXTRA_INIT 0, 0, + +#else +#define _PyObject_HEAD_EXTRA +#define _PyObject_EXTRA_INIT +#endif + +/* PyObject_HEAD defines the initial segment of every PyObject. */ +#define PyObject_HEAD \ + _PyObject_HEAD_EXTRA \ + Py_ssize_t ob_refcnt; \ + struct _typeobject *ob_type; + +#define PyObject_HEAD_INIT(type) \ + _PyObject_EXTRA_INIT \ + 1, type, + +#define PyVarObject_HEAD_INIT(type, size) \ + PyObject_HEAD_INIT(type) size, + +/* PyObject_VAR_HEAD defines the initial segment of all variable-size + * container objects. These end with a declaration of an array with 1 + * element, but enough space is malloc'ed so that the array actually + * has room for ob_size elements. Note that ob_size is an element count, + * not necessarily a byte count. + */ +#define PyObject_VAR_HEAD \ + PyObject_HEAD \ + Py_ssize_t ob_size; /* Number of items in variable part */ +#define Py_INVALID_SIZE (Py_ssize_t)-1 + +/* Nothing is actually declared to be a PyObject, but every pointer to + * a Python object can be cast to a PyObject*. This is inheritance built + * by hand. Similarly every pointer to a variable-size Python object can, + * in addition, be cast to PyVarObject*. + */ +typedef struct _object { + PyObject_HEAD +} PyObject; + +typedef struct { + PyObject_VAR_HEAD +} PyVarObject; + +#define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt) +#define Py_TYPE(ob) (((PyObject*)(ob))->ob_type) +#define Py_SIZE(ob) (((PyVarObject*)(ob))->ob_size) + +/* +Type objects contain a string containing the type name (to help somewhat +in debugging), the allocation parameters (see PyObject_New() and +PyObject_NewVar()), +and methods for accessing objects of the type. Methods are optional, a +nil pointer meaning that particular kind of access is not available for +this type. The Py_DECREF() macro uses the tp_dealloc method without +checking for a nil pointer; it should always be implemented except if +the implementation can guarantee that the reference count will never +reach zero (e.g., for statically allocated type objects). + +NB: the methods for certain type groups are now contained in separate +method blocks. +*/ + +typedef PyObject * (*unaryfunc)(PyObject *); +typedef PyObject * (*binaryfunc)(PyObject *, PyObject *); +typedef PyObject * (*ternaryfunc)(PyObject *, PyObject *, PyObject *); +typedef int (*inquiry)(PyObject *); +typedef Py_ssize_t (*lenfunc)(PyObject *); +typedef int (*coercion)(PyObject **, PyObject **); +typedef PyObject *(*intargfunc)(PyObject *, int) Py_DEPRECATED(2.5); +typedef PyObject *(*intintargfunc)(PyObject *, int, int) Py_DEPRECATED(2.5); +typedef PyObject *(*ssizeargfunc)(PyObject *, Py_ssize_t); +typedef PyObject *(*ssizessizeargfunc)(PyObject *, Py_ssize_t, Py_ssize_t); +typedef int(*intobjargproc)(PyObject *, int, PyObject *); +typedef int(*intintobjargproc)(PyObject *, int, int, PyObject *); +typedef int(*ssizeobjargproc)(PyObject *, Py_ssize_t, PyObject *); +typedef int(*ssizessizeobjargproc)(PyObject *, Py_ssize_t, Py_ssize_t, PyObject *); +typedef int(*objobjargproc)(PyObject *, PyObject *, PyObject *); + + + +/* int-based buffer interface */ +typedef int (*getreadbufferproc)(PyObject *, int, void **); +typedef int (*getwritebufferproc)(PyObject *, int, void **); +typedef int (*getsegcountproc)(PyObject *, int *); +typedef int (*getcharbufferproc)(PyObject *, int, char **); +/* ssize_t-based buffer interface */ +typedef Py_ssize_t (*readbufferproc)(PyObject *, Py_ssize_t, void **); +typedef Py_ssize_t (*writebufferproc)(PyObject *, Py_ssize_t, void **); +typedef Py_ssize_t (*segcountproc)(PyObject *, Py_ssize_t *); +typedef Py_ssize_t (*charbufferproc)(PyObject *, Py_ssize_t, char **); + + +/* Py3k buffer interface */ +typedef struct bufferinfo { + void *buf; + PyObject *obj; /* owned reference */ + Py_ssize_t len; + Py_ssize_t itemsize; /* This is Py_ssize_t so it can be + pointed to by strides in simple case.*/ + int readonly; + int ndim; + char *format; + Py_ssize_t *shape; + Py_ssize_t *strides; + Py_ssize_t *suboffsets; + Py_ssize_t smalltable[2]; /* static store for shape and strides of + mono-dimensional buffers. */ + void *internal; +} Py_buffer; + +typedef int (*getbufferproc)(PyObject *, Py_buffer *, int); +typedef void (*releasebufferproc)(PyObject *, Py_buffer *); + + /* Flags for getting buffers */ +#define PyBUF_SIMPLE 0 +#define PyBUF_WRITABLE 0x0001 +/* we used to include an E, backwards compatible alias */ +#define PyBUF_WRITEABLE PyBUF_WRITABLE +#define PyBUF_FORMAT 0x0004 +#define PyBUF_ND 0x0008 +#define PyBUF_STRIDES (0x0010 | PyBUF_ND) +#define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES) +#define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES) +#define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES) +#define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES) + +#define PyBUF_CONTIG (PyBUF_ND | PyBUF_WRITABLE) +#define PyBUF_CONTIG_RO (PyBUF_ND) + +#define PyBUF_STRIDED (PyBUF_STRIDES | PyBUF_WRITABLE) +#define PyBUF_STRIDED_RO (PyBUF_STRIDES) + +#define PyBUF_RECORDS (PyBUF_STRIDES | PyBUF_WRITABLE | PyBUF_FORMAT) +#define PyBUF_RECORDS_RO (PyBUF_STRIDES | PyBUF_FORMAT) + +#define PyBUF_FULL (PyBUF_INDIRECT | PyBUF_WRITABLE | PyBUF_FORMAT) +#define PyBUF_FULL_RO (PyBUF_INDIRECT | PyBUF_FORMAT) + + +#define PyBUF_READ 0x100 +#define PyBUF_WRITE 0x200 +#define PyBUF_SHADOW 0x400 +/* end Py3k buffer interface */ + +typedef int (*objobjproc)(PyObject *, PyObject *); +typedef int (*visitproc)(PyObject *, void *); +typedef int (*traverseproc)(PyObject *, visitproc, void *); + +typedef struct { + /* For numbers without flag bit Py_TPFLAGS_CHECKTYPES set, all + arguments are guaranteed to be of the object's type (modulo + coercion hacks -- i.e. if the type's coercion function + returns other types, then these are allowed as well). Numbers that + have the Py_TPFLAGS_CHECKTYPES flag bit set should check *both* + arguments for proper type and implement the necessary conversions + in the slot functions themselves. */ + + binaryfunc nb_add; + binaryfunc nb_subtract; + binaryfunc nb_multiply; + binaryfunc nb_divide; + binaryfunc nb_remainder; + binaryfunc nb_divmod; + ternaryfunc nb_power; + unaryfunc nb_negative; + unaryfunc nb_positive; + unaryfunc nb_absolute; + inquiry nb_nonzero; + unaryfunc nb_invert; + binaryfunc nb_lshift; + binaryfunc nb_rshift; + binaryfunc nb_and; + binaryfunc nb_xor; + binaryfunc nb_or; + coercion nb_coerce; + unaryfunc nb_int; + unaryfunc nb_long; + unaryfunc nb_float; + unaryfunc nb_oct; + unaryfunc nb_hex; + /* Added in release 2.0 */ + binaryfunc nb_inplace_add; + binaryfunc nb_inplace_subtract; + binaryfunc nb_inplace_multiply; + binaryfunc nb_inplace_divide; + binaryfunc nb_inplace_remainder; + ternaryfunc nb_inplace_power; + binaryfunc nb_inplace_lshift; + binaryfunc nb_inplace_rshift; + binaryfunc nb_inplace_and; + binaryfunc nb_inplace_xor; + binaryfunc nb_inplace_or; + + /* Added in release 2.2 */ + /* The following require the Py_TPFLAGS_HAVE_CLASS flag */ + binaryfunc nb_floor_divide; + binaryfunc nb_true_divide; + binaryfunc nb_inplace_floor_divide; + binaryfunc nb_inplace_true_divide; + + /* Added in release 2.5 */ + unaryfunc nb_index; +} PyNumberMethods; + +typedef struct { + lenfunc sq_length; + binaryfunc sq_concat; + ssizeargfunc sq_repeat; + ssizeargfunc sq_item; + ssizessizeargfunc sq_slice; + ssizeobjargproc sq_ass_item; + ssizessizeobjargproc sq_ass_slice; + objobjproc sq_contains; + /* Added in release 2.0 */ + binaryfunc sq_inplace_concat; + ssizeargfunc sq_inplace_repeat; +} PySequenceMethods; + +typedef struct { + lenfunc mp_length; + binaryfunc mp_subscript; + objobjargproc mp_ass_subscript; +} PyMappingMethods; + +typedef struct { + readbufferproc bf_getreadbuffer; + writebufferproc bf_getwritebuffer; + segcountproc bf_getsegcount; + charbufferproc bf_getcharbuffer; + getbufferproc bf_getbuffer; + releasebufferproc bf_releasebuffer; +} PyBufferProcs; + + +typedef void (*freefunc)(void *); +typedef void (*destructor)(PyObject *); +typedef int (*printfunc)(PyObject *, FILE *, int); +typedef PyObject *(*getattrfunc)(PyObject *, char *); +typedef PyObject *(*getattrofunc)(PyObject *, PyObject *); +typedef int (*setattrfunc)(PyObject *, char *, PyObject *); +typedef int (*setattrofunc)(PyObject *, PyObject *, PyObject *); +typedef int (*cmpfunc)(PyObject *, PyObject *); +typedef PyObject *(*reprfunc)(PyObject *); +typedef long (*hashfunc)(PyObject *); +typedef PyObject *(*richcmpfunc) (PyObject *, PyObject *, int); +typedef PyObject *(*getiterfunc) (PyObject *); +typedef PyObject *(*iternextfunc) (PyObject *); +typedef PyObject *(*descrgetfunc) (PyObject *, PyObject *, PyObject *); +typedef int (*descrsetfunc) (PyObject *, PyObject *, PyObject *); +typedef int (*initproc)(PyObject *, PyObject *, PyObject *); +typedef PyObject *(*newfunc)(struct _typeobject *, PyObject *, PyObject *); +typedef PyObject *(*allocfunc)(struct _typeobject *, Py_ssize_t); + +typedef struct _typeobject { + PyObject_VAR_HEAD + const char *tp_name; /* For printing, in format "." */ + Py_ssize_t tp_basicsize, tp_itemsize; /* For allocation */ + + /* Methods to implement standard operations */ + + destructor tp_dealloc; + printfunc tp_print; + getattrfunc tp_getattr; + setattrfunc tp_setattr; + cmpfunc tp_compare; + reprfunc tp_repr; + + /* Method suites for standard classes */ + + PyNumberMethods *tp_as_number; + PySequenceMethods *tp_as_sequence; + PyMappingMethods *tp_as_mapping; + + /* More standard operations (here for binary compatibility) */ + + hashfunc tp_hash; + ternaryfunc tp_call; + reprfunc tp_str; + getattrofunc tp_getattro; + setattrofunc tp_setattro; + + /* Functions to access object as input/output buffer */ + PyBufferProcs *tp_as_buffer; + + /* Flags to define presence of optional/expanded features */ + long tp_flags; + + const char *tp_doc; /* Documentation string */ + + /* Assigned meaning in release 2.0 */ + /* call function for all accessible objects */ + traverseproc tp_traverse; + + /* delete references to contained objects */ + inquiry tp_clear; + + /* Assigned meaning in release 2.1 */ + /* rich comparisons */ + richcmpfunc tp_richcompare; + + /* weak reference enabler */ + Py_ssize_t tp_weaklistoffset; + + /* Added in release 2.2 */ + /* Iterators */ + getiterfunc tp_iter; + iternextfunc tp_iternext; + + /* Attribute descriptor and subclassing stuff */ + struct PyMethodDef *tp_methods; + struct PyMemberDef *tp_members; + struct PyGetSetDef *tp_getset; + struct _typeobject *tp_base; + PyObject *tp_dict; + descrgetfunc tp_descr_get; + descrsetfunc tp_descr_set; + Py_ssize_t tp_dictoffset; + initproc tp_init; + allocfunc tp_alloc; + newfunc tp_new; + freefunc tp_free; /* Low-level free-memory routine */ + inquiry tp_is_gc; /* For PyObject_IS_GC */ + PyObject *tp_bases; + PyObject *tp_mro; /* method resolution order */ + PyObject *tp_cache; + PyObject *tp_subclasses; + PyObject *tp_weaklist; + destructor tp_del; + + /* Type attribute cache version tag. Added in version 2.6 */ + unsigned int tp_version_tag; + +#ifdef COUNT_ALLOCS + /* these must be last and never explicitly initialized */ + Py_ssize_t tp_allocs; + Py_ssize_t tp_frees; + Py_ssize_t tp_maxalloc; + struct _typeobject *tp_prev; + struct _typeobject *tp_next; +#endif +} PyTypeObject; + + +/* The *real* layout of a type object when allocated on the heap */ +typedef struct _heaptypeobject { + /* Note: there's a dependency on the order of these members + in slotptr() in typeobject.c . */ + PyTypeObject ht_type; + PyNumberMethods as_number; + PyMappingMethods as_mapping; + PySequenceMethods as_sequence; /* as_sequence comes after as_mapping, + so that the mapping wins when both + the mapping and the sequence define + a given operator (e.g. __getitem__). + see add_operators() in typeobject.c . */ + PyBufferProcs as_buffer; + PyObject *ht_name, *ht_slots; + /* here are optional user slots, followed by the members. */ +} PyHeapTypeObject; + +/* access macro to the members which are floating "behind" the object */ +#define PyHeapType_GET_MEMBERS(etype) \ + ((PyMemberDef *)(((char *)etype) + Py_TYPE(etype)->tp_basicsize)) + + +/* Generic type check */ +PyAPI_FUNC(int) PyType_IsSubtype(PyTypeObject *, PyTypeObject *); +#define PyObject_TypeCheck(ob, tp) \ + (Py_TYPE(ob) == (tp) || PyType_IsSubtype(Py_TYPE(ob), (tp))) + +PyAPI_DATA(PyTypeObject) PyType_Type; /* built-in 'type' */ +PyAPI_DATA(PyTypeObject) PyBaseObject_Type; /* built-in 'object' */ +PyAPI_DATA(PyTypeObject) PySuper_Type; /* built-in 'super' */ + +#define PyType_Check(op) \ + PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_TYPE_SUBCLASS) +#define PyType_CheckExact(op) (Py_TYPE(op) == &PyType_Type) + +PyAPI_FUNC(int) PyType_Ready(PyTypeObject *); +PyAPI_FUNC(PyObject *) PyType_GenericAlloc(PyTypeObject *, Py_ssize_t); +PyAPI_FUNC(PyObject *) PyType_GenericNew(PyTypeObject *, + PyObject *, PyObject *); +PyAPI_FUNC(PyObject *) _PyType_Lookup(PyTypeObject *, PyObject *); +PyAPI_FUNC(PyObject *) _PyObject_LookupSpecial(PyObject *, char *, PyObject **); +PyAPI_FUNC(unsigned int) PyType_ClearCache(void); +PyAPI_FUNC(void) PyType_Modified(PyTypeObject *); + +/* Generic operations on objects */ +PyAPI_FUNC(int) PyObject_Print(PyObject *, FILE *, int); +PyAPI_FUNC(void) _PyObject_Dump(PyObject *); +PyAPI_FUNC(PyObject *) PyObject_Repr(PyObject *); +PyAPI_FUNC(PyObject *) _PyObject_Str(PyObject *); +PyAPI_FUNC(PyObject *) PyObject_Str(PyObject *); +#define PyObject_Bytes PyObject_Str +#ifdef Py_USING_UNICODE +PyAPI_FUNC(PyObject *) PyObject_Unicode(PyObject *); +#endif +PyAPI_FUNC(int) PyObject_Compare(PyObject *, PyObject *); +PyAPI_FUNC(PyObject *) PyObject_RichCompare(PyObject *, PyObject *, int); +PyAPI_FUNC(int) PyObject_RichCompareBool(PyObject *, PyObject *, int); +PyAPI_FUNC(PyObject *) PyObject_GetAttrString(PyObject *, const char *); +PyAPI_FUNC(int) PyObject_SetAttrString(PyObject *, const char *, PyObject *); +PyAPI_FUNC(int) PyObject_HasAttrString(PyObject *, const char *); +PyAPI_FUNC(PyObject *) PyObject_GetAttr(PyObject *, PyObject *); +PyAPI_FUNC(int) PyObject_SetAttr(PyObject *, PyObject *, PyObject *); +PyAPI_FUNC(int) PyObject_HasAttr(PyObject *, PyObject *); +PyAPI_FUNC(PyObject **) _PyObject_GetDictPtr(PyObject *); +PyAPI_FUNC(PyObject *) PyObject_SelfIter(PyObject *); +PyAPI_FUNC(PyObject *) _PyObject_NextNotImplemented(PyObject *); +PyAPI_FUNC(PyObject *) PyObject_GenericGetAttr(PyObject *, PyObject *); +PyAPI_FUNC(int) PyObject_GenericSetAttr(PyObject *, + PyObject *, PyObject *); +PyAPI_FUNC(long) PyObject_Hash(PyObject *); +PyAPI_FUNC(long) PyObject_HashNotImplemented(PyObject *); +PyAPI_FUNC(int) PyObject_IsTrue(PyObject *); +PyAPI_FUNC(int) PyObject_Not(PyObject *); +PyAPI_FUNC(int) PyCallable_Check(PyObject *); +PyAPI_FUNC(int) PyNumber_Coerce(PyObject **, PyObject **); +PyAPI_FUNC(int) PyNumber_CoerceEx(PyObject **, PyObject **); + +PyAPI_FUNC(void) PyObject_ClearWeakRefs(PyObject *); + +/* A slot function whose address we need to compare */ +extern int _PyObject_SlotCompare(PyObject *, PyObject *); +/* Same as PyObject_Generic{Get,Set}Attr, but passing the attributes + dict as the last parameter. */ +PyAPI_FUNC(PyObject *) +_PyObject_GenericGetAttrWithDict(PyObject *, PyObject *, PyObject *); +PyAPI_FUNC(int) +_PyObject_GenericSetAttrWithDict(PyObject *, PyObject *, + PyObject *, PyObject *); + + +/* PyObject_Dir(obj) acts like Python __builtin__.dir(obj), returning a + list of strings. PyObject_Dir(NULL) is like __builtin__.dir(), + returning the names of the current locals. In this case, if there are + no current locals, NULL is returned, and PyErr_Occurred() is false. +*/ +PyAPI_FUNC(PyObject *) PyObject_Dir(PyObject *); + + +/* Helpers for printing recursive container types */ +PyAPI_FUNC(int) Py_ReprEnter(PyObject *); +PyAPI_FUNC(void) Py_ReprLeave(PyObject *); + +/* Helpers for hash functions */ +PyAPI_FUNC(long) _Py_HashDouble(double); +PyAPI_FUNC(long) _Py_HashPointer(void*); + +typedef struct { + long prefix; + long suffix; +} _Py_HashSecret_t; +PyAPI_DATA(_Py_HashSecret_t) _Py_HashSecret; + +#ifdef Py_DEBUG +PyAPI_DATA(int) _Py_HashSecret_Initialized; +#endif + +/* Helper for passing objects to printf and the like. + Leaks refcounts. Don't use it! +*/ +#define PyObject_REPR(obj) PyString_AS_STRING(PyObject_Repr(obj)) + +/* Flag bits for printing: */ +#define Py_PRINT_RAW 1 /* No string quotes etc. */ + +/* +`Type flags (tp_flags) + +These flags are used to extend the type structure in a backwards-compatible +fashion. Extensions can use the flags to indicate (and test) when a given +type structure contains a new feature. The Python core will use these when +introducing new functionality between major revisions (to avoid mid-version +changes in the PYTHON_API_VERSION). + +Arbitration of the flag bit positions will need to be coordinated among +all extension writers who publically release their extensions (this will +be fewer than you might expect!).. + +Python 1.5.2 introduced the bf_getcharbuffer slot into PyBufferProcs. + +Type definitions should use Py_TPFLAGS_DEFAULT for their tp_flags value. + +Code can use PyType_HasFeature(type_ob, flag_value) to test whether the +given type object has a specified feature. + +NOTE: when building the core, Py_TPFLAGS_DEFAULT includes +Py_TPFLAGS_HAVE_VERSION_TAG; outside the core, it doesn't. This is so +that extensions that modify tp_dict of their own types directly don't +break, since this was allowed in 2.5. In 3.0 they will have to +manually remove this flag though! +*/ + +/* PyBufferProcs contains bf_getcharbuffer */ +#define Py_TPFLAGS_HAVE_GETCHARBUFFER (1L<<0) + +/* PySequenceMethods contains sq_contains */ +#define Py_TPFLAGS_HAVE_SEQUENCE_IN (1L<<1) + +/* This is here for backwards compatibility. Extensions that use the old GC + * API will still compile but the objects will not be tracked by the GC. */ +#define Py_TPFLAGS_GC 0 /* used to be (1L<<2) */ + +/* PySequenceMethods and PyNumberMethods contain in-place operators */ +#define Py_TPFLAGS_HAVE_INPLACEOPS (1L<<3) + +/* PyNumberMethods do their own coercion */ +#define Py_TPFLAGS_CHECKTYPES (1L<<4) + +/* tp_richcompare is defined */ +#define Py_TPFLAGS_HAVE_RICHCOMPARE (1L<<5) + +/* Objects which are weakly referencable if their tp_weaklistoffset is >0 */ +#define Py_TPFLAGS_HAVE_WEAKREFS (1L<<6) + +/* tp_iter is defined */ +#define Py_TPFLAGS_HAVE_ITER (1L<<7) + +/* New members introduced by Python 2.2 exist */ +#define Py_TPFLAGS_HAVE_CLASS (1L<<8) + +/* Set if the type object is dynamically allocated */ +#define Py_TPFLAGS_HEAPTYPE (1L<<9) + +/* Set if the type allows subclassing */ +#define Py_TPFLAGS_BASETYPE (1L<<10) + +/* Set if the type is 'ready' -- fully initialized */ +#define Py_TPFLAGS_READY (1L<<12) + +/* Set while the type is being 'readied', to prevent recursive ready calls */ +#define Py_TPFLAGS_READYING (1L<<13) + +/* Objects support garbage collection (see objimp.h) */ +#define Py_TPFLAGS_HAVE_GC (1L<<14) + +/* These two bits are preserved for Stackless Python, next after this is 17 */ +#ifdef STACKLESS +#define Py_TPFLAGS_HAVE_STACKLESS_EXTENSION (3L<<15) +#else +#define Py_TPFLAGS_HAVE_STACKLESS_EXTENSION 0 +#endif + +/* Objects support nb_index in PyNumberMethods */ +#define Py_TPFLAGS_HAVE_INDEX (1L<<17) + +/* Objects support type attribute cache */ +#define Py_TPFLAGS_HAVE_VERSION_TAG (1L<<18) +#define Py_TPFLAGS_VALID_VERSION_TAG (1L<<19) + +/* Type is abstract and cannot be instantiated */ +#define Py_TPFLAGS_IS_ABSTRACT (1L<<20) + +/* Has the new buffer protocol */ +#define Py_TPFLAGS_HAVE_NEWBUFFER (1L<<21) + +/* These flags are used to determine if a type is a subclass. */ +#define Py_TPFLAGS_INT_SUBCLASS (1L<<23) +#define Py_TPFLAGS_LONG_SUBCLASS (1L<<24) +#define Py_TPFLAGS_LIST_SUBCLASS (1L<<25) +#define Py_TPFLAGS_TUPLE_SUBCLASS (1L<<26) +#define Py_TPFLAGS_STRING_SUBCLASS (1L<<27) +#define Py_TPFLAGS_UNICODE_SUBCLASS (1L<<28) +#define Py_TPFLAGS_DICT_SUBCLASS (1L<<29) +#define Py_TPFLAGS_BASE_EXC_SUBCLASS (1L<<30) +#define Py_TPFLAGS_TYPE_SUBCLASS (1L<<31) + +#define Py_TPFLAGS_DEFAULT_EXTERNAL ( \ + Py_TPFLAGS_HAVE_GETCHARBUFFER | \ + Py_TPFLAGS_HAVE_SEQUENCE_IN | \ + Py_TPFLAGS_HAVE_INPLACEOPS | \ + Py_TPFLAGS_HAVE_RICHCOMPARE | \ + Py_TPFLAGS_HAVE_WEAKREFS | \ + Py_TPFLAGS_HAVE_ITER | \ + Py_TPFLAGS_HAVE_CLASS | \ + Py_TPFLAGS_HAVE_STACKLESS_EXTENSION | \ + Py_TPFLAGS_HAVE_INDEX | \ + 0) +#define Py_TPFLAGS_DEFAULT_CORE (Py_TPFLAGS_DEFAULT_EXTERNAL | \ + Py_TPFLAGS_HAVE_VERSION_TAG) + +#ifdef Py_BUILD_CORE +#define Py_TPFLAGS_DEFAULT Py_TPFLAGS_DEFAULT_CORE +#else +#define Py_TPFLAGS_DEFAULT Py_TPFLAGS_DEFAULT_EXTERNAL +#endif + +#define PyType_HasFeature(t,f) (((t)->tp_flags & (f)) != 0) +#define PyType_FastSubclass(t,f) PyType_HasFeature(t,f) + + +/* +The macros Py_INCREF(op) and Py_DECREF(op) are used to increment or decrement +reference counts. Py_DECREF calls the object's deallocator function when +the refcount falls to 0; for +objects that don't contain references to other objects or heap memory +this can be the standard function free(). Both macros can be used +wherever a void expression is allowed. The argument must not be a +NULL pointer. If it may be NULL, use Py_XINCREF/Py_XDECREF instead. +The macro _Py_NewReference(op) initialize reference counts to 1, and +in special builds (Py_REF_DEBUG, Py_TRACE_REFS) performs additional +bookkeeping appropriate to the special build. + +We assume that the reference count field can never overflow; this can +be proven when the size of the field is the same as the pointer size, so +we ignore the possibility. Provided a C int is at least 32 bits (which +is implicitly assumed in many parts of this code), that's enough for +about 2**31 references to an object. + +XXX The following became out of date in Python 2.2, but I'm not sure +XXX what the full truth is now. Certainly, heap-allocated type objects +XXX can and should be deallocated. +Type objects should never be deallocated; the type pointer in an object +is not considered to be a reference to the type object, to save +complications in the deallocation function. (This is actually a +decision that's up to the implementer of each new type so if you want, +you can count such references to the type object.) + +*** WARNING*** The Py_DECREF macro must have a side-effect-free argument +since it may evaluate its argument multiple times. (The alternative +would be to mace it a proper function or assign it to a global temporary +variable first, both of which are slower; and in a multi-threaded +environment the global variable trick is not safe.) +*/ + +/* First define a pile of simple helper macros, one set per special + * build symbol. These either expand to the obvious things, or to + * nothing at all when the special mode isn't in effect. The main + * macros can later be defined just once then, yet expand to different + * things depending on which special build options are and aren't in effect. + * Trust me : while painful, this is 20x easier to understand than, + * e.g, defining _Py_NewReference five different times in a maze of nested + * #ifdefs (we used to do that -- it was impenetrable). + */ +#ifdef Py_REF_DEBUG +PyAPI_DATA(Py_ssize_t) _Py_RefTotal; +PyAPI_FUNC(void) _Py_NegativeRefcount(const char *fname, + int lineno, PyObject *op); +PyAPI_FUNC(PyObject *) _PyDict_Dummy(void); +PyAPI_FUNC(PyObject *) _PySet_Dummy(void); +PyAPI_FUNC(Py_ssize_t) _Py_GetRefTotal(void); +#define _Py_INC_REFTOTAL _Py_RefTotal++ +#define _Py_DEC_REFTOTAL _Py_RefTotal-- +#define _Py_REF_DEBUG_COMMA , +#define _Py_CHECK_REFCNT(OP) \ +{ if (((PyObject*)OP)->ob_refcnt < 0) \ + _Py_NegativeRefcount(__FILE__, __LINE__, \ + (PyObject *)(OP)); \ +} +#else +#define _Py_INC_REFTOTAL +#define _Py_DEC_REFTOTAL +#define _Py_REF_DEBUG_COMMA +#define _Py_CHECK_REFCNT(OP) /* a semicolon */; +#endif /* Py_REF_DEBUG */ + +#ifdef COUNT_ALLOCS +PyAPI_FUNC(void) inc_count(PyTypeObject *); +PyAPI_FUNC(void) dec_count(PyTypeObject *); +#define _Py_INC_TPALLOCS(OP) inc_count(Py_TYPE(OP)) +#define _Py_INC_TPFREES(OP) dec_count(Py_TYPE(OP)) +#define _Py_DEC_TPFREES(OP) Py_TYPE(OP)->tp_frees-- +#define _Py_COUNT_ALLOCS_COMMA , +#else +#define _Py_INC_TPALLOCS(OP) +#define _Py_INC_TPFREES(OP) +#define _Py_DEC_TPFREES(OP) +#define _Py_COUNT_ALLOCS_COMMA +#endif /* COUNT_ALLOCS */ + +#ifdef Py_TRACE_REFS +/* Py_TRACE_REFS is such major surgery that we call external routines. */ +PyAPI_FUNC(void) _Py_NewReference(PyObject *); +PyAPI_FUNC(void) _Py_ForgetReference(PyObject *); +PyAPI_FUNC(void) _Py_Dealloc(PyObject *); +PyAPI_FUNC(void) _Py_PrintReferences(FILE *); +PyAPI_FUNC(void) _Py_PrintReferenceAddresses(FILE *); +PyAPI_FUNC(void) _Py_AddToAllObjects(PyObject *, int force); + +#else +/* Without Py_TRACE_REFS, there's little enough to do that we expand code + * inline. + */ +#define _Py_NewReference(op) ( \ + _Py_INC_TPALLOCS(op) _Py_COUNT_ALLOCS_COMMA \ + _Py_INC_REFTOTAL _Py_REF_DEBUG_COMMA \ + Py_REFCNT(op) = 1) + +#define _Py_ForgetReference(op) _Py_INC_TPFREES(op) + +#define _Py_Dealloc(op) ( \ + _Py_INC_TPFREES(op) _Py_COUNT_ALLOCS_COMMA \ + (*Py_TYPE(op)->tp_dealloc)((PyObject *)(op))) +#endif /* !Py_TRACE_REFS */ + +#define Py_INCREF(op) ( \ + _Py_INC_REFTOTAL _Py_REF_DEBUG_COMMA \ + ((PyObject*)(op))->ob_refcnt++) + +#define Py_DECREF(op) \ + do { \ + if (_Py_DEC_REFTOTAL _Py_REF_DEBUG_COMMA \ + --((PyObject*)(op))->ob_refcnt != 0) \ + _Py_CHECK_REFCNT(op) \ + else \ + _Py_Dealloc((PyObject *)(op)); \ + } while (0) + +/* Safely decref `op` and set `op` to NULL, especially useful in tp_clear + * and tp_dealloc implementatons. + * + * Note that "the obvious" code can be deadly: + * + * Py_XDECREF(op); + * op = NULL; + * + * Typically, `op` is something like self->containee, and `self` is done + * using its `containee` member. In the code sequence above, suppose + * `containee` is non-NULL with a refcount of 1. Its refcount falls to + * 0 on the first line, which can trigger an arbitrary amount of code, + * possibly including finalizers (like __del__ methods or weakref callbacks) + * coded in Python, which in turn can release the GIL and allow other threads + * to run, etc. Such code may even invoke methods of `self` again, or cause + * cyclic gc to trigger, but-- oops! --self->containee still points to the + * object being torn down, and it may be in an insane state while being torn + * down. This has in fact been a rich historic source of miserable (rare & + * hard-to-diagnose) segfaulting (and other) bugs. + * + * The safe way is: + * + * Py_CLEAR(op); + * + * That arranges to set `op` to NULL _before_ decref'ing, so that any code + * triggered as a side-effect of `op` getting torn down no longer believes + * `op` points to a valid object. + * + * There are cases where it's safe to use the naive code, but they're brittle. + * For example, if `op` points to a Python integer, you know that destroying + * one of those can't cause problems -- but in part that relies on that + * Python integers aren't currently weakly referencable. Best practice is + * to use Py_CLEAR() even if you can't think of a reason for why you need to. + */ +#define Py_CLEAR(op) \ + do { \ + if (op) { \ + PyObject *_py_tmp = (PyObject *)(op); \ + (op) = NULL; \ + Py_DECREF(_py_tmp); \ + } \ + } while (0) + +/* Macros to use in case the object pointer may be NULL: */ +#define Py_XINCREF(op) do { if ((op) == NULL) ; else Py_INCREF(op); } while (0) +#define Py_XDECREF(op) do { if ((op) == NULL) ; else Py_DECREF(op); } while (0) + +/* +These are provided as conveniences to Python runtime embedders, so that +they can have object code that is not dependent on Python compilation flags. +*/ +PyAPI_FUNC(void) Py_IncRef(PyObject *); +PyAPI_FUNC(void) Py_DecRef(PyObject *); + +/* +_Py_NoneStruct is an object of undefined type which can be used in contexts +where NULL (nil) is not suitable (since NULL often means 'error'). + +Don't forget to apply Py_INCREF() when returning this value!!! +*/ +PyAPI_DATA(PyObject) _Py_NoneStruct; /* Don't use this directly */ +#define Py_None (&_Py_NoneStruct) + +/* Macro for returning Py_None from a function */ +#define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None + +/* +Py_NotImplemented is a singleton used to signal that an operation is +not implemented for a given type combination. +*/ +PyAPI_DATA(PyObject) _Py_NotImplementedStruct; /* Don't use this directly */ +#define Py_NotImplemented (&_Py_NotImplementedStruct) + +/* Rich comparison opcodes */ +#define Py_LT 0 +#define Py_LE 1 +#define Py_EQ 2 +#define Py_NE 3 +#define Py_GT 4 +#define Py_GE 5 + +/* Maps Py_LT to Py_GT, ..., Py_GE to Py_LE. + * Defined in object.c. + */ +PyAPI_DATA(int) _Py_SwappedOp[]; + +/* +Define staticforward and statichere for source compatibility with old +C extensions. + +The staticforward define was needed to support certain broken C +compilers (notably SCO ODT 3.0, perhaps early AIX as well) botched the +static keyword when it was used with a forward declaration of a static +initialized structure. Standard C allows the forward declaration with +static, and we've decided to stop catering to broken C compilers. +(In fact, we expect that the compilers are all fixed eight years later.) +*/ + +#define staticforward static +#define statichere static + + +/* +More conventions +================ + +Argument Checking +----------------- + +Functions that take objects as arguments normally don't check for nil +arguments, but they do check the type of the argument, and return an +error if the function doesn't apply to the type. + +Failure Modes +------------- + +Functions may fail for a variety of reasons, including running out of +memory. This is communicated to the caller in two ways: an error string +is set (see errors.h), and the function result differs: functions that +normally return a pointer return NULL for failure, functions returning +an integer return -1 (which could be a legal return value too!), and +other functions return 0 for success and -1 for failure. +Callers should always check for errors before using the result. If +an error was set, the caller must either explicitly clear it, or pass +the error on to its caller. + +Reference Counts +---------------- + +It takes a while to get used to the proper usage of reference counts. + +Functions that create an object set the reference count to 1; such new +objects must be stored somewhere or destroyed again with Py_DECREF(). +Some functions that 'store' objects, such as PyTuple_SetItem() and +PyList_SetItem(), +don't increment the reference count of the object, since the most +frequent use is to store a fresh object. Functions that 'retrieve' +objects, such as PyTuple_GetItem() and PyDict_GetItemString(), also +don't increment +the reference count, since most frequently the object is only looked at +quickly. Thus, to retrieve an object and store it again, the caller +must call Py_INCREF() explicitly. + +NOTE: functions that 'consume' a reference count, like +PyList_SetItem(), consume the reference even if the object wasn't +successfully stored, to simplify error handling. + +It seems attractive to make other functions that take an object as +argument consume a reference count; however, this may quickly get +confusing (even the current practice is already confusing). Consider +it carefully, it may save lots of calls to Py_INCREF() and Py_DECREF() at +times. +*/ + + +/* Trashcan mechanism, thanks to Christian Tismer. + +When deallocating a container object, it's possible to trigger an unbounded +chain of deallocations, as each Py_DECREF in turn drops the refcount on "the +next" object in the chain to 0. This can easily lead to stack faults, and +especially in threads (which typically have less stack space to work with). + +A container object that participates in cyclic gc can avoid this by +bracketing the body of its tp_dealloc function with a pair of macros: + +static void +mytype_dealloc(mytype *p) +{ + ... declarations go here ... + + PyObject_GC_UnTrack(p); // must untrack first + Py_TRASHCAN_SAFE_BEGIN(p) + ... The body of the deallocator goes here, including all calls ... + ... to Py_DECREF on contained objects. ... + Py_TRASHCAN_SAFE_END(p) +} + +CAUTION: Never return from the middle of the body! If the body needs to +"get out early", put a label immediately before the Py_TRASHCAN_SAFE_END +call, and goto it. Else the call-depth counter (see below) will stay +above 0 forever, and the trashcan will never get emptied. + +How it works: The BEGIN macro increments a call-depth counter. So long +as this counter is small, the body of the deallocator is run directly without +further ado. But if the counter gets large, it instead adds p to a list of +objects to be deallocated later, skips the body of the deallocator, and +resumes execution after the END macro. The tp_dealloc routine then returns +without deallocating anything (and so unbounded call-stack depth is avoided). + +When the call stack finishes unwinding again, code generated by the END macro +notices this, and calls another routine to deallocate all the objects that +may have been added to the list of deferred deallocations. In effect, a +chain of N deallocations is broken into N / PyTrash_UNWIND_LEVEL pieces, +with the call stack never exceeding a depth of PyTrash_UNWIND_LEVEL. +*/ + +/* This is the old private API, invoked by the macros before 2.7.4. + Kept for binary compatibility of extensions. */ +PyAPI_FUNC(void) _PyTrash_deposit_object(PyObject*); +PyAPI_FUNC(void) _PyTrash_destroy_chain(void); +PyAPI_DATA(int) _PyTrash_delete_nesting; +PyAPI_DATA(PyObject *) _PyTrash_delete_later; + +/* The new thread-safe private API, invoked by the macros below. */ +PyAPI_FUNC(void) _PyTrash_thread_deposit_object(PyObject*); +PyAPI_FUNC(void) _PyTrash_thread_destroy_chain(void); + +#define PyTrash_UNWIND_LEVEL 50 + +/* Note the workaround for when the thread state is NULL (issue #17703) */ +#define Py_TRASHCAN_SAFE_BEGIN(op) \ + do { \ + PyThreadState *_tstate = PyThreadState_GET(); \ + if (!_tstate || \ + _tstate->trash_delete_nesting < PyTrash_UNWIND_LEVEL) { \ + if (_tstate) \ + ++_tstate->trash_delete_nesting; + /* The body of the deallocator is here. */ +#define Py_TRASHCAN_SAFE_END(op) \ + if (_tstate) { \ + --_tstate->trash_delete_nesting; \ + if (_tstate->trash_delete_later \ + && _tstate->trash_delete_nesting <= 0) \ + _PyTrash_thread_destroy_chain(); \ + } \ + } \ + else \ + _PyTrash_thread_deposit_object((PyObject*)op); \ + } while (0); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_OBJECT_H */ diff --git a/android/python27/include/objimpl.h b/android/python27/include/objimpl.h new file mode 100644 index 000000000..55e83eced --- /dev/null +++ b/android/python27/include/objimpl.h @@ -0,0 +1,354 @@ +/* The PyObject_ memory family: high-level object memory interfaces. + See pymem.h for the low-level PyMem_ family. +*/ + +#ifndef Py_OBJIMPL_H +#define Py_OBJIMPL_H + +#include "pymem.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* BEWARE: + + Each interface exports both functions and macros. Extension modules should + use the functions, to ensure binary compatibility across Python versions. + Because the Python implementation is free to change internal details, and + the macros may (or may not) expose details for speed, if you do use the + macros you must recompile your extensions with each Python release. + + Never mix calls to PyObject_ memory functions with calls to the platform + malloc/realloc/ calloc/free, or with calls to PyMem_. +*/ + +/* +Functions and macros for modules that implement new object types. + + - PyObject_New(type, typeobj) allocates memory for a new object of the given + type, and initializes part of it. 'type' must be the C structure type used + to represent the object, and 'typeobj' the address of the corresponding + type object. Reference count and type pointer are filled in; the rest of + the bytes of the object are *undefined*! The resulting expression type is + 'type *'. The size of the object is determined by the tp_basicsize field + of the type object. + + - PyObject_NewVar(type, typeobj, n) is similar but allocates a variable-size + object with room for n items. In addition to the refcount and type pointer + fields, this also fills in the ob_size field. + + - PyObject_Del(op) releases the memory allocated for an object. It does not + run a destructor -- it only frees the memory. PyObject_Free is identical. + + - PyObject_Init(op, typeobj) and PyObject_InitVar(op, typeobj, n) don't + allocate memory. Instead of a 'type' parameter, they take a pointer to a + new object (allocated by an arbitrary allocator), and initialize its object + header fields. + +Note that objects created with PyObject_{New, NewVar} are allocated using the +specialized Python allocator (implemented in obmalloc.c), if WITH_PYMALLOC is +enabled. In addition, a special debugging allocator is used if PYMALLOC_DEBUG +is also #defined. + +In case a specific form of memory management is needed (for example, if you +must use the platform malloc heap(s), or shared memory, or C++ local storage or +operator new), you must first allocate the object with your custom allocator, +then pass its pointer to PyObject_{Init, InitVar} for filling in its Python- +specific fields: reference count, type pointer, possibly others. You should +be aware that Python no control over these objects because they don't +cooperate with the Python memory manager. Such objects may not be eligible +for automatic garbage collection and you have to make sure that they are +released accordingly whenever their destructor gets called (cf. the specific +form of memory management you're using). + +Unless you have specific memory management requirements, use +PyObject_{New, NewVar, Del}. +*/ + +/* + * Raw object memory interface + * =========================== + */ + +/* Functions to call the same malloc/realloc/free as used by Python's + object allocator. If WITH_PYMALLOC is enabled, these may differ from + the platform malloc/realloc/free. The Python object allocator is + designed for fast, cache-conscious allocation of many "small" objects, + and with low hidden memory overhead. + + PyObject_Malloc(0) returns a unique non-NULL pointer if possible. + + PyObject_Realloc(NULL, n) acts like PyObject_Malloc(n). + PyObject_Realloc(p != NULL, 0) does not return NULL, or free the memory + at p. + + Returned pointers must be checked for NULL explicitly; no action is + performed on failure other than to return NULL (no warning it printed, no + exception is set, etc). + + For allocating objects, use PyObject_{New, NewVar} instead whenever + possible. The PyObject_{Malloc, Realloc, Free} family is exposed + so that you can exploit Python's small-block allocator for non-object + uses. If you must use these routines to allocate object memory, make sure + the object gets initialized via PyObject_{Init, InitVar} after obtaining + the raw memory. +*/ +PyAPI_FUNC(void *) PyObject_Malloc(size_t); +PyAPI_FUNC(void *) PyObject_Realloc(void *, size_t); +PyAPI_FUNC(void) PyObject_Free(void *); + + +/* Macros */ +#ifdef WITH_PYMALLOC +#ifdef PYMALLOC_DEBUG /* WITH_PYMALLOC && PYMALLOC_DEBUG */ +PyAPI_FUNC(void *) _PyObject_DebugMalloc(size_t nbytes); +PyAPI_FUNC(void *) _PyObject_DebugRealloc(void *p, size_t nbytes); +PyAPI_FUNC(void) _PyObject_DebugFree(void *p); +PyAPI_FUNC(void) _PyObject_DebugDumpAddress(const void *p); +PyAPI_FUNC(void) _PyObject_DebugCheckAddress(const void *p); +PyAPI_FUNC(void) _PyObject_DebugMallocStats(void); +PyAPI_FUNC(void *) _PyObject_DebugMallocApi(char api, size_t nbytes); +PyAPI_FUNC(void *) _PyObject_DebugReallocApi(char api, void *p, size_t nbytes); +PyAPI_FUNC(void) _PyObject_DebugFreeApi(char api, void *p); +PyAPI_FUNC(void) _PyObject_DebugCheckAddressApi(char api, const void *p); +PyAPI_FUNC(void *) _PyMem_DebugMalloc(size_t nbytes); +PyAPI_FUNC(void *) _PyMem_DebugRealloc(void *p, size_t nbytes); +PyAPI_FUNC(void) _PyMem_DebugFree(void *p); +#define PyObject_MALLOC _PyObject_DebugMalloc +#define PyObject_Malloc _PyObject_DebugMalloc +#define PyObject_REALLOC _PyObject_DebugRealloc +#define PyObject_Realloc _PyObject_DebugRealloc +#define PyObject_FREE _PyObject_DebugFree +#define PyObject_Free _PyObject_DebugFree + +#else /* WITH_PYMALLOC && ! PYMALLOC_DEBUG */ +#define PyObject_MALLOC PyObject_Malloc +#define PyObject_REALLOC PyObject_Realloc +#define PyObject_FREE PyObject_Free +#endif + +#else /* ! WITH_PYMALLOC */ +#define PyObject_MALLOC PyMem_MALLOC +#define PyObject_REALLOC PyMem_REALLOC +#define PyObject_FREE PyMem_FREE + +#endif /* WITH_PYMALLOC */ + +#define PyObject_Del PyObject_Free +#define PyObject_DEL PyObject_FREE + +/* for source compatibility with 2.2 */ +#define _PyObject_Del PyObject_Free + +/* + * Generic object allocator interface + * ================================== + */ + +/* Functions */ +PyAPI_FUNC(PyObject *) PyObject_Init(PyObject *, PyTypeObject *); +PyAPI_FUNC(PyVarObject *) PyObject_InitVar(PyVarObject *, + PyTypeObject *, Py_ssize_t); +PyAPI_FUNC(PyObject *) _PyObject_New(PyTypeObject *); +PyAPI_FUNC(PyVarObject *) _PyObject_NewVar(PyTypeObject *, Py_ssize_t); + +#define PyObject_New(type, typeobj) \ + ( (type *) _PyObject_New(typeobj) ) +#define PyObject_NewVar(type, typeobj, n) \ + ( (type *) _PyObject_NewVar((typeobj), (n)) ) + +/* Macros trading binary compatibility for speed. See also pymem.h. + Note that these macros expect non-NULL object pointers.*/ +#define PyObject_INIT(op, typeobj) \ + ( Py_TYPE(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) ) +#define PyObject_INIT_VAR(op, typeobj, size) \ + ( Py_SIZE(op) = (size), PyObject_INIT((op), (typeobj)) ) + +#define _PyObject_SIZE(typeobj) ( (typeobj)->tp_basicsize ) + +/* _PyObject_VAR_SIZE returns the number of bytes (as size_t) allocated for a + vrbl-size object with nitems items, exclusive of gc overhead (if any). The + value is rounded up to the closest multiple of sizeof(void *), in order to + ensure that pointer fields at the end of the object are correctly aligned + for the platform (this is of special importance for subclasses of, e.g., + str or long, so that pointers can be stored after the embedded data). + + Note that there's no memory wastage in doing this, as malloc has to + return (at worst) pointer-aligned memory anyway. +*/ +#if ((SIZEOF_VOID_P - 1) & SIZEOF_VOID_P) != 0 +# error "_PyObject_VAR_SIZE requires SIZEOF_VOID_P be a power of 2" +#endif + +#define _PyObject_VAR_SIZE(typeobj, nitems) \ + (size_t) \ + ( ( (typeobj)->tp_basicsize + \ + (nitems)*(typeobj)->tp_itemsize + \ + (SIZEOF_VOID_P - 1) \ + ) & ~(SIZEOF_VOID_P - 1) \ + ) + +#define PyObject_NEW(type, typeobj) \ +( (type *) PyObject_Init( \ + (PyObject *) PyObject_MALLOC( _PyObject_SIZE(typeobj) ), (typeobj)) ) + +#define PyObject_NEW_VAR(type, typeobj, n) \ +( (type *) PyObject_InitVar( \ + (PyVarObject *) PyObject_MALLOC(_PyObject_VAR_SIZE((typeobj),(n)) ),\ + (typeobj), (n)) ) + +/* This example code implements an object constructor with a custom + allocator, where PyObject_New is inlined, and shows the important + distinction between two steps (at least): + 1) the actual allocation of the object storage; + 2) the initialization of the Python specific fields + in this storage with PyObject_{Init, InitVar}. + + PyObject * + YourObject_New(...) + { + PyObject *op; + + op = (PyObject *) Your_Allocator(_PyObject_SIZE(YourTypeStruct)); + if (op == NULL) + return PyErr_NoMemory(); + + PyObject_Init(op, &YourTypeStruct); + + op->ob_field = value; + ... + return op; + } + + Note that in C++, the use of the new operator usually implies that + the 1st step is performed automatically for you, so in a C++ class + constructor you would start directly with PyObject_Init/InitVar +*/ + +/* + * Garbage Collection Support + * ========================== + */ + +/* C equivalent of gc.collect(). */ +PyAPI_FUNC(Py_ssize_t) PyGC_Collect(void); + +/* Test if a type has a GC head */ +#define PyType_IS_GC(t) PyType_HasFeature((t), Py_TPFLAGS_HAVE_GC) + +/* Test if an object has a GC head */ +#define PyObject_IS_GC(o) (PyType_IS_GC(Py_TYPE(o)) && \ + (Py_TYPE(o)->tp_is_gc == NULL || Py_TYPE(o)->tp_is_gc(o))) + +PyAPI_FUNC(PyVarObject *) _PyObject_GC_Resize(PyVarObject *, Py_ssize_t); +#define PyObject_GC_Resize(type, op, n) \ + ( (type *) _PyObject_GC_Resize((PyVarObject *)(op), (n)) ) + +/* for source compatibility with 2.2 */ +#define _PyObject_GC_Del PyObject_GC_Del + +/* GC information is stored BEFORE the object structure. */ +typedef union _gc_head { + struct { + union _gc_head *gc_next; + union _gc_head *gc_prev; + Py_ssize_t gc_refs; + } gc; + long double dummy; /* force worst-case alignment */ +} PyGC_Head; + +extern PyGC_Head *_PyGC_generation0; + +#define _Py_AS_GC(o) ((PyGC_Head *)(o)-1) + +#define _PyGC_REFS_UNTRACKED (-2) +#define _PyGC_REFS_REACHABLE (-3) +#define _PyGC_REFS_TENTATIVELY_UNREACHABLE (-4) + +/* Tell the GC to track this object. NB: While the object is tracked the + * collector it must be safe to call the ob_traverse method. */ +#define _PyObject_GC_TRACK(o) do { \ + PyGC_Head *g = _Py_AS_GC(o); \ + if (g->gc.gc_refs != _PyGC_REFS_UNTRACKED) \ + Py_FatalError("GC object already tracked"); \ + g->gc.gc_refs = _PyGC_REFS_REACHABLE; \ + g->gc.gc_next = _PyGC_generation0; \ + g->gc.gc_prev = _PyGC_generation0->gc.gc_prev; \ + g->gc.gc_prev->gc.gc_next = g; \ + _PyGC_generation0->gc.gc_prev = g; \ + } while (0); + +/* Tell the GC to stop tracking this object. + * gc_next doesn't need to be set to NULL, but doing so is a good + * way to provoke memory errors if calling code is confused. + */ +#define _PyObject_GC_UNTRACK(o) do { \ + PyGC_Head *g = _Py_AS_GC(o); \ + assert(g->gc.gc_refs != _PyGC_REFS_UNTRACKED); \ + g->gc.gc_refs = _PyGC_REFS_UNTRACKED; \ + g->gc.gc_prev->gc.gc_next = g->gc.gc_next; \ + g->gc.gc_next->gc.gc_prev = g->gc.gc_prev; \ + g->gc.gc_next = NULL; \ + } while (0); + +/* True if the object is currently tracked by the GC. */ +#define _PyObject_GC_IS_TRACKED(o) \ + ((_Py_AS_GC(o))->gc.gc_refs != _PyGC_REFS_UNTRACKED) + +/* True if the object may be tracked by the GC in the future, or already is. + This can be useful to implement some optimizations. */ +#define _PyObject_GC_MAY_BE_TRACKED(obj) \ + (PyObject_IS_GC(obj) && \ + (!PyTuple_CheckExact(obj) || _PyObject_GC_IS_TRACKED(obj))) + + +PyAPI_FUNC(PyObject *) _PyObject_GC_Malloc(size_t); +PyAPI_FUNC(PyObject *) _PyObject_GC_New(PyTypeObject *); +PyAPI_FUNC(PyVarObject *) _PyObject_GC_NewVar(PyTypeObject *, Py_ssize_t); +PyAPI_FUNC(void) PyObject_GC_Track(void *); +PyAPI_FUNC(void) PyObject_GC_UnTrack(void *); +PyAPI_FUNC(void) PyObject_GC_Del(void *); + +#define PyObject_GC_New(type, typeobj) \ + ( (type *) _PyObject_GC_New(typeobj) ) +#define PyObject_GC_NewVar(type, typeobj, n) \ + ( (type *) _PyObject_GC_NewVar((typeobj), (n)) ) + + +/* Utility macro to help write tp_traverse functions. + * To use this macro, the tp_traverse function must name its arguments + * "visit" and "arg". This is intended to keep tp_traverse functions + * looking as much alike as possible. + */ +#define Py_VISIT(op) \ + do { \ + if (op) { \ + int vret = visit((PyObject *)(op), arg); \ + if (vret) \ + return vret; \ + } \ + } while (0) + +/* This is here for the sake of backwards compatibility. Extensions that + * use the old GC API will still compile but the objects will not be + * tracked by the GC. */ +#define PyGC_HEAD_SIZE 0 +#define PyObject_GC_Init(op) +#define PyObject_GC_Fini(op) +#define PyObject_AS_GC(op) (op) +#define PyObject_FROM_GC(op) (op) + + +/* Test if a type supports weak references */ +#define PyType_SUPPORTS_WEAKREFS(t) \ + (PyType_HasFeature((t), Py_TPFLAGS_HAVE_WEAKREFS) \ + && ((t)->tp_weaklistoffset > 0)) + +#define PyObject_GET_WEAKREFS_LISTPTR(o) \ + ((PyObject **) (((char *) (o)) + Py_TYPE(o)->tp_weaklistoffset)) + +#ifdef __cplusplus +} +#endif +#endif /* !Py_OBJIMPL_H */ diff --git a/android/python27/include/opcode.h b/android/python27/include/opcode.h new file mode 100644 index 000000000..9764109ad --- /dev/null +++ b/android/python27/include/opcode.h @@ -0,0 +1,162 @@ +#ifndef Py_OPCODE_H +#define Py_OPCODE_H +#ifdef __cplusplus +extern "C" { +#endif + + +/* Instruction opcodes for compiled code */ + +#define STOP_CODE 0 +#define POP_TOP 1 +#define ROT_TWO 2 +#define ROT_THREE 3 +#define DUP_TOP 4 +#define ROT_FOUR 5 +#define NOP 9 + +#define UNARY_POSITIVE 10 +#define UNARY_NEGATIVE 11 +#define UNARY_NOT 12 +#define UNARY_CONVERT 13 + +#define UNARY_INVERT 15 + +#define BINARY_POWER 19 + +#define BINARY_MULTIPLY 20 +#define BINARY_DIVIDE 21 +#define BINARY_MODULO 22 +#define BINARY_ADD 23 +#define BINARY_SUBTRACT 24 +#define BINARY_SUBSCR 25 +#define BINARY_FLOOR_DIVIDE 26 +#define BINARY_TRUE_DIVIDE 27 +#define INPLACE_FLOOR_DIVIDE 28 +#define INPLACE_TRUE_DIVIDE 29 + +#define SLICE 30 +/* Also uses 31-33 */ + +#define STORE_SLICE 40 +/* Also uses 41-43 */ + +#define DELETE_SLICE 50 +/* Also uses 51-53 */ + +#define STORE_MAP 54 +#define INPLACE_ADD 55 +#define INPLACE_SUBTRACT 56 +#define INPLACE_MULTIPLY 57 +#define INPLACE_DIVIDE 58 +#define INPLACE_MODULO 59 +#define STORE_SUBSCR 60 +#define DELETE_SUBSCR 61 + +#define BINARY_LSHIFT 62 +#define BINARY_RSHIFT 63 +#define BINARY_AND 64 +#define BINARY_XOR 65 +#define BINARY_OR 66 +#define INPLACE_POWER 67 +#define GET_ITER 68 + +#define PRINT_EXPR 70 +#define PRINT_ITEM 71 +#define PRINT_NEWLINE 72 +#define PRINT_ITEM_TO 73 +#define PRINT_NEWLINE_TO 74 +#define INPLACE_LSHIFT 75 +#define INPLACE_RSHIFT 76 +#define INPLACE_AND 77 +#define INPLACE_XOR 78 +#define INPLACE_OR 79 +#define BREAK_LOOP 80 +#define WITH_CLEANUP 81 +#define LOAD_LOCALS 82 +#define RETURN_VALUE 83 +#define IMPORT_STAR 84 +#define EXEC_STMT 85 +#define YIELD_VALUE 86 +#define POP_BLOCK 87 +#define END_FINALLY 88 +#define BUILD_CLASS 89 + +#define HAVE_ARGUMENT 90 /* Opcodes from here have an argument: */ + +#define STORE_NAME 90 /* Index in name list */ +#define DELETE_NAME 91 /* "" */ +#define UNPACK_SEQUENCE 92 /* Number of sequence items */ +#define FOR_ITER 93 +#define LIST_APPEND 94 + +#define STORE_ATTR 95 /* Index in name list */ +#define DELETE_ATTR 96 /* "" */ +#define STORE_GLOBAL 97 /* "" */ +#define DELETE_GLOBAL 98 /* "" */ +#define DUP_TOPX 99 /* number of items to duplicate */ +#define LOAD_CONST 100 /* Index in const list */ +#define LOAD_NAME 101 /* Index in name list */ +#define BUILD_TUPLE 102 /* Number of tuple items */ +#define BUILD_LIST 103 /* Number of list items */ +#define BUILD_SET 104 /* Number of set items */ +#define BUILD_MAP 105 /* Always zero for now */ +#define LOAD_ATTR 106 /* Index in name list */ +#define COMPARE_OP 107 /* Comparison operator */ +#define IMPORT_NAME 108 /* Index in name list */ +#define IMPORT_FROM 109 /* Index in name list */ +#define JUMP_FORWARD 110 /* Number of bytes to skip */ + +#define JUMP_IF_FALSE_OR_POP 111 /* Target byte offset from beginning + of code */ +#define JUMP_IF_TRUE_OR_POP 112 /* "" */ +#define JUMP_ABSOLUTE 113 /* "" */ +#define POP_JUMP_IF_FALSE 114 /* "" */ +#define POP_JUMP_IF_TRUE 115 /* "" */ + +#define LOAD_GLOBAL 116 /* Index in name list */ + +#define CONTINUE_LOOP 119 /* Start of loop (absolute) */ +#define SETUP_LOOP 120 /* Target address (relative) */ +#define SETUP_EXCEPT 121 /* "" */ +#define SETUP_FINALLY 122 /* "" */ + +#define LOAD_FAST 124 /* Local variable number */ +#define STORE_FAST 125 /* Local variable number */ +#define DELETE_FAST 126 /* Local variable number */ + +#define RAISE_VARARGS 130 /* Number of raise arguments (1, 2 or 3) */ +/* CALL_FUNCTION_XXX opcodes defined below depend on this definition */ +#define CALL_FUNCTION 131 /* #args + (#kwargs<<8) */ +#define MAKE_FUNCTION 132 /* #defaults */ +#define BUILD_SLICE 133 /* Number of items */ + +#define MAKE_CLOSURE 134 /* #free vars */ +#define LOAD_CLOSURE 135 /* Load free variable from closure */ +#define LOAD_DEREF 136 /* Load and dereference from closure cell */ +#define STORE_DEREF 137 /* Store into cell */ + +/* The next 3 opcodes must be contiguous and satisfy + (CALL_FUNCTION_VAR - CALL_FUNCTION) & 3 == 1 */ +#define CALL_FUNCTION_VAR 140 /* #args + (#kwargs<<8) */ +#define CALL_FUNCTION_KW 141 /* #args + (#kwargs<<8) */ +#define CALL_FUNCTION_VAR_KW 142 /* #args + (#kwargs<<8) */ + +#define SETUP_WITH 143 + +/* Support for opargs more than 16 bits long */ +#define EXTENDED_ARG 145 + +#define SET_ADD 146 +#define MAP_ADD 147 + + +enum cmp_op {PyCmp_LT=Py_LT, PyCmp_LE=Py_LE, PyCmp_EQ=Py_EQ, PyCmp_NE=Py_NE, PyCmp_GT=Py_GT, PyCmp_GE=Py_GE, + PyCmp_IN, PyCmp_NOT_IN, PyCmp_IS, PyCmp_IS_NOT, PyCmp_EXC_MATCH, PyCmp_BAD}; + +#define HAS_ARG(op) ((op) >= HAVE_ARGUMENT) + +#ifdef __cplusplus +} +#endif +#endif /* !Py_OPCODE_H */ diff --git a/android/python27/include/osdefs.h b/android/python27/include/osdefs.h new file mode 100644 index 000000000..77af92375 --- /dev/null +++ b/android/python27/include/osdefs.h @@ -0,0 +1,63 @@ +#ifndef Py_OSDEFS_H +#define Py_OSDEFS_H +#ifdef __cplusplus +extern "C" { +#endif + + +/* Operating system dependencies */ + +/* Mod by chrish: QNX has WATCOM, but isn't DOS */ +#if !defined(__QNX__) +#if defined(MS_WINDOWS) || defined(__BORLANDC__) || defined(__WATCOMC__) || defined(__DJGPP__) || defined(PYOS_OS2) +#if defined(PYOS_OS2) && defined(PYCC_GCC) +#define MAXPATHLEN 260 +#define SEP '/' +#define ALTSEP '\\' +#else +#define SEP '\\' +#define ALTSEP '/' +#define MAXPATHLEN 256 +#endif +#define DELIM ';' +#endif +#endif + +#ifdef RISCOS +#define SEP '.' +#define MAXPATHLEN 256 +#define DELIM ',' +#endif + + +/* Filename separator */ +#ifndef SEP +#define SEP '/' +#endif + +/* Max pathname length */ +#ifdef __hpux +#include +#include +#ifndef PATH_MAX +#define PATH_MAX MAXPATHLEN +#endif +#endif + +#ifndef MAXPATHLEN +#if defined(PATH_MAX) && PATH_MAX > 1024 +#define MAXPATHLEN PATH_MAX +#else +#define MAXPATHLEN 1024 +#endif +#endif + +/* Search path entry delimiter */ +#ifndef DELIM +#define DELIM ':' +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_OSDEFS_H */ diff --git a/android/python27/include/parsetok.h b/android/python27/include/parsetok.h new file mode 100644 index 000000000..ec1eb6ff7 --- /dev/null +++ b/android/python27/include/parsetok.h @@ -0,0 +1,64 @@ + +/* Parser-tokenizer link interface */ + +#ifndef Py_PARSETOK_H +#define Py_PARSETOK_H +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + int error; + const char *filename; + int lineno; + int offset; + char *text; + int token; + int expected; +} perrdetail; + +#if 0 +#define PyPARSE_YIELD_IS_KEYWORD 0x0001 +#endif + +#define PyPARSE_DONT_IMPLY_DEDENT 0x0002 + +#if 0 +#define PyPARSE_WITH_IS_KEYWORD 0x0003 +#endif + +#define PyPARSE_PRINT_IS_FUNCTION 0x0004 +#define PyPARSE_UNICODE_LITERALS 0x0008 + + + +PyAPI_FUNC(node *) PyParser_ParseString(const char *, grammar *, int, + perrdetail *); +PyAPI_FUNC(node *) PyParser_ParseFile (FILE *, const char *, grammar *, int, + char *, char *, perrdetail *); + +PyAPI_FUNC(node *) PyParser_ParseStringFlags(const char *, grammar *, int, + perrdetail *, int); +PyAPI_FUNC(node *) PyParser_ParseFileFlags(FILE *, const char *, grammar *, + int, char *, char *, + perrdetail *, int); +PyAPI_FUNC(node *) PyParser_ParseFileFlagsEx(FILE *, const char *, grammar *, + int, char *, char *, + perrdetail *, int *); + +PyAPI_FUNC(node *) PyParser_ParseStringFlagsFilename(const char *, + const char *, + grammar *, int, + perrdetail *, int); +PyAPI_FUNC(node *) PyParser_ParseStringFlagsFilenameEx(const char *, + const char *, + grammar *, int, + perrdetail *, int *); + +/* Note that he following function is defined in pythonrun.c not parsetok.c. */ +PyAPI_FUNC(void) PyParser_SetError(perrdetail *); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_PARSETOK_H */ diff --git a/android/python27/include/patchlevel.h b/android/python27/include/patchlevel.h new file mode 100644 index 000000000..a71efde61 --- /dev/null +++ b/android/python27/include/patchlevel.h @@ -0,0 +1,43 @@ + +/* Newfangled version identification scheme. + + This scheme was added in Python 1.5.2b2; before that time, only PATCHLEVEL + was available. To test for presence of the scheme, test for + defined(PY_MAJOR_VERSION). + + When the major or minor version changes, the VERSION variable in + configure.ac must also be changed. + + There is also (independent) API version information in modsupport.h. +*/ + +/* Values for PY_RELEASE_LEVEL */ +#define PY_RELEASE_LEVEL_ALPHA 0xA +#define PY_RELEASE_LEVEL_BETA 0xB +#define PY_RELEASE_LEVEL_GAMMA 0xC /* For release candidates */ +#define PY_RELEASE_LEVEL_FINAL 0xF /* Serial should be 0 here */ + /* Higher for patch releases */ + +/* Version parsed out into numeric values */ +/*--start constants--*/ +#define PY_MAJOR_VERSION 2 +#define PY_MINOR_VERSION 7 +#define PY_MICRO_VERSION 10 +#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_FINAL +#define PY_RELEASE_SERIAL 0 + +/* Version as a string */ +#define PY_VERSION "2.7.10" +/*--end constants--*/ + +/* Subversion Revision number of this file (not of the repository). Empty + since Mercurial migration. */ +#define PY_PATCHLEVEL_REVISION "" + +/* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2. + Use this for numeric comparisons, e.g. #if PY_VERSION_HEX >= ... */ +#define PY_VERSION_HEX ((PY_MAJOR_VERSION << 24) | \ + (PY_MINOR_VERSION << 16) | \ + (PY_MICRO_VERSION << 8) | \ + (PY_RELEASE_LEVEL << 4) | \ + (PY_RELEASE_SERIAL << 0)) diff --git a/android/python27/include/pgen.h b/android/python27/include/pgen.h new file mode 100644 index 000000000..8a325ed07 --- /dev/null +++ b/android/python27/include/pgen.h @@ -0,0 +1,18 @@ +#ifndef Py_PGEN_H +#define Py_PGEN_H +#ifdef __cplusplus +extern "C" { +#endif + + +/* Parser generator interface */ + +extern grammar *meta_grammar(void); + +struct _node; +extern grammar *pgen(struct _node *); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_PGEN_H */ diff --git a/android/python27/include/pgenheaders.h b/android/python27/include/pgenheaders.h new file mode 100644 index 000000000..2049ae32b --- /dev/null +++ b/android/python27/include/pgenheaders.h @@ -0,0 +1,42 @@ +#ifndef Py_PGENHEADERS_H +#define Py_PGENHEADERS_H +#ifdef __cplusplus +extern "C" { +#endif + + +/* Include files and extern declarations used by most of the parser. */ + +#include "Python.h" + +PyAPI_FUNC(void) PySys_WriteStdout(const char *format, ...) + Py_GCC_ATTRIBUTE((format(printf, 1, 2))); +PyAPI_FUNC(void) PySys_WriteStderr(const char *format, ...) + Py_GCC_ATTRIBUTE((format(printf, 1, 2))); + +#define addarc _Py_addarc +#define addbit _Py_addbit +#define adddfa _Py_adddfa +#define addfirstsets _Py_addfirstsets +#define addlabel _Py_addlabel +#define addstate _Py_addstate +#define delbitset _Py_delbitset +#define dumptree _Py_dumptree +#define findlabel _Py_findlabel +#define mergebitset _Py_mergebitset +#define meta_grammar _Py_meta_grammar +#define newbitset _Py_newbitset +#define newgrammar _Py_newgrammar +#define pgen _Py_pgen +#define printgrammar _Py_printgrammar +#define printnonterminals _Py_printnonterminals +#define printtree _Py_printtree +#define samebitset _Py_samebitset +#define showtree _Py_showtree +#define tok_dump _Py_tok_dump +#define translatelabels _Py_translatelabels + +#ifdef __cplusplus +} +#endif +#endif /* !Py_PGENHEADERS_H */ diff --git a/android/python27/include/py_curses.h b/android/python27/include/py_curses.h new file mode 100644 index 000000000..657816cbd --- /dev/null +++ b/android/python27/include/py_curses.h @@ -0,0 +1,176 @@ + +#ifndef Py_CURSES_H +#define Py_CURSES_H + +#ifdef __APPLE__ +/* +** On Mac OS X 10.2 [n]curses.h and stdlib.h use different guards +** against multiple definition of wchar_t. +*/ +#ifdef _BSD_WCHAR_T_DEFINED_ +#define _WCHAR_T +#endif + +/* the following define is necessary for OS X 10.6; without it, the + Apple-supplied ncurses.h sets NCURSES_OPAQUE to 1, and then Python + can't get at the WINDOW flags field. */ +#define NCURSES_OPAQUE 0 +#endif /* __APPLE__ */ + +#ifdef __FreeBSD__ +/* +** On FreeBSD, [n]curses.h and stdlib.h/wchar.h use different guards +** against multiple definition of wchar_t and wint_t. +*/ +#ifdef _XOPEN_SOURCE_EXTENDED +#ifndef __FreeBSD_version +#include +#endif +#if __FreeBSD_version >= 500000 +#ifndef __wchar_t +#define __wchar_t +#endif +#ifndef __wint_t +#define __wint_t +#endif +#else +#ifndef _WCHAR_T +#define _WCHAR_T +#endif +#ifndef _WINT_T +#define _WINT_T +#endif +#endif +#endif +#endif + +#ifdef HAVE_NCURSES_H +#include +#else +#include +#ifdef HAVE_TERM_H +/* for tigetstr, which is not declared in SysV curses */ +#include +#endif +#endif + +#ifdef HAVE_NCURSES_H +/* configure was checking , but we will + use , which has all these features. */ +#ifndef WINDOW_HAS_FLAGS +#define WINDOW_HAS_FLAGS 1 +#endif +#ifndef MVWDELCH_IS_EXPRESSION +#define MVWDELCH_IS_EXPRESSION 1 +#endif +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#define PyCurses_API_pointers 4 + +/* Type declarations */ + +typedef struct { + PyObject_HEAD + WINDOW *win; +} PyCursesWindowObject; + +#define PyCursesWindow_Check(v) (Py_TYPE(v) == &PyCursesWindow_Type) + +#define PyCurses_CAPSULE_NAME "_curses._C_API" + + +#ifdef CURSES_MODULE +/* This section is used when compiling _cursesmodule.c */ + +#else +/* This section is used in modules that use the _cursesmodule API */ + +static void **PyCurses_API; + +#define PyCursesWindow_Type (*(PyTypeObject *) PyCurses_API[0]) +#define PyCursesSetupTermCalled {if (! ((int (*)(void))PyCurses_API[1]) () ) return NULL;} +#define PyCursesInitialised {if (! ((int (*)(void))PyCurses_API[2]) () ) return NULL;} +#define PyCursesInitialisedColor {if (! ((int (*)(void))PyCurses_API[3]) () ) return NULL;} + +#define import_curses() \ + PyCurses_API = (void **)PyCapsule_Import(PyCurses_CAPSULE_NAME, 1); + +#endif + +/* general error messages */ +static char *catchall_ERR = "curses function returned ERR"; +static char *catchall_NULL = "curses function returned NULL"; + +/* Function Prototype Macros - They are ugly but very, very useful. ;-) + + X - function name + TYPE - parameter Type + ERGSTR - format string for construction of the return value + PARSESTR - format string for argument parsing + */ + +#define NoArgNoReturnFunction(X) \ +static PyObject *PyCurses_ ## X (PyObject *self) \ +{ \ + PyCursesInitialised \ + return PyCursesCheckERR(X(), # X); } + +#define NoArgOrFlagNoReturnFunction(X) \ +static PyObject *PyCurses_ ## X (PyObject *self, PyObject *args) \ +{ \ + int flag = 0; \ + PyCursesInitialised \ + switch(PyTuple_Size(args)) { \ + case 0: \ + return PyCursesCheckERR(X(), # X); \ + case 1: \ + if (!PyArg_ParseTuple(args, "i;True(1) or False(0)", &flag)) return NULL; \ + if (flag) return PyCursesCheckERR(X(), # X); \ + else return PyCursesCheckERR(no ## X (), # X); \ + default: \ + PyErr_SetString(PyExc_TypeError, # X " requires 0 or 1 arguments"); \ + return NULL; } } + +#define NoArgReturnIntFunction(X) \ +static PyObject *PyCurses_ ## X (PyObject *self) \ +{ \ + PyCursesInitialised \ + return PyInt_FromLong((long) X()); } + + +#define NoArgReturnStringFunction(X) \ +static PyObject *PyCurses_ ## X (PyObject *self) \ +{ \ + PyCursesInitialised \ + return PyString_FromString(X()); } + +#define NoArgTrueFalseFunction(X) \ +static PyObject *PyCurses_ ## X (PyObject *self) \ +{ \ + PyCursesInitialised \ + if (X () == FALSE) { \ + Py_INCREF(Py_False); \ + return Py_False; \ + } \ + Py_INCREF(Py_True); \ + return Py_True; } + +#define NoArgNoReturnVoidFunction(X) \ +static PyObject *PyCurses_ ## X (PyObject *self) \ +{ \ + PyCursesInitialised \ + X(); \ + Py_INCREF(Py_None); \ + return Py_None; } + +#ifdef __cplusplus +} +#endif + +#endif /* !defined(Py_CURSES_H) */ + + diff --git a/android/python27/include/pyarena.h b/android/python27/include/pyarena.h new file mode 100644 index 000000000..5f193fece --- /dev/null +++ b/android/python27/include/pyarena.h @@ -0,0 +1,62 @@ +/* An arena-like memory interface for the compiler. + */ + +#ifndef Py_PYARENA_H +#define Py_PYARENA_H + +#ifdef __cplusplus +extern "C" { +#endif + + typedef struct _arena PyArena; + + /* PyArena_New() and PyArena_Free() create a new arena and free it, + respectively. Once an arena has been created, it can be used + to allocate memory via PyArena_Malloc(). Pointers to PyObject can + also be registered with the arena via PyArena_AddPyObject(), and the + arena will ensure that the PyObjects stay alive at least until + PyArena_Free() is called. When an arena is freed, all the memory it + allocated is freed, the arena releases internal references to registered + PyObject*, and none of its pointers are valid. + XXX (tim) What does "none of its pointers are valid" mean? Does it + XXX mean that pointers previously obtained via PyArena_Malloc() are + XXX no longer valid? (That's clearly true, but not sure that's what + XXX the text is trying to say.) + + PyArena_New() returns an arena pointer. On error, it + returns a negative number and sets an exception. + XXX (tim): Not true. On error, PyArena_New() actually returns NULL, + XXX and looks like it may or may not set an exception (e.g., if the + XXX internal PyList_New(0) returns NULL, PyArena_New() passes that on + XXX and an exception is set; OTOH, if the internal + XXX block_new(DEFAULT_BLOCK_SIZE) returns NULL, that's passed on but + XXX an exception is not set in that case). + */ + PyAPI_FUNC(PyArena *) PyArena_New(void); + PyAPI_FUNC(void) PyArena_Free(PyArena *); + + /* Mostly like malloc(), return the address of a block of memory spanning + * `size` bytes, or return NULL (without setting an exception) if enough + * new memory can't be obtained. Unlike malloc(0), PyArena_Malloc() with + * size=0 does not guarantee to return a unique pointer (the pointer + * returned may equal one or more other pointers obtained from + * PyArena_Malloc()). + * Note that pointers obtained via PyArena_Malloc() must never be passed to + * the system free() or realloc(), or to any of Python's similar memory- + * management functions. PyArena_Malloc()-obtained pointers remain valid + * until PyArena_Free(ar) is called, at which point all pointers obtained + * from the arena `ar` become invalid simultaneously. + */ + PyAPI_FUNC(void *) PyArena_Malloc(PyArena *, size_t size); + + /* This routine isn't a proper arena allocation routine. It takes + * a PyObject* and records it so that it can be DECREFed when the + * arena is freed. + */ + PyAPI_FUNC(int) PyArena_AddPyObject(PyArena *, PyObject *); + +#ifdef __cplusplus +} +#endif + +#endif /* !Py_PYARENA_H */ diff --git a/android/python27/include/pycapsule.h b/android/python27/include/pycapsule.h new file mode 100644 index 000000000..cd682fc7d --- /dev/null +++ b/android/python27/include/pycapsule.h @@ -0,0 +1,56 @@ + +/* Capsule objects let you wrap a C "void *" pointer in a Python + object. They're a way of passing data through the Python interpreter + without creating your own custom type. + + Capsules are used for communication between extension modules. + They provide a way for an extension module to export a C interface + to other extension modules, so that extension modules can use the + Python import mechanism to link to one another. + + For more information, please see "c-api/capsule.html" in the + documentation. +*/ + +#ifndef Py_CAPSULE_H +#define Py_CAPSULE_H +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_DATA(PyTypeObject) PyCapsule_Type; + +typedef void (*PyCapsule_Destructor)(PyObject *); + +#define PyCapsule_CheckExact(op) (Py_TYPE(op) == &PyCapsule_Type) + + +PyAPI_FUNC(PyObject *) PyCapsule_New( + void *pointer, + const char *name, + PyCapsule_Destructor destructor); + +PyAPI_FUNC(void *) PyCapsule_GetPointer(PyObject *capsule, const char *name); + +PyAPI_FUNC(PyCapsule_Destructor) PyCapsule_GetDestructor(PyObject *capsule); + +PyAPI_FUNC(const char *) PyCapsule_GetName(PyObject *capsule); + +PyAPI_FUNC(void *) PyCapsule_GetContext(PyObject *capsule); + +PyAPI_FUNC(int) PyCapsule_IsValid(PyObject *capsule, const char *name); + +PyAPI_FUNC(int) PyCapsule_SetPointer(PyObject *capsule, void *pointer); + +PyAPI_FUNC(int) PyCapsule_SetDestructor(PyObject *capsule, PyCapsule_Destructor destructor); + +PyAPI_FUNC(int) PyCapsule_SetName(PyObject *capsule, const char *name); + +PyAPI_FUNC(int) PyCapsule_SetContext(PyObject *capsule, void *context); + +PyAPI_FUNC(void *) PyCapsule_Import(const char *name, int no_block); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_CAPSULE_H */ diff --git a/android/python27/include/pyconfig.h b/android/python27/include/pyconfig.h new file mode 100644 index 000000000..1068f5eed --- /dev/null +++ b/android/python27/include/pyconfig.h @@ -0,0 +1,20 @@ +#if defined(__ARM_ARCH_5TE__) +#include "pyconfig_armeabi.h" +#elif defined(__ARM_ARCH_7A__) && !defined(__ARM_PCS_VFP) +#include "pyconfig_armeabi_v7a.h" +#elif defined(__ARM_ARCH_7A__) && defined(__ARM_PCS_VFP) +#include "pyconfig_armeabi_v7a_hard.h" +#elif defined(__aarch64__) +#include "pyconfig_arm64_v8a.h" +#elif defined(__i386__) +#include "pyconfig_x86.h" +#elif defined(__x86_64__) +#include "pyconfig_x86_64.h" +#elif defined(__mips__) && !defined(__mips64) +#include "pyconfig_mips.h" +#elif defined(__mips__) && defined(__mips64) +#include "pyconfig_mips64.h" +#else +#error "Unsupported ABI" +#endif + diff --git a/android/python27/include/pyconfig_arm64_v8a.h b/android/python27/include/pyconfig_arm64_v8a.h new file mode 100644 index 000000000..c4882a695 --- /dev/null +++ b/android/python27/include/pyconfig_arm64_v8a.h @@ -0,0 +1,1282 @@ +/* pyconfig.h. Generated from pyconfig.h.in by configure. */ +/* pyconfig.h.in. Generated from configure.ac by autoheader. */ + + +#ifndef Py_PYCONFIG_H +#define Py_PYCONFIG_H + + +/* Define if building universal (internal helper macro) */ +/* #undef AC_APPLE_UNIVERSAL_BUILD */ + +/* Define for AIX if your compiler is a genuine IBM xlC/xlC_r and you want + support for AIX C++ shared extension modules. */ +/* #undef AIX_GENUINE_CPLUSPLUS */ + +/* Define this if you have AtheOS threads. */ +/* #undef ATHEOS_THREADS */ + +/* Define this if you have BeOS threads. */ +/* #undef BEOS_THREADS */ + +/* Define if you have the Mach cthreads package */ +/* #undef C_THREADS */ + +/* Define if C doubles are 64-bit IEEE 754 binary format, stored in ARM + mixed-endian order (byte order 45670123) */ +/* #undef DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754 */ + +/* Define if C doubles are 64-bit IEEE 754 binary format, stored with the most + significant byte first */ +/* #undef DOUBLE_IS_BIG_ENDIAN_IEEE754 */ + +/* Define if C doubles are 64-bit IEEE 754 binary format, stored with the + least significant byte first */ +/* #undef DOUBLE_IS_LITTLE_ENDIAN_IEEE754 */ + +/* Define if --enable-ipv6 is specified */ +#define ENABLE_IPV6 1 + +/* Define if flock needs to be linked with bsd library. */ +/* #undef FLOCK_NEEDS_LIBBSD */ + +/* Define if getpgrp() must be called as getpgrp(0). */ +/* #undef GETPGRP_HAVE_ARG */ + +/* Define if gettimeofday() does not have second (timezone) argument This is + the case on Motorola V4 (R40V4.2) */ +/* #undef GETTIMEOFDAY_NO_TZ */ + +/* Define to 1 if you have the `acosh' function. */ +#define HAVE_ACOSH 1 + +/* struct addrinfo (netdb.h) */ +#define HAVE_ADDRINFO 1 + +/* Define to 1 if you have the `alarm' function. */ +#define HAVE_ALARM 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ALLOCA_H 1 + +/* Define this if your time.h defines altzone. */ +/* #undef HAVE_ALTZONE */ + +/* Define to 1 if you have the `asinh' function. */ +#define HAVE_ASINH 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ASM_TYPES_H 1 + +/* Define to 1 if you have the `atanh' function. */ +#define HAVE_ATANH 1 + +/* Define if GCC supports __attribute__((format(PyArg_ParseTuple, 2, 3))) */ +/* #undef HAVE_ATTRIBUTE_FORMAT_PARSETUPLE */ + +/* Define to 1 if you have the `bind_textdomain_codeset' function. */ +/* #undef HAVE_BIND_TEXTDOMAIN_CODESET */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_BLUETOOTH_BLUETOOTH_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_BLUETOOTH_H */ + +/* Define if nice() returns success/failure instead of the new priority. */ +/* #undef HAVE_BROKEN_NICE */ + +/* Define if the system reports an invalid PIPE_BUF value. */ +/* #undef HAVE_BROKEN_PIPE_BUF */ + +/* Define if poll() sets errno on invalid file descriptors. */ +/* #undef HAVE_BROKEN_POLL */ + +/* Define if the Posix semaphores do not work on your system */ +/* #undef HAVE_BROKEN_POSIX_SEMAPHORES */ + +/* Define if pthread_sigmask() does not work on your system. */ +/* #undef HAVE_BROKEN_PTHREAD_SIGMASK */ + +/* define to 1 if your sem_getvalue is broken. */ +#define HAVE_BROKEN_SEM_GETVALUE 1 + +/* Define if `unsetenv` does not return an int. */ +/* #undef HAVE_BROKEN_UNSETENV */ + +/* Define this if you have the type _Bool. */ +#define HAVE_C99_BOOL 1 + +/* Define to 1 if you have the 'chflags' function. */ +/* #undef HAVE_CHFLAGS */ + +/* Define to 1 if you have the `chown' function. */ +#define HAVE_CHOWN 1 + +/* Define if you have the 'chroot' function. */ +#define HAVE_CHROOT 1 + +/* Define to 1 if you have the `clock' function. */ +#define HAVE_CLOCK 1 + +/* Define to 1 if you have the `confstr' function. */ +/* #undef HAVE_CONFSTR */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_CONIO_H */ + +/* Define to 1 if you have the `copysign' function. */ +#define HAVE_COPYSIGN 1 + +/* Define to 1 if you have the `ctermid' function. */ +/* #undef HAVE_CTERMID */ + +/* Define if you have the 'ctermid_r' function. */ +#define HAVE_CTERMID_R 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_CURSES_H */ + +/* Define if you have the 'is_term_resized' function. */ +/* #undef HAVE_CURSES_IS_TERM_RESIZED */ + +/* Define if you have the 'resizeterm' function. */ +/* #undef HAVE_CURSES_RESIZETERM */ + +/* Define if you have the 'resize_term' function. */ +/* #undef HAVE_CURSES_RESIZE_TERM */ + +/* Define to 1 if you have the declaration of `isfinite', and to 0 if you + don't. */ +#define HAVE_DECL_ISFINITE 1 + +/* Define to 1 if you have the declaration of `isinf', and to 0 if you don't. + */ +#define HAVE_DECL_ISINF 1 + +/* Define to 1 if you have the declaration of `isnan', and to 0 if you don't. + */ +#define HAVE_DECL_ISNAN 1 + +/* Define to 1 if you have the declaration of `tzname', and to 0 if you don't. + */ +/* #undef HAVE_DECL_TZNAME */ + +/* Define to 1 if you have the device macros. */ +#define HAVE_DEVICE_MACROS 1 + +/* Define to 1 if you have the /dev/ptc device file. */ +/* #undef HAVE_DEV_PTC */ + +/* Define to 1 if you have the /dev/ptmx device file. */ +/* #undef HAVE_DEV_PTMX */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_DIRECT_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#define HAVE_DIRENT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_DLFCN_H 1 + +/* Define to 1 if you have the `dlopen' function. */ +#define HAVE_DLOPEN 1 + +/* Define to 1 if you have the `dup2' function. */ +#define HAVE_DUP2 1 + +/* Defined when any dynamic module loading is enabled. */ +#define HAVE_DYNAMIC_LOADING 1 + +/* Define if you have the 'epoll' functions. */ +#define HAVE_EPOLL 1 + +/* Define to 1 if you have the `erf' function. */ +#define HAVE_ERF 1 + +/* Define to 1 if you have the `erfc' function. */ +#define HAVE_ERFC 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ERRNO_H 1 + +/* Define to 1 if you have the `execv' function. */ +#define HAVE_EXECV 1 + +/* Define to 1 if you have the `expm1' function. */ +#define HAVE_EXPM1 1 + +/* Define if you have the 'fchdir' function. */ +#define HAVE_FCHDIR 1 + +/* Define to 1 if you have the `fchmod' function. */ +#define HAVE_FCHMOD 1 + +/* Define to 1 if you have the `fchown' function. */ +#define HAVE_FCHOWN 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* Define if you have the 'fdatasync' function. */ +#define HAVE_FDATASYNC 1 + +/* Define to 1 if you have the `finite' function. */ +#define HAVE_FINITE 1 + +/* Define to 1 if you have the `flock' function. */ +#define HAVE_FLOCK 1 + +/* Define to 1 if you have the `fork' function. */ +#define HAVE_FORK 1 + +/* Define to 1 if you have the `forkpty' function. */ +/* #undef HAVE_FORKPTY */ + +/* Define to 1 if you have the `fpathconf' function. */ +#define HAVE_FPATHCONF 1 + +/* Define to 1 if you have the `fseek64' function. */ +/* #undef HAVE_FSEEK64 */ + +/* Define to 1 if you have the `fseeko' function. */ +#define HAVE_FSEEKO 1 + +/* Define to 1 if you have the `fstatvfs' function. */ +#define HAVE_FSTATVFS 1 + +/* Define if you have the 'fsync' function. */ +#define HAVE_FSYNC 1 + +/* Define to 1 if you have the `ftell64' function. */ +/* #undef HAVE_FTELL64 */ + +/* Define to 1 if you have the `ftello' function. */ +#define HAVE_FTELLO 1 + +/* Define to 1 if you have the `ftime' function. */ +/* #undef HAVE_FTIME */ + +/* Define to 1 if you have the `ftruncate' function. */ +#define HAVE_FTRUNCATE 1 + +/* Define to 1 if you have the `gai_strerror' function. */ +#define HAVE_GAI_STRERROR 1 + +/* Define to 1 if you have the `gamma' function. */ +/* #undef HAVE_GAMMA */ + +/* Define if we can use gcc inline assembler to get and set x87 control word + */ +/* #undef HAVE_GCC_ASM_FOR_X87 */ + +/* Define if you have the getaddrinfo function. */ +#define HAVE_GETADDRINFO 1 + +/* Define to 1 if you have the `getcwd' function. */ +#define HAVE_GETCWD 1 + +/* Define this if you have flockfile(), getc_unlocked(), and funlockfile() */ +#define HAVE_GETC_UNLOCKED 1 + +/* Define to 1 if you have the `getentropy' function. */ +/* #undef HAVE_GETENTROPY */ + +/* Define to 1 if you have the `getgroups' function. */ +#define HAVE_GETGROUPS 1 + +/* Define to 1 if you have the `gethostbyname' function. */ +#define HAVE_GETHOSTBYNAME 1 + +/* Define this if you have some version of gethostbyname_r() */ +/* #undef HAVE_GETHOSTBYNAME_R */ + +/* Define this if you have the 3-arg version of gethostbyname_r(). */ +/* #undef HAVE_GETHOSTBYNAME_R_3_ARG */ + +/* Define this if you have the 5-arg version of gethostbyname_r(). */ +/* #undef HAVE_GETHOSTBYNAME_R_5_ARG */ + +/* Define this if you have the 6-arg version of gethostbyname_r(). */ +/* #undef HAVE_GETHOSTBYNAME_R_6_ARG */ + +/* Define to 1 if you have the `getitimer' function. */ +#define HAVE_GETITIMER 1 + +/* Define to 1 if you have the `getloadavg' function. */ +#define HAVE_GETLOADAVG 1 + +/* Define to 1 if you have the `getlogin' function. */ +#define HAVE_GETLOGIN 1 + +/* Define to 1 if you have the `getnameinfo' function. */ +#define HAVE_GETNAMEINFO 1 + +/* Define if you have the 'getpagesize' function. */ +#define HAVE_GETPAGESIZE 1 + +/* Define to 1 if you have the `getpeername' function. */ +#define HAVE_GETPEERNAME 1 + +/* Define to 1 if you have the `getpgid' function. */ +#define HAVE_GETPGID 1 + +/* Define to 1 if you have the `getpgrp' function. */ +#define HAVE_GETPGRP 1 + +/* Define to 1 if you have the `getpid' function. */ +#define HAVE_GETPID 1 + +/* Define to 1 if you have the `getpriority' function. */ +#define HAVE_GETPRIORITY 1 + +/* Define to 1 if you have the `getpwent' function. */ +#define HAVE_GETPWENT 1 + +/* Define to 1 if you have the `getresgid' function. */ +#define HAVE_GETRESGID 1 + +/* Define to 1 if you have the `getresuid' function. */ +#define HAVE_GETRESUID 1 + +/* Define to 1 if you have the `getsid' function. */ +#define HAVE_GETSID 1 + +/* Define to 1 if you have the `getspent' function. */ +/* #undef HAVE_GETSPENT */ + +/* Define to 1 if you have the `getspnam' function. */ +/* #undef HAVE_GETSPNAM */ + +/* Define to 1 if you have the `gettimeofday' function. */ +#define HAVE_GETTIMEOFDAY 1 + +/* Define to 1 if you have the `getwd' function. */ +/* #undef HAVE_GETWD */ + +/* Define to 1 if you have the header file. */ +#define HAVE_GRP_H 1 + +/* Define if you have the 'hstrerror' function. */ +#define HAVE_HSTRERROR 1 + +/* Define to 1 if you have the `hypot' function. */ +#define HAVE_HYPOT 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_IEEEFP_H */ + +/* Define if you have the 'inet_aton' function. */ +#define HAVE_INET_ATON 1 + +/* Define if you have the 'inet_pton' function. */ +#define HAVE_INET_PTON 1 + +/* Define to 1 if you have the `initgroups' function. */ +#define HAVE_INITGROUPS 1 + +/* Define if your compiler provides int32_t. */ +#define HAVE_INT32_T 1 + +/* Define if your compiler provides int64_t. */ +#define HAVE_INT64_T 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_IO_H */ + +/* Define to 1 if you have the `kill' function. */ +#define HAVE_KILL 1 + +/* Define to 1 if you have the `killpg' function. */ +#define HAVE_KILLPG 1 + +/* Define if you have the 'kqueue' functions. */ +#define HAVE_KQUEUE 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_LANGINFO_H 1 + +/* Defined to enable large file support when an off_t is bigger than a long + and long long is available and at least as big as an off_t. You may need to + add some flags for configuration and compilation to enable this mode. (For + Solaris and Linux, the necessary defines are already defined.) */ +/* #undef HAVE_LARGEFILE_SUPPORT */ + +/* Define to 1 if you have the 'lchflags' function. */ +/* #undef HAVE_LCHFLAGS */ + +/* Define to 1 if you have the `lchmod' function. */ +/* #undef HAVE_LCHMOD */ + +/* Define to 1 if you have the `lchown' function. */ +#define HAVE_LCHOWN 1 + +/* Define to 1 if you have the `lgamma' function. */ +#define HAVE_LGAMMA 1 + +/* Define to 1 if you have the `dl' library (-ldl). */ +#define HAVE_LIBDL 1 + +/* Define to 1 if you have the `dld' library (-ldld). */ +/* #undef HAVE_LIBDLD */ + +/* Define to 1 if you have the `ieee' library (-lieee). */ +/* #undef HAVE_LIBIEEE */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LIBINTL_H */ + +/* Define if you have the readline library (-lreadline). */ +/* #undef HAVE_LIBREADLINE */ + +/* Define to 1 if you have the `resolv' library (-lresolv). */ +/* #undef HAVE_LIBRESOLV */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LIBUTIL_H */ + +/* Define if you have the 'link' function. */ +#define HAVE_LINK 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_LINUX_NETLINK_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_LINUX_TIPC_H 1 + +/* Define to 1 if you have the `log1p' function. */ +#define HAVE_LOG1P 1 + +/* Define this if you have the type long double. */ +#define HAVE_LONG_DOUBLE 1 + +/* Define this if you have the type long long. */ +#define HAVE_LONG_LONG 1 + +/* Define to 1 if you have the `lstat' function. */ +#define HAVE_LSTAT 1 + +/* Define this if you have the makedev macro. */ +#define HAVE_MAKEDEV 1 + +/* Define to 1 if you have the `memmove' function. */ +#define HAVE_MEMMOVE 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `mkfifo' function. */ +#define HAVE_MKFIFO 1 + +/* Define to 1 if you have the `mknod' function. */ +#define HAVE_MKNOD 1 + +/* Define to 1 if you have the `mktime' function. */ +#define HAVE_MKTIME 1 + +/* Define to 1 if you have the `mmap' function. */ +#define HAVE_MMAP 1 + +/* Define to 1 if you have the `mremap' function. */ +#define HAVE_MREMAP 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NCURSES_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. */ +/* #undef HAVE_NDIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_NETPACKET_PACKET_H 1 + +/* Define to 1 if you have the `nice' function. */ +#define HAVE_NICE 1 + +/* Define to 1 if you have the `openpty' function. */ +/* #undef HAVE_OPENPTY */ + +/* Define if compiling using MacOS X 10.5 SDK or later. */ +/* #undef HAVE_OSX105_SDK */ + +/* Define to 1 if you have the `pathconf' function. */ +#define HAVE_PATHCONF 1 + +/* Define to 1 if you have the `pause' function. */ +#define HAVE_PAUSE 1 + +/* Define to 1 if you have the `plock' function. */ +/* #undef HAVE_PLOCK */ + +/* Define to 1 if you have the `poll' function. */ +#define HAVE_POLL 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_POLL_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PROCESS_H */ + +/* Define if your compiler supports function prototype */ +#define HAVE_PROTOTYPES 1 + +/* Define if you have GNU PTH threads. */ +/* #undef HAVE_PTH */ + +/* Define to 1 if you have the `pthread_atfork' function. */ +#define HAVE_PTHREAD_ATFORK 1 + +/* Defined for Solaris 2.6 bug in pthread header. */ +/* #undef HAVE_PTHREAD_DESTRUCTOR */ + +/* Define to 1 if you have the header file. */ +#define HAVE_PTHREAD_H 1 + +/* Define to 1 if you have the `pthread_init' function. */ +/* #undef HAVE_PTHREAD_INIT */ + +/* Define to 1 if you have the `pthread_sigmask' function. */ +#define HAVE_PTHREAD_SIGMASK 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PTY_H */ + +/* Define to 1 if you have the `putenv' function. */ +#define HAVE_PUTENV 1 + +/* Define if the libcrypto has RAND_egd */ +/* #undef HAVE_RAND_EGD */ + +/* Define to 1 if you have the `readlink' function. */ +#define HAVE_READLINK 1 + +/* Define to 1 if you have the `realpath' function. */ +#define HAVE_REALPATH 1 + +/* Define if you have readline 2.1 */ +/* #undef HAVE_RL_CALLBACK */ + +/* Define if you can turn off readline's signal handling. */ +/* #undef HAVE_RL_CATCH_SIGNAL */ + +/* Define if you have readline 2.2 */ +/* #undef HAVE_RL_COMPLETION_APPEND_CHARACTER */ + +/* Define if you have readline 4.0 */ +/* #undef HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK */ + +/* Define if you have readline 4.2 */ +/* #undef HAVE_RL_COMPLETION_MATCHES */ + +/* Define if you have rl_completion_suppress_append */ +/* #undef HAVE_RL_COMPLETION_SUPPRESS_APPEND */ + +/* Define if you have readline 4.0 */ +/* #undef HAVE_RL_PRE_INPUT_HOOK */ + +/* Define to 1 if you have the `round' function. */ +#define HAVE_ROUND 1 + +/* Define to 1 if you have the `select' function. */ +#define HAVE_SELECT 1 + +/* Define to 1 if you have the `sem_getvalue' function. */ +#define HAVE_SEM_GETVALUE 1 + +/* Define to 1 if you have the `sem_open' function. */ +#define HAVE_SEM_OPEN 1 + +/* Define to 1 if you have the `sem_timedwait' function. */ +#define HAVE_SEM_TIMEDWAIT 1 + +/* Define to 1 if you have the `sem_unlink' function. */ +#define HAVE_SEM_UNLINK 1 + +/* Define to 1 if you have the `setegid' function. */ +#define HAVE_SETEGID 1 + +/* Define to 1 if you have the `seteuid' function. */ +#define HAVE_SETEUID 1 + +/* Define to 1 if you have the `setgid' function. */ +#define HAVE_SETGID 1 + +/* Define if you have the 'setgroups' function. */ +#define HAVE_SETGROUPS 1 + +/* Define to 1 if you have the `setitimer' function. */ +#define HAVE_SETITIMER 1 + +/* Define to 1 if you have the `setlocale' function. */ +#define HAVE_SETLOCALE 1 + +/* Define to 1 if you have the `setpgid' function. */ +#define HAVE_SETPGID 1 + +/* Define to 1 if you have the `setpgrp' function. */ +#define HAVE_SETPGRP 1 + +/* Define to 1 if you have the `setregid' function. */ +#define HAVE_SETREGID 1 + +/* Define to 1 if you have the `setresgid' function. */ +#define HAVE_SETRESGID 1 + +/* Define to 1 if you have the `setresuid' function. */ +#define HAVE_SETRESUID 1 + +/* Define to 1 if you have the `setreuid' function. */ +#define HAVE_SETREUID 1 + +/* Define to 1 if you have the `setsid' function. */ +#define HAVE_SETSID 1 + +/* Define to 1 if you have the `setuid' function. */ +#define HAVE_SETUID 1 + +/* Define to 1 if you have the `setvbuf' function. */ +#define HAVE_SETVBUF 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SHADOW_H */ + +/* Define to 1 if you have the `sigaction' function. */ +#define HAVE_SIGACTION 1 + +/* Define to 1 if you have the `siginterrupt' function. */ +#define HAVE_SIGINTERRUPT 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SIGNAL_H 1 + +/* Define to 1 if you have the `sigrelse' function. */ +/* #undef HAVE_SIGRELSE */ + +/* Define to 1 if you have the `snprintf' function. */ +#define HAVE_SNPRINTF 1 + +/* Define if sockaddr has sa_len member */ +/* #undef HAVE_SOCKADDR_SA_LEN */ + +/* struct sockaddr_storage (sys/socket.h) */ +#define HAVE_SOCKADDR_STORAGE 1 + +/* Define if you have the 'socketpair' function. */ +#define HAVE_SOCKETPAIR 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SPAWN_H */ + +/* Define if your compiler provides ssize_t */ +#define HAVE_SSIZE_T 1 + +/* Define to 1 if you have the `statvfs' function. */ +#define HAVE_STATVFS 1 + +/* Define if you have struct stat.st_mtim.tv_nsec */ +/* #undef HAVE_STAT_TV_NSEC */ + +/* Define if you have struct stat.st_mtimensec */ +/* #undef HAVE_STAT_TV_NSEC2 */ + +/* Define if your compiler supports variable length function prototypes (e.g. + void fprintf(FILE *, char *, ...);) *and* */ +#define HAVE_STDARG_PROTOTYPES 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the `strdup' function. */ +#define HAVE_STRDUP 1 + +/* Define to 1 if you have the `strftime' function. */ +#define HAVE_STRFTIME 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_STROPTS_H */ + +/* Define to 1 if `st_birthtime' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_BIRTHTIME */ + +/* Define to 1 if `st_blksize' is a member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_BLKSIZE 1 + +/* Define to 1 if `st_blocks' is a member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_BLOCKS 1 + +/* Define to 1 if `st_flags' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_FLAGS */ + +/* Define to 1 if `st_gen' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_GEN */ + +/* Define to 1 if `st_rdev' is a member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_RDEV 1 + +/* Define to 1 if `tm_zone' is a member of `struct tm'. */ +#define HAVE_STRUCT_TM_TM_ZONE 1 + +/* Define to 1 if your `struct stat' has `st_blocks'. Deprecated, use + `HAVE_STRUCT_STAT_ST_BLOCKS' instead. */ +#define HAVE_ST_BLOCKS 1 + +/* Define if you have the 'symlink' function. */ +#define HAVE_SYMLINK 1 + +/* Define to 1 if you have the `sysconf' function. */ +#define HAVE_SYSCONF 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYSEXITS_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_AUDIOIO_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_BSDTTY_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +/* #undef HAVE_SYS_DIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_EPOLL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_EVENT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_FILE_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_LOADAVG_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_LOCK_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_MKDEV_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_MODEM_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +/* #undef HAVE_SYS_NDIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_PARAM_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_POLL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_RESOURCE_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SELECT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SOCKET_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STATVFS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_TERMIO_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIMES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UN_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UTSNAME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_WAIT_H 1 + +/* Define to 1 if you have the `tcgetpgrp' function. */ +#define HAVE_TCGETPGRP 1 + +/* Define to 1 if you have the `tcsetpgrp' function. */ +#define HAVE_TCSETPGRP 1 + +/* Define to 1 if you have the `tempnam' function. */ +#define HAVE_TEMPNAM 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_TERMIOS_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_TERM_H */ + +/* Define to 1 if you have the `tgamma' function. */ +#define HAVE_TGAMMA 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_THREAD_H */ + +/* Define to 1 if you have the `timegm' function. */ +#define HAVE_TIMEGM 1 + +/* Define to 1 if you have the `times' function. */ +#define HAVE_TIMES 1 + +/* Define to 1 if you have the `tmpfile' function. */ +#define HAVE_TMPFILE 1 + +/* Define to 1 if you have the `tmpnam' function. */ +#define HAVE_TMPNAM 1 + +/* Define to 1 if you have the `tmpnam_r' function. */ +/* #undef HAVE_TMPNAM_R */ + +/* Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use + `HAVE_STRUCT_TM_TM_ZONE' instead. */ +#define HAVE_TM_ZONE 1 + +/* Define to 1 if you have the `truncate' function. */ +#define HAVE_TRUNCATE 1 + +/* Define to 1 if you don't have `tm_zone' but do have the external array + `tzname'. */ +/* #undef HAVE_TZNAME */ + +/* Define this if you have tcl and TCL_UTF_MAX==6 */ +/* #undef HAVE_UCS4_TCL */ + +/* Define if your compiler provides uint32_t. */ +#define HAVE_UINT32_T 1 + +/* Define if your compiler provides uint64_t. */ +#define HAVE_UINT64_T 1 + +/* Define to 1 if the system has the type `uintptr_t'. */ +#define HAVE_UINTPTR_T 1 + +/* Define to 1 if you have the `uname' function. */ +#define HAVE_UNAME 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you have the `unsetenv' function. */ +#define HAVE_UNSETENV 1 + +/* Define if you have a useable wchar_t type defined in wchar.h; useable means + wchar_t must be an unsigned type with at least 16 bits. (see + Include/unicodeobject.h). */ +/* #undef HAVE_USABLE_WCHAR_T */ + +/* Define to 1 if you have the header file. */ +#define HAVE_UTIL_H 1 + +/* Define to 1 if you have the `utimes' function. */ +#define HAVE_UTIMES 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UTIME_H 1 + +/* Define to 1 if you have the `wait3' function. */ +/* #undef HAVE_WAIT3 */ + +/* Define to 1 if you have the `wait4' function. */ +#define HAVE_WAIT4 1 + +/* Define to 1 if you have the `waitpid' function. */ +#define HAVE_WAITPID 1 + +/* Define if the compiler provides a wchar.h header file. */ +#define HAVE_WCHAR_H 1 + +/* Define to 1 if you have the `wcscoll' function. */ +#define HAVE_WCSCOLL 1 + +/* Define if tzset() actually switches the local timezone in a meaningful way. + */ +/* #undef HAVE_WORKING_TZSET */ + +/* Define if the zlib library has inflateCopy */ +#define HAVE_ZLIB_COPY 1 + +/* Define to 1 if you have the `_getpty' function. */ +/* #undef HAVE__GETPTY */ + +/* Define if you are using Mach cthreads directly under /include */ +/* #undef HURD_C_THREADS */ + +/* Define if you are using Mach cthreads under mach / */ +/* #undef MACH_C_THREADS */ + +/* Define to 1 if `major', `minor', and `makedev' are declared in . + */ +/* #undef MAJOR_IN_MKDEV */ + +/* Define to 1 if `major', `minor', and `makedev' are declared in + . */ +#define MAJOR_IN_SYSMACROS 1 + +/* Define if mvwdelch in curses.h is an expression. */ +/* #undef MVWDELCH_IS_EXPRESSION */ + +/* Define to the address where bug reports for this package should be sent. */ +/* #undef PACKAGE_BUGREPORT */ + +/* Define to the full name of this package. */ +/* #undef PACKAGE_NAME */ + +/* Define to the full name and version of this package. */ +/* #undef PACKAGE_STRING */ + +/* Define to the one symbol short name of this package. */ +/* #undef PACKAGE_TARNAME */ + +/* Define to the home page for this package. */ +/* #undef PACKAGE_URL */ + +/* Define to the version of this package. */ +/* #undef PACKAGE_VERSION */ + +/* Define if POSIX semaphores aren't enabled on your system */ +/* #undef POSIX_SEMAPHORES_NOT_ENABLED */ + +/* Defined if PTHREAD_SCOPE_SYSTEM supported. */ +/* #undef PTHREAD_SYSTEM_SCHED_SUPPORTED */ + +/* Define as the preferred size in bits of long digits */ +/* #undef PYLONG_BITS_IN_DIGIT */ + +/* Define to printf format modifier for long long type */ +#define PY_FORMAT_LONG_LONG "ll" + +/* Define to printf format modifier for Py_ssize_t */ +#define PY_FORMAT_SIZE_T "z" + +/* Define as the integral type used for Unicode representation. */ +/* #undef PY_UNICODE_TYPE */ + +/* Define if you want to build an interpreter with many run-time checks. */ +/* #undef Py_DEBUG */ + +/* Defined if Python is built as a shared library. */ +#define Py_ENABLE_SHARED 1 + +/* Define as the size of the unicode type. */ +#define Py_UNICODE_SIZE 4 + +/* Define if you want to have a Unicode type. */ +#define Py_USING_UNICODE 1 + +/* assume C89 semantics that RETSIGTYPE is always void */ +#define RETSIGTYPE void + +/* Define if setpgrp() must be called as setpgrp(0, 0). */ +/* #undef SETPGRP_HAVE_ARG */ + +/* Define this to be extension of shared libraries (including the dot!). */ +#define SHLIB_EXT ".so" + +/* Define if i>>j for signed int i does not extend the sign bit when i < 0 */ +/* #undef SIGNED_RIGHT_SHIFT_ZERO_FILLS */ + +/* The size of `double', as computed by sizeof. */ +#define SIZEOF_DOUBLE 8 + +/* The size of `float', as computed by sizeof. */ +#define SIZEOF_FLOAT 4 + +/* The size of `fpos_t', as computed by sizeof. */ +#define SIZEOF_FPOS_T 8 + +/* The size of `int', as computed by sizeof. */ +#define SIZEOF_INT 4 + +/* The size of `long', as computed by sizeof. */ +#define SIZEOF_LONG 8 + +/* The size of `long double', as computed by sizeof. */ +#define SIZEOF_LONG_DOUBLE 16 + +/* The size of `long long', as computed by sizeof. */ +#define SIZEOF_LONG_LONG 8 + +/* The size of `off_t', as computed by sizeof. */ +#define SIZEOF_OFF_T 8 + +/* The size of `pid_t', as computed by sizeof. */ +#define SIZEOF_PID_T 4 + +/* The size of `pthread_t', as computed by sizeof. */ +#define SIZEOF_PTHREAD_T 8 + +/* The size of `short', as computed by sizeof. */ +#define SIZEOF_SHORT 2 + +/* The size of `size_t', as computed by sizeof. */ +#define SIZEOF_SIZE_T 8 + +/* The size of `time_t', as computed by sizeof. */ +#define SIZEOF_TIME_T 8 + +/* The size of `uintptr_t', as computed by sizeof. */ +#define SIZEOF_UINTPTR_T 8 + +/* The size of `void *', as computed by sizeof. */ +#define SIZEOF_VOID_P 8 + +/* The size of `wchar_t', as computed by sizeof. */ +#define SIZEOF_WCHAR_T 4 + +/* The size of `_Bool', as computed by sizeof. */ +#define SIZEOF__BOOL 1 + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define if you can safely include both and + (which you can't on SCO ODT 3.0). */ +#define SYS_SELECT_WITH_SYS_TIME 1 + +/* Define if tanh(-0.) is -0., or if platform doesn't have signed zeros */ +/* #undef TANH_PRESERVES_ZERO_SIGN */ + +/* Define to 1 if you can safely include both and . */ +#define TIME_WITH_SYS_TIME 1 + +/* Define to 1 if your declares `struct tm'. */ +/* #undef TM_IN_SYS_TIME */ + +/* Enable extensions on AIX 3, Interix. */ +#ifndef _ALL_SOURCE +# define _ALL_SOURCE 1 +#endif +/* Enable GNU extensions on systems that have them. */ +#ifndef _GNU_SOURCE +# define _GNU_SOURCE 1 +#endif +/* Enable threading extensions on Solaris. */ +#ifndef _POSIX_PTHREAD_SEMANTICS +# define _POSIX_PTHREAD_SEMANTICS 1 +#endif +/* Enable extensions on HP NonStop. */ +#ifndef _TANDEM_SOURCE +# define _TANDEM_SOURCE 1 +#endif +/* Enable general extensions on Solaris. */ +#ifndef __EXTENSIONS__ +# define __EXTENSIONS__ 1 +#endif + + +/* Define if you want to use MacPython modules on MacOSX in unix-Python. */ +/* #undef USE_TOOLBOX_OBJECT_GLUE */ + +/* Define if a va_list is an array of some kind */ +/* #undef VA_LIST_IS_ARRAY */ + +/* Define if you want SIGFPE handled (see Include/pyfpe.h). */ +/* #undef WANT_SIGFPE_HANDLER */ + +/* Define if you want wctype.h functions to be used instead of the one + supplied by Python itself. (see Include/unicodectype.h). */ +/* #undef WANT_WCTYPE_FUNCTIONS */ + +/* Define if WINDOW in curses.h offers a field _flags. */ +/* #undef WINDOW_HAS_FLAGS */ + +/* Define if you want documentation strings in extension modules */ +#define WITH_DOC_STRINGS 1 + +/* Define if you want to use the new-style (Openstep, Rhapsody, MacOS) dynamic + linker (dyld) instead of the old-style (NextStep) dynamic linker (rld). + Dyld is necessary to support frameworks. */ +/* #undef WITH_DYLD */ + +/* Define to 1 if libintl is needed for locale functions. */ +/* #undef WITH_LIBINTL */ + +/* Define if you want to produce an OpenStep/Rhapsody framework (shared + library plus accessory files). */ +/* #undef WITH_NEXT_FRAMEWORK */ + +/* Define if you want to compile in Python-specific mallocs */ +#define WITH_PYMALLOC 1 + +/* Define if you want to compile in rudimentary thread support */ +#define WITH_THREAD 1 + +/* Define to profile with the Pentium timestamp counter */ +/* #undef WITH_TSC */ + +/* Define if you want pymalloc to be disabled when running under valgrind */ +/* #undef WITH_VALGRIND */ + +/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most + significant byte first (like Motorola and SPARC, unlike Intel). */ +#if defined AC_APPLE_UNIVERSAL_BUILD +# if defined __BIG_ENDIAN__ +# define WORDS_BIGENDIAN 1 +# endif +#else +# ifndef WORDS_BIGENDIAN +/* # undef WORDS_BIGENDIAN */ +# endif +#endif + +/* Define if arithmetic is subject to x87-style double rounding issue */ +/* #undef X87_DOUBLE_ROUNDING */ + +/* Define on OpenBSD to activate all library features */ +/* #undef _BSD_SOURCE */ + +/* Define on Irix to enable u_int */ +#define _BSD_TYPES 1 + +/* Define on Darwin to activate all library features */ +#define _DARWIN_C_SOURCE 1 + +/* This must be set to 64 on some systems to enable large file support. */ +#define _FILE_OFFSET_BITS 64 + +/* Define on Linux to activate all library features */ +#define _GNU_SOURCE 1 + +/* This must be defined on some systems to enable large file support. */ +#define _LARGEFILE_SOURCE 1 + +/* This must be defined on AIX systems to enable large file support. */ +/* #undef _LARGE_FILES */ + +/* Define to 1 if on MINIX. */ +/* #undef _MINIX */ + +/* Define on NetBSD to activate all library features */ +#define _NETBSD_SOURCE 1 + +/* Define _OSF_SOURCE to get the makedev macro. */ +/* #undef _OSF_SOURCE */ + +/* Define to 2 if the system does not provide POSIX.1 features except with + this defined. */ +/* #undef _POSIX_1_SOURCE */ + +/* Define to activate features from IEEE Stds 1003.1-2001 */ +#define _POSIX_C_SOURCE 200112L + +/* Define to 1 if you need to in order for `stat' and other things to work. */ +/* #undef _POSIX_SOURCE */ + +/* Define if you have POSIX threads, and your system does not define that. */ +/* #undef _POSIX_THREADS */ + +/* Define to force use of thread-safe errno, h_errno, and other functions */ +#define _REENTRANT 1 + +/* Define for Solaris 2.5.1 so the uint32_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +/* #undef _UINT32_T */ + +/* Define for Solaris 2.5.1 so the uint64_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +/* #undef _UINT64_T */ + +/* Define to the level of X/Open that your system supports */ +#define _XOPEN_SOURCE 600 + +/* Define to activate Unix95-and-earlier features */ +#define _XOPEN_SOURCE_EXTENDED 1 + +/* Define on FreeBSD to activate all library features */ +#define __BSD_VISIBLE 1 + +/* Define to 1 if type `char' is unsigned and you are not using gcc. */ +#ifndef __CHAR_UNSIGNED__ +/* # undef __CHAR_UNSIGNED__ */ +#endif + +/* Defined on Solaris to see additional function prototypes. */ +#define __EXTENSIONS__ 1 + +/* Define to 'long' if doesn't define. */ +/* #undef clock_t */ + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ + +/* Define to `int' if doesn't define. */ +/* #undef gid_t */ + +/* Define to the type of a signed integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +/* #undef int32_t */ + +/* Define to the type of a signed integer type of width exactly 64 bits if + such a type exists and the standard includes do not define it. */ +/* #undef int64_t */ + +/* Define to `int' if does not define. */ +/* #undef mode_t */ + +/* Define to `long int' if does not define. */ +/* #undef off_t */ + +/* Define to `int' if does not define. */ +/* #undef pid_t */ + +/* Define to empty if the keyword does not work. */ +/* #undef signed */ + +/* Define to `unsigned int' if does not define. */ +/* #undef size_t */ + +/* Define to `int' if does not define. */ +/* #undef socklen_t */ + +/* Define to `int' if doesn't define. */ +/* #undef uid_t */ + +/* Define to the type of an unsigned integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint32_t */ + +/* Define to the type of an unsigned integer type of width exactly 64 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint64_t */ + +/* Define to empty if the keyword does not work. */ +/* #undef volatile */ + + +/* Define the macros needed if on a UnixWare 7.x system. */ +#if defined(__USLC__) && defined(__SCO_VERSION__) +#define STRICT_SYSV_CURSES /* Don't use ncurses extensions */ +#endif + +#endif /*Py_PYCONFIG_H*/ + diff --git a/android/python27/include/pyconfig_armeabi.h b/android/python27/include/pyconfig_armeabi.h new file mode 100644 index 000000000..8c9ca6178 --- /dev/null +++ b/android/python27/include/pyconfig_armeabi.h @@ -0,0 +1,1282 @@ +/* pyconfig.h. Generated from pyconfig.h.in by configure. */ +/* pyconfig.h.in. Generated from configure.ac by autoheader. */ + + +#ifndef Py_PYCONFIG_H +#define Py_PYCONFIG_H + + +/* Define if building universal (internal helper macro) */ +/* #undef AC_APPLE_UNIVERSAL_BUILD */ + +/* Define for AIX if your compiler is a genuine IBM xlC/xlC_r and you want + support for AIX C++ shared extension modules. */ +/* #undef AIX_GENUINE_CPLUSPLUS */ + +/* Define this if you have AtheOS threads. */ +/* #undef ATHEOS_THREADS */ + +/* Define this if you have BeOS threads. */ +/* #undef BEOS_THREADS */ + +/* Define if you have the Mach cthreads package */ +/* #undef C_THREADS */ + +/* Define if C doubles are 64-bit IEEE 754 binary format, stored in ARM + mixed-endian order (byte order 45670123) */ +/* #undef DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754 */ + +/* Define if C doubles are 64-bit IEEE 754 binary format, stored with the most + significant byte first */ +/* #undef DOUBLE_IS_BIG_ENDIAN_IEEE754 */ + +/* Define if C doubles are 64-bit IEEE 754 binary format, stored with the + least significant byte first */ +/* #undef DOUBLE_IS_LITTLE_ENDIAN_IEEE754 */ + +/* Define if --enable-ipv6 is specified */ +#define ENABLE_IPV6 1 + +/* Define if flock needs to be linked with bsd library. */ +/* #undef FLOCK_NEEDS_LIBBSD */ + +/* Define if getpgrp() must be called as getpgrp(0). */ +/* #undef GETPGRP_HAVE_ARG */ + +/* Define if gettimeofday() does not have second (timezone) argument This is + the case on Motorola V4 (R40V4.2) */ +/* #undef GETTIMEOFDAY_NO_TZ */ + +/* Define to 1 if you have the `acosh' function. */ +#define HAVE_ACOSH 1 + +/* struct addrinfo (netdb.h) */ +#define HAVE_ADDRINFO 1 + +/* Define to 1 if you have the `alarm' function. */ +#define HAVE_ALARM 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ALLOCA_H 1 + +/* Define this if your time.h defines altzone. */ +/* #undef HAVE_ALTZONE */ + +/* Define to 1 if you have the `asinh' function. */ +#define HAVE_ASINH 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ASM_TYPES_H 1 + +/* Define to 1 if you have the `atanh' function. */ +#define HAVE_ATANH 1 + +/* Define if GCC supports __attribute__((format(PyArg_ParseTuple, 2, 3))) */ +/* #undef HAVE_ATTRIBUTE_FORMAT_PARSETUPLE */ + +/* Define to 1 if you have the `bind_textdomain_codeset' function. */ +/* #undef HAVE_BIND_TEXTDOMAIN_CODESET */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_BLUETOOTH_BLUETOOTH_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_BLUETOOTH_H */ + +/* Define if nice() returns success/failure instead of the new priority. */ +/* #undef HAVE_BROKEN_NICE */ + +/* Define if the system reports an invalid PIPE_BUF value. */ +/* #undef HAVE_BROKEN_PIPE_BUF */ + +/* Define if poll() sets errno on invalid file descriptors. */ +/* #undef HAVE_BROKEN_POLL */ + +/* Define if the Posix semaphores do not work on your system */ +/* #undef HAVE_BROKEN_POSIX_SEMAPHORES */ + +/* Define if pthread_sigmask() does not work on your system. */ +/* #undef HAVE_BROKEN_PTHREAD_SIGMASK */ + +/* define to 1 if your sem_getvalue is broken. */ +#define HAVE_BROKEN_SEM_GETVALUE 1 + +/* Define if `unsetenv` does not return an int. */ +/* #undef HAVE_BROKEN_UNSETENV */ + +/* Define this if you have the type _Bool. */ +#define HAVE_C99_BOOL 1 + +/* Define to 1 if you have the 'chflags' function. */ +/* #undef HAVE_CHFLAGS */ + +/* Define to 1 if you have the `chown' function. */ +#define HAVE_CHOWN 1 + +/* Define if you have the 'chroot' function. */ +#define HAVE_CHROOT 1 + +/* Define to 1 if you have the `clock' function. */ +#define HAVE_CLOCK 1 + +/* Define to 1 if you have the `confstr' function. */ +/* #undef HAVE_CONFSTR */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_CONIO_H */ + +/* Define to 1 if you have the `copysign' function. */ +#define HAVE_COPYSIGN 1 + +/* Define to 1 if you have the `ctermid' function. */ +/* #undef HAVE_CTERMID */ + +/* Define if you have the 'ctermid_r' function. */ +#define HAVE_CTERMID_R 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_CURSES_H */ + +/* Define if you have the 'is_term_resized' function. */ +/* #undef HAVE_CURSES_IS_TERM_RESIZED */ + +/* Define if you have the 'resizeterm' function. */ +/* #undef HAVE_CURSES_RESIZETERM */ + +/* Define if you have the 'resize_term' function. */ +/* #undef HAVE_CURSES_RESIZE_TERM */ + +/* Define to 1 if you have the declaration of `isfinite', and to 0 if you + don't. */ +#define HAVE_DECL_ISFINITE 1 + +/* Define to 1 if you have the declaration of `isinf', and to 0 if you don't. + */ +#define HAVE_DECL_ISINF 1 + +/* Define to 1 if you have the declaration of `isnan', and to 0 if you don't. + */ +#define HAVE_DECL_ISNAN 1 + +/* Define to 1 if you have the declaration of `tzname', and to 0 if you don't. + */ +/* #undef HAVE_DECL_TZNAME */ + +/* Define to 1 if you have the device macros. */ +#define HAVE_DEVICE_MACROS 1 + +/* Define to 1 if you have the /dev/ptc device file. */ +/* #undef HAVE_DEV_PTC */ + +/* Define to 1 if you have the /dev/ptmx device file. */ +/* #undef HAVE_DEV_PTMX */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_DIRECT_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#define HAVE_DIRENT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_DLFCN_H 1 + +/* Define to 1 if you have the `dlopen' function. */ +#define HAVE_DLOPEN 1 + +/* Define to 1 if you have the `dup2' function. */ +#define HAVE_DUP2 1 + +/* Defined when any dynamic module loading is enabled. */ +#define HAVE_DYNAMIC_LOADING 1 + +/* Define if you have the 'epoll' functions. */ +#define HAVE_EPOLL 1 + +/* Define to 1 if you have the `erf' function. */ +#define HAVE_ERF 1 + +/* Define to 1 if you have the `erfc' function. */ +#define HAVE_ERFC 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ERRNO_H 1 + +/* Define to 1 if you have the `execv' function. */ +#define HAVE_EXECV 1 + +/* Define to 1 if you have the `expm1' function. */ +#define HAVE_EXPM1 1 + +/* Define if you have the 'fchdir' function. */ +#define HAVE_FCHDIR 1 + +/* Define to 1 if you have the `fchmod' function. */ +#define HAVE_FCHMOD 1 + +/* Define to 1 if you have the `fchown' function. */ +#define HAVE_FCHOWN 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* Define if you have the 'fdatasync' function. */ +#define HAVE_FDATASYNC 1 + +/* Define to 1 if you have the `finite' function. */ +#define HAVE_FINITE 1 + +/* Define to 1 if you have the `flock' function. */ +#define HAVE_FLOCK 1 + +/* Define to 1 if you have the `fork' function. */ +#define HAVE_FORK 1 + +/* Define to 1 if you have the `forkpty' function. */ +/* #undef HAVE_FORKPTY */ + +/* Define to 1 if you have the `fpathconf' function. */ +#define HAVE_FPATHCONF 1 + +/* Define to 1 if you have the `fseek64' function. */ +/* #undef HAVE_FSEEK64 */ + +/* Define to 1 if you have the `fseeko' function. */ +#define HAVE_FSEEKO 1 + +/* Define to 1 if you have the `fstatvfs' function. */ +/* #undef HAVE_FSTATVFS */ + +/* Define if you have the 'fsync' function. */ +#define HAVE_FSYNC 1 + +/* Define to 1 if you have the `ftell64' function. */ +/* #undef HAVE_FTELL64 */ + +/* Define to 1 if you have the `ftello' function. */ +#define HAVE_FTELLO 1 + +/* Define to 1 if you have the `ftime' function. */ +#define HAVE_FTIME 1 + +/* Define to 1 if you have the `ftruncate' function. */ +#define HAVE_FTRUNCATE 1 + +/* Define to 1 if you have the `gai_strerror' function. */ +#define HAVE_GAI_STRERROR 1 + +/* Define to 1 if you have the `gamma' function. */ +/* #undef HAVE_GAMMA */ + +/* Define if we can use gcc inline assembler to get and set x87 control word + */ +/* #undef HAVE_GCC_ASM_FOR_X87 */ + +/* Define if you have the getaddrinfo function. */ +#define HAVE_GETADDRINFO 1 + +/* Define to 1 if you have the `getcwd' function. */ +#define HAVE_GETCWD 1 + +/* Define this if you have flockfile(), getc_unlocked(), and funlockfile() */ +#define HAVE_GETC_UNLOCKED 1 + +/* Define to 1 if you have the `getentropy' function. */ +/* #undef HAVE_GETENTROPY */ + +/* Define to 1 if you have the `getgroups' function. */ +#define HAVE_GETGROUPS 1 + +/* Define to 1 if you have the `gethostbyname' function. */ +#define HAVE_GETHOSTBYNAME 1 + +/* Define this if you have some version of gethostbyname_r() */ +/* #undef HAVE_GETHOSTBYNAME_R */ + +/* Define this if you have the 3-arg version of gethostbyname_r(). */ +/* #undef HAVE_GETHOSTBYNAME_R_3_ARG */ + +/* Define this if you have the 5-arg version of gethostbyname_r(). */ +/* #undef HAVE_GETHOSTBYNAME_R_5_ARG */ + +/* Define this if you have the 6-arg version of gethostbyname_r(). */ +/* #undef HAVE_GETHOSTBYNAME_R_6_ARG */ + +/* Define to 1 if you have the `getitimer' function. */ +#define HAVE_GETITIMER 1 + +/* Define to 1 if you have the `getloadavg' function. */ +#define HAVE_GETLOADAVG 1 + +/* Define to 1 if you have the `getlogin' function. */ +#define HAVE_GETLOGIN 1 + +/* Define to 1 if you have the `getnameinfo' function. */ +#define HAVE_GETNAMEINFO 1 + +/* Define if you have the 'getpagesize' function. */ +#define HAVE_GETPAGESIZE 1 + +/* Define to 1 if you have the `getpeername' function. */ +#define HAVE_GETPEERNAME 1 + +/* Define to 1 if you have the `getpgid' function. */ +#define HAVE_GETPGID 1 + +/* Define to 1 if you have the `getpgrp' function. */ +#define HAVE_GETPGRP 1 + +/* Define to 1 if you have the `getpid' function. */ +#define HAVE_GETPID 1 + +/* Define to 1 if you have the `getpriority' function. */ +#define HAVE_GETPRIORITY 1 + +/* Define to 1 if you have the `getpwent' function. */ +#define HAVE_GETPWENT 1 + +/* Define to 1 if you have the `getresgid' function. */ +#define HAVE_GETRESGID 1 + +/* Define to 1 if you have the `getresuid' function. */ +#define HAVE_GETRESUID 1 + +/* Define to 1 if you have the `getsid' function. */ +/* #undef HAVE_GETSID */ + +/* Define to 1 if you have the `getspent' function. */ +/* #undef HAVE_GETSPENT */ + +/* Define to 1 if you have the `getspnam' function. */ +/* #undef HAVE_GETSPNAM */ + +/* Define to 1 if you have the `gettimeofday' function. */ +#define HAVE_GETTIMEOFDAY 1 + +/* Define to 1 if you have the `getwd' function. */ +/* #undef HAVE_GETWD */ + +/* Define to 1 if you have the header file. */ +#define HAVE_GRP_H 1 + +/* Define if you have the 'hstrerror' function. */ +#define HAVE_HSTRERROR 1 + +/* Define to 1 if you have the `hypot' function. */ +#define HAVE_HYPOT 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_IEEEFP_H */ + +/* Define if you have the 'inet_aton' function. */ +#define HAVE_INET_ATON 1 + +/* Define if you have the 'inet_pton' function. */ +#define HAVE_INET_PTON 1 + +/* Define to 1 if you have the `initgroups' function. */ +#define HAVE_INITGROUPS 1 + +/* Define if your compiler provides int32_t. */ +#define HAVE_INT32_T 1 + +/* Define if your compiler provides int64_t. */ +#define HAVE_INT64_T 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_IO_H */ + +/* Define to 1 if you have the `kill' function. */ +#define HAVE_KILL 1 + +/* Define to 1 if you have the `killpg' function. */ +#define HAVE_KILLPG 1 + +/* Define if you have the 'kqueue' functions. */ +#define HAVE_KQUEUE 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_LANGINFO_H 1 + +/* Defined to enable large file support when an off_t is bigger than a long + and long long is available and at least as big as an off_t. You may need to + add some flags for configuration and compilation to enable this mode. (For + Solaris and Linux, the necessary defines are already defined.) */ +/* #undef HAVE_LARGEFILE_SUPPORT */ + +/* Define to 1 if you have the 'lchflags' function. */ +/* #undef HAVE_LCHFLAGS */ + +/* Define to 1 if you have the `lchmod' function. */ +/* #undef HAVE_LCHMOD */ + +/* Define to 1 if you have the `lchown' function. */ +#define HAVE_LCHOWN 1 + +/* Define to 1 if you have the `lgamma' function. */ +#define HAVE_LGAMMA 1 + +/* Define to 1 if you have the `dl' library (-ldl). */ +#define HAVE_LIBDL 1 + +/* Define to 1 if you have the `dld' library (-ldld). */ +/* #undef HAVE_LIBDLD */ + +/* Define to 1 if you have the `ieee' library (-lieee). */ +/* #undef HAVE_LIBIEEE */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LIBINTL_H */ + +/* Define if you have the readline library (-lreadline). */ +/* #undef HAVE_LIBREADLINE */ + +/* Define to 1 if you have the `resolv' library (-lresolv). */ +/* #undef HAVE_LIBRESOLV */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LIBUTIL_H */ + +/* Define if you have the 'link' function. */ +#define HAVE_LINK 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_LINUX_NETLINK_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LINUX_TIPC_H */ + +/* Define to 1 if you have the `log1p' function. */ +#define HAVE_LOG1P 1 + +/* Define this if you have the type long double. */ +#define HAVE_LONG_DOUBLE 1 + +/* Define this if you have the type long long. */ +#define HAVE_LONG_LONG 1 + +/* Define to 1 if you have the `lstat' function. */ +#define HAVE_LSTAT 1 + +/* Define this if you have the makedev macro. */ +#define HAVE_MAKEDEV 1 + +/* Define to 1 if you have the `memmove' function. */ +#define HAVE_MEMMOVE 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `mkfifo' function. */ +/* #undef HAVE_MKFIFO */ + +/* Define to 1 if you have the `mknod' function. */ +#define HAVE_MKNOD 1 + +/* Define to 1 if you have the `mktime' function. */ +#define HAVE_MKTIME 1 + +/* Define to 1 if you have the `mmap' function. */ +#define HAVE_MMAP 1 + +/* Define to 1 if you have the `mremap' function. */ +#define HAVE_MREMAP 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NCURSES_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. */ +/* #undef HAVE_NDIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_NETPACKET_PACKET_H 1 + +/* Define to 1 if you have the `nice' function. */ +#define HAVE_NICE 1 + +/* Define to 1 if you have the `openpty' function. */ +/* #undef HAVE_OPENPTY */ + +/* Define if compiling using MacOS X 10.5 SDK or later. */ +/* #undef HAVE_OSX105_SDK */ + +/* Define to 1 if you have the `pathconf' function. */ +#define HAVE_PATHCONF 1 + +/* Define to 1 if you have the `pause' function. */ +#define HAVE_PAUSE 1 + +/* Define to 1 if you have the `plock' function. */ +/* #undef HAVE_PLOCK */ + +/* Define to 1 if you have the `poll' function. */ +#define HAVE_POLL 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_POLL_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PROCESS_H */ + +/* Define if your compiler supports function prototype */ +#define HAVE_PROTOTYPES 1 + +/* Define if you have GNU PTH threads. */ +/* #undef HAVE_PTH */ + +/* Define to 1 if you have the `pthread_atfork' function. */ +/* #undef HAVE_PTHREAD_ATFORK */ + +/* Defined for Solaris 2.6 bug in pthread header. */ +/* #undef HAVE_PTHREAD_DESTRUCTOR */ + +/* Define to 1 if you have the header file. */ +#define HAVE_PTHREAD_H 1 + +/* Define to 1 if you have the `pthread_init' function. */ +/* #undef HAVE_PTHREAD_INIT */ + +/* Define to 1 if you have the `pthread_sigmask' function. */ +#define HAVE_PTHREAD_SIGMASK 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PTY_H */ + +/* Define to 1 if you have the `putenv' function. */ +#define HAVE_PUTENV 1 + +/* Define if the libcrypto has RAND_egd */ +/* #undef HAVE_RAND_EGD */ + +/* Define to 1 if you have the `readlink' function. */ +#define HAVE_READLINK 1 + +/* Define to 1 if you have the `realpath' function. */ +#define HAVE_REALPATH 1 + +/* Define if you have readline 2.1 */ +/* #undef HAVE_RL_CALLBACK */ + +/* Define if you can turn off readline's signal handling. */ +/* #undef HAVE_RL_CATCH_SIGNAL */ + +/* Define if you have readline 2.2 */ +/* #undef HAVE_RL_COMPLETION_APPEND_CHARACTER */ + +/* Define if you have readline 4.0 */ +/* #undef HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK */ + +/* Define if you have readline 4.2 */ +/* #undef HAVE_RL_COMPLETION_MATCHES */ + +/* Define if you have rl_completion_suppress_append */ +/* #undef HAVE_RL_COMPLETION_SUPPRESS_APPEND */ + +/* Define if you have readline 4.0 */ +/* #undef HAVE_RL_PRE_INPUT_HOOK */ + +/* Define to 1 if you have the `round' function. */ +#define HAVE_ROUND 1 + +/* Define to 1 if you have the `select' function. */ +#define HAVE_SELECT 1 + +/* Define to 1 if you have the `sem_getvalue' function. */ +#define HAVE_SEM_GETVALUE 1 + +/* Define to 1 if you have the `sem_open' function. */ +#define HAVE_SEM_OPEN 1 + +/* Define to 1 if you have the `sem_timedwait' function. */ +#define HAVE_SEM_TIMEDWAIT 1 + +/* Define to 1 if you have the `sem_unlink' function. */ +#define HAVE_SEM_UNLINK 1 + +/* Define to 1 if you have the `setegid' function. */ +#define HAVE_SETEGID 1 + +/* Define to 1 if you have the `seteuid' function. */ +#define HAVE_SETEUID 1 + +/* Define to 1 if you have the `setgid' function. */ +#define HAVE_SETGID 1 + +/* Define if you have the 'setgroups' function. */ +#define HAVE_SETGROUPS 1 + +/* Define to 1 if you have the `setitimer' function. */ +#define HAVE_SETITIMER 1 + +/* Define to 1 if you have the `setlocale' function. */ +#define HAVE_SETLOCALE 1 + +/* Define to 1 if you have the `setpgid' function. */ +#define HAVE_SETPGID 1 + +/* Define to 1 if you have the `setpgrp' function. */ +#define HAVE_SETPGRP 1 + +/* Define to 1 if you have the `setregid' function. */ +#define HAVE_SETREGID 1 + +/* Define to 1 if you have the `setresgid' function. */ +#define HAVE_SETRESGID 1 + +/* Define to 1 if you have the `setresuid' function. */ +#define HAVE_SETRESUID 1 + +/* Define to 1 if you have the `setreuid' function. */ +#define HAVE_SETREUID 1 + +/* Define to 1 if you have the `setsid' function. */ +#define HAVE_SETSID 1 + +/* Define to 1 if you have the `setuid' function. */ +#define HAVE_SETUID 1 + +/* Define to 1 if you have the `setvbuf' function. */ +#define HAVE_SETVBUF 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SHADOW_H */ + +/* Define to 1 if you have the `sigaction' function. */ +#define HAVE_SIGACTION 1 + +/* Define to 1 if you have the `siginterrupt' function. */ +#define HAVE_SIGINTERRUPT 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SIGNAL_H 1 + +/* Define to 1 if you have the `sigrelse' function. */ +/* #undef HAVE_SIGRELSE */ + +/* Define to 1 if you have the `snprintf' function. */ +#define HAVE_SNPRINTF 1 + +/* Define if sockaddr has sa_len member */ +/* #undef HAVE_SOCKADDR_SA_LEN */ + +/* struct sockaddr_storage (sys/socket.h) */ +#define HAVE_SOCKADDR_STORAGE 1 + +/* Define if you have the 'socketpair' function. */ +#define HAVE_SOCKETPAIR 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SPAWN_H */ + +/* Define if your compiler provides ssize_t */ +#define HAVE_SSIZE_T 1 + +/* Define to 1 if you have the `statvfs' function. */ +/* #undef HAVE_STATVFS */ + +/* Define if you have struct stat.st_mtim.tv_nsec */ +/* #undef HAVE_STAT_TV_NSEC */ + +/* Define if you have struct stat.st_mtimensec */ +/* #undef HAVE_STAT_TV_NSEC2 */ + +/* Define if your compiler supports variable length function prototypes (e.g. + void fprintf(FILE *, char *, ...);) *and* */ +#define HAVE_STDARG_PROTOTYPES 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the `strdup' function. */ +#define HAVE_STRDUP 1 + +/* Define to 1 if you have the `strftime' function. */ +#define HAVE_STRFTIME 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_STROPTS_H */ + +/* Define to 1 if `st_birthtime' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_BIRTHTIME */ + +/* Define to 1 if `st_blksize' is a member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_BLKSIZE 1 + +/* Define to 1 if `st_blocks' is a member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_BLOCKS 1 + +/* Define to 1 if `st_flags' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_FLAGS */ + +/* Define to 1 if `st_gen' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_GEN */ + +/* Define to 1 if `st_rdev' is a member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_RDEV 1 + +/* Define to 1 if `tm_zone' is a member of `struct tm'. */ +#define HAVE_STRUCT_TM_TM_ZONE 1 + +/* Define to 1 if your `struct stat' has `st_blocks'. Deprecated, use + `HAVE_STRUCT_STAT_ST_BLOCKS' instead. */ +#define HAVE_ST_BLOCKS 1 + +/* Define if you have the 'symlink' function. */ +#define HAVE_SYMLINK 1 + +/* Define to 1 if you have the `sysconf' function. */ +#define HAVE_SYSCONF 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYSEXITS_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_AUDIOIO_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_BSDTTY_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +/* #undef HAVE_SYS_DIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_EPOLL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_EVENT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_FILE_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_LOADAVG_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_LOCK_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_MKDEV_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_MODEM_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +/* #undef HAVE_SYS_NDIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_PARAM_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_POLL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_RESOURCE_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SELECT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SOCKET_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_STATVFS_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_TERMIO_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIMES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UN_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UTSNAME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_WAIT_H 1 + +/* Define to 1 if you have the `tcgetpgrp' function. */ +#define HAVE_TCGETPGRP 1 + +/* Define to 1 if you have the `tcsetpgrp' function. */ +#define HAVE_TCSETPGRP 1 + +/* Define to 1 if you have the `tempnam' function. */ +#define HAVE_TEMPNAM 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_TERMIOS_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_TERM_H */ + +/* Define to 1 if you have the `tgamma' function. */ +#define HAVE_TGAMMA 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_THREAD_H */ + +/* Define to 1 if you have the `timegm' function. */ +/* #undef HAVE_TIMEGM */ + +/* Define to 1 if you have the `times' function. */ +#define HAVE_TIMES 1 + +/* Define to 1 if you have the `tmpfile' function. */ +#define HAVE_TMPFILE 1 + +/* Define to 1 if you have the `tmpnam' function. */ +#define HAVE_TMPNAM 1 + +/* Define to 1 if you have the `tmpnam_r' function. */ +/* #undef HAVE_TMPNAM_R */ + +/* Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use + `HAVE_STRUCT_TM_TM_ZONE' instead. */ +#define HAVE_TM_ZONE 1 + +/* Define to 1 if you have the `truncate' function. */ +#define HAVE_TRUNCATE 1 + +/* Define to 1 if you don't have `tm_zone' but do have the external array + `tzname'. */ +/* #undef HAVE_TZNAME */ + +/* Define this if you have tcl and TCL_UTF_MAX==6 */ +/* #undef HAVE_UCS4_TCL */ + +/* Define if your compiler provides uint32_t. */ +#define HAVE_UINT32_T 1 + +/* Define if your compiler provides uint64_t. */ +#define HAVE_UINT64_T 1 + +/* Define to 1 if the system has the type `uintptr_t'. */ +#define HAVE_UINTPTR_T 1 + +/* Define to 1 if you have the `uname' function. */ +#define HAVE_UNAME 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you have the `unsetenv' function. */ +#define HAVE_UNSETENV 1 + +/* Define if you have a useable wchar_t type defined in wchar.h; useable means + wchar_t must be an unsigned type with at least 16 bits. (see + Include/unicodeobject.h). */ +/* #undef HAVE_USABLE_WCHAR_T */ + +/* Define to 1 if you have the header file. */ +#define HAVE_UTIL_H 1 + +/* Define to 1 if you have the `utimes' function. */ +#define HAVE_UTIMES 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UTIME_H 1 + +/* Define to 1 if you have the `wait3' function. */ +#define HAVE_WAIT3 1 + +/* Define to 1 if you have the `wait4' function. */ +/* #undef HAVE_WAIT4 */ + +/* Define to 1 if you have the `waitpid' function. */ +#define HAVE_WAITPID 1 + +/* Define if the compiler provides a wchar.h header file. */ +#define HAVE_WCHAR_H 1 + +/* Define to 1 if you have the `wcscoll' function. */ +#define HAVE_WCSCOLL 1 + +/* Define if tzset() actually switches the local timezone in a meaningful way. + */ +/* #undef HAVE_WORKING_TZSET */ + +/* Define if the zlib library has inflateCopy */ +#define HAVE_ZLIB_COPY 1 + +/* Define to 1 if you have the `_getpty' function. */ +/* #undef HAVE__GETPTY */ + +/* Define if you are using Mach cthreads directly under /include */ +/* #undef HURD_C_THREADS */ + +/* Define if you are using Mach cthreads under mach / */ +/* #undef MACH_C_THREADS */ + +/* Define to 1 if `major', `minor', and `makedev' are declared in . + */ +/* #undef MAJOR_IN_MKDEV */ + +/* Define to 1 if `major', `minor', and `makedev' are declared in + . */ +#define MAJOR_IN_SYSMACROS 1 + +/* Define if mvwdelch in curses.h is an expression. */ +/* #undef MVWDELCH_IS_EXPRESSION */ + +/* Define to the address where bug reports for this package should be sent. */ +/* #undef PACKAGE_BUGREPORT */ + +/* Define to the full name of this package. */ +/* #undef PACKAGE_NAME */ + +/* Define to the full name and version of this package. */ +/* #undef PACKAGE_STRING */ + +/* Define to the one symbol short name of this package. */ +/* #undef PACKAGE_TARNAME */ + +/* Define to the home page for this package. */ +/* #undef PACKAGE_URL */ + +/* Define to the version of this package. */ +/* #undef PACKAGE_VERSION */ + +/* Define if POSIX semaphores aren't enabled on your system */ +/* #undef POSIX_SEMAPHORES_NOT_ENABLED */ + +/* Defined if PTHREAD_SCOPE_SYSTEM supported. */ +/* #undef PTHREAD_SYSTEM_SCHED_SUPPORTED */ + +/* Define as the preferred size in bits of long digits */ +/* #undef PYLONG_BITS_IN_DIGIT */ + +/* Define to printf format modifier for long long type */ +#define PY_FORMAT_LONG_LONG "ll" + +/* Define to printf format modifier for Py_ssize_t */ +#define PY_FORMAT_SIZE_T "z" + +/* Define as the integral type used for Unicode representation. */ +#define PY_UNICODE_TYPE unsigned long + +/* Define if you want to build an interpreter with many run-time checks. */ +/* #undef Py_DEBUG */ + +/* Defined if Python is built as a shared library. */ +#define Py_ENABLE_SHARED 1 + +/* Define as the size of the unicode type. */ +#define Py_UNICODE_SIZE 4 + +/* Define if you want to have a Unicode type. */ +#define Py_USING_UNICODE 1 + +/* assume C89 semantics that RETSIGTYPE is always void */ +#define RETSIGTYPE void + +/* Define if setpgrp() must be called as setpgrp(0, 0). */ +/* #undef SETPGRP_HAVE_ARG */ + +/* Define this to be extension of shared libraries (including the dot!). */ +#define SHLIB_EXT ".so" + +/* Define if i>>j for signed int i does not extend the sign bit when i < 0 */ +/* #undef SIGNED_RIGHT_SHIFT_ZERO_FILLS */ + +/* The size of `double', as computed by sizeof. */ +#define SIZEOF_DOUBLE 8 + +/* The size of `float', as computed by sizeof. */ +#define SIZEOF_FLOAT 4 + +/* The size of `fpos_t', as computed by sizeof. */ +#define SIZEOF_FPOS_T 4 + +/* The size of `int', as computed by sizeof. */ +#define SIZEOF_INT 4 + +/* The size of `long', as computed by sizeof. */ +#define SIZEOF_LONG 4 + +/* The size of `long double', as computed by sizeof. */ +#define SIZEOF_LONG_DOUBLE 8 + +/* The size of `long long', as computed by sizeof. */ +#define SIZEOF_LONG_LONG 8 + +/* The size of `off_t', as computed by sizeof. */ +#define SIZEOF_OFF_T 4 + +/* The size of `pid_t', as computed by sizeof. */ +#define SIZEOF_PID_T 4 + +/* The size of `pthread_t', as computed by sizeof. */ +#define SIZEOF_PTHREAD_T 4 + +/* The size of `short', as computed by sizeof. */ +#define SIZEOF_SHORT 2 + +/* The size of `size_t', as computed by sizeof. */ +#define SIZEOF_SIZE_T 4 + +/* The size of `time_t', as computed by sizeof. */ +#define SIZEOF_TIME_T 4 + +/* The size of `uintptr_t', as computed by sizeof. */ +#define SIZEOF_UINTPTR_T 4 + +/* The size of `void *', as computed by sizeof. */ +#define SIZEOF_VOID_P 4 + +/* The size of `wchar_t', as computed by sizeof. */ +#define SIZEOF_WCHAR_T 4 + +/* The size of `_Bool', as computed by sizeof. */ +#define SIZEOF__BOOL 1 + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define if you can safely include both and + (which you can't on SCO ODT 3.0). */ +#define SYS_SELECT_WITH_SYS_TIME 1 + +/* Define if tanh(-0.) is -0., or if platform doesn't have signed zeros */ +/* #undef TANH_PRESERVES_ZERO_SIGN */ + +/* Define to 1 if you can safely include both and . */ +#define TIME_WITH_SYS_TIME 1 + +/* Define to 1 if your declares `struct tm'. */ +/* #undef TM_IN_SYS_TIME */ + +/* Enable extensions on AIX 3, Interix. */ +#ifndef _ALL_SOURCE +# define _ALL_SOURCE 1 +#endif +/* Enable GNU extensions on systems that have them. */ +#ifndef _GNU_SOURCE +# define _GNU_SOURCE 1 +#endif +/* Enable threading extensions on Solaris. */ +#ifndef _POSIX_PTHREAD_SEMANTICS +# define _POSIX_PTHREAD_SEMANTICS 1 +#endif +/* Enable extensions on HP NonStop. */ +#ifndef _TANDEM_SOURCE +# define _TANDEM_SOURCE 1 +#endif +/* Enable general extensions on Solaris. */ +#ifndef __EXTENSIONS__ +# define __EXTENSIONS__ 1 +#endif + + +/* Define if you want to use MacPython modules on MacOSX in unix-Python. */ +/* #undef USE_TOOLBOX_OBJECT_GLUE */ + +/* Define if a va_list is an array of some kind */ +/* #undef VA_LIST_IS_ARRAY */ + +/* Define if you want SIGFPE handled (see Include/pyfpe.h). */ +/* #undef WANT_SIGFPE_HANDLER */ + +/* Define if you want wctype.h functions to be used instead of the one + supplied by Python itself. (see Include/unicodectype.h). */ +/* #undef WANT_WCTYPE_FUNCTIONS */ + +/* Define if WINDOW in curses.h offers a field _flags. */ +/* #undef WINDOW_HAS_FLAGS */ + +/* Define if you want documentation strings in extension modules */ +#define WITH_DOC_STRINGS 1 + +/* Define if you want to use the new-style (Openstep, Rhapsody, MacOS) dynamic + linker (dyld) instead of the old-style (NextStep) dynamic linker (rld). + Dyld is necessary to support frameworks. */ +/* #undef WITH_DYLD */ + +/* Define to 1 if libintl is needed for locale functions. */ +/* #undef WITH_LIBINTL */ + +/* Define if you want to produce an OpenStep/Rhapsody framework (shared + library plus accessory files). */ +/* #undef WITH_NEXT_FRAMEWORK */ + +/* Define if you want to compile in Python-specific mallocs */ +#define WITH_PYMALLOC 1 + +/* Define if you want to compile in rudimentary thread support */ +#define WITH_THREAD 1 + +/* Define to profile with the Pentium timestamp counter */ +/* #undef WITH_TSC */ + +/* Define if you want pymalloc to be disabled when running under valgrind */ +/* #undef WITH_VALGRIND */ + +/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most + significant byte first (like Motorola and SPARC, unlike Intel). */ +#if defined AC_APPLE_UNIVERSAL_BUILD +# if defined __BIG_ENDIAN__ +# define WORDS_BIGENDIAN 1 +# endif +#else +# ifndef WORDS_BIGENDIAN +/* # undef WORDS_BIGENDIAN */ +# endif +#endif + +/* Define if arithmetic is subject to x87-style double rounding issue */ +/* #undef X87_DOUBLE_ROUNDING */ + +/* Define on OpenBSD to activate all library features */ +/* #undef _BSD_SOURCE */ + +/* Define on Irix to enable u_int */ +#define _BSD_TYPES 1 + +/* Define on Darwin to activate all library features */ +#define _DARWIN_C_SOURCE 1 + +/* This must be set to 64 on some systems to enable large file support. */ +#define _FILE_OFFSET_BITS 64 + +/* Define on Linux to activate all library features */ +#define _GNU_SOURCE 1 + +/* This must be defined on some systems to enable large file support. */ +#define _LARGEFILE_SOURCE 1 + +/* This must be defined on AIX systems to enable large file support. */ +/* #undef _LARGE_FILES */ + +/* Define to 1 if on MINIX. */ +/* #undef _MINIX */ + +/* Define on NetBSD to activate all library features */ +#define _NETBSD_SOURCE 1 + +/* Define _OSF_SOURCE to get the makedev macro. */ +/* #undef _OSF_SOURCE */ + +/* Define to 2 if the system does not provide POSIX.1 features except with + this defined. */ +/* #undef _POSIX_1_SOURCE */ + +/* Define to activate features from IEEE Stds 1003.1-2001 */ +#define _POSIX_C_SOURCE 200112L + +/* Define to 1 if you need to in order for `stat' and other things to work. */ +/* #undef _POSIX_SOURCE */ + +/* Define if you have POSIX threads, and your system does not define that. */ +/* #undef _POSIX_THREADS */ + +/* Define to force use of thread-safe errno, h_errno, and other functions */ +#define _REENTRANT 1 + +/* Define for Solaris 2.5.1 so the uint32_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +/* #undef _UINT32_T */ + +/* Define for Solaris 2.5.1 so the uint64_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +/* #undef _UINT64_T */ + +/* Define to the level of X/Open that your system supports */ +#define _XOPEN_SOURCE 600 + +/* Define to activate Unix95-and-earlier features */ +#define _XOPEN_SOURCE_EXTENDED 1 + +/* Define on FreeBSD to activate all library features */ +#define __BSD_VISIBLE 1 + +/* Define to 1 if type `char' is unsigned and you are not using gcc. */ +#ifndef __CHAR_UNSIGNED__ +/* # undef __CHAR_UNSIGNED__ */ +#endif + +/* Defined on Solaris to see additional function prototypes. */ +#define __EXTENSIONS__ 1 + +/* Define to 'long' if doesn't define. */ +/* #undef clock_t */ + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ + +/* Define to `int' if doesn't define. */ +/* #undef gid_t */ + +/* Define to the type of a signed integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +/* #undef int32_t */ + +/* Define to the type of a signed integer type of width exactly 64 bits if + such a type exists and the standard includes do not define it. */ +/* #undef int64_t */ + +/* Define to `int' if does not define. */ +/* #undef mode_t */ + +/* Define to `long int' if does not define. */ +/* #undef off_t */ + +/* Define to `int' if does not define. */ +/* #undef pid_t */ + +/* Define to empty if the keyword does not work. */ +/* #undef signed */ + +/* Define to `unsigned int' if does not define. */ +/* #undef size_t */ + +/* Define to `int' if does not define. */ +/* #undef socklen_t */ + +/* Define to `int' if doesn't define. */ +/* #undef uid_t */ + +/* Define to the type of an unsigned integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint32_t */ + +/* Define to the type of an unsigned integer type of width exactly 64 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint64_t */ + +/* Define to empty if the keyword does not work. */ +/* #undef volatile */ + + +/* Define the macros needed if on a UnixWare 7.x system. */ +#if defined(__USLC__) && defined(__SCO_VERSION__) +#define STRICT_SYSV_CURSES /* Don't use ncurses extensions */ +#endif + +#endif /*Py_PYCONFIG_H*/ + diff --git a/android/python27/include/pyconfig_armeabi_v7a.h b/android/python27/include/pyconfig_armeabi_v7a.h new file mode 100644 index 000000000..8c9ca6178 --- /dev/null +++ b/android/python27/include/pyconfig_armeabi_v7a.h @@ -0,0 +1,1282 @@ +/* pyconfig.h. Generated from pyconfig.h.in by configure. */ +/* pyconfig.h.in. Generated from configure.ac by autoheader. */ + + +#ifndef Py_PYCONFIG_H +#define Py_PYCONFIG_H + + +/* Define if building universal (internal helper macro) */ +/* #undef AC_APPLE_UNIVERSAL_BUILD */ + +/* Define for AIX if your compiler is a genuine IBM xlC/xlC_r and you want + support for AIX C++ shared extension modules. */ +/* #undef AIX_GENUINE_CPLUSPLUS */ + +/* Define this if you have AtheOS threads. */ +/* #undef ATHEOS_THREADS */ + +/* Define this if you have BeOS threads. */ +/* #undef BEOS_THREADS */ + +/* Define if you have the Mach cthreads package */ +/* #undef C_THREADS */ + +/* Define if C doubles are 64-bit IEEE 754 binary format, stored in ARM + mixed-endian order (byte order 45670123) */ +/* #undef DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754 */ + +/* Define if C doubles are 64-bit IEEE 754 binary format, stored with the most + significant byte first */ +/* #undef DOUBLE_IS_BIG_ENDIAN_IEEE754 */ + +/* Define if C doubles are 64-bit IEEE 754 binary format, stored with the + least significant byte first */ +/* #undef DOUBLE_IS_LITTLE_ENDIAN_IEEE754 */ + +/* Define if --enable-ipv6 is specified */ +#define ENABLE_IPV6 1 + +/* Define if flock needs to be linked with bsd library. */ +/* #undef FLOCK_NEEDS_LIBBSD */ + +/* Define if getpgrp() must be called as getpgrp(0). */ +/* #undef GETPGRP_HAVE_ARG */ + +/* Define if gettimeofday() does not have second (timezone) argument This is + the case on Motorola V4 (R40V4.2) */ +/* #undef GETTIMEOFDAY_NO_TZ */ + +/* Define to 1 if you have the `acosh' function. */ +#define HAVE_ACOSH 1 + +/* struct addrinfo (netdb.h) */ +#define HAVE_ADDRINFO 1 + +/* Define to 1 if you have the `alarm' function. */ +#define HAVE_ALARM 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ALLOCA_H 1 + +/* Define this if your time.h defines altzone. */ +/* #undef HAVE_ALTZONE */ + +/* Define to 1 if you have the `asinh' function. */ +#define HAVE_ASINH 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ASM_TYPES_H 1 + +/* Define to 1 if you have the `atanh' function. */ +#define HAVE_ATANH 1 + +/* Define if GCC supports __attribute__((format(PyArg_ParseTuple, 2, 3))) */ +/* #undef HAVE_ATTRIBUTE_FORMAT_PARSETUPLE */ + +/* Define to 1 if you have the `bind_textdomain_codeset' function. */ +/* #undef HAVE_BIND_TEXTDOMAIN_CODESET */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_BLUETOOTH_BLUETOOTH_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_BLUETOOTH_H */ + +/* Define if nice() returns success/failure instead of the new priority. */ +/* #undef HAVE_BROKEN_NICE */ + +/* Define if the system reports an invalid PIPE_BUF value. */ +/* #undef HAVE_BROKEN_PIPE_BUF */ + +/* Define if poll() sets errno on invalid file descriptors. */ +/* #undef HAVE_BROKEN_POLL */ + +/* Define if the Posix semaphores do not work on your system */ +/* #undef HAVE_BROKEN_POSIX_SEMAPHORES */ + +/* Define if pthread_sigmask() does not work on your system. */ +/* #undef HAVE_BROKEN_PTHREAD_SIGMASK */ + +/* define to 1 if your sem_getvalue is broken. */ +#define HAVE_BROKEN_SEM_GETVALUE 1 + +/* Define if `unsetenv` does not return an int. */ +/* #undef HAVE_BROKEN_UNSETENV */ + +/* Define this if you have the type _Bool. */ +#define HAVE_C99_BOOL 1 + +/* Define to 1 if you have the 'chflags' function. */ +/* #undef HAVE_CHFLAGS */ + +/* Define to 1 if you have the `chown' function. */ +#define HAVE_CHOWN 1 + +/* Define if you have the 'chroot' function. */ +#define HAVE_CHROOT 1 + +/* Define to 1 if you have the `clock' function. */ +#define HAVE_CLOCK 1 + +/* Define to 1 if you have the `confstr' function. */ +/* #undef HAVE_CONFSTR */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_CONIO_H */ + +/* Define to 1 if you have the `copysign' function. */ +#define HAVE_COPYSIGN 1 + +/* Define to 1 if you have the `ctermid' function. */ +/* #undef HAVE_CTERMID */ + +/* Define if you have the 'ctermid_r' function. */ +#define HAVE_CTERMID_R 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_CURSES_H */ + +/* Define if you have the 'is_term_resized' function. */ +/* #undef HAVE_CURSES_IS_TERM_RESIZED */ + +/* Define if you have the 'resizeterm' function. */ +/* #undef HAVE_CURSES_RESIZETERM */ + +/* Define if you have the 'resize_term' function. */ +/* #undef HAVE_CURSES_RESIZE_TERM */ + +/* Define to 1 if you have the declaration of `isfinite', and to 0 if you + don't. */ +#define HAVE_DECL_ISFINITE 1 + +/* Define to 1 if you have the declaration of `isinf', and to 0 if you don't. + */ +#define HAVE_DECL_ISINF 1 + +/* Define to 1 if you have the declaration of `isnan', and to 0 if you don't. + */ +#define HAVE_DECL_ISNAN 1 + +/* Define to 1 if you have the declaration of `tzname', and to 0 if you don't. + */ +/* #undef HAVE_DECL_TZNAME */ + +/* Define to 1 if you have the device macros. */ +#define HAVE_DEVICE_MACROS 1 + +/* Define to 1 if you have the /dev/ptc device file. */ +/* #undef HAVE_DEV_PTC */ + +/* Define to 1 if you have the /dev/ptmx device file. */ +/* #undef HAVE_DEV_PTMX */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_DIRECT_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#define HAVE_DIRENT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_DLFCN_H 1 + +/* Define to 1 if you have the `dlopen' function. */ +#define HAVE_DLOPEN 1 + +/* Define to 1 if you have the `dup2' function. */ +#define HAVE_DUP2 1 + +/* Defined when any dynamic module loading is enabled. */ +#define HAVE_DYNAMIC_LOADING 1 + +/* Define if you have the 'epoll' functions. */ +#define HAVE_EPOLL 1 + +/* Define to 1 if you have the `erf' function. */ +#define HAVE_ERF 1 + +/* Define to 1 if you have the `erfc' function. */ +#define HAVE_ERFC 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ERRNO_H 1 + +/* Define to 1 if you have the `execv' function. */ +#define HAVE_EXECV 1 + +/* Define to 1 if you have the `expm1' function. */ +#define HAVE_EXPM1 1 + +/* Define if you have the 'fchdir' function. */ +#define HAVE_FCHDIR 1 + +/* Define to 1 if you have the `fchmod' function. */ +#define HAVE_FCHMOD 1 + +/* Define to 1 if you have the `fchown' function. */ +#define HAVE_FCHOWN 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* Define if you have the 'fdatasync' function. */ +#define HAVE_FDATASYNC 1 + +/* Define to 1 if you have the `finite' function. */ +#define HAVE_FINITE 1 + +/* Define to 1 if you have the `flock' function. */ +#define HAVE_FLOCK 1 + +/* Define to 1 if you have the `fork' function. */ +#define HAVE_FORK 1 + +/* Define to 1 if you have the `forkpty' function. */ +/* #undef HAVE_FORKPTY */ + +/* Define to 1 if you have the `fpathconf' function. */ +#define HAVE_FPATHCONF 1 + +/* Define to 1 if you have the `fseek64' function. */ +/* #undef HAVE_FSEEK64 */ + +/* Define to 1 if you have the `fseeko' function. */ +#define HAVE_FSEEKO 1 + +/* Define to 1 if you have the `fstatvfs' function. */ +/* #undef HAVE_FSTATVFS */ + +/* Define if you have the 'fsync' function. */ +#define HAVE_FSYNC 1 + +/* Define to 1 if you have the `ftell64' function. */ +/* #undef HAVE_FTELL64 */ + +/* Define to 1 if you have the `ftello' function. */ +#define HAVE_FTELLO 1 + +/* Define to 1 if you have the `ftime' function. */ +#define HAVE_FTIME 1 + +/* Define to 1 if you have the `ftruncate' function. */ +#define HAVE_FTRUNCATE 1 + +/* Define to 1 if you have the `gai_strerror' function. */ +#define HAVE_GAI_STRERROR 1 + +/* Define to 1 if you have the `gamma' function. */ +/* #undef HAVE_GAMMA */ + +/* Define if we can use gcc inline assembler to get and set x87 control word + */ +/* #undef HAVE_GCC_ASM_FOR_X87 */ + +/* Define if you have the getaddrinfo function. */ +#define HAVE_GETADDRINFO 1 + +/* Define to 1 if you have the `getcwd' function. */ +#define HAVE_GETCWD 1 + +/* Define this if you have flockfile(), getc_unlocked(), and funlockfile() */ +#define HAVE_GETC_UNLOCKED 1 + +/* Define to 1 if you have the `getentropy' function. */ +/* #undef HAVE_GETENTROPY */ + +/* Define to 1 if you have the `getgroups' function. */ +#define HAVE_GETGROUPS 1 + +/* Define to 1 if you have the `gethostbyname' function. */ +#define HAVE_GETHOSTBYNAME 1 + +/* Define this if you have some version of gethostbyname_r() */ +/* #undef HAVE_GETHOSTBYNAME_R */ + +/* Define this if you have the 3-arg version of gethostbyname_r(). */ +/* #undef HAVE_GETHOSTBYNAME_R_3_ARG */ + +/* Define this if you have the 5-arg version of gethostbyname_r(). */ +/* #undef HAVE_GETHOSTBYNAME_R_5_ARG */ + +/* Define this if you have the 6-arg version of gethostbyname_r(). */ +/* #undef HAVE_GETHOSTBYNAME_R_6_ARG */ + +/* Define to 1 if you have the `getitimer' function. */ +#define HAVE_GETITIMER 1 + +/* Define to 1 if you have the `getloadavg' function. */ +#define HAVE_GETLOADAVG 1 + +/* Define to 1 if you have the `getlogin' function. */ +#define HAVE_GETLOGIN 1 + +/* Define to 1 if you have the `getnameinfo' function. */ +#define HAVE_GETNAMEINFO 1 + +/* Define if you have the 'getpagesize' function. */ +#define HAVE_GETPAGESIZE 1 + +/* Define to 1 if you have the `getpeername' function. */ +#define HAVE_GETPEERNAME 1 + +/* Define to 1 if you have the `getpgid' function. */ +#define HAVE_GETPGID 1 + +/* Define to 1 if you have the `getpgrp' function. */ +#define HAVE_GETPGRP 1 + +/* Define to 1 if you have the `getpid' function. */ +#define HAVE_GETPID 1 + +/* Define to 1 if you have the `getpriority' function. */ +#define HAVE_GETPRIORITY 1 + +/* Define to 1 if you have the `getpwent' function. */ +#define HAVE_GETPWENT 1 + +/* Define to 1 if you have the `getresgid' function. */ +#define HAVE_GETRESGID 1 + +/* Define to 1 if you have the `getresuid' function. */ +#define HAVE_GETRESUID 1 + +/* Define to 1 if you have the `getsid' function. */ +/* #undef HAVE_GETSID */ + +/* Define to 1 if you have the `getspent' function. */ +/* #undef HAVE_GETSPENT */ + +/* Define to 1 if you have the `getspnam' function. */ +/* #undef HAVE_GETSPNAM */ + +/* Define to 1 if you have the `gettimeofday' function. */ +#define HAVE_GETTIMEOFDAY 1 + +/* Define to 1 if you have the `getwd' function. */ +/* #undef HAVE_GETWD */ + +/* Define to 1 if you have the header file. */ +#define HAVE_GRP_H 1 + +/* Define if you have the 'hstrerror' function. */ +#define HAVE_HSTRERROR 1 + +/* Define to 1 if you have the `hypot' function. */ +#define HAVE_HYPOT 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_IEEEFP_H */ + +/* Define if you have the 'inet_aton' function. */ +#define HAVE_INET_ATON 1 + +/* Define if you have the 'inet_pton' function. */ +#define HAVE_INET_PTON 1 + +/* Define to 1 if you have the `initgroups' function. */ +#define HAVE_INITGROUPS 1 + +/* Define if your compiler provides int32_t. */ +#define HAVE_INT32_T 1 + +/* Define if your compiler provides int64_t. */ +#define HAVE_INT64_T 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_IO_H */ + +/* Define to 1 if you have the `kill' function. */ +#define HAVE_KILL 1 + +/* Define to 1 if you have the `killpg' function. */ +#define HAVE_KILLPG 1 + +/* Define if you have the 'kqueue' functions. */ +#define HAVE_KQUEUE 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_LANGINFO_H 1 + +/* Defined to enable large file support when an off_t is bigger than a long + and long long is available and at least as big as an off_t. You may need to + add some flags for configuration and compilation to enable this mode. (For + Solaris and Linux, the necessary defines are already defined.) */ +/* #undef HAVE_LARGEFILE_SUPPORT */ + +/* Define to 1 if you have the 'lchflags' function. */ +/* #undef HAVE_LCHFLAGS */ + +/* Define to 1 if you have the `lchmod' function. */ +/* #undef HAVE_LCHMOD */ + +/* Define to 1 if you have the `lchown' function. */ +#define HAVE_LCHOWN 1 + +/* Define to 1 if you have the `lgamma' function. */ +#define HAVE_LGAMMA 1 + +/* Define to 1 if you have the `dl' library (-ldl). */ +#define HAVE_LIBDL 1 + +/* Define to 1 if you have the `dld' library (-ldld). */ +/* #undef HAVE_LIBDLD */ + +/* Define to 1 if you have the `ieee' library (-lieee). */ +/* #undef HAVE_LIBIEEE */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LIBINTL_H */ + +/* Define if you have the readline library (-lreadline). */ +/* #undef HAVE_LIBREADLINE */ + +/* Define to 1 if you have the `resolv' library (-lresolv). */ +/* #undef HAVE_LIBRESOLV */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LIBUTIL_H */ + +/* Define if you have the 'link' function. */ +#define HAVE_LINK 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_LINUX_NETLINK_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LINUX_TIPC_H */ + +/* Define to 1 if you have the `log1p' function. */ +#define HAVE_LOG1P 1 + +/* Define this if you have the type long double. */ +#define HAVE_LONG_DOUBLE 1 + +/* Define this if you have the type long long. */ +#define HAVE_LONG_LONG 1 + +/* Define to 1 if you have the `lstat' function. */ +#define HAVE_LSTAT 1 + +/* Define this if you have the makedev macro. */ +#define HAVE_MAKEDEV 1 + +/* Define to 1 if you have the `memmove' function. */ +#define HAVE_MEMMOVE 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `mkfifo' function. */ +/* #undef HAVE_MKFIFO */ + +/* Define to 1 if you have the `mknod' function. */ +#define HAVE_MKNOD 1 + +/* Define to 1 if you have the `mktime' function. */ +#define HAVE_MKTIME 1 + +/* Define to 1 if you have the `mmap' function. */ +#define HAVE_MMAP 1 + +/* Define to 1 if you have the `mremap' function. */ +#define HAVE_MREMAP 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NCURSES_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. */ +/* #undef HAVE_NDIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_NETPACKET_PACKET_H 1 + +/* Define to 1 if you have the `nice' function. */ +#define HAVE_NICE 1 + +/* Define to 1 if you have the `openpty' function. */ +/* #undef HAVE_OPENPTY */ + +/* Define if compiling using MacOS X 10.5 SDK or later. */ +/* #undef HAVE_OSX105_SDK */ + +/* Define to 1 if you have the `pathconf' function. */ +#define HAVE_PATHCONF 1 + +/* Define to 1 if you have the `pause' function. */ +#define HAVE_PAUSE 1 + +/* Define to 1 if you have the `plock' function. */ +/* #undef HAVE_PLOCK */ + +/* Define to 1 if you have the `poll' function. */ +#define HAVE_POLL 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_POLL_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PROCESS_H */ + +/* Define if your compiler supports function prototype */ +#define HAVE_PROTOTYPES 1 + +/* Define if you have GNU PTH threads. */ +/* #undef HAVE_PTH */ + +/* Define to 1 if you have the `pthread_atfork' function. */ +/* #undef HAVE_PTHREAD_ATFORK */ + +/* Defined for Solaris 2.6 bug in pthread header. */ +/* #undef HAVE_PTHREAD_DESTRUCTOR */ + +/* Define to 1 if you have the header file. */ +#define HAVE_PTHREAD_H 1 + +/* Define to 1 if you have the `pthread_init' function. */ +/* #undef HAVE_PTHREAD_INIT */ + +/* Define to 1 if you have the `pthread_sigmask' function. */ +#define HAVE_PTHREAD_SIGMASK 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PTY_H */ + +/* Define to 1 if you have the `putenv' function. */ +#define HAVE_PUTENV 1 + +/* Define if the libcrypto has RAND_egd */ +/* #undef HAVE_RAND_EGD */ + +/* Define to 1 if you have the `readlink' function. */ +#define HAVE_READLINK 1 + +/* Define to 1 if you have the `realpath' function. */ +#define HAVE_REALPATH 1 + +/* Define if you have readline 2.1 */ +/* #undef HAVE_RL_CALLBACK */ + +/* Define if you can turn off readline's signal handling. */ +/* #undef HAVE_RL_CATCH_SIGNAL */ + +/* Define if you have readline 2.2 */ +/* #undef HAVE_RL_COMPLETION_APPEND_CHARACTER */ + +/* Define if you have readline 4.0 */ +/* #undef HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK */ + +/* Define if you have readline 4.2 */ +/* #undef HAVE_RL_COMPLETION_MATCHES */ + +/* Define if you have rl_completion_suppress_append */ +/* #undef HAVE_RL_COMPLETION_SUPPRESS_APPEND */ + +/* Define if you have readline 4.0 */ +/* #undef HAVE_RL_PRE_INPUT_HOOK */ + +/* Define to 1 if you have the `round' function. */ +#define HAVE_ROUND 1 + +/* Define to 1 if you have the `select' function. */ +#define HAVE_SELECT 1 + +/* Define to 1 if you have the `sem_getvalue' function. */ +#define HAVE_SEM_GETVALUE 1 + +/* Define to 1 if you have the `sem_open' function. */ +#define HAVE_SEM_OPEN 1 + +/* Define to 1 if you have the `sem_timedwait' function. */ +#define HAVE_SEM_TIMEDWAIT 1 + +/* Define to 1 if you have the `sem_unlink' function. */ +#define HAVE_SEM_UNLINK 1 + +/* Define to 1 if you have the `setegid' function. */ +#define HAVE_SETEGID 1 + +/* Define to 1 if you have the `seteuid' function. */ +#define HAVE_SETEUID 1 + +/* Define to 1 if you have the `setgid' function. */ +#define HAVE_SETGID 1 + +/* Define if you have the 'setgroups' function. */ +#define HAVE_SETGROUPS 1 + +/* Define to 1 if you have the `setitimer' function. */ +#define HAVE_SETITIMER 1 + +/* Define to 1 if you have the `setlocale' function. */ +#define HAVE_SETLOCALE 1 + +/* Define to 1 if you have the `setpgid' function. */ +#define HAVE_SETPGID 1 + +/* Define to 1 if you have the `setpgrp' function. */ +#define HAVE_SETPGRP 1 + +/* Define to 1 if you have the `setregid' function. */ +#define HAVE_SETREGID 1 + +/* Define to 1 if you have the `setresgid' function. */ +#define HAVE_SETRESGID 1 + +/* Define to 1 if you have the `setresuid' function. */ +#define HAVE_SETRESUID 1 + +/* Define to 1 if you have the `setreuid' function. */ +#define HAVE_SETREUID 1 + +/* Define to 1 if you have the `setsid' function. */ +#define HAVE_SETSID 1 + +/* Define to 1 if you have the `setuid' function. */ +#define HAVE_SETUID 1 + +/* Define to 1 if you have the `setvbuf' function. */ +#define HAVE_SETVBUF 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SHADOW_H */ + +/* Define to 1 if you have the `sigaction' function. */ +#define HAVE_SIGACTION 1 + +/* Define to 1 if you have the `siginterrupt' function. */ +#define HAVE_SIGINTERRUPT 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SIGNAL_H 1 + +/* Define to 1 if you have the `sigrelse' function. */ +/* #undef HAVE_SIGRELSE */ + +/* Define to 1 if you have the `snprintf' function. */ +#define HAVE_SNPRINTF 1 + +/* Define if sockaddr has sa_len member */ +/* #undef HAVE_SOCKADDR_SA_LEN */ + +/* struct sockaddr_storage (sys/socket.h) */ +#define HAVE_SOCKADDR_STORAGE 1 + +/* Define if you have the 'socketpair' function. */ +#define HAVE_SOCKETPAIR 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SPAWN_H */ + +/* Define if your compiler provides ssize_t */ +#define HAVE_SSIZE_T 1 + +/* Define to 1 if you have the `statvfs' function. */ +/* #undef HAVE_STATVFS */ + +/* Define if you have struct stat.st_mtim.tv_nsec */ +/* #undef HAVE_STAT_TV_NSEC */ + +/* Define if you have struct stat.st_mtimensec */ +/* #undef HAVE_STAT_TV_NSEC2 */ + +/* Define if your compiler supports variable length function prototypes (e.g. + void fprintf(FILE *, char *, ...);) *and* */ +#define HAVE_STDARG_PROTOTYPES 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the `strdup' function. */ +#define HAVE_STRDUP 1 + +/* Define to 1 if you have the `strftime' function. */ +#define HAVE_STRFTIME 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_STROPTS_H */ + +/* Define to 1 if `st_birthtime' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_BIRTHTIME */ + +/* Define to 1 if `st_blksize' is a member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_BLKSIZE 1 + +/* Define to 1 if `st_blocks' is a member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_BLOCKS 1 + +/* Define to 1 if `st_flags' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_FLAGS */ + +/* Define to 1 if `st_gen' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_GEN */ + +/* Define to 1 if `st_rdev' is a member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_RDEV 1 + +/* Define to 1 if `tm_zone' is a member of `struct tm'. */ +#define HAVE_STRUCT_TM_TM_ZONE 1 + +/* Define to 1 if your `struct stat' has `st_blocks'. Deprecated, use + `HAVE_STRUCT_STAT_ST_BLOCKS' instead. */ +#define HAVE_ST_BLOCKS 1 + +/* Define if you have the 'symlink' function. */ +#define HAVE_SYMLINK 1 + +/* Define to 1 if you have the `sysconf' function. */ +#define HAVE_SYSCONF 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYSEXITS_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_AUDIOIO_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_BSDTTY_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +/* #undef HAVE_SYS_DIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_EPOLL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_EVENT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_FILE_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_LOADAVG_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_LOCK_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_MKDEV_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_MODEM_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +/* #undef HAVE_SYS_NDIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_PARAM_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_POLL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_RESOURCE_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SELECT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SOCKET_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_STATVFS_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_TERMIO_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIMES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UN_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UTSNAME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_WAIT_H 1 + +/* Define to 1 if you have the `tcgetpgrp' function. */ +#define HAVE_TCGETPGRP 1 + +/* Define to 1 if you have the `tcsetpgrp' function. */ +#define HAVE_TCSETPGRP 1 + +/* Define to 1 if you have the `tempnam' function. */ +#define HAVE_TEMPNAM 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_TERMIOS_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_TERM_H */ + +/* Define to 1 if you have the `tgamma' function. */ +#define HAVE_TGAMMA 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_THREAD_H */ + +/* Define to 1 if you have the `timegm' function. */ +/* #undef HAVE_TIMEGM */ + +/* Define to 1 if you have the `times' function. */ +#define HAVE_TIMES 1 + +/* Define to 1 if you have the `tmpfile' function. */ +#define HAVE_TMPFILE 1 + +/* Define to 1 if you have the `tmpnam' function. */ +#define HAVE_TMPNAM 1 + +/* Define to 1 if you have the `tmpnam_r' function. */ +/* #undef HAVE_TMPNAM_R */ + +/* Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use + `HAVE_STRUCT_TM_TM_ZONE' instead. */ +#define HAVE_TM_ZONE 1 + +/* Define to 1 if you have the `truncate' function. */ +#define HAVE_TRUNCATE 1 + +/* Define to 1 if you don't have `tm_zone' but do have the external array + `tzname'. */ +/* #undef HAVE_TZNAME */ + +/* Define this if you have tcl and TCL_UTF_MAX==6 */ +/* #undef HAVE_UCS4_TCL */ + +/* Define if your compiler provides uint32_t. */ +#define HAVE_UINT32_T 1 + +/* Define if your compiler provides uint64_t. */ +#define HAVE_UINT64_T 1 + +/* Define to 1 if the system has the type `uintptr_t'. */ +#define HAVE_UINTPTR_T 1 + +/* Define to 1 if you have the `uname' function. */ +#define HAVE_UNAME 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you have the `unsetenv' function. */ +#define HAVE_UNSETENV 1 + +/* Define if you have a useable wchar_t type defined in wchar.h; useable means + wchar_t must be an unsigned type with at least 16 bits. (see + Include/unicodeobject.h). */ +/* #undef HAVE_USABLE_WCHAR_T */ + +/* Define to 1 if you have the header file. */ +#define HAVE_UTIL_H 1 + +/* Define to 1 if you have the `utimes' function. */ +#define HAVE_UTIMES 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UTIME_H 1 + +/* Define to 1 if you have the `wait3' function. */ +#define HAVE_WAIT3 1 + +/* Define to 1 if you have the `wait4' function. */ +/* #undef HAVE_WAIT4 */ + +/* Define to 1 if you have the `waitpid' function. */ +#define HAVE_WAITPID 1 + +/* Define if the compiler provides a wchar.h header file. */ +#define HAVE_WCHAR_H 1 + +/* Define to 1 if you have the `wcscoll' function. */ +#define HAVE_WCSCOLL 1 + +/* Define if tzset() actually switches the local timezone in a meaningful way. + */ +/* #undef HAVE_WORKING_TZSET */ + +/* Define if the zlib library has inflateCopy */ +#define HAVE_ZLIB_COPY 1 + +/* Define to 1 if you have the `_getpty' function. */ +/* #undef HAVE__GETPTY */ + +/* Define if you are using Mach cthreads directly under /include */ +/* #undef HURD_C_THREADS */ + +/* Define if you are using Mach cthreads under mach / */ +/* #undef MACH_C_THREADS */ + +/* Define to 1 if `major', `minor', and `makedev' are declared in . + */ +/* #undef MAJOR_IN_MKDEV */ + +/* Define to 1 if `major', `minor', and `makedev' are declared in + . */ +#define MAJOR_IN_SYSMACROS 1 + +/* Define if mvwdelch in curses.h is an expression. */ +/* #undef MVWDELCH_IS_EXPRESSION */ + +/* Define to the address where bug reports for this package should be sent. */ +/* #undef PACKAGE_BUGREPORT */ + +/* Define to the full name of this package. */ +/* #undef PACKAGE_NAME */ + +/* Define to the full name and version of this package. */ +/* #undef PACKAGE_STRING */ + +/* Define to the one symbol short name of this package. */ +/* #undef PACKAGE_TARNAME */ + +/* Define to the home page for this package. */ +/* #undef PACKAGE_URL */ + +/* Define to the version of this package. */ +/* #undef PACKAGE_VERSION */ + +/* Define if POSIX semaphores aren't enabled on your system */ +/* #undef POSIX_SEMAPHORES_NOT_ENABLED */ + +/* Defined if PTHREAD_SCOPE_SYSTEM supported. */ +/* #undef PTHREAD_SYSTEM_SCHED_SUPPORTED */ + +/* Define as the preferred size in bits of long digits */ +/* #undef PYLONG_BITS_IN_DIGIT */ + +/* Define to printf format modifier for long long type */ +#define PY_FORMAT_LONG_LONG "ll" + +/* Define to printf format modifier for Py_ssize_t */ +#define PY_FORMAT_SIZE_T "z" + +/* Define as the integral type used for Unicode representation. */ +#define PY_UNICODE_TYPE unsigned long + +/* Define if you want to build an interpreter with many run-time checks. */ +/* #undef Py_DEBUG */ + +/* Defined if Python is built as a shared library. */ +#define Py_ENABLE_SHARED 1 + +/* Define as the size of the unicode type. */ +#define Py_UNICODE_SIZE 4 + +/* Define if you want to have a Unicode type. */ +#define Py_USING_UNICODE 1 + +/* assume C89 semantics that RETSIGTYPE is always void */ +#define RETSIGTYPE void + +/* Define if setpgrp() must be called as setpgrp(0, 0). */ +/* #undef SETPGRP_HAVE_ARG */ + +/* Define this to be extension of shared libraries (including the dot!). */ +#define SHLIB_EXT ".so" + +/* Define if i>>j for signed int i does not extend the sign bit when i < 0 */ +/* #undef SIGNED_RIGHT_SHIFT_ZERO_FILLS */ + +/* The size of `double', as computed by sizeof. */ +#define SIZEOF_DOUBLE 8 + +/* The size of `float', as computed by sizeof. */ +#define SIZEOF_FLOAT 4 + +/* The size of `fpos_t', as computed by sizeof. */ +#define SIZEOF_FPOS_T 4 + +/* The size of `int', as computed by sizeof. */ +#define SIZEOF_INT 4 + +/* The size of `long', as computed by sizeof. */ +#define SIZEOF_LONG 4 + +/* The size of `long double', as computed by sizeof. */ +#define SIZEOF_LONG_DOUBLE 8 + +/* The size of `long long', as computed by sizeof. */ +#define SIZEOF_LONG_LONG 8 + +/* The size of `off_t', as computed by sizeof. */ +#define SIZEOF_OFF_T 4 + +/* The size of `pid_t', as computed by sizeof. */ +#define SIZEOF_PID_T 4 + +/* The size of `pthread_t', as computed by sizeof. */ +#define SIZEOF_PTHREAD_T 4 + +/* The size of `short', as computed by sizeof. */ +#define SIZEOF_SHORT 2 + +/* The size of `size_t', as computed by sizeof. */ +#define SIZEOF_SIZE_T 4 + +/* The size of `time_t', as computed by sizeof. */ +#define SIZEOF_TIME_T 4 + +/* The size of `uintptr_t', as computed by sizeof. */ +#define SIZEOF_UINTPTR_T 4 + +/* The size of `void *', as computed by sizeof. */ +#define SIZEOF_VOID_P 4 + +/* The size of `wchar_t', as computed by sizeof. */ +#define SIZEOF_WCHAR_T 4 + +/* The size of `_Bool', as computed by sizeof. */ +#define SIZEOF__BOOL 1 + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define if you can safely include both and + (which you can't on SCO ODT 3.0). */ +#define SYS_SELECT_WITH_SYS_TIME 1 + +/* Define if tanh(-0.) is -0., or if platform doesn't have signed zeros */ +/* #undef TANH_PRESERVES_ZERO_SIGN */ + +/* Define to 1 if you can safely include both and . */ +#define TIME_WITH_SYS_TIME 1 + +/* Define to 1 if your declares `struct tm'. */ +/* #undef TM_IN_SYS_TIME */ + +/* Enable extensions on AIX 3, Interix. */ +#ifndef _ALL_SOURCE +# define _ALL_SOURCE 1 +#endif +/* Enable GNU extensions on systems that have them. */ +#ifndef _GNU_SOURCE +# define _GNU_SOURCE 1 +#endif +/* Enable threading extensions on Solaris. */ +#ifndef _POSIX_PTHREAD_SEMANTICS +# define _POSIX_PTHREAD_SEMANTICS 1 +#endif +/* Enable extensions on HP NonStop. */ +#ifndef _TANDEM_SOURCE +# define _TANDEM_SOURCE 1 +#endif +/* Enable general extensions on Solaris. */ +#ifndef __EXTENSIONS__ +# define __EXTENSIONS__ 1 +#endif + + +/* Define if you want to use MacPython modules on MacOSX in unix-Python. */ +/* #undef USE_TOOLBOX_OBJECT_GLUE */ + +/* Define if a va_list is an array of some kind */ +/* #undef VA_LIST_IS_ARRAY */ + +/* Define if you want SIGFPE handled (see Include/pyfpe.h). */ +/* #undef WANT_SIGFPE_HANDLER */ + +/* Define if you want wctype.h functions to be used instead of the one + supplied by Python itself. (see Include/unicodectype.h). */ +/* #undef WANT_WCTYPE_FUNCTIONS */ + +/* Define if WINDOW in curses.h offers a field _flags. */ +/* #undef WINDOW_HAS_FLAGS */ + +/* Define if you want documentation strings in extension modules */ +#define WITH_DOC_STRINGS 1 + +/* Define if you want to use the new-style (Openstep, Rhapsody, MacOS) dynamic + linker (dyld) instead of the old-style (NextStep) dynamic linker (rld). + Dyld is necessary to support frameworks. */ +/* #undef WITH_DYLD */ + +/* Define to 1 if libintl is needed for locale functions. */ +/* #undef WITH_LIBINTL */ + +/* Define if you want to produce an OpenStep/Rhapsody framework (shared + library plus accessory files). */ +/* #undef WITH_NEXT_FRAMEWORK */ + +/* Define if you want to compile in Python-specific mallocs */ +#define WITH_PYMALLOC 1 + +/* Define if you want to compile in rudimentary thread support */ +#define WITH_THREAD 1 + +/* Define to profile with the Pentium timestamp counter */ +/* #undef WITH_TSC */ + +/* Define if you want pymalloc to be disabled when running under valgrind */ +/* #undef WITH_VALGRIND */ + +/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most + significant byte first (like Motorola and SPARC, unlike Intel). */ +#if defined AC_APPLE_UNIVERSAL_BUILD +# if defined __BIG_ENDIAN__ +# define WORDS_BIGENDIAN 1 +# endif +#else +# ifndef WORDS_BIGENDIAN +/* # undef WORDS_BIGENDIAN */ +# endif +#endif + +/* Define if arithmetic is subject to x87-style double rounding issue */ +/* #undef X87_DOUBLE_ROUNDING */ + +/* Define on OpenBSD to activate all library features */ +/* #undef _BSD_SOURCE */ + +/* Define on Irix to enable u_int */ +#define _BSD_TYPES 1 + +/* Define on Darwin to activate all library features */ +#define _DARWIN_C_SOURCE 1 + +/* This must be set to 64 on some systems to enable large file support. */ +#define _FILE_OFFSET_BITS 64 + +/* Define on Linux to activate all library features */ +#define _GNU_SOURCE 1 + +/* This must be defined on some systems to enable large file support. */ +#define _LARGEFILE_SOURCE 1 + +/* This must be defined on AIX systems to enable large file support. */ +/* #undef _LARGE_FILES */ + +/* Define to 1 if on MINIX. */ +/* #undef _MINIX */ + +/* Define on NetBSD to activate all library features */ +#define _NETBSD_SOURCE 1 + +/* Define _OSF_SOURCE to get the makedev macro. */ +/* #undef _OSF_SOURCE */ + +/* Define to 2 if the system does not provide POSIX.1 features except with + this defined. */ +/* #undef _POSIX_1_SOURCE */ + +/* Define to activate features from IEEE Stds 1003.1-2001 */ +#define _POSIX_C_SOURCE 200112L + +/* Define to 1 if you need to in order for `stat' and other things to work. */ +/* #undef _POSIX_SOURCE */ + +/* Define if you have POSIX threads, and your system does not define that. */ +/* #undef _POSIX_THREADS */ + +/* Define to force use of thread-safe errno, h_errno, and other functions */ +#define _REENTRANT 1 + +/* Define for Solaris 2.5.1 so the uint32_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +/* #undef _UINT32_T */ + +/* Define for Solaris 2.5.1 so the uint64_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +/* #undef _UINT64_T */ + +/* Define to the level of X/Open that your system supports */ +#define _XOPEN_SOURCE 600 + +/* Define to activate Unix95-and-earlier features */ +#define _XOPEN_SOURCE_EXTENDED 1 + +/* Define on FreeBSD to activate all library features */ +#define __BSD_VISIBLE 1 + +/* Define to 1 if type `char' is unsigned and you are not using gcc. */ +#ifndef __CHAR_UNSIGNED__ +/* # undef __CHAR_UNSIGNED__ */ +#endif + +/* Defined on Solaris to see additional function prototypes. */ +#define __EXTENSIONS__ 1 + +/* Define to 'long' if doesn't define. */ +/* #undef clock_t */ + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ + +/* Define to `int' if doesn't define. */ +/* #undef gid_t */ + +/* Define to the type of a signed integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +/* #undef int32_t */ + +/* Define to the type of a signed integer type of width exactly 64 bits if + such a type exists and the standard includes do not define it. */ +/* #undef int64_t */ + +/* Define to `int' if does not define. */ +/* #undef mode_t */ + +/* Define to `long int' if does not define. */ +/* #undef off_t */ + +/* Define to `int' if does not define. */ +/* #undef pid_t */ + +/* Define to empty if the keyword does not work. */ +/* #undef signed */ + +/* Define to `unsigned int' if does not define. */ +/* #undef size_t */ + +/* Define to `int' if does not define. */ +/* #undef socklen_t */ + +/* Define to `int' if doesn't define. */ +/* #undef uid_t */ + +/* Define to the type of an unsigned integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint32_t */ + +/* Define to the type of an unsigned integer type of width exactly 64 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint64_t */ + +/* Define to empty if the keyword does not work. */ +/* #undef volatile */ + + +/* Define the macros needed if on a UnixWare 7.x system. */ +#if defined(__USLC__) && defined(__SCO_VERSION__) +#define STRICT_SYSV_CURSES /* Don't use ncurses extensions */ +#endif + +#endif /*Py_PYCONFIG_H*/ + diff --git a/android/python27/include/pyconfig_armeabi_v7a_hard.h b/android/python27/include/pyconfig_armeabi_v7a_hard.h new file mode 100644 index 000000000..8c9ca6178 --- /dev/null +++ b/android/python27/include/pyconfig_armeabi_v7a_hard.h @@ -0,0 +1,1282 @@ +/* pyconfig.h. Generated from pyconfig.h.in by configure. */ +/* pyconfig.h.in. Generated from configure.ac by autoheader. */ + + +#ifndef Py_PYCONFIG_H +#define Py_PYCONFIG_H + + +/* Define if building universal (internal helper macro) */ +/* #undef AC_APPLE_UNIVERSAL_BUILD */ + +/* Define for AIX if your compiler is a genuine IBM xlC/xlC_r and you want + support for AIX C++ shared extension modules. */ +/* #undef AIX_GENUINE_CPLUSPLUS */ + +/* Define this if you have AtheOS threads. */ +/* #undef ATHEOS_THREADS */ + +/* Define this if you have BeOS threads. */ +/* #undef BEOS_THREADS */ + +/* Define if you have the Mach cthreads package */ +/* #undef C_THREADS */ + +/* Define if C doubles are 64-bit IEEE 754 binary format, stored in ARM + mixed-endian order (byte order 45670123) */ +/* #undef DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754 */ + +/* Define if C doubles are 64-bit IEEE 754 binary format, stored with the most + significant byte first */ +/* #undef DOUBLE_IS_BIG_ENDIAN_IEEE754 */ + +/* Define if C doubles are 64-bit IEEE 754 binary format, stored with the + least significant byte first */ +/* #undef DOUBLE_IS_LITTLE_ENDIAN_IEEE754 */ + +/* Define if --enable-ipv6 is specified */ +#define ENABLE_IPV6 1 + +/* Define if flock needs to be linked with bsd library. */ +/* #undef FLOCK_NEEDS_LIBBSD */ + +/* Define if getpgrp() must be called as getpgrp(0). */ +/* #undef GETPGRP_HAVE_ARG */ + +/* Define if gettimeofday() does not have second (timezone) argument This is + the case on Motorola V4 (R40V4.2) */ +/* #undef GETTIMEOFDAY_NO_TZ */ + +/* Define to 1 if you have the `acosh' function. */ +#define HAVE_ACOSH 1 + +/* struct addrinfo (netdb.h) */ +#define HAVE_ADDRINFO 1 + +/* Define to 1 if you have the `alarm' function. */ +#define HAVE_ALARM 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ALLOCA_H 1 + +/* Define this if your time.h defines altzone. */ +/* #undef HAVE_ALTZONE */ + +/* Define to 1 if you have the `asinh' function. */ +#define HAVE_ASINH 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ASM_TYPES_H 1 + +/* Define to 1 if you have the `atanh' function. */ +#define HAVE_ATANH 1 + +/* Define if GCC supports __attribute__((format(PyArg_ParseTuple, 2, 3))) */ +/* #undef HAVE_ATTRIBUTE_FORMAT_PARSETUPLE */ + +/* Define to 1 if you have the `bind_textdomain_codeset' function. */ +/* #undef HAVE_BIND_TEXTDOMAIN_CODESET */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_BLUETOOTH_BLUETOOTH_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_BLUETOOTH_H */ + +/* Define if nice() returns success/failure instead of the new priority. */ +/* #undef HAVE_BROKEN_NICE */ + +/* Define if the system reports an invalid PIPE_BUF value. */ +/* #undef HAVE_BROKEN_PIPE_BUF */ + +/* Define if poll() sets errno on invalid file descriptors. */ +/* #undef HAVE_BROKEN_POLL */ + +/* Define if the Posix semaphores do not work on your system */ +/* #undef HAVE_BROKEN_POSIX_SEMAPHORES */ + +/* Define if pthread_sigmask() does not work on your system. */ +/* #undef HAVE_BROKEN_PTHREAD_SIGMASK */ + +/* define to 1 if your sem_getvalue is broken. */ +#define HAVE_BROKEN_SEM_GETVALUE 1 + +/* Define if `unsetenv` does not return an int. */ +/* #undef HAVE_BROKEN_UNSETENV */ + +/* Define this if you have the type _Bool. */ +#define HAVE_C99_BOOL 1 + +/* Define to 1 if you have the 'chflags' function. */ +/* #undef HAVE_CHFLAGS */ + +/* Define to 1 if you have the `chown' function. */ +#define HAVE_CHOWN 1 + +/* Define if you have the 'chroot' function. */ +#define HAVE_CHROOT 1 + +/* Define to 1 if you have the `clock' function. */ +#define HAVE_CLOCK 1 + +/* Define to 1 if you have the `confstr' function. */ +/* #undef HAVE_CONFSTR */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_CONIO_H */ + +/* Define to 1 if you have the `copysign' function. */ +#define HAVE_COPYSIGN 1 + +/* Define to 1 if you have the `ctermid' function. */ +/* #undef HAVE_CTERMID */ + +/* Define if you have the 'ctermid_r' function. */ +#define HAVE_CTERMID_R 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_CURSES_H */ + +/* Define if you have the 'is_term_resized' function. */ +/* #undef HAVE_CURSES_IS_TERM_RESIZED */ + +/* Define if you have the 'resizeterm' function. */ +/* #undef HAVE_CURSES_RESIZETERM */ + +/* Define if you have the 'resize_term' function. */ +/* #undef HAVE_CURSES_RESIZE_TERM */ + +/* Define to 1 if you have the declaration of `isfinite', and to 0 if you + don't. */ +#define HAVE_DECL_ISFINITE 1 + +/* Define to 1 if you have the declaration of `isinf', and to 0 if you don't. + */ +#define HAVE_DECL_ISINF 1 + +/* Define to 1 if you have the declaration of `isnan', and to 0 if you don't. + */ +#define HAVE_DECL_ISNAN 1 + +/* Define to 1 if you have the declaration of `tzname', and to 0 if you don't. + */ +/* #undef HAVE_DECL_TZNAME */ + +/* Define to 1 if you have the device macros. */ +#define HAVE_DEVICE_MACROS 1 + +/* Define to 1 if you have the /dev/ptc device file. */ +/* #undef HAVE_DEV_PTC */ + +/* Define to 1 if you have the /dev/ptmx device file. */ +/* #undef HAVE_DEV_PTMX */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_DIRECT_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#define HAVE_DIRENT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_DLFCN_H 1 + +/* Define to 1 if you have the `dlopen' function. */ +#define HAVE_DLOPEN 1 + +/* Define to 1 if you have the `dup2' function. */ +#define HAVE_DUP2 1 + +/* Defined when any dynamic module loading is enabled. */ +#define HAVE_DYNAMIC_LOADING 1 + +/* Define if you have the 'epoll' functions. */ +#define HAVE_EPOLL 1 + +/* Define to 1 if you have the `erf' function. */ +#define HAVE_ERF 1 + +/* Define to 1 if you have the `erfc' function. */ +#define HAVE_ERFC 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ERRNO_H 1 + +/* Define to 1 if you have the `execv' function. */ +#define HAVE_EXECV 1 + +/* Define to 1 if you have the `expm1' function. */ +#define HAVE_EXPM1 1 + +/* Define if you have the 'fchdir' function. */ +#define HAVE_FCHDIR 1 + +/* Define to 1 if you have the `fchmod' function. */ +#define HAVE_FCHMOD 1 + +/* Define to 1 if you have the `fchown' function. */ +#define HAVE_FCHOWN 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* Define if you have the 'fdatasync' function. */ +#define HAVE_FDATASYNC 1 + +/* Define to 1 if you have the `finite' function. */ +#define HAVE_FINITE 1 + +/* Define to 1 if you have the `flock' function. */ +#define HAVE_FLOCK 1 + +/* Define to 1 if you have the `fork' function. */ +#define HAVE_FORK 1 + +/* Define to 1 if you have the `forkpty' function. */ +/* #undef HAVE_FORKPTY */ + +/* Define to 1 if you have the `fpathconf' function. */ +#define HAVE_FPATHCONF 1 + +/* Define to 1 if you have the `fseek64' function. */ +/* #undef HAVE_FSEEK64 */ + +/* Define to 1 if you have the `fseeko' function. */ +#define HAVE_FSEEKO 1 + +/* Define to 1 if you have the `fstatvfs' function. */ +/* #undef HAVE_FSTATVFS */ + +/* Define if you have the 'fsync' function. */ +#define HAVE_FSYNC 1 + +/* Define to 1 if you have the `ftell64' function. */ +/* #undef HAVE_FTELL64 */ + +/* Define to 1 if you have the `ftello' function. */ +#define HAVE_FTELLO 1 + +/* Define to 1 if you have the `ftime' function. */ +#define HAVE_FTIME 1 + +/* Define to 1 if you have the `ftruncate' function. */ +#define HAVE_FTRUNCATE 1 + +/* Define to 1 if you have the `gai_strerror' function. */ +#define HAVE_GAI_STRERROR 1 + +/* Define to 1 if you have the `gamma' function. */ +/* #undef HAVE_GAMMA */ + +/* Define if we can use gcc inline assembler to get and set x87 control word + */ +/* #undef HAVE_GCC_ASM_FOR_X87 */ + +/* Define if you have the getaddrinfo function. */ +#define HAVE_GETADDRINFO 1 + +/* Define to 1 if you have the `getcwd' function. */ +#define HAVE_GETCWD 1 + +/* Define this if you have flockfile(), getc_unlocked(), and funlockfile() */ +#define HAVE_GETC_UNLOCKED 1 + +/* Define to 1 if you have the `getentropy' function. */ +/* #undef HAVE_GETENTROPY */ + +/* Define to 1 if you have the `getgroups' function. */ +#define HAVE_GETGROUPS 1 + +/* Define to 1 if you have the `gethostbyname' function. */ +#define HAVE_GETHOSTBYNAME 1 + +/* Define this if you have some version of gethostbyname_r() */ +/* #undef HAVE_GETHOSTBYNAME_R */ + +/* Define this if you have the 3-arg version of gethostbyname_r(). */ +/* #undef HAVE_GETHOSTBYNAME_R_3_ARG */ + +/* Define this if you have the 5-arg version of gethostbyname_r(). */ +/* #undef HAVE_GETHOSTBYNAME_R_5_ARG */ + +/* Define this if you have the 6-arg version of gethostbyname_r(). */ +/* #undef HAVE_GETHOSTBYNAME_R_6_ARG */ + +/* Define to 1 if you have the `getitimer' function. */ +#define HAVE_GETITIMER 1 + +/* Define to 1 if you have the `getloadavg' function. */ +#define HAVE_GETLOADAVG 1 + +/* Define to 1 if you have the `getlogin' function. */ +#define HAVE_GETLOGIN 1 + +/* Define to 1 if you have the `getnameinfo' function. */ +#define HAVE_GETNAMEINFO 1 + +/* Define if you have the 'getpagesize' function. */ +#define HAVE_GETPAGESIZE 1 + +/* Define to 1 if you have the `getpeername' function. */ +#define HAVE_GETPEERNAME 1 + +/* Define to 1 if you have the `getpgid' function. */ +#define HAVE_GETPGID 1 + +/* Define to 1 if you have the `getpgrp' function. */ +#define HAVE_GETPGRP 1 + +/* Define to 1 if you have the `getpid' function. */ +#define HAVE_GETPID 1 + +/* Define to 1 if you have the `getpriority' function. */ +#define HAVE_GETPRIORITY 1 + +/* Define to 1 if you have the `getpwent' function. */ +#define HAVE_GETPWENT 1 + +/* Define to 1 if you have the `getresgid' function. */ +#define HAVE_GETRESGID 1 + +/* Define to 1 if you have the `getresuid' function. */ +#define HAVE_GETRESUID 1 + +/* Define to 1 if you have the `getsid' function. */ +/* #undef HAVE_GETSID */ + +/* Define to 1 if you have the `getspent' function. */ +/* #undef HAVE_GETSPENT */ + +/* Define to 1 if you have the `getspnam' function. */ +/* #undef HAVE_GETSPNAM */ + +/* Define to 1 if you have the `gettimeofday' function. */ +#define HAVE_GETTIMEOFDAY 1 + +/* Define to 1 if you have the `getwd' function. */ +/* #undef HAVE_GETWD */ + +/* Define to 1 if you have the header file. */ +#define HAVE_GRP_H 1 + +/* Define if you have the 'hstrerror' function. */ +#define HAVE_HSTRERROR 1 + +/* Define to 1 if you have the `hypot' function. */ +#define HAVE_HYPOT 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_IEEEFP_H */ + +/* Define if you have the 'inet_aton' function. */ +#define HAVE_INET_ATON 1 + +/* Define if you have the 'inet_pton' function. */ +#define HAVE_INET_PTON 1 + +/* Define to 1 if you have the `initgroups' function. */ +#define HAVE_INITGROUPS 1 + +/* Define if your compiler provides int32_t. */ +#define HAVE_INT32_T 1 + +/* Define if your compiler provides int64_t. */ +#define HAVE_INT64_T 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_IO_H */ + +/* Define to 1 if you have the `kill' function. */ +#define HAVE_KILL 1 + +/* Define to 1 if you have the `killpg' function. */ +#define HAVE_KILLPG 1 + +/* Define if you have the 'kqueue' functions. */ +#define HAVE_KQUEUE 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_LANGINFO_H 1 + +/* Defined to enable large file support when an off_t is bigger than a long + and long long is available and at least as big as an off_t. You may need to + add some flags for configuration and compilation to enable this mode. (For + Solaris and Linux, the necessary defines are already defined.) */ +/* #undef HAVE_LARGEFILE_SUPPORT */ + +/* Define to 1 if you have the 'lchflags' function. */ +/* #undef HAVE_LCHFLAGS */ + +/* Define to 1 if you have the `lchmod' function. */ +/* #undef HAVE_LCHMOD */ + +/* Define to 1 if you have the `lchown' function. */ +#define HAVE_LCHOWN 1 + +/* Define to 1 if you have the `lgamma' function. */ +#define HAVE_LGAMMA 1 + +/* Define to 1 if you have the `dl' library (-ldl). */ +#define HAVE_LIBDL 1 + +/* Define to 1 if you have the `dld' library (-ldld). */ +/* #undef HAVE_LIBDLD */ + +/* Define to 1 if you have the `ieee' library (-lieee). */ +/* #undef HAVE_LIBIEEE */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LIBINTL_H */ + +/* Define if you have the readline library (-lreadline). */ +/* #undef HAVE_LIBREADLINE */ + +/* Define to 1 if you have the `resolv' library (-lresolv). */ +/* #undef HAVE_LIBRESOLV */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LIBUTIL_H */ + +/* Define if you have the 'link' function. */ +#define HAVE_LINK 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_LINUX_NETLINK_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LINUX_TIPC_H */ + +/* Define to 1 if you have the `log1p' function. */ +#define HAVE_LOG1P 1 + +/* Define this if you have the type long double. */ +#define HAVE_LONG_DOUBLE 1 + +/* Define this if you have the type long long. */ +#define HAVE_LONG_LONG 1 + +/* Define to 1 if you have the `lstat' function. */ +#define HAVE_LSTAT 1 + +/* Define this if you have the makedev macro. */ +#define HAVE_MAKEDEV 1 + +/* Define to 1 if you have the `memmove' function. */ +#define HAVE_MEMMOVE 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `mkfifo' function. */ +/* #undef HAVE_MKFIFO */ + +/* Define to 1 if you have the `mknod' function. */ +#define HAVE_MKNOD 1 + +/* Define to 1 if you have the `mktime' function. */ +#define HAVE_MKTIME 1 + +/* Define to 1 if you have the `mmap' function. */ +#define HAVE_MMAP 1 + +/* Define to 1 if you have the `mremap' function. */ +#define HAVE_MREMAP 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NCURSES_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. */ +/* #undef HAVE_NDIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_NETPACKET_PACKET_H 1 + +/* Define to 1 if you have the `nice' function. */ +#define HAVE_NICE 1 + +/* Define to 1 if you have the `openpty' function. */ +/* #undef HAVE_OPENPTY */ + +/* Define if compiling using MacOS X 10.5 SDK or later. */ +/* #undef HAVE_OSX105_SDK */ + +/* Define to 1 if you have the `pathconf' function. */ +#define HAVE_PATHCONF 1 + +/* Define to 1 if you have the `pause' function. */ +#define HAVE_PAUSE 1 + +/* Define to 1 if you have the `plock' function. */ +/* #undef HAVE_PLOCK */ + +/* Define to 1 if you have the `poll' function. */ +#define HAVE_POLL 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_POLL_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PROCESS_H */ + +/* Define if your compiler supports function prototype */ +#define HAVE_PROTOTYPES 1 + +/* Define if you have GNU PTH threads. */ +/* #undef HAVE_PTH */ + +/* Define to 1 if you have the `pthread_atfork' function. */ +/* #undef HAVE_PTHREAD_ATFORK */ + +/* Defined for Solaris 2.6 bug in pthread header. */ +/* #undef HAVE_PTHREAD_DESTRUCTOR */ + +/* Define to 1 if you have the header file. */ +#define HAVE_PTHREAD_H 1 + +/* Define to 1 if you have the `pthread_init' function. */ +/* #undef HAVE_PTHREAD_INIT */ + +/* Define to 1 if you have the `pthread_sigmask' function. */ +#define HAVE_PTHREAD_SIGMASK 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PTY_H */ + +/* Define to 1 if you have the `putenv' function. */ +#define HAVE_PUTENV 1 + +/* Define if the libcrypto has RAND_egd */ +/* #undef HAVE_RAND_EGD */ + +/* Define to 1 if you have the `readlink' function. */ +#define HAVE_READLINK 1 + +/* Define to 1 if you have the `realpath' function. */ +#define HAVE_REALPATH 1 + +/* Define if you have readline 2.1 */ +/* #undef HAVE_RL_CALLBACK */ + +/* Define if you can turn off readline's signal handling. */ +/* #undef HAVE_RL_CATCH_SIGNAL */ + +/* Define if you have readline 2.2 */ +/* #undef HAVE_RL_COMPLETION_APPEND_CHARACTER */ + +/* Define if you have readline 4.0 */ +/* #undef HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK */ + +/* Define if you have readline 4.2 */ +/* #undef HAVE_RL_COMPLETION_MATCHES */ + +/* Define if you have rl_completion_suppress_append */ +/* #undef HAVE_RL_COMPLETION_SUPPRESS_APPEND */ + +/* Define if you have readline 4.0 */ +/* #undef HAVE_RL_PRE_INPUT_HOOK */ + +/* Define to 1 if you have the `round' function. */ +#define HAVE_ROUND 1 + +/* Define to 1 if you have the `select' function. */ +#define HAVE_SELECT 1 + +/* Define to 1 if you have the `sem_getvalue' function. */ +#define HAVE_SEM_GETVALUE 1 + +/* Define to 1 if you have the `sem_open' function. */ +#define HAVE_SEM_OPEN 1 + +/* Define to 1 if you have the `sem_timedwait' function. */ +#define HAVE_SEM_TIMEDWAIT 1 + +/* Define to 1 if you have the `sem_unlink' function. */ +#define HAVE_SEM_UNLINK 1 + +/* Define to 1 if you have the `setegid' function. */ +#define HAVE_SETEGID 1 + +/* Define to 1 if you have the `seteuid' function. */ +#define HAVE_SETEUID 1 + +/* Define to 1 if you have the `setgid' function. */ +#define HAVE_SETGID 1 + +/* Define if you have the 'setgroups' function. */ +#define HAVE_SETGROUPS 1 + +/* Define to 1 if you have the `setitimer' function. */ +#define HAVE_SETITIMER 1 + +/* Define to 1 if you have the `setlocale' function. */ +#define HAVE_SETLOCALE 1 + +/* Define to 1 if you have the `setpgid' function. */ +#define HAVE_SETPGID 1 + +/* Define to 1 if you have the `setpgrp' function. */ +#define HAVE_SETPGRP 1 + +/* Define to 1 if you have the `setregid' function. */ +#define HAVE_SETREGID 1 + +/* Define to 1 if you have the `setresgid' function. */ +#define HAVE_SETRESGID 1 + +/* Define to 1 if you have the `setresuid' function. */ +#define HAVE_SETRESUID 1 + +/* Define to 1 if you have the `setreuid' function. */ +#define HAVE_SETREUID 1 + +/* Define to 1 if you have the `setsid' function. */ +#define HAVE_SETSID 1 + +/* Define to 1 if you have the `setuid' function. */ +#define HAVE_SETUID 1 + +/* Define to 1 if you have the `setvbuf' function. */ +#define HAVE_SETVBUF 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SHADOW_H */ + +/* Define to 1 if you have the `sigaction' function. */ +#define HAVE_SIGACTION 1 + +/* Define to 1 if you have the `siginterrupt' function. */ +#define HAVE_SIGINTERRUPT 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SIGNAL_H 1 + +/* Define to 1 if you have the `sigrelse' function. */ +/* #undef HAVE_SIGRELSE */ + +/* Define to 1 if you have the `snprintf' function. */ +#define HAVE_SNPRINTF 1 + +/* Define if sockaddr has sa_len member */ +/* #undef HAVE_SOCKADDR_SA_LEN */ + +/* struct sockaddr_storage (sys/socket.h) */ +#define HAVE_SOCKADDR_STORAGE 1 + +/* Define if you have the 'socketpair' function. */ +#define HAVE_SOCKETPAIR 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SPAWN_H */ + +/* Define if your compiler provides ssize_t */ +#define HAVE_SSIZE_T 1 + +/* Define to 1 if you have the `statvfs' function. */ +/* #undef HAVE_STATVFS */ + +/* Define if you have struct stat.st_mtim.tv_nsec */ +/* #undef HAVE_STAT_TV_NSEC */ + +/* Define if you have struct stat.st_mtimensec */ +/* #undef HAVE_STAT_TV_NSEC2 */ + +/* Define if your compiler supports variable length function prototypes (e.g. + void fprintf(FILE *, char *, ...);) *and* */ +#define HAVE_STDARG_PROTOTYPES 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the `strdup' function. */ +#define HAVE_STRDUP 1 + +/* Define to 1 if you have the `strftime' function. */ +#define HAVE_STRFTIME 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_STROPTS_H */ + +/* Define to 1 if `st_birthtime' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_BIRTHTIME */ + +/* Define to 1 if `st_blksize' is a member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_BLKSIZE 1 + +/* Define to 1 if `st_blocks' is a member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_BLOCKS 1 + +/* Define to 1 if `st_flags' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_FLAGS */ + +/* Define to 1 if `st_gen' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_GEN */ + +/* Define to 1 if `st_rdev' is a member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_RDEV 1 + +/* Define to 1 if `tm_zone' is a member of `struct tm'. */ +#define HAVE_STRUCT_TM_TM_ZONE 1 + +/* Define to 1 if your `struct stat' has `st_blocks'. Deprecated, use + `HAVE_STRUCT_STAT_ST_BLOCKS' instead. */ +#define HAVE_ST_BLOCKS 1 + +/* Define if you have the 'symlink' function. */ +#define HAVE_SYMLINK 1 + +/* Define to 1 if you have the `sysconf' function. */ +#define HAVE_SYSCONF 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYSEXITS_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_AUDIOIO_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_BSDTTY_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +/* #undef HAVE_SYS_DIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_EPOLL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_EVENT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_FILE_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_LOADAVG_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_LOCK_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_MKDEV_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_MODEM_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +/* #undef HAVE_SYS_NDIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_PARAM_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_POLL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_RESOURCE_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SELECT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SOCKET_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_STATVFS_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_TERMIO_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIMES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UN_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UTSNAME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_WAIT_H 1 + +/* Define to 1 if you have the `tcgetpgrp' function. */ +#define HAVE_TCGETPGRP 1 + +/* Define to 1 if you have the `tcsetpgrp' function. */ +#define HAVE_TCSETPGRP 1 + +/* Define to 1 if you have the `tempnam' function. */ +#define HAVE_TEMPNAM 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_TERMIOS_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_TERM_H */ + +/* Define to 1 if you have the `tgamma' function. */ +#define HAVE_TGAMMA 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_THREAD_H */ + +/* Define to 1 if you have the `timegm' function. */ +/* #undef HAVE_TIMEGM */ + +/* Define to 1 if you have the `times' function. */ +#define HAVE_TIMES 1 + +/* Define to 1 if you have the `tmpfile' function. */ +#define HAVE_TMPFILE 1 + +/* Define to 1 if you have the `tmpnam' function. */ +#define HAVE_TMPNAM 1 + +/* Define to 1 if you have the `tmpnam_r' function. */ +/* #undef HAVE_TMPNAM_R */ + +/* Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use + `HAVE_STRUCT_TM_TM_ZONE' instead. */ +#define HAVE_TM_ZONE 1 + +/* Define to 1 if you have the `truncate' function. */ +#define HAVE_TRUNCATE 1 + +/* Define to 1 if you don't have `tm_zone' but do have the external array + `tzname'. */ +/* #undef HAVE_TZNAME */ + +/* Define this if you have tcl and TCL_UTF_MAX==6 */ +/* #undef HAVE_UCS4_TCL */ + +/* Define if your compiler provides uint32_t. */ +#define HAVE_UINT32_T 1 + +/* Define if your compiler provides uint64_t. */ +#define HAVE_UINT64_T 1 + +/* Define to 1 if the system has the type `uintptr_t'. */ +#define HAVE_UINTPTR_T 1 + +/* Define to 1 if you have the `uname' function. */ +#define HAVE_UNAME 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you have the `unsetenv' function. */ +#define HAVE_UNSETENV 1 + +/* Define if you have a useable wchar_t type defined in wchar.h; useable means + wchar_t must be an unsigned type with at least 16 bits. (see + Include/unicodeobject.h). */ +/* #undef HAVE_USABLE_WCHAR_T */ + +/* Define to 1 if you have the header file. */ +#define HAVE_UTIL_H 1 + +/* Define to 1 if you have the `utimes' function. */ +#define HAVE_UTIMES 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UTIME_H 1 + +/* Define to 1 if you have the `wait3' function. */ +#define HAVE_WAIT3 1 + +/* Define to 1 if you have the `wait4' function. */ +/* #undef HAVE_WAIT4 */ + +/* Define to 1 if you have the `waitpid' function. */ +#define HAVE_WAITPID 1 + +/* Define if the compiler provides a wchar.h header file. */ +#define HAVE_WCHAR_H 1 + +/* Define to 1 if you have the `wcscoll' function. */ +#define HAVE_WCSCOLL 1 + +/* Define if tzset() actually switches the local timezone in a meaningful way. + */ +/* #undef HAVE_WORKING_TZSET */ + +/* Define if the zlib library has inflateCopy */ +#define HAVE_ZLIB_COPY 1 + +/* Define to 1 if you have the `_getpty' function. */ +/* #undef HAVE__GETPTY */ + +/* Define if you are using Mach cthreads directly under /include */ +/* #undef HURD_C_THREADS */ + +/* Define if you are using Mach cthreads under mach / */ +/* #undef MACH_C_THREADS */ + +/* Define to 1 if `major', `minor', and `makedev' are declared in . + */ +/* #undef MAJOR_IN_MKDEV */ + +/* Define to 1 if `major', `minor', and `makedev' are declared in + . */ +#define MAJOR_IN_SYSMACROS 1 + +/* Define if mvwdelch in curses.h is an expression. */ +/* #undef MVWDELCH_IS_EXPRESSION */ + +/* Define to the address where bug reports for this package should be sent. */ +/* #undef PACKAGE_BUGREPORT */ + +/* Define to the full name of this package. */ +/* #undef PACKAGE_NAME */ + +/* Define to the full name and version of this package. */ +/* #undef PACKAGE_STRING */ + +/* Define to the one symbol short name of this package. */ +/* #undef PACKAGE_TARNAME */ + +/* Define to the home page for this package. */ +/* #undef PACKAGE_URL */ + +/* Define to the version of this package. */ +/* #undef PACKAGE_VERSION */ + +/* Define if POSIX semaphores aren't enabled on your system */ +/* #undef POSIX_SEMAPHORES_NOT_ENABLED */ + +/* Defined if PTHREAD_SCOPE_SYSTEM supported. */ +/* #undef PTHREAD_SYSTEM_SCHED_SUPPORTED */ + +/* Define as the preferred size in bits of long digits */ +/* #undef PYLONG_BITS_IN_DIGIT */ + +/* Define to printf format modifier for long long type */ +#define PY_FORMAT_LONG_LONG "ll" + +/* Define to printf format modifier for Py_ssize_t */ +#define PY_FORMAT_SIZE_T "z" + +/* Define as the integral type used for Unicode representation. */ +#define PY_UNICODE_TYPE unsigned long + +/* Define if you want to build an interpreter with many run-time checks. */ +/* #undef Py_DEBUG */ + +/* Defined if Python is built as a shared library. */ +#define Py_ENABLE_SHARED 1 + +/* Define as the size of the unicode type. */ +#define Py_UNICODE_SIZE 4 + +/* Define if you want to have a Unicode type. */ +#define Py_USING_UNICODE 1 + +/* assume C89 semantics that RETSIGTYPE is always void */ +#define RETSIGTYPE void + +/* Define if setpgrp() must be called as setpgrp(0, 0). */ +/* #undef SETPGRP_HAVE_ARG */ + +/* Define this to be extension of shared libraries (including the dot!). */ +#define SHLIB_EXT ".so" + +/* Define if i>>j for signed int i does not extend the sign bit when i < 0 */ +/* #undef SIGNED_RIGHT_SHIFT_ZERO_FILLS */ + +/* The size of `double', as computed by sizeof. */ +#define SIZEOF_DOUBLE 8 + +/* The size of `float', as computed by sizeof. */ +#define SIZEOF_FLOAT 4 + +/* The size of `fpos_t', as computed by sizeof. */ +#define SIZEOF_FPOS_T 4 + +/* The size of `int', as computed by sizeof. */ +#define SIZEOF_INT 4 + +/* The size of `long', as computed by sizeof. */ +#define SIZEOF_LONG 4 + +/* The size of `long double', as computed by sizeof. */ +#define SIZEOF_LONG_DOUBLE 8 + +/* The size of `long long', as computed by sizeof. */ +#define SIZEOF_LONG_LONG 8 + +/* The size of `off_t', as computed by sizeof. */ +#define SIZEOF_OFF_T 4 + +/* The size of `pid_t', as computed by sizeof. */ +#define SIZEOF_PID_T 4 + +/* The size of `pthread_t', as computed by sizeof. */ +#define SIZEOF_PTHREAD_T 4 + +/* The size of `short', as computed by sizeof. */ +#define SIZEOF_SHORT 2 + +/* The size of `size_t', as computed by sizeof. */ +#define SIZEOF_SIZE_T 4 + +/* The size of `time_t', as computed by sizeof. */ +#define SIZEOF_TIME_T 4 + +/* The size of `uintptr_t', as computed by sizeof. */ +#define SIZEOF_UINTPTR_T 4 + +/* The size of `void *', as computed by sizeof. */ +#define SIZEOF_VOID_P 4 + +/* The size of `wchar_t', as computed by sizeof. */ +#define SIZEOF_WCHAR_T 4 + +/* The size of `_Bool', as computed by sizeof. */ +#define SIZEOF__BOOL 1 + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define if you can safely include both and + (which you can't on SCO ODT 3.0). */ +#define SYS_SELECT_WITH_SYS_TIME 1 + +/* Define if tanh(-0.) is -0., or if platform doesn't have signed zeros */ +/* #undef TANH_PRESERVES_ZERO_SIGN */ + +/* Define to 1 if you can safely include both and . */ +#define TIME_WITH_SYS_TIME 1 + +/* Define to 1 if your declares `struct tm'. */ +/* #undef TM_IN_SYS_TIME */ + +/* Enable extensions on AIX 3, Interix. */ +#ifndef _ALL_SOURCE +# define _ALL_SOURCE 1 +#endif +/* Enable GNU extensions on systems that have them. */ +#ifndef _GNU_SOURCE +# define _GNU_SOURCE 1 +#endif +/* Enable threading extensions on Solaris. */ +#ifndef _POSIX_PTHREAD_SEMANTICS +# define _POSIX_PTHREAD_SEMANTICS 1 +#endif +/* Enable extensions on HP NonStop. */ +#ifndef _TANDEM_SOURCE +# define _TANDEM_SOURCE 1 +#endif +/* Enable general extensions on Solaris. */ +#ifndef __EXTENSIONS__ +# define __EXTENSIONS__ 1 +#endif + + +/* Define if you want to use MacPython modules on MacOSX in unix-Python. */ +/* #undef USE_TOOLBOX_OBJECT_GLUE */ + +/* Define if a va_list is an array of some kind */ +/* #undef VA_LIST_IS_ARRAY */ + +/* Define if you want SIGFPE handled (see Include/pyfpe.h). */ +/* #undef WANT_SIGFPE_HANDLER */ + +/* Define if you want wctype.h functions to be used instead of the one + supplied by Python itself. (see Include/unicodectype.h). */ +/* #undef WANT_WCTYPE_FUNCTIONS */ + +/* Define if WINDOW in curses.h offers a field _flags. */ +/* #undef WINDOW_HAS_FLAGS */ + +/* Define if you want documentation strings in extension modules */ +#define WITH_DOC_STRINGS 1 + +/* Define if you want to use the new-style (Openstep, Rhapsody, MacOS) dynamic + linker (dyld) instead of the old-style (NextStep) dynamic linker (rld). + Dyld is necessary to support frameworks. */ +/* #undef WITH_DYLD */ + +/* Define to 1 if libintl is needed for locale functions. */ +/* #undef WITH_LIBINTL */ + +/* Define if you want to produce an OpenStep/Rhapsody framework (shared + library plus accessory files). */ +/* #undef WITH_NEXT_FRAMEWORK */ + +/* Define if you want to compile in Python-specific mallocs */ +#define WITH_PYMALLOC 1 + +/* Define if you want to compile in rudimentary thread support */ +#define WITH_THREAD 1 + +/* Define to profile with the Pentium timestamp counter */ +/* #undef WITH_TSC */ + +/* Define if you want pymalloc to be disabled when running under valgrind */ +/* #undef WITH_VALGRIND */ + +/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most + significant byte first (like Motorola and SPARC, unlike Intel). */ +#if defined AC_APPLE_UNIVERSAL_BUILD +# if defined __BIG_ENDIAN__ +# define WORDS_BIGENDIAN 1 +# endif +#else +# ifndef WORDS_BIGENDIAN +/* # undef WORDS_BIGENDIAN */ +# endif +#endif + +/* Define if arithmetic is subject to x87-style double rounding issue */ +/* #undef X87_DOUBLE_ROUNDING */ + +/* Define on OpenBSD to activate all library features */ +/* #undef _BSD_SOURCE */ + +/* Define on Irix to enable u_int */ +#define _BSD_TYPES 1 + +/* Define on Darwin to activate all library features */ +#define _DARWIN_C_SOURCE 1 + +/* This must be set to 64 on some systems to enable large file support. */ +#define _FILE_OFFSET_BITS 64 + +/* Define on Linux to activate all library features */ +#define _GNU_SOURCE 1 + +/* This must be defined on some systems to enable large file support. */ +#define _LARGEFILE_SOURCE 1 + +/* This must be defined on AIX systems to enable large file support. */ +/* #undef _LARGE_FILES */ + +/* Define to 1 if on MINIX. */ +/* #undef _MINIX */ + +/* Define on NetBSD to activate all library features */ +#define _NETBSD_SOURCE 1 + +/* Define _OSF_SOURCE to get the makedev macro. */ +/* #undef _OSF_SOURCE */ + +/* Define to 2 if the system does not provide POSIX.1 features except with + this defined. */ +/* #undef _POSIX_1_SOURCE */ + +/* Define to activate features from IEEE Stds 1003.1-2001 */ +#define _POSIX_C_SOURCE 200112L + +/* Define to 1 if you need to in order for `stat' and other things to work. */ +/* #undef _POSIX_SOURCE */ + +/* Define if you have POSIX threads, and your system does not define that. */ +/* #undef _POSIX_THREADS */ + +/* Define to force use of thread-safe errno, h_errno, and other functions */ +#define _REENTRANT 1 + +/* Define for Solaris 2.5.1 so the uint32_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +/* #undef _UINT32_T */ + +/* Define for Solaris 2.5.1 so the uint64_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +/* #undef _UINT64_T */ + +/* Define to the level of X/Open that your system supports */ +#define _XOPEN_SOURCE 600 + +/* Define to activate Unix95-and-earlier features */ +#define _XOPEN_SOURCE_EXTENDED 1 + +/* Define on FreeBSD to activate all library features */ +#define __BSD_VISIBLE 1 + +/* Define to 1 if type `char' is unsigned and you are not using gcc. */ +#ifndef __CHAR_UNSIGNED__ +/* # undef __CHAR_UNSIGNED__ */ +#endif + +/* Defined on Solaris to see additional function prototypes. */ +#define __EXTENSIONS__ 1 + +/* Define to 'long' if doesn't define. */ +/* #undef clock_t */ + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ + +/* Define to `int' if doesn't define. */ +/* #undef gid_t */ + +/* Define to the type of a signed integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +/* #undef int32_t */ + +/* Define to the type of a signed integer type of width exactly 64 bits if + such a type exists and the standard includes do not define it. */ +/* #undef int64_t */ + +/* Define to `int' if does not define. */ +/* #undef mode_t */ + +/* Define to `long int' if does not define. */ +/* #undef off_t */ + +/* Define to `int' if does not define. */ +/* #undef pid_t */ + +/* Define to empty if the keyword does not work. */ +/* #undef signed */ + +/* Define to `unsigned int' if does not define. */ +/* #undef size_t */ + +/* Define to `int' if does not define. */ +/* #undef socklen_t */ + +/* Define to `int' if doesn't define. */ +/* #undef uid_t */ + +/* Define to the type of an unsigned integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint32_t */ + +/* Define to the type of an unsigned integer type of width exactly 64 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint64_t */ + +/* Define to empty if the keyword does not work. */ +/* #undef volatile */ + + +/* Define the macros needed if on a UnixWare 7.x system. */ +#if defined(__USLC__) && defined(__SCO_VERSION__) +#define STRICT_SYSV_CURSES /* Don't use ncurses extensions */ +#endif + +#endif /*Py_PYCONFIG_H*/ + diff --git a/android/python27/include/pyconfig_mips.h b/android/python27/include/pyconfig_mips.h new file mode 100644 index 000000000..8c9ca6178 --- /dev/null +++ b/android/python27/include/pyconfig_mips.h @@ -0,0 +1,1282 @@ +/* pyconfig.h. Generated from pyconfig.h.in by configure. */ +/* pyconfig.h.in. Generated from configure.ac by autoheader. */ + + +#ifndef Py_PYCONFIG_H +#define Py_PYCONFIG_H + + +/* Define if building universal (internal helper macro) */ +/* #undef AC_APPLE_UNIVERSAL_BUILD */ + +/* Define for AIX if your compiler is a genuine IBM xlC/xlC_r and you want + support for AIX C++ shared extension modules. */ +/* #undef AIX_GENUINE_CPLUSPLUS */ + +/* Define this if you have AtheOS threads. */ +/* #undef ATHEOS_THREADS */ + +/* Define this if you have BeOS threads. */ +/* #undef BEOS_THREADS */ + +/* Define if you have the Mach cthreads package */ +/* #undef C_THREADS */ + +/* Define if C doubles are 64-bit IEEE 754 binary format, stored in ARM + mixed-endian order (byte order 45670123) */ +/* #undef DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754 */ + +/* Define if C doubles are 64-bit IEEE 754 binary format, stored with the most + significant byte first */ +/* #undef DOUBLE_IS_BIG_ENDIAN_IEEE754 */ + +/* Define if C doubles are 64-bit IEEE 754 binary format, stored with the + least significant byte first */ +/* #undef DOUBLE_IS_LITTLE_ENDIAN_IEEE754 */ + +/* Define if --enable-ipv6 is specified */ +#define ENABLE_IPV6 1 + +/* Define if flock needs to be linked with bsd library. */ +/* #undef FLOCK_NEEDS_LIBBSD */ + +/* Define if getpgrp() must be called as getpgrp(0). */ +/* #undef GETPGRP_HAVE_ARG */ + +/* Define if gettimeofday() does not have second (timezone) argument This is + the case on Motorola V4 (R40V4.2) */ +/* #undef GETTIMEOFDAY_NO_TZ */ + +/* Define to 1 if you have the `acosh' function. */ +#define HAVE_ACOSH 1 + +/* struct addrinfo (netdb.h) */ +#define HAVE_ADDRINFO 1 + +/* Define to 1 if you have the `alarm' function. */ +#define HAVE_ALARM 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ALLOCA_H 1 + +/* Define this if your time.h defines altzone. */ +/* #undef HAVE_ALTZONE */ + +/* Define to 1 if you have the `asinh' function. */ +#define HAVE_ASINH 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ASM_TYPES_H 1 + +/* Define to 1 if you have the `atanh' function. */ +#define HAVE_ATANH 1 + +/* Define if GCC supports __attribute__((format(PyArg_ParseTuple, 2, 3))) */ +/* #undef HAVE_ATTRIBUTE_FORMAT_PARSETUPLE */ + +/* Define to 1 if you have the `bind_textdomain_codeset' function. */ +/* #undef HAVE_BIND_TEXTDOMAIN_CODESET */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_BLUETOOTH_BLUETOOTH_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_BLUETOOTH_H */ + +/* Define if nice() returns success/failure instead of the new priority. */ +/* #undef HAVE_BROKEN_NICE */ + +/* Define if the system reports an invalid PIPE_BUF value. */ +/* #undef HAVE_BROKEN_PIPE_BUF */ + +/* Define if poll() sets errno on invalid file descriptors. */ +/* #undef HAVE_BROKEN_POLL */ + +/* Define if the Posix semaphores do not work on your system */ +/* #undef HAVE_BROKEN_POSIX_SEMAPHORES */ + +/* Define if pthread_sigmask() does not work on your system. */ +/* #undef HAVE_BROKEN_PTHREAD_SIGMASK */ + +/* define to 1 if your sem_getvalue is broken. */ +#define HAVE_BROKEN_SEM_GETVALUE 1 + +/* Define if `unsetenv` does not return an int. */ +/* #undef HAVE_BROKEN_UNSETENV */ + +/* Define this if you have the type _Bool. */ +#define HAVE_C99_BOOL 1 + +/* Define to 1 if you have the 'chflags' function. */ +/* #undef HAVE_CHFLAGS */ + +/* Define to 1 if you have the `chown' function. */ +#define HAVE_CHOWN 1 + +/* Define if you have the 'chroot' function. */ +#define HAVE_CHROOT 1 + +/* Define to 1 if you have the `clock' function. */ +#define HAVE_CLOCK 1 + +/* Define to 1 if you have the `confstr' function. */ +/* #undef HAVE_CONFSTR */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_CONIO_H */ + +/* Define to 1 if you have the `copysign' function. */ +#define HAVE_COPYSIGN 1 + +/* Define to 1 if you have the `ctermid' function. */ +/* #undef HAVE_CTERMID */ + +/* Define if you have the 'ctermid_r' function. */ +#define HAVE_CTERMID_R 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_CURSES_H */ + +/* Define if you have the 'is_term_resized' function. */ +/* #undef HAVE_CURSES_IS_TERM_RESIZED */ + +/* Define if you have the 'resizeterm' function. */ +/* #undef HAVE_CURSES_RESIZETERM */ + +/* Define if you have the 'resize_term' function. */ +/* #undef HAVE_CURSES_RESIZE_TERM */ + +/* Define to 1 if you have the declaration of `isfinite', and to 0 if you + don't. */ +#define HAVE_DECL_ISFINITE 1 + +/* Define to 1 if you have the declaration of `isinf', and to 0 if you don't. + */ +#define HAVE_DECL_ISINF 1 + +/* Define to 1 if you have the declaration of `isnan', and to 0 if you don't. + */ +#define HAVE_DECL_ISNAN 1 + +/* Define to 1 if you have the declaration of `tzname', and to 0 if you don't. + */ +/* #undef HAVE_DECL_TZNAME */ + +/* Define to 1 if you have the device macros. */ +#define HAVE_DEVICE_MACROS 1 + +/* Define to 1 if you have the /dev/ptc device file. */ +/* #undef HAVE_DEV_PTC */ + +/* Define to 1 if you have the /dev/ptmx device file. */ +/* #undef HAVE_DEV_PTMX */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_DIRECT_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#define HAVE_DIRENT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_DLFCN_H 1 + +/* Define to 1 if you have the `dlopen' function. */ +#define HAVE_DLOPEN 1 + +/* Define to 1 if you have the `dup2' function. */ +#define HAVE_DUP2 1 + +/* Defined when any dynamic module loading is enabled. */ +#define HAVE_DYNAMIC_LOADING 1 + +/* Define if you have the 'epoll' functions. */ +#define HAVE_EPOLL 1 + +/* Define to 1 if you have the `erf' function. */ +#define HAVE_ERF 1 + +/* Define to 1 if you have the `erfc' function. */ +#define HAVE_ERFC 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ERRNO_H 1 + +/* Define to 1 if you have the `execv' function. */ +#define HAVE_EXECV 1 + +/* Define to 1 if you have the `expm1' function. */ +#define HAVE_EXPM1 1 + +/* Define if you have the 'fchdir' function. */ +#define HAVE_FCHDIR 1 + +/* Define to 1 if you have the `fchmod' function. */ +#define HAVE_FCHMOD 1 + +/* Define to 1 if you have the `fchown' function. */ +#define HAVE_FCHOWN 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* Define if you have the 'fdatasync' function. */ +#define HAVE_FDATASYNC 1 + +/* Define to 1 if you have the `finite' function. */ +#define HAVE_FINITE 1 + +/* Define to 1 if you have the `flock' function. */ +#define HAVE_FLOCK 1 + +/* Define to 1 if you have the `fork' function. */ +#define HAVE_FORK 1 + +/* Define to 1 if you have the `forkpty' function. */ +/* #undef HAVE_FORKPTY */ + +/* Define to 1 if you have the `fpathconf' function. */ +#define HAVE_FPATHCONF 1 + +/* Define to 1 if you have the `fseek64' function. */ +/* #undef HAVE_FSEEK64 */ + +/* Define to 1 if you have the `fseeko' function. */ +#define HAVE_FSEEKO 1 + +/* Define to 1 if you have the `fstatvfs' function. */ +/* #undef HAVE_FSTATVFS */ + +/* Define if you have the 'fsync' function. */ +#define HAVE_FSYNC 1 + +/* Define to 1 if you have the `ftell64' function. */ +/* #undef HAVE_FTELL64 */ + +/* Define to 1 if you have the `ftello' function. */ +#define HAVE_FTELLO 1 + +/* Define to 1 if you have the `ftime' function. */ +#define HAVE_FTIME 1 + +/* Define to 1 if you have the `ftruncate' function. */ +#define HAVE_FTRUNCATE 1 + +/* Define to 1 if you have the `gai_strerror' function. */ +#define HAVE_GAI_STRERROR 1 + +/* Define to 1 if you have the `gamma' function. */ +/* #undef HAVE_GAMMA */ + +/* Define if we can use gcc inline assembler to get and set x87 control word + */ +/* #undef HAVE_GCC_ASM_FOR_X87 */ + +/* Define if you have the getaddrinfo function. */ +#define HAVE_GETADDRINFO 1 + +/* Define to 1 if you have the `getcwd' function. */ +#define HAVE_GETCWD 1 + +/* Define this if you have flockfile(), getc_unlocked(), and funlockfile() */ +#define HAVE_GETC_UNLOCKED 1 + +/* Define to 1 if you have the `getentropy' function. */ +/* #undef HAVE_GETENTROPY */ + +/* Define to 1 if you have the `getgroups' function. */ +#define HAVE_GETGROUPS 1 + +/* Define to 1 if you have the `gethostbyname' function. */ +#define HAVE_GETHOSTBYNAME 1 + +/* Define this if you have some version of gethostbyname_r() */ +/* #undef HAVE_GETHOSTBYNAME_R */ + +/* Define this if you have the 3-arg version of gethostbyname_r(). */ +/* #undef HAVE_GETHOSTBYNAME_R_3_ARG */ + +/* Define this if you have the 5-arg version of gethostbyname_r(). */ +/* #undef HAVE_GETHOSTBYNAME_R_5_ARG */ + +/* Define this if you have the 6-arg version of gethostbyname_r(). */ +/* #undef HAVE_GETHOSTBYNAME_R_6_ARG */ + +/* Define to 1 if you have the `getitimer' function. */ +#define HAVE_GETITIMER 1 + +/* Define to 1 if you have the `getloadavg' function. */ +#define HAVE_GETLOADAVG 1 + +/* Define to 1 if you have the `getlogin' function. */ +#define HAVE_GETLOGIN 1 + +/* Define to 1 if you have the `getnameinfo' function. */ +#define HAVE_GETNAMEINFO 1 + +/* Define if you have the 'getpagesize' function. */ +#define HAVE_GETPAGESIZE 1 + +/* Define to 1 if you have the `getpeername' function. */ +#define HAVE_GETPEERNAME 1 + +/* Define to 1 if you have the `getpgid' function. */ +#define HAVE_GETPGID 1 + +/* Define to 1 if you have the `getpgrp' function. */ +#define HAVE_GETPGRP 1 + +/* Define to 1 if you have the `getpid' function. */ +#define HAVE_GETPID 1 + +/* Define to 1 if you have the `getpriority' function. */ +#define HAVE_GETPRIORITY 1 + +/* Define to 1 if you have the `getpwent' function. */ +#define HAVE_GETPWENT 1 + +/* Define to 1 if you have the `getresgid' function. */ +#define HAVE_GETRESGID 1 + +/* Define to 1 if you have the `getresuid' function. */ +#define HAVE_GETRESUID 1 + +/* Define to 1 if you have the `getsid' function. */ +/* #undef HAVE_GETSID */ + +/* Define to 1 if you have the `getspent' function. */ +/* #undef HAVE_GETSPENT */ + +/* Define to 1 if you have the `getspnam' function. */ +/* #undef HAVE_GETSPNAM */ + +/* Define to 1 if you have the `gettimeofday' function. */ +#define HAVE_GETTIMEOFDAY 1 + +/* Define to 1 if you have the `getwd' function. */ +/* #undef HAVE_GETWD */ + +/* Define to 1 if you have the header file. */ +#define HAVE_GRP_H 1 + +/* Define if you have the 'hstrerror' function. */ +#define HAVE_HSTRERROR 1 + +/* Define to 1 if you have the `hypot' function. */ +#define HAVE_HYPOT 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_IEEEFP_H */ + +/* Define if you have the 'inet_aton' function. */ +#define HAVE_INET_ATON 1 + +/* Define if you have the 'inet_pton' function. */ +#define HAVE_INET_PTON 1 + +/* Define to 1 if you have the `initgroups' function. */ +#define HAVE_INITGROUPS 1 + +/* Define if your compiler provides int32_t. */ +#define HAVE_INT32_T 1 + +/* Define if your compiler provides int64_t. */ +#define HAVE_INT64_T 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_IO_H */ + +/* Define to 1 if you have the `kill' function. */ +#define HAVE_KILL 1 + +/* Define to 1 if you have the `killpg' function. */ +#define HAVE_KILLPG 1 + +/* Define if you have the 'kqueue' functions. */ +#define HAVE_KQUEUE 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_LANGINFO_H 1 + +/* Defined to enable large file support when an off_t is bigger than a long + and long long is available and at least as big as an off_t. You may need to + add some flags for configuration and compilation to enable this mode. (For + Solaris and Linux, the necessary defines are already defined.) */ +/* #undef HAVE_LARGEFILE_SUPPORT */ + +/* Define to 1 if you have the 'lchflags' function. */ +/* #undef HAVE_LCHFLAGS */ + +/* Define to 1 if you have the `lchmod' function. */ +/* #undef HAVE_LCHMOD */ + +/* Define to 1 if you have the `lchown' function. */ +#define HAVE_LCHOWN 1 + +/* Define to 1 if you have the `lgamma' function. */ +#define HAVE_LGAMMA 1 + +/* Define to 1 if you have the `dl' library (-ldl). */ +#define HAVE_LIBDL 1 + +/* Define to 1 if you have the `dld' library (-ldld). */ +/* #undef HAVE_LIBDLD */ + +/* Define to 1 if you have the `ieee' library (-lieee). */ +/* #undef HAVE_LIBIEEE */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LIBINTL_H */ + +/* Define if you have the readline library (-lreadline). */ +/* #undef HAVE_LIBREADLINE */ + +/* Define to 1 if you have the `resolv' library (-lresolv). */ +/* #undef HAVE_LIBRESOLV */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LIBUTIL_H */ + +/* Define if you have the 'link' function. */ +#define HAVE_LINK 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_LINUX_NETLINK_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LINUX_TIPC_H */ + +/* Define to 1 if you have the `log1p' function. */ +#define HAVE_LOG1P 1 + +/* Define this if you have the type long double. */ +#define HAVE_LONG_DOUBLE 1 + +/* Define this if you have the type long long. */ +#define HAVE_LONG_LONG 1 + +/* Define to 1 if you have the `lstat' function. */ +#define HAVE_LSTAT 1 + +/* Define this if you have the makedev macro. */ +#define HAVE_MAKEDEV 1 + +/* Define to 1 if you have the `memmove' function. */ +#define HAVE_MEMMOVE 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `mkfifo' function. */ +/* #undef HAVE_MKFIFO */ + +/* Define to 1 if you have the `mknod' function. */ +#define HAVE_MKNOD 1 + +/* Define to 1 if you have the `mktime' function. */ +#define HAVE_MKTIME 1 + +/* Define to 1 if you have the `mmap' function. */ +#define HAVE_MMAP 1 + +/* Define to 1 if you have the `mremap' function. */ +#define HAVE_MREMAP 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NCURSES_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. */ +/* #undef HAVE_NDIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_NETPACKET_PACKET_H 1 + +/* Define to 1 if you have the `nice' function. */ +#define HAVE_NICE 1 + +/* Define to 1 if you have the `openpty' function. */ +/* #undef HAVE_OPENPTY */ + +/* Define if compiling using MacOS X 10.5 SDK or later. */ +/* #undef HAVE_OSX105_SDK */ + +/* Define to 1 if you have the `pathconf' function. */ +#define HAVE_PATHCONF 1 + +/* Define to 1 if you have the `pause' function. */ +#define HAVE_PAUSE 1 + +/* Define to 1 if you have the `plock' function. */ +/* #undef HAVE_PLOCK */ + +/* Define to 1 if you have the `poll' function. */ +#define HAVE_POLL 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_POLL_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PROCESS_H */ + +/* Define if your compiler supports function prototype */ +#define HAVE_PROTOTYPES 1 + +/* Define if you have GNU PTH threads. */ +/* #undef HAVE_PTH */ + +/* Define to 1 if you have the `pthread_atfork' function. */ +/* #undef HAVE_PTHREAD_ATFORK */ + +/* Defined for Solaris 2.6 bug in pthread header. */ +/* #undef HAVE_PTHREAD_DESTRUCTOR */ + +/* Define to 1 if you have the header file. */ +#define HAVE_PTHREAD_H 1 + +/* Define to 1 if you have the `pthread_init' function. */ +/* #undef HAVE_PTHREAD_INIT */ + +/* Define to 1 if you have the `pthread_sigmask' function. */ +#define HAVE_PTHREAD_SIGMASK 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PTY_H */ + +/* Define to 1 if you have the `putenv' function. */ +#define HAVE_PUTENV 1 + +/* Define if the libcrypto has RAND_egd */ +/* #undef HAVE_RAND_EGD */ + +/* Define to 1 if you have the `readlink' function. */ +#define HAVE_READLINK 1 + +/* Define to 1 if you have the `realpath' function. */ +#define HAVE_REALPATH 1 + +/* Define if you have readline 2.1 */ +/* #undef HAVE_RL_CALLBACK */ + +/* Define if you can turn off readline's signal handling. */ +/* #undef HAVE_RL_CATCH_SIGNAL */ + +/* Define if you have readline 2.2 */ +/* #undef HAVE_RL_COMPLETION_APPEND_CHARACTER */ + +/* Define if you have readline 4.0 */ +/* #undef HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK */ + +/* Define if you have readline 4.2 */ +/* #undef HAVE_RL_COMPLETION_MATCHES */ + +/* Define if you have rl_completion_suppress_append */ +/* #undef HAVE_RL_COMPLETION_SUPPRESS_APPEND */ + +/* Define if you have readline 4.0 */ +/* #undef HAVE_RL_PRE_INPUT_HOOK */ + +/* Define to 1 if you have the `round' function. */ +#define HAVE_ROUND 1 + +/* Define to 1 if you have the `select' function. */ +#define HAVE_SELECT 1 + +/* Define to 1 if you have the `sem_getvalue' function. */ +#define HAVE_SEM_GETVALUE 1 + +/* Define to 1 if you have the `sem_open' function. */ +#define HAVE_SEM_OPEN 1 + +/* Define to 1 if you have the `sem_timedwait' function. */ +#define HAVE_SEM_TIMEDWAIT 1 + +/* Define to 1 if you have the `sem_unlink' function. */ +#define HAVE_SEM_UNLINK 1 + +/* Define to 1 if you have the `setegid' function. */ +#define HAVE_SETEGID 1 + +/* Define to 1 if you have the `seteuid' function. */ +#define HAVE_SETEUID 1 + +/* Define to 1 if you have the `setgid' function. */ +#define HAVE_SETGID 1 + +/* Define if you have the 'setgroups' function. */ +#define HAVE_SETGROUPS 1 + +/* Define to 1 if you have the `setitimer' function. */ +#define HAVE_SETITIMER 1 + +/* Define to 1 if you have the `setlocale' function. */ +#define HAVE_SETLOCALE 1 + +/* Define to 1 if you have the `setpgid' function. */ +#define HAVE_SETPGID 1 + +/* Define to 1 if you have the `setpgrp' function. */ +#define HAVE_SETPGRP 1 + +/* Define to 1 if you have the `setregid' function. */ +#define HAVE_SETREGID 1 + +/* Define to 1 if you have the `setresgid' function. */ +#define HAVE_SETRESGID 1 + +/* Define to 1 if you have the `setresuid' function. */ +#define HAVE_SETRESUID 1 + +/* Define to 1 if you have the `setreuid' function. */ +#define HAVE_SETREUID 1 + +/* Define to 1 if you have the `setsid' function. */ +#define HAVE_SETSID 1 + +/* Define to 1 if you have the `setuid' function. */ +#define HAVE_SETUID 1 + +/* Define to 1 if you have the `setvbuf' function. */ +#define HAVE_SETVBUF 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SHADOW_H */ + +/* Define to 1 if you have the `sigaction' function. */ +#define HAVE_SIGACTION 1 + +/* Define to 1 if you have the `siginterrupt' function. */ +#define HAVE_SIGINTERRUPT 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SIGNAL_H 1 + +/* Define to 1 if you have the `sigrelse' function. */ +/* #undef HAVE_SIGRELSE */ + +/* Define to 1 if you have the `snprintf' function. */ +#define HAVE_SNPRINTF 1 + +/* Define if sockaddr has sa_len member */ +/* #undef HAVE_SOCKADDR_SA_LEN */ + +/* struct sockaddr_storage (sys/socket.h) */ +#define HAVE_SOCKADDR_STORAGE 1 + +/* Define if you have the 'socketpair' function. */ +#define HAVE_SOCKETPAIR 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SPAWN_H */ + +/* Define if your compiler provides ssize_t */ +#define HAVE_SSIZE_T 1 + +/* Define to 1 if you have the `statvfs' function. */ +/* #undef HAVE_STATVFS */ + +/* Define if you have struct stat.st_mtim.tv_nsec */ +/* #undef HAVE_STAT_TV_NSEC */ + +/* Define if you have struct stat.st_mtimensec */ +/* #undef HAVE_STAT_TV_NSEC2 */ + +/* Define if your compiler supports variable length function prototypes (e.g. + void fprintf(FILE *, char *, ...);) *and* */ +#define HAVE_STDARG_PROTOTYPES 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the `strdup' function. */ +#define HAVE_STRDUP 1 + +/* Define to 1 if you have the `strftime' function. */ +#define HAVE_STRFTIME 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_STROPTS_H */ + +/* Define to 1 if `st_birthtime' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_BIRTHTIME */ + +/* Define to 1 if `st_blksize' is a member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_BLKSIZE 1 + +/* Define to 1 if `st_blocks' is a member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_BLOCKS 1 + +/* Define to 1 if `st_flags' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_FLAGS */ + +/* Define to 1 if `st_gen' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_GEN */ + +/* Define to 1 if `st_rdev' is a member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_RDEV 1 + +/* Define to 1 if `tm_zone' is a member of `struct tm'. */ +#define HAVE_STRUCT_TM_TM_ZONE 1 + +/* Define to 1 if your `struct stat' has `st_blocks'. Deprecated, use + `HAVE_STRUCT_STAT_ST_BLOCKS' instead. */ +#define HAVE_ST_BLOCKS 1 + +/* Define if you have the 'symlink' function. */ +#define HAVE_SYMLINK 1 + +/* Define to 1 if you have the `sysconf' function. */ +#define HAVE_SYSCONF 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYSEXITS_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_AUDIOIO_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_BSDTTY_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +/* #undef HAVE_SYS_DIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_EPOLL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_EVENT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_FILE_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_LOADAVG_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_LOCK_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_MKDEV_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_MODEM_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +/* #undef HAVE_SYS_NDIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_PARAM_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_POLL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_RESOURCE_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SELECT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SOCKET_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_STATVFS_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_TERMIO_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIMES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UN_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UTSNAME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_WAIT_H 1 + +/* Define to 1 if you have the `tcgetpgrp' function. */ +#define HAVE_TCGETPGRP 1 + +/* Define to 1 if you have the `tcsetpgrp' function. */ +#define HAVE_TCSETPGRP 1 + +/* Define to 1 if you have the `tempnam' function. */ +#define HAVE_TEMPNAM 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_TERMIOS_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_TERM_H */ + +/* Define to 1 if you have the `tgamma' function. */ +#define HAVE_TGAMMA 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_THREAD_H */ + +/* Define to 1 if you have the `timegm' function. */ +/* #undef HAVE_TIMEGM */ + +/* Define to 1 if you have the `times' function. */ +#define HAVE_TIMES 1 + +/* Define to 1 if you have the `tmpfile' function. */ +#define HAVE_TMPFILE 1 + +/* Define to 1 if you have the `tmpnam' function. */ +#define HAVE_TMPNAM 1 + +/* Define to 1 if you have the `tmpnam_r' function. */ +/* #undef HAVE_TMPNAM_R */ + +/* Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use + `HAVE_STRUCT_TM_TM_ZONE' instead. */ +#define HAVE_TM_ZONE 1 + +/* Define to 1 if you have the `truncate' function. */ +#define HAVE_TRUNCATE 1 + +/* Define to 1 if you don't have `tm_zone' but do have the external array + `tzname'. */ +/* #undef HAVE_TZNAME */ + +/* Define this if you have tcl and TCL_UTF_MAX==6 */ +/* #undef HAVE_UCS4_TCL */ + +/* Define if your compiler provides uint32_t. */ +#define HAVE_UINT32_T 1 + +/* Define if your compiler provides uint64_t. */ +#define HAVE_UINT64_T 1 + +/* Define to 1 if the system has the type `uintptr_t'. */ +#define HAVE_UINTPTR_T 1 + +/* Define to 1 if you have the `uname' function. */ +#define HAVE_UNAME 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you have the `unsetenv' function. */ +#define HAVE_UNSETENV 1 + +/* Define if you have a useable wchar_t type defined in wchar.h; useable means + wchar_t must be an unsigned type with at least 16 bits. (see + Include/unicodeobject.h). */ +/* #undef HAVE_USABLE_WCHAR_T */ + +/* Define to 1 if you have the header file. */ +#define HAVE_UTIL_H 1 + +/* Define to 1 if you have the `utimes' function. */ +#define HAVE_UTIMES 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UTIME_H 1 + +/* Define to 1 if you have the `wait3' function. */ +#define HAVE_WAIT3 1 + +/* Define to 1 if you have the `wait4' function. */ +/* #undef HAVE_WAIT4 */ + +/* Define to 1 if you have the `waitpid' function. */ +#define HAVE_WAITPID 1 + +/* Define if the compiler provides a wchar.h header file. */ +#define HAVE_WCHAR_H 1 + +/* Define to 1 if you have the `wcscoll' function. */ +#define HAVE_WCSCOLL 1 + +/* Define if tzset() actually switches the local timezone in a meaningful way. + */ +/* #undef HAVE_WORKING_TZSET */ + +/* Define if the zlib library has inflateCopy */ +#define HAVE_ZLIB_COPY 1 + +/* Define to 1 if you have the `_getpty' function. */ +/* #undef HAVE__GETPTY */ + +/* Define if you are using Mach cthreads directly under /include */ +/* #undef HURD_C_THREADS */ + +/* Define if you are using Mach cthreads under mach / */ +/* #undef MACH_C_THREADS */ + +/* Define to 1 if `major', `minor', and `makedev' are declared in . + */ +/* #undef MAJOR_IN_MKDEV */ + +/* Define to 1 if `major', `minor', and `makedev' are declared in + . */ +#define MAJOR_IN_SYSMACROS 1 + +/* Define if mvwdelch in curses.h is an expression. */ +/* #undef MVWDELCH_IS_EXPRESSION */ + +/* Define to the address where bug reports for this package should be sent. */ +/* #undef PACKAGE_BUGREPORT */ + +/* Define to the full name of this package. */ +/* #undef PACKAGE_NAME */ + +/* Define to the full name and version of this package. */ +/* #undef PACKAGE_STRING */ + +/* Define to the one symbol short name of this package. */ +/* #undef PACKAGE_TARNAME */ + +/* Define to the home page for this package. */ +/* #undef PACKAGE_URL */ + +/* Define to the version of this package. */ +/* #undef PACKAGE_VERSION */ + +/* Define if POSIX semaphores aren't enabled on your system */ +/* #undef POSIX_SEMAPHORES_NOT_ENABLED */ + +/* Defined if PTHREAD_SCOPE_SYSTEM supported. */ +/* #undef PTHREAD_SYSTEM_SCHED_SUPPORTED */ + +/* Define as the preferred size in bits of long digits */ +/* #undef PYLONG_BITS_IN_DIGIT */ + +/* Define to printf format modifier for long long type */ +#define PY_FORMAT_LONG_LONG "ll" + +/* Define to printf format modifier for Py_ssize_t */ +#define PY_FORMAT_SIZE_T "z" + +/* Define as the integral type used for Unicode representation. */ +#define PY_UNICODE_TYPE unsigned long + +/* Define if you want to build an interpreter with many run-time checks. */ +/* #undef Py_DEBUG */ + +/* Defined if Python is built as a shared library. */ +#define Py_ENABLE_SHARED 1 + +/* Define as the size of the unicode type. */ +#define Py_UNICODE_SIZE 4 + +/* Define if you want to have a Unicode type. */ +#define Py_USING_UNICODE 1 + +/* assume C89 semantics that RETSIGTYPE is always void */ +#define RETSIGTYPE void + +/* Define if setpgrp() must be called as setpgrp(0, 0). */ +/* #undef SETPGRP_HAVE_ARG */ + +/* Define this to be extension of shared libraries (including the dot!). */ +#define SHLIB_EXT ".so" + +/* Define if i>>j for signed int i does not extend the sign bit when i < 0 */ +/* #undef SIGNED_RIGHT_SHIFT_ZERO_FILLS */ + +/* The size of `double', as computed by sizeof. */ +#define SIZEOF_DOUBLE 8 + +/* The size of `float', as computed by sizeof. */ +#define SIZEOF_FLOAT 4 + +/* The size of `fpos_t', as computed by sizeof. */ +#define SIZEOF_FPOS_T 4 + +/* The size of `int', as computed by sizeof. */ +#define SIZEOF_INT 4 + +/* The size of `long', as computed by sizeof. */ +#define SIZEOF_LONG 4 + +/* The size of `long double', as computed by sizeof. */ +#define SIZEOF_LONG_DOUBLE 8 + +/* The size of `long long', as computed by sizeof. */ +#define SIZEOF_LONG_LONG 8 + +/* The size of `off_t', as computed by sizeof. */ +#define SIZEOF_OFF_T 4 + +/* The size of `pid_t', as computed by sizeof. */ +#define SIZEOF_PID_T 4 + +/* The size of `pthread_t', as computed by sizeof. */ +#define SIZEOF_PTHREAD_T 4 + +/* The size of `short', as computed by sizeof. */ +#define SIZEOF_SHORT 2 + +/* The size of `size_t', as computed by sizeof. */ +#define SIZEOF_SIZE_T 4 + +/* The size of `time_t', as computed by sizeof. */ +#define SIZEOF_TIME_T 4 + +/* The size of `uintptr_t', as computed by sizeof. */ +#define SIZEOF_UINTPTR_T 4 + +/* The size of `void *', as computed by sizeof. */ +#define SIZEOF_VOID_P 4 + +/* The size of `wchar_t', as computed by sizeof. */ +#define SIZEOF_WCHAR_T 4 + +/* The size of `_Bool', as computed by sizeof. */ +#define SIZEOF__BOOL 1 + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define if you can safely include both and + (which you can't on SCO ODT 3.0). */ +#define SYS_SELECT_WITH_SYS_TIME 1 + +/* Define if tanh(-0.) is -0., or if platform doesn't have signed zeros */ +/* #undef TANH_PRESERVES_ZERO_SIGN */ + +/* Define to 1 if you can safely include both and . */ +#define TIME_WITH_SYS_TIME 1 + +/* Define to 1 if your declares `struct tm'. */ +/* #undef TM_IN_SYS_TIME */ + +/* Enable extensions on AIX 3, Interix. */ +#ifndef _ALL_SOURCE +# define _ALL_SOURCE 1 +#endif +/* Enable GNU extensions on systems that have them. */ +#ifndef _GNU_SOURCE +# define _GNU_SOURCE 1 +#endif +/* Enable threading extensions on Solaris. */ +#ifndef _POSIX_PTHREAD_SEMANTICS +# define _POSIX_PTHREAD_SEMANTICS 1 +#endif +/* Enable extensions on HP NonStop. */ +#ifndef _TANDEM_SOURCE +# define _TANDEM_SOURCE 1 +#endif +/* Enable general extensions on Solaris. */ +#ifndef __EXTENSIONS__ +# define __EXTENSIONS__ 1 +#endif + + +/* Define if you want to use MacPython modules on MacOSX in unix-Python. */ +/* #undef USE_TOOLBOX_OBJECT_GLUE */ + +/* Define if a va_list is an array of some kind */ +/* #undef VA_LIST_IS_ARRAY */ + +/* Define if you want SIGFPE handled (see Include/pyfpe.h). */ +/* #undef WANT_SIGFPE_HANDLER */ + +/* Define if you want wctype.h functions to be used instead of the one + supplied by Python itself. (see Include/unicodectype.h). */ +/* #undef WANT_WCTYPE_FUNCTIONS */ + +/* Define if WINDOW in curses.h offers a field _flags. */ +/* #undef WINDOW_HAS_FLAGS */ + +/* Define if you want documentation strings in extension modules */ +#define WITH_DOC_STRINGS 1 + +/* Define if you want to use the new-style (Openstep, Rhapsody, MacOS) dynamic + linker (dyld) instead of the old-style (NextStep) dynamic linker (rld). + Dyld is necessary to support frameworks. */ +/* #undef WITH_DYLD */ + +/* Define to 1 if libintl is needed for locale functions. */ +/* #undef WITH_LIBINTL */ + +/* Define if you want to produce an OpenStep/Rhapsody framework (shared + library plus accessory files). */ +/* #undef WITH_NEXT_FRAMEWORK */ + +/* Define if you want to compile in Python-specific mallocs */ +#define WITH_PYMALLOC 1 + +/* Define if you want to compile in rudimentary thread support */ +#define WITH_THREAD 1 + +/* Define to profile with the Pentium timestamp counter */ +/* #undef WITH_TSC */ + +/* Define if you want pymalloc to be disabled when running under valgrind */ +/* #undef WITH_VALGRIND */ + +/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most + significant byte first (like Motorola and SPARC, unlike Intel). */ +#if defined AC_APPLE_UNIVERSAL_BUILD +# if defined __BIG_ENDIAN__ +# define WORDS_BIGENDIAN 1 +# endif +#else +# ifndef WORDS_BIGENDIAN +/* # undef WORDS_BIGENDIAN */ +# endif +#endif + +/* Define if arithmetic is subject to x87-style double rounding issue */ +/* #undef X87_DOUBLE_ROUNDING */ + +/* Define on OpenBSD to activate all library features */ +/* #undef _BSD_SOURCE */ + +/* Define on Irix to enable u_int */ +#define _BSD_TYPES 1 + +/* Define on Darwin to activate all library features */ +#define _DARWIN_C_SOURCE 1 + +/* This must be set to 64 on some systems to enable large file support. */ +#define _FILE_OFFSET_BITS 64 + +/* Define on Linux to activate all library features */ +#define _GNU_SOURCE 1 + +/* This must be defined on some systems to enable large file support. */ +#define _LARGEFILE_SOURCE 1 + +/* This must be defined on AIX systems to enable large file support. */ +/* #undef _LARGE_FILES */ + +/* Define to 1 if on MINIX. */ +/* #undef _MINIX */ + +/* Define on NetBSD to activate all library features */ +#define _NETBSD_SOURCE 1 + +/* Define _OSF_SOURCE to get the makedev macro. */ +/* #undef _OSF_SOURCE */ + +/* Define to 2 if the system does not provide POSIX.1 features except with + this defined. */ +/* #undef _POSIX_1_SOURCE */ + +/* Define to activate features from IEEE Stds 1003.1-2001 */ +#define _POSIX_C_SOURCE 200112L + +/* Define to 1 if you need to in order for `stat' and other things to work. */ +/* #undef _POSIX_SOURCE */ + +/* Define if you have POSIX threads, and your system does not define that. */ +/* #undef _POSIX_THREADS */ + +/* Define to force use of thread-safe errno, h_errno, and other functions */ +#define _REENTRANT 1 + +/* Define for Solaris 2.5.1 so the uint32_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +/* #undef _UINT32_T */ + +/* Define for Solaris 2.5.1 so the uint64_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +/* #undef _UINT64_T */ + +/* Define to the level of X/Open that your system supports */ +#define _XOPEN_SOURCE 600 + +/* Define to activate Unix95-and-earlier features */ +#define _XOPEN_SOURCE_EXTENDED 1 + +/* Define on FreeBSD to activate all library features */ +#define __BSD_VISIBLE 1 + +/* Define to 1 if type `char' is unsigned and you are not using gcc. */ +#ifndef __CHAR_UNSIGNED__ +/* # undef __CHAR_UNSIGNED__ */ +#endif + +/* Defined on Solaris to see additional function prototypes. */ +#define __EXTENSIONS__ 1 + +/* Define to 'long' if doesn't define. */ +/* #undef clock_t */ + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ + +/* Define to `int' if doesn't define. */ +/* #undef gid_t */ + +/* Define to the type of a signed integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +/* #undef int32_t */ + +/* Define to the type of a signed integer type of width exactly 64 bits if + such a type exists and the standard includes do not define it. */ +/* #undef int64_t */ + +/* Define to `int' if does not define. */ +/* #undef mode_t */ + +/* Define to `long int' if does not define. */ +/* #undef off_t */ + +/* Define to `int' if does not define. */ +/* #undef pid_t */ + +/* Define to empty if the keyword does not work. */ +/* #undef signed */ + +/* Define to `unsigned int' if does not define. */ +/* #undef size_t */ + +/* Define to `int' if does not define. */ +/* #undef socklen_t */ + +/* Define to `int' if doesn't define. */ +/* #undef uid_t */ + +/* Define to the type of an unsigned integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint32_t */ + +/* Define to the type of an unsigned integer type of width exactly 64 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint64_t */ + +/* Define to empty if the keyword does not work. */ +/* #undef volatile */ + + +/* Define the macros needed if on a UnixWare 7.x system. */ +#if defined(__USLC__) && defined(__SCO_VERSION__) +#define STRICT_SYSV_CURSES /* Don't use ncurses extensions */ +#endif + +#endif /*Py_PYCONFIG_H*/ + diff --git a/android/python27/include/pyconfig_mips64.h b/android/python27/include/pyconfig_mips64.h new file mode 100644 index 000000000..c4882a695 --- /dev/null +++ b/android/python27/include/pyconfig_mips64.h @@ -0,0 +1,1282 @@ +/* pyconfig.h. Generated from pyconfig.h.in by configure. */ +/* pyconfig.h.in. Generated from configure.ac by autoheader. */ + + +#ifndef Py_PYCONFIG_H +#define Py_PYCONFIG_H + + +/* Define if building universal (internal helper macro) */ +/* #undef AC_APPLE_UNIVERSAL_BUILD */ + +/* Define for AIX if your compiler is a genuine IBM xlC/xlC_r and you want + support for AIX C++ shared extension modules. */ +/* #undef AIX_GENUINE_CPLUSPLUS */ + +/* Define this if you have AtheOS threads. */ +/* #undef ATHEOS_THREADS */ + +/* Define this if you have BeOS threads. */ +/* #undef BEOS_THREADS */ + +/* Define if you have the Mach cthreads package */ +/* #undef C_THREADS */ + +/* Define if C doubles are 64-bit IEEE 754 binary format, stored in ARM + mixed-endian order (byte order 45670123) */ +/* #undef DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754 */ + +/* Define if C doubles are 64-bit IEEE 754 binary format, stored with the most + significant byte first */ +/* #undef DOUBLE_IS_BIG_ENDIAN_IEEE754 */ + +/* Define if C doubles are 64-bit IEEE 754 binary format, stored with the + least significant byte first */ +/* #undef DOUBLE_IS_LITTLE_ENDIAN_IEEE754 */ + +/* Define if --enable-ipv6 is specified */ +#define ENABLE_IPV6 1 + +/* Define if flock needs to be linked with bsd library. */ +/* #undef FLOCK_NEEDS_LIBBSD */ + +/* Define if getpgrp() must be called as getpgrp(0). */ +/* #undef GETPGRP_HAVE_ARG */ + +/* Define if gettimeofday() does not have second (timezone) argument This is + the case on Motorola V4 (R40V4.2) */ +/* #undef GETTIMEOFDAY_NO_TZ */ + +/* Define to 1 if you have the `acosh' function. */ +#define HAVE_ACOSH 1 + +/* struct addrinfo (netdb.h) */ +#define HAVE_ADDRINFO 1 + +/* Define to 1 if you have the `alarm' function. */ +#define HAVE_ALARM 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ALLOCA_H 1 + +/* Define this if your time.h defines altzone. */ +/* #undef HAVE_ALTZONE */ + +/* Define to 1 if you have the `asinh' function. */ +#define HAVE_ASINH 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ASM_TYPES_H 1 + +/* Define to 1 if you have the `atanh' function. */ +#define HAVE_ATANH 1 + +/* Define if GCC supports __attribute__((format(PyArg_ParseTuple, 2, 3))) */ +/* #undef HAVE_ATTRIBUTE_FORMAT_PARSETUPLE */ + +/* Define to 1 if you have the `bind_textdomain_codeset' function. */ +/* #undef HAVE_BIND_TEXTDOMAIN_CODESET */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_BLUETOOTH_BLUETOOTH_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_BLUETOOTH_H */ + +/* Define if nice() returns success/failure instead of the new priority. */ +/* #undef HAVE_BROKEN_NICE */ + +/* Define if the system reports an invalid PIPE_BUF value. */ +/* #undef HAVE_BROKEN_PIPE_BUF */ + +/* Define if poll() sets errno on invalid file descriptors. */ +/* #undef HAVE_BROKEN_POLL */ + +/* Define if the Posix semaphores do not work on your system */ +/* #undef HAVE_BROKEN_POSIX_SEMAPHORES */ + +/* Define if pthread_sigmask() does not work on your system. */ +/* #undef HAVE_BROKEN_PTHREAD_SIGMASK */ + +/* define to 1 if your sem_getvalue is broken. */ +#define HAVE_BROKEN_SEM_GETVALUE 1 + +/* Define if `unsetenv` does not return an int. */ +/* #undef HAVE_BROKEN_UNSETENV */ + +/* Define this if you have the type _Bool. */ +#define HAVE_C99_BOOL 1 + +/* Define to 1 if you have the 'chflags' function. */ +/* #undef HAVE_CHFLAGS */ + +/* Define to 1 if you have the `chown' function. */ +#define HAVE_CHOWN 1 + +/* Define if you have the 'chroot' function. */ +#define HAVE_CHROOT 1 + +/* Define to 1 if you have the `clock' function. */ +#define HAVE_CLOCK 1 + +/* Define to 1 if you have the `confstr' function. */ +/* #undef HAVE_CONFSTR */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_CONIO_H */ + +/* Define to 1 if you have the `copysign' function. */ +#define HAVE_COPYSIGN 1 + +/* Define to 1 if you have the `ctermid' function. */ +/* #undef HAVE_CTERMID */ + +/* Define if you have the 'ctermid_r' function. */ +#define HAVE_CTERMID_R 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_CURSES_H */ + +/* Define if you have the 'is_term_resized' function. */ +/* #undef HAVE_CURSES_IS_TERM_RESIZED */ + +/* Define if you have the 'resizeterm' function. */ +/* #undef HAVE_CURSES_RESIZETERM */ + +/* Define if you have the 'resize_term' function. */ +/* #undef HAVE_CURSES_RESIZE_TERM */ + +/* Define to 1 if you have the declaration of `isfinite', and to 0 if you + don't. */ +#define HAVE_DECL_ISFINITE 1 + +/* Define to 1 if you have the declaration of `isinf', and to 0 if you don't. + */ +#define HAVE_DECL_ISINF 1 + +/* Define to 1 if you have the declaration of `isnan', and to 0 if you don't. + */ +#define HAVE_DECL_ISNAN 1 + +/* Define to 1 if you have the declaration of `tzname', and to 0 if you don't. + */ +/* #undef HAVE_DECL_TZNAME */ + +/* Define to 1 if you have the device macros. */ +#define HAVE_DEVICE_MACROS 1 + +/* Define to 1 if you have the /dev/ptc device file. */ +/* #undef HAVE_DEV_PTC */ + +/* Define to 1 if you have the /dev/ptmx device file. */ +/* #undef HAVE_DEV_PTMX */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_DIRECT_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#define HAVE_DIRENT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_DLFCN_H 1 + +/* Define to 1 if you have the `dlopen' function. */ +#define HAVE_DLOPEN 1 + +/* Define to 1 if you have the `dup2' function. */ +#define HAVE_DUP2 1 + +/* Defined when any dynamic module loading is enabled. */ +#define HAVE_DYNAMIC_LOADING 1 + +/* Define if you have the 'epoll' functions. */ +#define HAVE_EPOLL 1 + +/* Define to 1 if you have the `erf' function. */ +#define HAVE_ERF 1 + +/* Define to 1 if you have the `erfc' function. */ +#define HAVE_ERFC 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ERRNO_H 1 + +/* Define to 1 if you have the `execv' function. */ +#define HAVE_EXECV 1 + +/* Define to 1 if you have the `expm1' function. */ +#define HAVE_EXPM1 1 + +/* Define if you have the 'fchdir' function. */ +#define HAVE_FCHDIR 1 + +/* Define to 1 if you have the `fchmod' function. */ +#define HAVE_FCHMOD 1 + +/* Define to 1 if you have the `fchown' function. */ +#define HAVE_FCHOWN 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* Define if you have the 'fdatasync' function. */ +#define HAVE_FDATASYNC 1 + +/* Define to 1 if you have the `finite' function. */ +#define HAVE_FINITE 1 + +/* Define to 1 if you have the `flock' function. */ +#define HAVE_FLOCK 1 + +/* Define to 1 if you have the `fork' function. */ +#define HAVE_FORK 1 + +/* Define to 1 if you have the `forkpty' function. */ +/* #undef HAVE_FORKPTY */ + +/* Define to 1 if you have the `fpathconf' function. */ +#define HAVE_FPATHCONF 1 + +/* Define to 1 if you have the `fseek64' function. */ +/* #undef HAVE_FSEEK64 */ + +/* Define to 1 if you have the `fseeko' function. */ +#define HAVE_FSEEKO 1 + +/* Define to 1 if you have the `fstatvfs' function. */ +#define HAVE_FSTATVFS 1 + +/* Define if you have the 'fsync' function. */ +#define HAVE_FSYNC 1 + +/* Define to 1 if you have the `ftell64' function. */ +/* #undef HAVE_FTELL64 */ + +/* Define to 1 if you have the `ftello' function. */ +#define HAVE_FTELLO 1 + +/* Define to 1 if you have the `ftime' function. */ +/* #undef HAVE_FTIME */ + +/* Define to 1 if you have the `ftruncate' function. */ +#define HAVE_FTRUNCATE 1 + +/* Define to 1 if you have the `gai_strerror' function. */ +#define HAVE_GAI_STRERROR 1 + +/* Define to 1 if you have the `gamma' function. */ +/* #undef HAVE_GAMMA */ + +/* Define if we can use gcc inline assembler to get and set x87 control word + */ +/* #undef HAVE_GCC_ASM_FOR_X87 */ + +/* Define if you have the getaddrinfo function. */ +#define HAVE_GETADDRINFO 1 + +/* Define to 1 if you have the `getcwd' function. */ +#define HAVE_GETCWD 1 + +/* Define this if you have flockfile(), getc_unlocked(), and funlockfile() */ +#define HAVE_GETC_UNLOCKED 1 + +/* Define to 1 if you have the `getentropy' function. */ +/* #undef HAVE_GETENTROPY */ + +/* Define to 1 if you have the `getgroups' function. */ +#define HAVE_GETGROUPS 1 + +/* Define to 1 if you have the `gethostbyname' function. */ +#define HAVE_GETHOSTBYNAME 1 + +/* Define this if you have some version of gethostbyname_r() */ +/* #undef HAVE_GETHOSTBYNAME_R */ + +/* Define this if you have the 3-arg version of gethostbyname_r(). */ +/* #undef HAVE_GETHOSTBYNAME_R_3_ARG */ + +/* Define this if you have the 5-arg version of gethostbyname_r(). */ +/* #undef HAVE_GETHOSTBYNAME_R_5_ARG */ + +/* Define this if you have the 6-arg version of gethostbyname_r(). */ +/* #undef HAVE_GETHOSTBYNAME_R_6_ARG */ + +/* Define to 1 if you have the `getitimer' function. */ +#define HAVE_GETITIMER 1 + +/* Define to 1 if you have the `getloadavg' function. */ +#define HAVE_GETLOADAVG 1 + +/* Define to 1 if you have the `getlogin' function. */ +#define HAVE_GETLOGIN 1 + +/* Define to 1 if you have the `getnameinfo' function. */ +#define HAVE_GETNAMEINFO 1 + +/* Define if you have the 'getpagesize' function. */ +#define HAVE_GETPAGESIZE 1 + +/* Define to 1 if you have the `getpeername' function. */ +#define HAVE_GETPEERNAME 1 + +/* Define to 1 if you have the `getpgid' function. */ +#define HAVE_GETPGID 1 + +/* Define to 1 if you have the `getpgrp' function. */ +#define HAVE_GETPGRP 1 + +/* Define to 1 if you have the `getpid' function. */ +#define HAVE_GETPID 1 + +/* Define to 1 if you have the `getpriority' function. */ +#define HAVE_GETPRIORITY 1 + +/* Define to 1 if you have the `getpwent' function. */ +#define HAVE_GETPWENT 1 + +/* Define to 1 if you have the `getresgid' function. */ +#define HAVE_GETRESGID 1 + +/* Define to 1 if you have the `getresuid' function. */ +#define HAVE_GETRESUID 1 + +/* Define to 1 if you have the `getsid' function. */ +#define HAVE_GETSID 1 + +/* Define to 1 if you have the `getspent' function. */ +/* #undef HAVE_GETSPENT */ + +/* Define to 1 if you have the `getspnam' function. */ +/* #undef HAVE_GETSPNAM */ + +/* Define to 1 if you have the `gettimeofday' function. */ +#define HAVE_GETTIMEOFDAY 1 + +/* Define to 1 if you have the `getwd' function. */ +/* #undef HAVE_GETWD */ + +/* Define to 1 if you have the header file. */ +#define HAVE_GRP_H 1 + +/* Define if you have the 'hstrerror' function. */ +#define HAVE_HSTRERROR 1 + +/* Define to 1 if you have the `hypot' function. */ +#define HAVE_HYPOT 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_IEEEFP_H */ + +/* Define if you have the 'inet_aton' function. */ +#define HAVE_INET_ATON 1 + +/* Define if you have the 'inet_pton' function. */ +#define HAVE_INET_PTON 1 + +/* Define to 1 if you have the `initgroups' function. */ +#define HAVE_INITGROUPS 1 + +/* Define if your compiler provides int32_t. */ +#define HAVE_INT32_T 1 + +/* Define if your compiler provides int64_t. */ +#define HAVE_INT64_T 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_IO_H */ + +/* Define to 1 if you have the `kill' function. */ +#define HAVE_KILL 1 + +/* Define to 1 if you have the `killpg' function. */ +#define HAVE_KILLPG 1 + +/* Define if you have the 'kqueue' functions. */ +#define HAVE_KQUEUE 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_LANGINFO_H 1 + +/* Defined to enable large file support when an off_t is bigger than a long + and long long is available and at least as big as an off_t. You may need to + add some flags for configuration and compilation to enable this mode. (For + Solaris and Linux, the necessary defines are already defined.) */ +/* #undef HAVE_LARGEFILE_SUPPORT */ + +/* Define to 1 if you have the 'lchflags' function. */ +/* #undef HAVE_LCHFLAGS */ + +/* Define to 1 if you have the `lchmod' function. */ +/* #undef HAVE_LCHMOD */ + +/* Define to 1 if you have the `lchown' function. */ +#define HAVE_LCHOWN 1 + +/* Define to 1 if you have the `lgamma' function. */ +#define HAVE_LGAMMA 1 + +/* Define to 1 if you have the `dl' library (-ldl). */ +#define HAVE_LIBDL 1 + +/* Define to 1 if you have the `dld' library (-ldld). */ +/* #undef HAVE_LIBDLD */ + +/* Define to 1 if you have the `ieee' library (-lieee). */ +/* #undef HAVE_LIBIEEE */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LIBINTL_H */ + +/* Define if you have the readline library (-lreadline). */ +/* #undef HAVE_LIBREADLINE */ + +/* Define to 1 if you have the `resolv' library (-lresolv). */ +/* #undef HAVE_LIBRESOLV */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LIBUTIL_H */ + +/* Define if you have the 'link' function. */ +#define HAVE_LINK 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_LINUX_NETLINK_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_LINUX_TIPC_H 1 + +/* Define to 1 if you have the `log1p' function. */ +#define HAVE_LOG1P 1 + +/* Define this if you have the type long double. */ +#define HAVE_LONG_DOUBLE 1 + +/* Define this if you have the type long long. */ +#define HAVE_LONG_LONG 1 + +/* Define to 1 if you have the `lstat' function. */ +#define HAVE_LSTAT 1 + +/* Define this if you have the makedev macro. */ +#define HAVE_MAKEDEV 1 + +/* Define to 1 if you have the `memmove' function. */ +#define HAVE_MEMMOVE 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `mkfifo' function. */ +#define HAVE_MKFIFO 1 + +/* Define to 1 if you have the `mknod' function. */ +#define HAVE_MKNOD 1 + +/* Define to 1 if you have the `mktime' function. */ +#define HAVE_MKTIME 1 + +/* Define to 1 if you have the `mmap' function. */ +#define HAVE_MMAP 1 + +/* Define to 1 if you have the `mremap' function. */ +#define HAVE_MREMAP 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NCURSES_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. */ +/* #undef HAVE_NDIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_NETPACKET_PACKET_H 1 + +/* Define to 1 if you have the `nice' function. */ +#define HAVE_NICE 1 + +/* Define to 1 if you have the `openpty' function. */ +/* #undef HAVE_OPENPTY */ + +/* Define if compiling using MacOS X 10.5 SDK or later. */ +/* #undef HAVE_OSX105_SDK */ + +/* Define to 1 if you have the `pathconf' function. */ +#define HAVE_PATHCONF 1 + +/* Define to 1 if you have the `pause' function. */ +#define HAVE_PAUSE 1 + +/* Define to 1 if you have the `plock' function. */ +/* #undef HAVE_PLOCK */ + +/* Define to 1 if you have the `poll' function. */ +#define HAVE_POLL 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_POLL_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PROCESS_H */ + +/* Define if your compiler supports function prototype */ +#define HAVE_PROTOTYPES 1 + +/* Define if you have GNU PTH threads. */ +/* #undef HAVE_PTH */ + +/* Define to 1 if you have the `pthread_atfork' function. */ +#define HAVE_PTHREAD_ATFORK 1 + +/* Defined for Solaris 2.6 bug in pthread header. */ +/* #undef HAVE_PTHREAD_DESTRUCTOR */ + +/* Define to 1 if you have the header file. */ +#define HAVE_PTHREAD_H 1 + +/* Define to 1 if you have the `pthread_init' function. */ +/* #undef HAVE_PTHREAD_INIT */ + +/* Define to 1 if you have the `pthread_sigmask' function. */ +#define HAVE_PTHREAD_SIGMASK 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PTY_H */ + +/* Define to 1 if you have the `putenv' function. */ +#define HAVE_PUTENV 1 + +/* Define if the libcrypto has RAND_egd */ +/* #undef HAVE_RAND_EGD */ + +/* Define to 1 if you have the `readlink' function. */ +#define HAVE_READLINK 1 + +/* Define to 1 if you have the `realpath' function. */ +#define HAVE_REALPATH 1 + +/* Define if you have readline 2.1 */ +/* #undef HAVE_RL_CALLBACK */ + +/* Define if you can turn off readline's signal handling. */ +/* #undef HAVE_RL_CATCH_SIGNAL */ + +/* Define if you have readline 2.2 */ +/* #undef HAVE_RL_COMPLETION_APPEND_CHARACTER */ + +/* Define if you have readline 4.0 */ +/* #undef HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK */ + +/* Define if you have readline 4.2 */ +/* #undef HAVE_RL_COMPLETION_MATCHES */ + +/* Define if you have rl_completion_suppress_append */ +/* #undef HAVE_RL_COMPLETION_SUPPRESS_APPEND */ + +/* Define if you have readline 4.0 */ +/* #undef HAVE_RL_PRE_INPUT_HOOK */ + +/* Define to 1 if you have the `round' function. */ +#define HAVE_ROUND 1 + +/* Define to 1 if you have the `select' function. */ +#define HAVE_SELECT 1 + +/* Define to 1 if you have the `sem_getvalue' function. */ +#define HAVE_SEM_GETVALUE 1 + +/* Define to 1 if you have the `sem_open' function. */ +#define HAVE_SEM_OPEN 1 + +/* Define to 1 if you have the `sem_timedwait' function. */ +#define HAVE_SEM_TIMEDWAIT 1 + +/* Define to 1 if you have the `sem_unlink' function. */ +#define HAVE_SEM_UNLINK 1 + +/* Define to 1 if you have the `setegid' function. */ +#define HAVE_SETEGID 1 + +/* Define to 1 if you have the `seteuid' function. */ +#define HAVE_SETEUID 1 + +/* Define to 1 if you have the `setgid' function. */ +#define HAVE_SETGID 1 + +/* Define if you have the 'setgroups' function. */ +#define HAVE_SETGROUPS 1 + +/* Define to 1 if you have the `setitimer' function. */ +#define HAVE_SETITIMER 1 + +/* Define to 1 if you have the `setlocale' function. */ +#define HAVE_SETLOCALE 1 + +/* Define to 1 if you have the `setpgid' function. */ +#define HAVE_SETPGID 1 + +/* Define to 1 if you have the `setpgrp' function. */ +#define HAVE_SETPGRP 1 + +/* Define to 1 if you have the `setregid' function. */ +#define HAVE_SETREGID 1 + +/* Define to 1 if you have the `setresgid' function. */ +#define HAVE_SETRESGID 1 + +/* Define to 1 if you have the `setresuid' function. */ +#define HAVE_SETRESUID 1 + +/* Define to 1 if you have the `setreuid' function. */ +#define HAVE_SETREUID 1 + +/* Define to 1 if you have the `setsid' function. */ +#define HAVE_SETSID 1 + +/* Define to 1 if you have the `setuid' function. */ +#define HAVE_SETUID 1 + +/* Define to 1 if you have the `setvbuf' function. */ +#define HAVE_SETVBUF 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SHADOW_H */ + +/* Define to 1 if you have the `sigaction' function. */ +#define HAVE_SIGACTION 1 + +/* Define to 1 if you have the `siginterrupt' function. */ +#define HAVE_SIGINTERRUPT 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SIGNAL_H 1 + +/* Define to 1 if you have the `sigrelse' function. */ +/* #undef HAVE_SIGRELSE */ + +/* Define to 1 if you have the `snprintf' function. */ +#define HAVE_SNPRINTF 1 + +/* Define if sockaddr has sa_len member */ +/* #undef HAVE_SOCKADDR_SA_LEN */ + +/* struct sockaddr_storage (sys/socket.h) */ +#define HAVE_SOCKADDR_STORAGE 1 + +/* Define if you have the 'socketpair' function. */ +#define HAVE_SOCKETPAIR 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SPAWN_H */ + +/* Define if your compiler provides ssize_t */ +#define HAVE_SSIZE_T 1 + +/* Define to 1 if you have the `statvfs' function. */ +#define HAVE_STATVFS 1 + +/* Define if you have struct stat.st_mtim.tv_nsec */ +/* #undef HAVE_STAT_TV_NSEC */ + +/* Define if you have struct stat.st_mtimensec */ +/* #undef HAVE_STAT_TV_NSEC2 */ + +/* Define if your compiler supports variable length function prototypes (e.g. + void fprintf(FILE *, char *, ...);) *and* */ +#define HAVE_STDARG_PROTOTYPES 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the `strdup' function. */ +#define HAVE_STRDUP 1 + +/* Define to 1 if you have the `strftime' function. */ +#define HAVE_STRFTIME 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_STROPTS_H */ + +/* Define to 1 if `st_birthtime' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_BIRTHTIME */ + +/* Define to 1 if `st_blksize' is a member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_BLKSIZE 1 + +/* Define to 1 if `st_blocks' is a member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_BLOCKS 1 + +/* Define to 1 if `st_flags' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_FLAGS */ + +/* Define to 1 if `st_gen' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_GEN */ + +/* Define to 1 if `st_rdev' is a member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_RDEV 1 + +/* Define to 1 if `tm_zone' is a member of `struct tm'. */ +#define HAVE_STRUCT_TM_TM_ZONE 1 + +/* Define to 1 if your `struct stat' has `st_blocks'. Deprecated, use + `HAVE_STRUCT_STAT_ST_BLOCKS' instead. */ +#define HAVE_ST_BLOCKS 1 + +/* Define if you have the 'symlink' function. */ +#define HAVE_SYMLINK 1 + +/* Define to 1 if you have the `sysconf' function. */ +#define HAVE_SYSCONF 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYSEXITS_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_AUDIOIO_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_BSDTTY_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +/* #undef HAVE_SYS_DIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_EPOLL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_EVENT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_FILE_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_LOADAVG_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_LOCK_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_MKDEV_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_MODEM_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +/* #undef HAVE_SYS_NDIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_PARAM_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_POLL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_RESOURCE_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SELECT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SOCKET_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STATVFS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_TERMIO_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIMES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UN_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UTSNAME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_WAIT_H 1 + +/* Define to 1 if you have the `tcgetpgrp' function. */ +#define HAVE_TCGETPGRP 1 + +/* Define to 1 if you have the `tcsetpgrp' function. */ +#define HAVE_TCSETPGRP 1 + +/* Define to 1 if you have the `tempnam' function. */ +#define HAVE_TEMPNAM 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_TERMIOS_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_TERM_H */ + +/* Define to 1 if you have the `tgamma' function. */ +#define HAVE_TGAMMA 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_THREAD_H */ + +/* Define to 1 if you have the `timegm' function. */ +#define HAVE_TIMEGM 1 + +/* Define to 1 if you have the `times' function. */ +#define HAVE_TIMES 1 + +/* Define to 1 if you have the `tmpfile' function. */ +#define HAVE_TMPFILE 1 + +/* Define to 1 if you have the `tmpnam' function. */ +#define HAVE_TMPNAM 1 + +/* Define to 1 if you have the `tmpnam_r' function. */ +/* #undef HAVE_TMPNAM_R */ + +/* Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use + `HAVE_STRUCT_TM_TM_ZONE' instead. */ +#define HAVE_TM_ZONE 1 + +/* Define to 1 if you have the `truncate' function. */ +#define HAVE_TRUNCATE 1 + +/* Define to 1 if you don't have `tm_zone' but do have the external array + `tzname'. */ +/* #undef HAVE_TZNAME */ + +/* Define this if you have tcl and TCL_UTF_MAX==6 */ +/* #undef HAVE_UCS4_TCL */ + +/* Define if your compiler provides uint32_t. */ +#define HAVE_UINT32_T 1 + +/* Define if your compiler provides uint64_t. */ +#define HAVE_UINT64_T 1 + +/* Define to 1 if the system has the type `uintptr_t'. */ +#define HAVE_UINTPTR_T 1 + +/* Define to 1 if you have the `uname' function. */ +#define HAVE_UNAME 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you have the `unsetenv' function. */ +#define HAVE_UNSETENV 1 + +/* Define if you have a useable wchar_t type defined in wchar.h; useable means + wchar_t must be an unsigned type with at least 16 bits. (see + Include/unicodeobject.h). */ +/* #undef HAVE_USABLE_WCHAR_T */ + +/* Define to 1 if you have the header file. */ +#define HAVE_UTIL_H 1 + +/* Define to 1 if you have the `utimes' function. */ +#define HAVE_UTIMES 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UTIME_H 1 + +/* Define to 1 if you have the `wait3' function. */ +/* #undef HAVE_WAIT3 */ + +/* Define to 1 if you have the `wait4' function. */ +#define HAVE_WAIT4 1 + +/* Define to 1 if you have the `waitpid' function. */ +#define HAVE_WAITPID 1 + +/* Define if the compiler provides a wchar.h header file. */ +#define HAVE_WCHAR_H 1 + +/* Define to 1 if you have the `wcscoll' function. */ +#define HAVE_WCSCOLL 1 + +/* Define if tzset() actually switches the local timezone in a meaningful way. + */ +/* #undef HAVE_WORKING_TZSET */ + +/* Define if the zlib library has inflateCopy */ +#define HAVE_ZLIB_COPY 1 + +/* Define to 1 if you have the `_getpty' function. */ +/* #undef HAVE__GETPTY */ + +/* Define if you are using Mach cthreads directly under /include */ +/* #undef HURD_C_THREADS */ + +/* Define if you are using Mach cthreads under mach / */ +/* #undef MACH_C_THREADS */ + +/* Define to 1 if `major', `minor', and `makedev' are declared in . + */ +/* #undef MAJOR_IN_MKDEV */ + +/* Define to 1 if `major', `minor', and `makedev' are declared in + . */ +#define MAJOR_IN_SYSMACROS 1 + +/* Define if mvwdelch in curses.h is an expression. */ +/* #undef MVWDELCH_IS_EXPRESSION */ + +/* Define to the address where bug reports for this package should be sent. */ +/* #undef PACKAGE_BUGREPORT */ + +/* Define to the full name of this package. */ +/* #undef PACKAGE_NAME */ + +/* Define to the full name and version of this package. */ +/* #undef PACKAGE_STRING */ + +/* Define to the one symbol short name of this package. */ +/* #undef PACKAGE_TARNAME */ + +/* Define to the home page for this package. */ +/* #undef PACKAGE_URL */ + +/* Define to the version of this package. */ +/* #undef PACKAGE_VERSION */ + +/* Define if POSIX semaphores aren't enabled on your system */ +/* #undef POSIX_SEMAPHORES_NOT_ENABLED */ + +/* Defined if PTHREAD_SCOPE_SYSTEM supported. */ +/* #undef PTHREAD_SYSTEM_SCHED_SUPPORTED */ + +/* Define as the preferred size in bits of long digits */ +/* #undef PYLONG_BITS_IN_DIGIT */ + +/* Define to printf format modifier for long long type */ +#define PY_FORMAT_LONG_LONG "ll" + +/* Define to printf format modifier for Py_ssize_t */ +#define PY_FORMAT_SIZE_T "z" + +/* Define as the integral type used for Unicode representation. */ +/* #undef PY_UNICODE_TYPE */ + +/* Define if you want to build an interpreter with many run-time checks. */ +/* #undef Py_DEBUG */ + +/* Defined if Python is built as a shared library. */ +#define Py_ENABLE_SHARED 1 + +/* Define as the size of the unicode type. */ +#define Py_UNICODE_SIZE 4 + +/* Define if you want to have a Unicode type. */ +#define Py_USING_UNICODE 1 + +/* assume C89 semantics that RETSIGTYPE is always void */ +#define RETSIGTYPE void + +/* Define if setpgrp() must be called as setpgrp(0, 0). */ +/* #undef SETPGRP_HAVE_ARG */ + +/* Define this to be extension of shared libraries (including the dot!). */ +#define SHLIB_EXT ".so" + +/* Define if i>>j for signed int i does not extend the sign bit when i < 0 */ +/* #undef SIGNED_RIGHT_SHIFT_ZERO_FILLS */ + +/* The size of `double', as computed by sizeof. */ +#define SIZEOF_DOUBLE 8 + +/* The size of `float', as computed by sizeof. */ +#define SIZEOF_FLOAT 4 + +/* The size of `fpos_t', as computed by sizeof. */ +#define SIZEOF_FPOS_T 8 + +/* The size of `int', as computed by sizeof. */ +#define SIZEOF_INT 4 + +/* The size of `long', as computed by sizeof. */ +#define SIZEOF_LONG 8 + +/* The size of `long double', as computed by sizeof. */ +#define SIZEOF_LONG_DOUBLE 16 + +/* The size of `long long', as computed by sizeof. */ +#define SIZEOF_LONG_LONG 8 + +/* The size of `off_t', as computed by sizeof. */ +#define SIZEOF_OFF_T 8 + +/* The size of `pid_t', as computed by sizeof. */ +#define SIZEOF_PID_T 4 + +/* The size of `pthread_t', as computed by sizeof. */ +#define SIZEOF_PTHREAD_T 8 + +/* The size of `short', as computed by sizeof. */ +#define SIZEOF_SHORT 2 + +/* The size of `size_t', as computed by sizeof. */ +#define SIZEOF_SIZE_T 8 + +/* The size of `time_t', as computed by sizeof. */ +#define SIZEOF_TIME_T 8 + +/* The size of `uintptr_t', as computed by sizeof. */ +#define SIZEOF_UINTPTR_T 8 + +/* The size of `void *', as computed by sizeof. */ +#define SIZEOF_VOID_P 8 + +/* The size of `wchar_t', as computed by sizeof. */ +#define SIZEOF_WCHAR_T 4 + +/* The size of `_Bool', as computed by sizeof. */ +#define SIZEOF__BOOL 1 + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define if you can safely include both and + (which you can't on SCO ODT 3.0). */ +#define SYS_SELECT_WITH_SYS_TIME 1 + +/* Define if tanh(-0.) is -0., or if platform doesn't have signed zeros */ +/* #undef TANH_PRESERVES_ZERO_SIGN */ + +/* Define to 1 if you can safely include both and . */ +#define TIME_WITH_SYS_TIME 1 + +/* Define to 1 if your declares `struct tm'. */ +/* #undef TM_IN_SYS_TIME */ + +/* Enable extensions on AIX 3, Interix. */ +#ifndef _ALL_SOURCE +# define _ALL_SOURCE 1 +#endif +/* Enable GNU extensions on systems that have them. */ +#ifndef _GNU_SOURCE +# define _GNU_SOURCE 1 +#endif +/* Enable threading extensions on Solaris. */ +#ifndef _POSIX_PTHREAD_SEMANTICS +# define _POSIX_PTHREAD_SEMANTICS 1 +#endif +/* Enable extensions on HP NonStop. */ +#ifndef _TANDEM_SOURCE +# define _TANDEM_SOURCE 1 +#endif +/* Enable general extensions on Solaris. */ +#ifndef __EXTENSIONS__ +# define __EXTENSIONS__ 1 +#endif + + +/* Define if you want to use MacPython modules on MacOSX in unix-Python. */ +/* #undef USE_TOOLBOX_OBJECT_GLUE */ + +/* Define if a va_list is an array of some kind */ +/* #undef VA_LIST_IS_ARRAY */ + +/* Define if you want SIGFPE handled (see Include/pyfpe.h). */ +/* #undef WANT_SIGFPE_HANDLER */ + +/* Define if you want wctype.h functions to be used instead of the one + supplied by Python itself. (see Include/unicodectype.h). */ +/* #undef WANT_WCTYPE_FUNCTIONS */ + +/* Define if WINDOW in curses.h offers a field _flags. */ +/* #undef WINDOW_HAS_FLAGS */ + +/* Define if you want documentation strings in extension modules */ +#define WITH_DOC_STRINGS 1 + +/* Define if you want to use the new-style (Openstep, Rhapsody, MacOS) dynamic + linker (dyld) instead of the old-style (NextStep) dynamic linker (rld). + Dyld is necessary to support frameworks. */ +/* #undef WITH_DYLD */ + +/* Define to 1 if libintl is needed for locale functions. */ +/* #undef WITH_LIBINTL */ + +/* Define if you want to produce an OpenStep/Rhapsody framework (shared + library plus accessory files). */ +/* #undef WITH_NEXT_FRAMEWORK */ + +/* Define if you want to compile in Python-specific mallocs */ +#define WITH_PYMALLOC 1 + +/* Define if you want to compile in rudimentary thread support */ +#define WITH_THREAD 1 + +/* Define to profile with the Pentium timestamp counter */ +/* #undef WITH_TSC */ + +/* Define if you want pymalloc to be disabled when running under valgrind */ +/* #undef WITH_VALGRIND */ + +/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most + significant byte first (like Motorola and SPARC, unlike Intel). */ +#if defined AC_APPLE_UNIVERSAL_BUILD +# if defined __BIG_ENDIAN__ +# define WORDS_BIGENDIAN 1 +# endif +#else +# ifndef WORDS_BIGENDIAN +/* # undef WORDS_BIGENDIAN */ +# endif +#endif + +/* Define if arithmetic is subject to x87-style double rounding issue */ +/* #undef X87_DOUBLE_ROUNDING */ + +/* Define on OpenBSD to activate all library features */ +/* #undef _BSD_SOURCE */ + +/* Define on Irix to enable u_int */ +#define _BSD_TYPES 1 + +/* Define on Darwin to activate all library features */ +#define _DARWIN_C_SOURCE 1 + +/* This must be set to 64 on some systems to enable large file support. */ +#define _FILE_OFFSET_BITS 64 + +/* Define on Linux to activate all library features */ +#define _GNU_SOURCE 1 + +/* This must be defined on some systems to enable large file support. */ +#define _LARGEFILE_SOURCE 1 + +/* This must be defined on AIX systems to enable large file support. */ +/* #undef _LARGE_FILES */ + +/* Define to 1 if on MINIX. */ +/* #undef _MINIX */ + +/* Define on NetBSD to activate all library features */ +#define _NETBSD_SOURCE 1 + +/* Define _OSF_SOURCE to get the makedev macro. */ +/* #undef _OSF_SOURCE */ + +/* Define to 2 if the system does not provide POSIX.1 features except with + this defined. */ +/* #undef _POSIX_1_SOURCE */ + +/* Define to activate features from IEEE Stds 1003.1-2001 */ +#define _POSIX_C_SOURCE 200112L + +/* Define to 1 if you need to in order for `stat' and other things to work. */ +/* #undef _POSIX_SOURCE */ + +/* Define if you have POSIX threads, and your system does not define that. */ +/* #undef _POSIX_THREADS */ + +/* Define to force use of thread-safe errno, h_errno, and other functions */ +#define _REENTRANT 1 + +/* Define for Solaris 2.5.1 so the uint32_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +/* #undef _UINT32_T */ + +/* Define for Solaris 2.5.1 so the uint64_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +/* #undef _UINT64_T */ + +/* Define to the level of X/Open that your system supports */ +#define _XOPEN_SOURCE 600 + +/* Define to activate Unix95-and-earlier features */ +#define _XOPEN_SOURCE_EXTENDED 1 + +/* Define on FreeBSD to activate all library features */ +#define __BSD_VISIBLE 1 + +/* Define to 1 if type `char' is unsigned and you are not using gcc. */ +#ifndef __CHAR_UNSIGNED__ +/* # undef __CHAR_UNSIGNED__ */ +#endif + +/* Defined on Solaris to see additional function prototypes. */ +#define __EXTENSIONS__ 1 + +/* Define to 'long' if doesn't define. */ +/* #undef clock_t */ + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ + +/* Define to `int' if doesn't define. */ +/* #undef gid_t */ + +/* Define to the type of a signed integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +/* #undef int32_t */ + +/* Define to the type of a signed integer type of width exactly 64 bits if + such a type exists and the standard includes do not define it. */ +/* #undef int64_t */ + +/* Define to `int' if does not define. */ +/* #undef mode_t */ + +/* Define to `long int' if does not define. */ +/* #undef off_t */ + +/* Define to `int' if does not define. */ +/* #undef pid_t */ + +/* Define to empty if the keyword does not work. */ +/* #undef signed */ + +/* Define to `unsigned int' if does not define. */ +/* #undef size_t */ + +/* Define to `int' if does not define. */ +/* #undef socklen_t */ + +/* Define to `int' if doesn't define. */ +/* #undef uid_t */ + +/* Define to the type of an unsigned integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint32_t */ + +/* Define to the type of an unsigned integer type of width exactly 64 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint64_t */ + +/* Define to empty if the keyword does not work. */ +/* #undef volatile */ + + +/* Define the macros needed if on a UnixWare 7.x system. */ +#if defined(__USLC__) && defined(__SCO_VERSION__) +#define STRICT_SYSV_CURSES /* Don't use ncurses extensions */ +#endif + +#endif /*Py_PYCONFIG_H*/ + diff --git a/android/python27/include/pyconfig_x86.h b/android/python27/include/pyconfig_x86.h new file mode 100644 index 000000000..22948d94c --- /dev/null +++ b/android/python27/include/pyconfig_x86.h @@ -0,0 +1,1282 @@ +/* pyconfig.h. Generated from pyconfig.h.in by configure. */ +/* pyconfig.h.in. Generated from configure.ac by autoheader. */ + + +#ifndef Py_PYCONFIG_H +#define Py_PYCONFIG_H + + +/* Define if building universal (internal helper macro) */ +/* #undef AC_APPLE_UNIVERSAL_BUILD */ + +/* Define for AIX if your compiler is a genuine IBM xlC/xlC_r and you want + support for AIX C++ shared extension modules. */ +/* #undef AIX_GENUINE_CPLUSPLUS */ + +/* Define this if you have AtheOS threads. */ +/* #undef ATHEOS_THREADS */ + +/* Define this if you have BeOS threads. */ +/* #undef BEOS_THREADS */ + +/* Define if you have the Mach cthreads package */ +/* #undef C_THREADS */ + +/* Define if C doubles are 64-bit IEEE 754 binary format, stored in ARM + mixed-endian order (byte order 45670123) */ +/* #undef DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754 */ + +/* Define if C doubles are 64-bit IEEE 754 binary format, stored with the most + significant byte first */ +/* #undef DOUBLE_IS_BIG_ENDIAN_IEEE754 */ + +/* Define if C doubles are 64-bit IEEE 754 binary format, stored with the + least significant byte first */ +/* #undef DOUBLE_IS_LITTLE_ENDIAN_IEEE754 */ + +/* Define if --enable-ipv6 is specified */ +#define ENABLE_IPV6 1 + +/* Define if flock needs to be linked with bsd library. */ +/* #undef FLOCK_NEEDS_LIBBSD */ + +/* Define if getpgrp() must be called as getpgrp(0). */ +/* #undef GETPGRP_HAVE_ARG */ + +/* Define if gettimeofday() does not have second (timezone) argument This is + the case on Motorola V4 (R40V4.2) */ +/* #undef GETTIMEOFDAY_NO_TZ */ + +/* Define to 1 if you have the `acosh' function. */ +#define HAVE_ACOSH 1 + +/* struct addrinfo (netdb.h) */ +#define HAVE_ADDRINFO 1 + +/* Define to 1 if you have the `alarm' function. */ +#define HAVE_ALARM 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ALLOCA_H 1 + +/* Define this if your time.h defines altzone. */ +/* #undef HAVE_ALTZONE */ + +/* Define to 1 if you have the `asinh' function. */ +#define HAVE_ASINH 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ASM_TYPES_H 1 + +/* Define to 1 if you have the `atanh' function. */ +#define HAVE_ATANH 1 + +/* Define if GCC supports __attribute__((format(PyArg_ParseTuple, 2, 3))) */ +/* #undef HAVE_ATTRIBUTE_FORMAT_PARSETUPLE */ + +/* Define to 1 if you have the `bind_textdomain_codeset' function. */ +/* #undef HAVE_BIND_TEXTDOMAIN_CODESET */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_BLUETOOTH_BLUETOOTH_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_BLUETOOTH_H */ + +/* Define if nice() returns success/failure instead of the new priority. */ +/* #undef HAVE_BROKEN_NICE */ + +/* Define if the system reports an invalid PIPE_BUF value. */ +/* #undef HAVE_BROKEN_PIPE_BUF */ + +/* Define if poll() sets errno on invalid file descriptors. */ +/* #undef HAVE_BROKEN_POLL */ + +/* Define if the Posix semaphores do not work on your system */ +/* #undef HAVE_BROKEN_POSIX_SEMAPHORES */ + +/* Define if pthread_sigmask() does not work on your system. */ +/* #undef HAVE_BROKEN_PTHREAD_SIGMASK */ + +/* define to 1 if your sem_getvalue is broken. */ +#define HAVE_BROKEN_SEM_GETVALUE 1 + +/* Define if `unsetenv` does not return an int. */ +/* #undef HAVE_BROKEN_UNSETENV */ + +/* Define this if you have the type _Bool. */ +#define HAVE_C99_BOOL 1 + +/* Define to 1 if you have the 'chflags' function. */ +/* #undef HAVE_CHFLAGS */ + +/* Define to 1 if you have the `chown' function. */ +#define HAVE_CHOWN 1 + +/* Define if you have the 'chroot' function. */ +#define HAVE_CHROOT 1 + +/* Define to 1 if you have the `clock' function. */ +#define HAVE_CLOCK 1 + +/* Define to 1 if you have the `confstr' function. */ +/* #undef HAVE_CONFSTR */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_CONIO_H */ + +/* Define to 1 if you have the `copysign' function. */ +#define HAVE_COPYSIGN 1 + +/* Define to 1 if you have the `ctermid' function. */ +/* #undef HAVE_CTERMID */ + +/* Define if you have the 'ctermid_r' function. */ +#define HAVE_CTERMID_R 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_CURSES_H */ + +/* Define if you have the 'is_term_resized' function. */ +/* #undef HAVE_CURSES_IS_TERM_RESIZED */ + +/* Define if you have the 'resizeterm' function. */ +/* #undef HAVE_CURSES_RESIZETERM */ + +/* Define if you have the 'resize_term' function. */ +/* #undef HAVE_CURSES_RESIZE_TERM */ + +/* Define to 1 if you have the declaration of `isfinite', and to 0 if you + don't. */ +#define HAVE_DECL_ISFINITE 1 + +/* Define to 1 if you have the declaration of `isinf', and to 0 if you don't. + */ +#define HAVE_DECL_ISINF 1 + +/* Define to 1 if you have the declaration of `isnan', and to 0 if you don't. + */ +#define HAVE_DECL_ISNAN 1 + +/* Define to 1 if you have the declaration of `tzname', and to 0 if you don't. + */ +/* #undef HAVE_DECL_TZNAME */ + +/* Define to 1 if you have the device macros. */ +#define HAVE_DEVICE_MACROS 1 + +/* Define to 1 if you have the /dev/ptc device file. */ +/* #undef HAVE_DEV_PTC */ + +/* Define to 1 if you have the /dev/ptmx device file. */ +/* #undef HAVE_DEV_PTMX */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_DIRECT_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#define HAVE_DIRENT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_DLFCN_H 1 + +/* Define to 1 if you have the `dlopen' function. */ +#define HAVE_DLOPEN 1 + +/* Define to 1 if you have the `dup2' function. */ +#define HAVE_DUP2 1 + +/* Defined when any dynamic module loading is enabled. */ +#define HAVE_DYNAMIC_LOADING 1 + +/* Define if you have the 'epoll' functions. */ +#define HAVE_EPOLL 1 + +/* Define to 1 if you have the `erf' function. */ +#define HAVE_ERF 1 + +/* Define to 1 if you have the `erfc' function. */ +#define HAVE_ERFC 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ERRNO_H 1 + +/* Define to 1 if you have the `execv' function. */ +#define HAVE_EXECV 1 + +/* Define to 1 if you have the `expm1' function. */ +#define HAVE_EXPM1 1 + +/* Define if you have the 'fchdir' function. */ +#define HAVE_FCHDIR 1 + +/* Define to 1 if you have the `fchmod' function. */ +#define HAVE_FCHMOD 1 + +/* Define to 1 if you have the `fchown' function. */ +#define HAVE_FCHOWN 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* Define if you have the 'fdatasync' function. */ +#define HAVE_FDATASYNC 1 + +/* Define to 1 if you have the `finite' function. */ +#define HAVE_FINITE 1 + +/* Define to 1 if you have the `flock' function. */ +#define HAVE_FLOCK 1 + +/* Define to 1 if you have the `fork' function. */ +#define HAVE_FORK 1 + +/* Define to 1 if you have the `forkpty' function. */ +/* #undef HAVE_FORKPTY */ + +/* Define to 1 if you have the `fpathconf' function. */ +#define HAVE_FPATHCONF 1 + +/* Define to 1 if you have the `fseek64' function. */ +/* #undef HAVE_FSEEK64 */ + +/* Define to 1 if you have the `fseeko' function. */ +#define HAVE_FSEEKO 1 + +/* Define to 1 if you have the `fstatvfs' function. */ +/* #undef HAVE_FSTATVFS */ + +/* Define if you have the 'fsync' function. */ +#define HAVE_FSYNC 1 + +/* Define to 1 if you have the `ftell64' function. */ +/* #undef HAVE_FTELL64 */ + +/* Define to 1 if you have the `ftello' function. */ +#define HAVE_FTELLO 1 + +/* Define to 1 if you have the `ftime' function. */ +#define HAVE_FTIME 1 + +/* Define to 1 if you have the `ftruncate' function. */ +#define HAVE_FTRUNCATE 1 + +/* Define to 1 if you have the `gai_strerror' function. */ +#define HAVE_GAI_STRERROR 1 + +/* Define to 1 if you have the `gamma' function. */ +/* #undef HAVE_GAMMA */ + +/* Define if we can use gcc inline assembler to get and set x87 control word + */ +#define HAVE_GCC_ASM_FOR_X87 1 + +/* Define if you have the getaddrinfo function. */ +#define HAVE_GETADDRINFO 1 + +/* Define to 1 if you have the `getcwd' function. */ +#define HAVE_GETCWD 1 + +/* Define this if you have flockfile(), getc_unlocked(), and funlockfile() */ +#define HAVE_GETC_UNLOCKED 1 + +/* Define to 1 if you have the `getentropy' function. */ +/* #undef HAVE_GETENTROPY */ + +/* Define to 1 if you have the `getgroups' function. */ +#define HAVE_GETGROUPS 1 + +/* Define to 1 if you have the `gethostbyname' function. */ +#define HAVE_GETHOSTBYNAME 1 + +/* Define this if you have some version of gethostbyname_r() */ +/* #undef HAVE_GETHOSTBYNAME_R */ + +/* Define this if you have the 3-arg version of gethostbyname_r(). */ +/* #undef HAVE_GETHOSTBYNAME_R_3_ARG */ + +/* Define this if you have the 5-arg version of gethostbyname_r(). */ +/* #undef HAVE_GETHOSTBYNAME_R_5_ARG */ + +/* Define this if you have the 6-arg version of gethostbyname_r(). */ +/* #undef HAVE_GETHOSTBYNAME_R_6_ARG */ + +/* Define to 1 if you have the `getitimer' function. */ +#define HAVE_GETITIMER 1 + +/* Define to 1 if you have the `getloadavg' function. */ +#define HAVE_GETLOADAVG 1 + +/* Define to 1 if you have the `getlogin' function. */ +#define HAVE_GETLOGIN 1 + +/* Define to 1 if you have the `getnameinfo' function. */ +#define HAVE_GETNAMEINFO 1 + +/* Define if you have the 'getpagesize' function. */ +#define HAVE_GETPAGESIZE 1 + +/* Define to 1 if you have the `getpeername' function. */ +#define HAVE_GETPEERNAME 1 + +/* Define to 1 if you have the `getpgid' function. */ +#define HAVE_GETPGID 1 + +/* Define to 1 if you have the `getpgrp' function. */ +#define HAVE_GETPGRP 1 + +/* Define to 1 if you have the `getpid' function. */ +#define HAVE_GETPID 1 + +/* Define to 1 if you have the `getpriority' function. */ +#define HAVE_GETPRIORITY 1 + +/* Define to 1 if you have the `getpwent' function. */ +#define HAVE_GETPWENT 1 + +/* Define to 1 if you have the `getresgid' function. */ +#define HAVE_GETRESGID 1 + +/* Define to 1 if you have the `getresuid' function. */ +#define HAVE_GETRESUID 1 + +/* Define to 1 if you have the `getsid' function. */ +/* #undef HAVE_GETSID */ + +/* Define to 1 if you have the `getspent' function. */ +/* #undef HAVE_GETSPENT */ + +/* Define to 1 if you have the `getspnam' function. */ +/* #undef HAVE_GETSPNAM */ + +/* Define to 1 if you have the `gettimeofday' function. */ +#define HAVE_GETTIMEOFDAY 1 + +/* Define to 1 if you have the `getwd' function. */ +/* #undef HAVE_GETWD */ + +/* Define to 1 if you have the header file. */ +#define HAVE_GRP_H 1 + +/* Define if you have the 'hstrerror' function. */ +#define HAVE_HSTRERROR 1 + +/* Define to 1 if you have the `hypot' function. */ +#define HAVE_HYPOT 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_IEEEFP_H 1 + +/* Define if you have the 'inet_aton' function. */ +#define HAVE_INET_ATON 1 + +/* Define if you have the 'inet_pton' function. */ +#define HAVE_INET_PTON 1 + +/* Define to 1 if you have the `initgroups' function. */ +#define HAVE_INITGROUPS 1 + +/* Define if your compiler provides int32_t. */ +#define HAVE_INT32_T 1 + +/* Define if your compiler provides int64_t. */ +#define HAVE_INT64_T 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_IO_H */ + +/* Define to 1 if you have the `kill' function. */ +#define HAVE_KILL 1 + +/* Define to 1 if you have the `killpg' function. */ +#define HAVE_KILLPG 1 + +/* Define if you have the 'kqueue' functions. */ +#define HAVE_KQUEUE 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_LANGINFO_H 1 + +/* Defined to enable large file support when an off_t is bigger than a long + and long long is available and at least as big as an off_t. You may need to + add some flags for configuration and compilation to enable this mode. (For + Solaris and Linux, the necessary defines are already defined.) */ +/* #undef HAVE_LARGEFILE_SUPPORT */ + +/* Define to 1 if you have the 'lchflags' function. */ +/* #undef HAVE_LCHFLAGS */ + +/* Define to 1 if you have the `lchmod' function. */ +/* #undef HAVE_LCHMOD */ + +/* Define to 1 if you have the `lchown' function. */ +#define HAVE_LCHOWN 1 + +/* Define to 1 if you have the `lgamma' function. */ +#define HAVE_LGAMMA 1 + +/* Define to 1 if you have the `dl' library (-ldl). */ +#define HAVE_LIBDL 1 + +/* Define to 1 if you have the `dld' library (-ldld). */ +/* #undef HAVE_LIBDLD */ + +/* Define to 1 if you have the `ieee' library (-lieee). */ +/* #undef HAVE_LIBIEEE */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LIBINTL_H */ + +/* Define if you have the readline library (-lreadline). */ +/* #undef HAVE_LIBREADLINE */ + +/* Define to 1 if you have the `resolv' library (-lresolv). */ +/* #undef HAVE_LIBRESOLV */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LIBUTIL_H */ + +/* Define if you have the 'link' function. */ +#define HAVE_LINK 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_LINUX_NETLINK_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LINUX_TIPC_H */ + +/* Define to 1 if you have the `log1p' function. */ +#define HAVE_LOG1P 1 + +/* Define this if you have the type long double. */ +#define HAVE_LONG_DOUBLE 1 + +/* Define this if you have the type long long. */ +#define HAVE_LONG_LONG 1 + +/* Define to 1 if you have the `lstat' function. */ +#define HAVE_LSTAT 1 + +/* Define this if you have the makedev macro. */ +#define HAVE_MAKEDEV 1 + +/* Define to 1 if you have the `memmove' function. */ +#define HAVE_MEMMOVE 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `mkfifo' function. */ +/* #undef HAVE_MKFIFO */ + +/* Define to 1 if you have the `mknod' function. */ +#define HAVE_MKNOD 1 + +/* Define to 1 if you have the `mktime' function. */ +#define HAVE_MKTIME 1 + +/* Define to 1 if you have the `mmap' function. */ +#define HAVE_MMAP 1 + +/* Define to 1 if you have the `mremap' function. */ +#define HAVE_MREMAP 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NCURSES_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. */ +/* #undef HAVE_NDIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_NETPACKET_PACKET_H 1 + +/* Define to 1 if you have the `nice' function. */ +#define HAVE_NICE 1 + +/* Define to 1 if you have the `openpty' function. */ +/* #undef HAVE_OPENPTY */ + +/* Define if compiling using MacOS X 10.5 SDK or later. */ +/* #undef HAVE_OSX105_SDK */ + +/* Define to 1 if you have the `pathconf' function. */ +#define HAVE_PATHCONF 1 + +/* Define to 1 if you have the `pause' function. */ +#define HAVE_PAUSE 1 + +/* Define to 1 if you have the `plock' function. */ +/* #undef HAVE_PLOCK */ + +/* Define to 1 if you have the `poll' function. */ +#define HAVE_POLL 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_POLL_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PROCESS_H */ + +/* Define if your compiler supports function prototype */ +#define HAVE_PROTOTYPES 1 + +/* Define if you have GNU PTH threads. */ +/* #undef HAVE_PTH */ + +/* Define to 1 if you have the `pthread_atfork' function. */ +/* #undef HAVE_PTHREAD_ATFORK */ + +/* Defined for Solaris 2.6 bug in pthread header. */ +/* #undef HAVE_PTHREAD_DESTRUCTOR */ + +/* Define to 1 if you have the header file. */ +#define HAVE_PTHREAD_H 1 + +/* Define to 1 if you have the `pthread_init' function. */ +/* #undef HAVE_PTHREAD_INIT */ + +/* Define to 1 if you have the `pthread_sigmask' function. */ +#define HAVE_PTHREAD_SIGMASK 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PTY_H */ + +/* Define to 1 if you have the `putenv' function. */ +#define HAVE_PUTENV 1 + +/* Define if the libcrypto has RAND_egd */ +/* #undef HAVE_RAND_EGD */ + +/* Define to 1 if you have the `readlink' function. */ +#define HAVE_READLINK 1 + +/* Define to 1 if you have the `realpath' function. */ +#define HAVE_REALPATH 1 + +/* Define if you have readline 2.1 */ +/* #undef HAVE_RL_CALLBACK */ + +/* Define if you can turn off readline's signal handling. */ +/* #undef HAVE_RL_CATCH_SIGNAL */ + +/* Define if you have readline 2.2 */ +/* #undef HAVE_RL_COMPLETION_APPEND_CHARACTER */ + +/* Define if you have readline 4.0 */ +/* #undef HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK */ + +/* Define if you have readline 4.2 */ +/* #undef HAVE_RL_COMPLETION_MATCHES */ + +/* Define if you have rl_completion_suppress_append */ +/* #undef HAVE_RL_COMPLETION_SUPPRESS_APPEND */ + +/* Define if you have readline 4.0 */ +/* #undef HAVE_RL_PRE_INPUT_HOOK */ + +/* Define to 1 if you have the `round' function. */ +#define HAVE_ROUND 1 + +/* Define to 1 if you have the `select' function. */ +#define HAVE_SELECT 1 + +/* Define to 1 if you have the `sem_getvalue' function. */ +#define HAVE_SEM_GETVALUE 1 + +/* Define to 1 if you have the `sem_open' function. */ +#define HAVE_SEM_OPEN 1 + +/* Define to 1 if you have the `sem_timedwait' function. */ +#define HAVE_SEM_TIMEDWAIT 1 + +/* Define to 1 if you have the `sem_unlink' function. */ +#define HAVE_SEM_UNLINK 1 + +/* Define to 1 if you have the `setegid' function. */ +#define HAVE_SETEGID 1 + +/* Define to 1 if you have the `seteuid' function. */ +#define HAVE_SETEUID 1 + +/* Define to 1 if you have the `setgid' function. */ +#define HAVE_SETGID 1 + +/* Define if you have the 'setgroups' function. */ +#define HAVE_SETGROUPS 1 + +/* Define to 1 if you have the `setitimer' function. */ +#define HAVE_SETITIMER 1 + +/* Define to 1 if you have the `setlocale' function. */ +#define HAVE_SETLOCALE 1 + +/* Define to 1 if you have the `setpgid' function. */ +#define HAVE_SETPGID 1 + +/* Define to 1 if you have the `setpgrp' function. */ +#define HAVE_SETPGRP 1 + +/* Define to 1 if you have the `setregid' function. */ +#define HAVE_SETREGID 1 + +/* Define to 1 if you have the `setresgid' function. */ +#define HAVE_SETRESGID 1 + +/* Define to 1 if you have the `setresuid' function. */ +#define HAVE_SETRESUID 1 + +/* Define to 1 if you have the `setreuid' function. */ +#define HAVE_SETREUID 1 + +/* Define to 1 if you have the `setsid' function. */ +#define HAVE_SETSID 1 + +/* Define to 1 if you have the `setuid' function. */ +#define HAVE_SETUID 1 + +/* Define to 1 if you have the `setvbuf' function. */ +#define HAVE_SETVBUF 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SHADOW_H */ + +/* Define to 1 if you have the `sigaction' function. */ +#define HAVE_SIGACTION 1 + +/* Define to 1 if you have the `siginterrupt' function. */ +#define HAVE_SIGINTERRUPT 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SIGNAL_H 1 + +/* Define to 1 if you have the `sigrelse' function. */ +/* #undef HAVE_SIGRELSE */ + +/* Define to 1 if you have the `snprintf' function. */ +#define HAVE_SNPRINTF 1 + +/* Define if sockaddr has sa_len member */ +/* #undef HAVE_SOCKADDR_SA_LEN */ + +/* struct sockaddr_storage (sys/socket.h) */ +#define HAVE_SOCKADDR_STORAGE 1 + +/* Define if you have the 'socketpair' function. */ +#define HAVE_SOCKETPAIR 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SPAWN_H */ + +/* Define if your compiler provides ssize_t */ +#define HAVE_SSIZE_T 1 + +/* Define to 1 if you have the `statvfs' function. */ +/* #undef HAVE_STATVFS */ + +/* Define if you have struct stat.st_mtim.tv_nsec */ +/* #undef HAVE_STAT_TV_NSEC */ + +/* Define if you have struct stat.st_mtimensec */ +/* #undef HAVE_STAT_TV_NSEC2 */ + +/* Define if your compiler supports variable length function prototypes (e.g. + void fprintf(FILE *, char *, ...);) *and* */ +#define HAVE_STDARG_PROTOTYPES 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the `strdup' function. */ +#define HAVE_STRDUP 1 + +/* Define to 1 if you have the `strftime' function. */ +#define HAVE_STRFTIME 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_STROPTS_H */ + +/* Define to 1 if `st_birthtime' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_BIRTHTIME */ + +/* Define to 1 if `st_blksize' is a member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_BLKSIZE 1 + +/* Define to 1 if `st_blocks' is a member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_BLOCKS 1 + +/* Define to 1 if `st_flags' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_FLAGS */ + +/* Define to 1 if `st_gen' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_GEN */ + +/* Define to 1 if `st_rdev' is a member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_RDEV 1 + +/* Define to 1 if `tm_zone' is a member of `struct tm'. */ +#define HAVE_STRUCT_TM_TM_ZONE 1 + +/* Define to 1 if your `struct stat' has `st_blocks'. Deprecated, use + `HAVE_STRUCT_STAT_ST_BLOCKS' instead. */ +#define HAVE_ST_BLOCKS 1 + +/* Define if you have the 'symlink' function. */ +#define HAVE_SYMLINK 1 + +/* Define to 1 if you have the `sysconf' function. */ +#define HAVE_SYSCONF 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYSEXITS_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_AUDIOIO_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_BSDTTY_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +/* #undef HAVE_SYS_DIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_EPOLL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_EVENT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_FILE_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_LOADAVG_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_LOCK_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_MKDEV_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_MODEM_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +/* #undef HAVE_SYS_NDIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_PARAM_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_POLL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_RESOURCE_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SELECT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SOCKET_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_STATVFS_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_TERMIO_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIMES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UN_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UTSNAME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_WAIT_H 1 + +/* Define to 1 if you have the `tcgetpgrp' function. */ +#define HAVE_TCGETPGRP 1 + +/* Define to 1 if you have the `tcsetpgrp' function. */ +#define HAVE_TCSETPGRP 1 + +/* Define to 1 if you have the `tempnam' function. */ +#define HAVE_TEMPNAM 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_TERMIOS_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_TERM_H */ + +/* Define to 1 if you have the `tgamma' function. */ +#define HAVE_TGAMMA 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_THREAD_H */ + +/* Define to 1 if you have the `timegm' function. */ +/* #undef HAVE_TIMEGM */ + +/* Define to 1 if you have the `times' function. */ +#define HAVE_TIMES 1 + +/* Define to 1 if you have the `tmpfile' function. */ +#define HAVE_TMPFILE 1 + +/* Define to 1 if you have the `tmpnam' function. */ +#define HAVE_TMPNAM 1 + +/* Define to 1 if you have the `tmpnam_r' function. */ +/* #undef HAVE_TMPNAM_R */ + +/* Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use + `HAVE_STRUCT_TM_TM_ZONE' instead. */ +#define HAVE_TM_ZONE 1 + +/* Define to 1 if you have the `truncate' function. */ +#define HAVE_TRUNCATE 1 + +/* Define to 1 if you don't have `tm_zone' but do have the external array + `tzname'. */ +/* #undef HAVE_TZNAME */ + +/* Define this if you have tcl and TCL_UTF_MAX==6 */ +/* #undef HAVE_UCS4_TCL */ + +/* Define if your compiler provides uint32_t. */ +#define HAVE_UINT32_T 1 + +/* Define if your compiler provides uint64_t. */ +#define HAVE_UINT64_T 1 + +/* Define to 1 if the system has the type `uintptr_t'. */ +#define HAVE_UINTPTR_T 1 + +/* Define to 1 if you have the `uname' function. */ +#define HAVE_UNAME 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you have the `unsetenv' function. */ +#define HAVE_UNSETENV 1 + +/* Define if you have a useable wchar_t type defined in wchar.h; useable means + wchar_t must be an unsigned type with at least 16 bits. (see + Include/unicodeobject.h). */ +/* #undef HAVE_USABLE_WCHAR_T */ + +/* Define to 1 if you have the header file. */ +#define HAVE_UTIL_H 1 + +/* Define to 1 if you have the `utimes' function. */ +#define HAVE_UTIMES 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UTIME_H 1 + +/* Define to 1 if you have the `wait3' function. */ +#define HAVE_WAIT3 1 + +/* Define to 1 if you have the `wait4' function. */ +/* #undef HAVE_WAIT4 */ + +/* Define to 1 if you have the `waitpid' function. */ +#define HAVE_WAITPID 1 + +/* Define if the compiler provides a wchar.h header file. */ +#define HAVE_WCHAR_H 1 + +/* Define to 1 if you have the `wcscoll' function. */ +#define HAVE_WCSCOLL 1 + +/* Define if tzset() actually switches the local timezone in a meaningful way. + */ +/* #undef HAVE_WORKING_TZSET */ + +/* Define if the zlib library has inflateCopy */ +#define HAVE_ZLIB_COPY 1 + +/* Define to 1 if you have the `_getpty' function. */ +/* #undef HAVE__GETPTY */ + +/* Define if you are using Mach cthreads directly under /include */ +/* #undef HURD_C_THREADS */ + +/* Define if you are using Mach cthreads under mach / */ +/* #undef MACH_C_THREADS */ + +/* Define to 1 if `major', `minor', and `makedev' are declared in . + */ +/* #undef MAJOR_IN_MKDEV */ + +/* Define to 1 if `major', `minor', and `makedev' are declared in + . */ +#define MAJOR_IN_SYSMACROS 1 + +/* Define if mvwdelch in curses.h is an expression. */ +/* #undef MVWDELCH_IS_EXPRESSION */ + +/* Define to the address where bug reports for this package should be sent. */ +/* #undef PACKAGE_BUGREPORT */ + +/* Define to the full name of this package. */ +/* #undef PACKAGE_NAME */ + +/* Define to the full name and version of this package. */ +/* #undef PACKAGE_STRING */ + +/* Define to the one symbol short name of this package. */ +/* #undef PACKAGE_TARNAME */ + +/* Define to the home page for this package. */ +/* #undef PACKAGE_URL */ + +/* Define to the version of this package. */ +/* #undef PACKAGE_VERSION */ + +/* Define if POSIX semaphores aren't enabled on your system */ +/* #undef POSIX_SEMAPHORES_NOT_ENABLED */ + +/* Defined if PTHREAD_SCOPE_SYSTEM supported. */ +/* #undef PTHREAD_SYSTEM_SCHED_SUPPORTED */ + +/* Define as the preferred size in bits of long digits */ +/* #undef PYLONG_BITS_IN_DIGIT */ + +/* Define to printf format modifier for long long type */ +#define PY_FORMAT_LONG_LONG "ll" + +/* Define to printf format modifier for Py_ssize_t */ +#define PY_FORMAT_SIZE_T "z" + +/* Define as the integral type used for Unicode representation. */ +#define PY_UNICODE_TYPE unsigned long + +/* Define if you want to build an interpreter with many run-time checks. */ +/* #undef Py_DEBUG */ + +/* Defined if Python is built as a shared library. */ +#define Py_ENABLE_SHARED 1 + +/* Define as the size of the unicode type. */ +#define Py_UNICODE_SIZE 4 + +/* Define if you want to have a Unicode type. */ +#define Py_USING_UNICODE 1 + +/* assume C89 semantics that RETSIGTYPE is always void */ +#define RETSIGTYPE void + +/* Define if setpgrp() must be called as setpgrp(0, 0). */ +/* #undef SETPGRP_HAVE_ARG */ + +/* Define this to be extension of shared libraries (including the dot!). */ +#define SHLIB_EXT ".so" + +/* Define if i>>j for signed int i does not extend the sign bit when i < 0 */ +/* #undef SIGNED_RIGHT_SHIFT_ZERO_FILLS */ + +/* The size of `double', as computed by sizeof. */ +#define SIZEOF_DOUBLE 8 + +/* The size of `float', as computed by sizeof. */ +#define SIZEOF_FLOAT 4 + +/* The size of `fpos_t', as computed by sizeof. */ +#define SIZEOF_FPOS_T 4 + +/* The size of `int', as computed by sizeof. */ +#define SIZEOF_INT 4 + +/* The size of `long', as computed by sizeof. */ +#define SIZEOF_LONG 4 + +/* The size of `long double', as computed by sizeof. */ +#define SIZEOF_LONG_DOUBLE 8 + +/* The size of `long long', as computed by sizeof. */ +#define SIZEOF_LONG_LONG 8 + +/* The size of `off_t', as computed by sizeof. */ +#define SIZEOF_OFF_T 4 + +/* The size of `pid_t', as computed by sizeof. */ +#define SIZEOF_PID_T 4 + +/* The size of `pthread_t', as computed by sizeof. */ +#define SIZEOF_PTHREAD_T 4 + +/* The size of `short', as computed by sizeof. */ +#define SIZEOF_SHORT 2 + +/* The size of `size_t', as computed by sizeof. */ +#define SIZEOF_SIZE_T 4 + +/* The size of `time_t', as computed by sizeof. */ +#define SIZEOF_TIME_T 4 + +/* The size of `uintptr_t', as computed by sizeof. */ +#define SIZEOF_UINTPTR_T 4 + +/* The size of `void *', as computed by sizeof. */ +#define SIZEOF_VOID_P 4 + +/* The size of `wchar_t', as computed by sizeof. */ +#define SIZEOF_WCHAR_T 4 + +/* The size of `_Bool', as computed by sizeof. */ +#define SIZEOF__BOOL 1 + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define if you can safely include both and + (which you can't on SCO ODT 3.0). */ +#define SYS_SELECT_WITH_SYS_TIME 1 + +/* Define if tanh(-0.) is -0., or if platform doesn't have signed zeros */ +/* #undef TANH_PRESERVES_ZERO_SIGN */ + +/* Define to 1 if you can safely include both and . */ +#define TIME_WITH_SYS_TIME 1 + +/* Define to 1 if your declares `struct tm'. */ +/* #undef TM_IN_SYS_TIME */ + +/* Enable extensions on AIX 3, Interix. */ +#ifndef _ALL_SOURCE +# define _ALL_SOURCE 1 +#endif +/* Enable GNU extensions on systems that have them. */ +#ifndef _GNU_SOURCE +# define _GNU_SOURCE 1 +#endif +/* Enable threading extensions on Solaris. */ +#ifndef _POSIX_PTHREAD_SEMANTICS +# define _POSIX_PTHREAD_SEMANTICS 1 +#endif +/* Enable extensions on HP NonStop. */ +#ifndef _TANDEM_SOURCE +# define _TANDEM_SOURCE 1 +#endif +/* Enable general extensions on Solaris. */ +#ifndef __EXTENSIONS__ +# define __EXTENSIONS__ 1 +#endif + + +/* Define if you want to use MacPython modules on MacOSX in unix-Python. */ +/* #undef USE_TOOLBOX_OBJECT_GLUE */ + +/* Define if a va_list is an array of some kind */ +/* #undef VA_LIST_IS_ARRAY */ + +/* Define if you want SIGFPE handled (see Include/pyfpe.h). */ +/* #undef WANT_SIGFPE_HANDLER */ + +/* Define if you want wctype.h functions to be used instead of the one + supplied by Python itself. (see Include/unicodectype.h). */ +/* #undef WANT_WCTYPE_FUNCTIONS */ + +/* Define if WINDOW in curses.h offers a field _flags. */ +/* #undef WINDOW_HAS_FLAGS */ + +/* Define if you want documentation strings in extension modules */ +#define WITH_DOC_STRINGS 1 + +/* Define if you want to use the new-style (Openstep, Rhapsody, MacOS) dynamic + linker (dyld) instead of the old-style (NextStep) dynamic linker (rld). + Dyld is necessary to support frameworks. */ +/* #undef WITH_DYLD */ + +/* Define to 1 if libintl is needed for locale functions. */ +/* #undef WITH_LIBINTL */ + +/* Define if you want to produce an OpenStep/Rhapsody framework (shared + library plus accessory files). */ +/* #undef WITH_NEXT_FRAMEWORK */ + +/* Define if you want to compile in Python-specific mallocs */ +#define WITH_PYMALLOC 1 + +/* Define if you want to compile in rudimentary thread support */ +#define WITH_THREAD 1 + +/* Define to profile with the Pentium timestamp counter */ +/* #undef WITH_TSC */ + +/* Define if you want pymalloc to be disabled when running under valgrind */ +/* #undef WITH_VALGRIND */ + +/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most + significant byte first (like Motorola and SPARC, unlike Intel). */ +#if defined AC_APPLE_UNIVERSAL_BUILD +# if defined __BIG_ENDIAN__ +# define WORDS_BIGENDIAN 1 +# endif +#else +# ifndef WORDS_BIGENDIAN +/* # undef WORDS_BIGENDIAN */ +# endif +#endif + +/* Define if arithmetic is subject to x87-style double rounding issue */ +/* #undef X87_DOUBLE_ROUNDING */ + +/* Define on OpenBSD to activate all library features */ +/* #undef _BSD_SOURCE */ + +/* Define on Irix to enable u_int */ +#define _BSD_TYPES 1 + +/* Define on Darwin to activate all library features */ +#define _DARWIN_C_SOURCE 1 + +/* This must be set to 64 on some systems to enable large file support. */ +#define _FILE_OFFSET_BITS 64 + +/* Define on Linux to activate all library features */ +#define _GNU_SOURCE 1 + +/* This must be defined on some systems to enable large file support. */ +#define _LARGEFILE_SOURCE 1 + +/* This must be defined on AIX systems to enable large file support. */ +/* #undef _LARGE_FILES */ + +/* Define to 1 if on MINIX. */ +/* #undef _MINIX */ + +/* Define on NetBSD to activate all library features */ +#define _NETBSD_SOURCE 1 + +/* Define _OSF_SOURCE to get the makedev macro. */ +/* #undef _OSF_SOURCE */ + +/* Define to 2 if the system does not provide POSIX.1 features except with + this defined. */ +/* #undef _POSIX_1_SOURCE */ + +/* Define to activate features from IEEE Stds 1003.1-2001 */ +#define _POSIX_C_SOURCE 200112L + +/* Define to 1 if you need to in order for `stat' and other things to work. */ +/* #undef _POSIX_SOURCE */ + +/* Define if you have POSIX threads, and your system does not define that. */ +/* #undef _POSIX_THREADS */ + +/* Define to force use of thread-safe errno, h_errno, and other functions */ +#define _REENTRANT 1 + +/* Define for Solaris 2.5.1 so the uint32_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +/* #undef _UINT32_T */ + +/* Define for Solaris 2.5.1 so the uint64_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +/* #undef _UINT64_T */ + +/* Define to the level of X/Open that your system supports */ +#define _XOPEN_SOURCE 600 + +/* Define to activate Unix95-and-earlier features */ +#define _XOPEN_SOURCE_EXTENDED 1 + +/* Define on FreeBSD to activate all library features */ +#define __BSD_VISIBLE 1 + +/* Define to 1 if type `char' is unsigned and you are not using gcc. */ +#ifndef __CHAR_UNSIGNED__ +/* # undef __CHAR_UNSIGNED__ */ +#endif + +/* Defined on Solaris to see additional function prototypes. */ +#define __EXTENSIONS__ 1 + +/* Define to 'long' if doesn't define. */ +/* #undef clock_t */ + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ + +/* Define to `int' if doesn't define. */ +/* #undef gid_t */ + +/* Define to the type of a signed integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +/* #undef int32_t */ + +/* Define to the type of a signed integer type of width exactly 64 bits if + such a type exists and the standard includes do not define it. */ +/* #undef int64_t */ + +/* Define to `int' if does not define. */ +/* #undef mode_t */ + +/* Define to `long int' if does not define. */ +/* #undef off_t */ + +/* Define to `int' if does not define. */ +/* #undef pid_t */ + +/* Define to empty if the keyword does not work. */ +/* #undef signed */ + +/* Define to `unsigned int' if does not define. */ +/* #undef size_t */ + +/* Define to `int' if does not define. */ +/* #undef socklen_t */ + +/* Define to `int' if doesn't define. */ +/* #undef uid_t */ + +/* Define to the type of an unsigned integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint32_t */ + +/* Define to the type of an unsigned integer type of width exactly 64 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint64_t */ + +/* Define to empty if the keyword does not work. */ +/* #undef volatile */ + + +/* Define the macros needed if on a UnixWare 7.x system. */ +#if defined(__USLC__) && defined(__SCO_VERSION__) +#define STRICT_SYSV_CURSES /* Don't use ncurses extensions */ +#endif + +#endif /*Py_PYCONFIG_H*/ + diff --git a/android/python27/include/pyconfig_x86_64.h b/android/python27/include/pyconfig_x86_64.h new file mode 100644 index 000000000..1f01c8cd7 --- /dev/null +++ b/android/python27/include/pyconfig_x86_64.h @@ -0,0 +1,1282 @@ +/* pyconfig.h. Generated from pyconfig.h.in by configure. */ +/* pyconfig.h.in. Generated from configure.ac by autoheader. */ + + +#ifndef Py_PYCONFIG_H +#define Py_PYCONFIG_H + + +/* Define if building universal (internal helper macro) */ +/* #undef AC_APPLE_UNIVERSAL_BUILD */ + +/* Define for AIX if your compiler is a genuine IBM xlC/xlC_r and you want + support for AIX C++ shared extension modules. */ +/* #undef AIX_GENUINE_CPLUSPLUS */ + +/* Define this if you have AtheOS threads. */ +/* #undef ATHEOS_THREADS */ + +/* Define this if you have BeOS threads. */ +/* #undef BEOS_THREADS */ + +/* Define if you have the Mach cthreads package */ +/* #undef C_THREADS */ + +/* Define if C doubles are 64-bit IEEE 754 binary format, stored in ARM + mixed-endian order (byte order 45670123) */ +/* #undef DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754 */ + +/* Define if C doubles are 64-bit IEEE 754 binary format, stored with the most + significant byte first */ +/* #undef DOUBLE_IS_BIG_ENDIAN_IEEE754 */ + +/* Define if C doubles are 64-bit IEEE 754 binary format, stored with the + least significant byte first */ +/* #undef DOUBLE_IS_LITTLE_ENDIAN_IEEE754 */ + +/* Define if --enable-ipv6 is specified */ +#define ENABLE_IPV6 1 + +/* Define if flock needs to be linked with bsd library. */ +/* #undef FLOCK_NEEDS_LIBBSD */ + +/* Define if getpgrp() must be called as getpgrp(0). */ +/* #undef GETPGRP_HAVE_ARG */ + +/* Define if gettimeofday() does not have second (timezone) argument This is + the case on Motorola V4 (R40V4.2) */ +/* #undef GETTIMEOFDAY_NO_TZ */ + +/* Define to 1 if you have the `acosh' function. */ +#define HAVE_ACOSH 1 + +/* struct addrinfo (netdb.h) */ +#define HAVE_ADDRINFO 1 + +/* Define to 1 if you have the `alarm' function. */ +#define HAVE_ALARM 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ALLOCA_H 1 + +/* Define this if your time.h defines altzone. */ +/* #undef HAVE_ALTZONE */ + +/* Define to 1 if you have the `asinh' function. */ +#define HAVE_ASINH 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ASM_TYPES_H 1 + +/* Define to 1 if you have the `atanh' function. */ +#define HAVE_ATANH 1 + +/* Define if GCC supports __attribute__((format(PyArg_ParseTuple, 2, 3))) */ +/* #undef HAVE_ATTRIBUTE_FORMAT_PARSETUPLE */ + +/* Define to 1 if you have the `bind_textdomain_codeset' function. */ +/* #undef HAVE_BIND_TEXTDOMAIN_CODESET */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_BLUETOOTH_BLUETOOTH_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_BLUETOOTH_H */ + +/* Define if nice() returns success/failure instead of the new priority. */ +/* #undef HAVE_BROKEN_NICE */ + +/* Define if the system reports an invalid PIPE_BUF value. */ +/* #undef HAVE_BROKEN_PIPE_BUF */ + +/* Define if poll() sets errno on invalid file descriptors. */ +/* #undef HAVE_BROKEN_POLL */ + +/* Define if the Posix semaphores do not work on your system */ +/* #undef HAVE_BROKEN_POSIX_SEMAPHORES */ + +/* Define if pthread_sigmask() does not work on your system. */ +/* #undef HAVE_BROKEN_PTHREAD_SIGMASK */ + +/* define to 1 if your sem_getvalue is broken. */ +#define HAVE_BROKEN_SEM_GETVALUE 1 + +/* Define if `unsetenv` does not return an int. */ +/* #undef HAVE_BROKEN_UNSETENV */ + +/* Define this if you have the type _Bool. */ +#define HAVE_C99_BOOL 1 + +/* Define to 1 if you have the 'chflags' function. */ +/* #undef HAVE_CHFLAGS */ + +/* Define to 1 if you have the `chown' function. */ +#define HAVE_CHOWN 1 + +/* Define if you have the 'chroot' function. */ +#define HAVE_CHROOT 1 + +/* Define to 1 if you have the `clock' function. */ +#define HAVE_CLOCK 1 + +/* Define to 1 if you have the `confstr' function. */ +/* #undef HAVE_CONFSTR */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_CONIO_H */ + +/* Define to 1 if you have the `copysign' function. */ +#define HAVE_COPYSIGN 1 + +/* Define to 1 if you have the `ctermid' function. */ +/* #undef HAVE_CTERMID */ + +/* Define if you have the 'ctermid_r' function. */ +#define HAVE_CTERMID_R 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_CURSES_H */ + +/* Define if you have the 'is_term_resized' function. */ +/* #undef HAVE_CURSES_IS_TERM_RESIZED */ + +/* Define if you have the 'resizeterm' function. */ +/* #undef HAVE_CURSES_RESIZETERM */ + +/* Define if you have the 'resize_term' function. */ +/* #undef HAVE_CURSES_RESIZE_TERM */ + +/* Define to 1 if you have the declaration of `isfinite', and to 0 if you + don't. */ +#define HAVE_DECL_ISFINITE 1 + +/* Define to 1 if you have the declaration of `isinf', and to 0 if you don't. + */ +#define HAVE_DECL_ISINF 1 + +/* Define to 1 if you have the declaration of `isnan', and to 0 if you don't. + */ +#define HAVE_DECL_ISNAN 1 + +/* Define to 1 if you have the declaration of `tzname', and to 0 if you don't. + */ +/* #undef HAVE_DECL_TZNAME */ + +/* Define to 1 if you have the device macros. */ +#define HAVE_DEVICE_MACROS 1 + +/* Define to 1 if you have the /dev/ptc device file. */ +/* #undef HAVE_DEV_PTC */ + +/* Define to 1 if you have the /dev/ptmx device file. */ +/* #undef HAVE_DEV_PTMX */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_DIRECT_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#define HAVE_DIRENT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_DLFCN_H 1 + +/* Define to 1 if you have the `dlopen' function. */ +#define HAVE_DLOPEN 1 + +/* Define to 1 if you have the `dup2' function. */ +#define HAVE_DUP2 1 + +/* Defined when any dynamic module loading is enabled. */ +#define HAVE_DYNAMIC_LOADING 1 + +/* Define if you have the 'epoll' functions. */ +#define HAVE_EPOLL 1 + +/* Define to 1 if you have the `erf' function. */ +#define HAVE_ERF 1 + +/* Define to 1 if you have the `erfc' function. */ +#define HAVE_ERFC 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ERRNO_H 1 + +/* Define to 1 if you have the `execv' function. */ +#define HAVE_EXECV 1 + +/* Define to 1 if you have the `expm1' function. */ +#define HAVE_EXPM1 1 + +/* Define if you have the 'fchdir' function. */ +#define HAVE_FCHDIR 1 + +/* Define to 1 if you have the `fchmod' function. */ +#define HAVE_FCHMOD 1 + +/* Define to 1 if you have the `fchown' function. */ +#define HAVE_FCHOWN 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* Define if you have the 'fdatasync' function. */ +#define HAVE_FDATASYNC 1 + +/* Define to 1 if you have the `finite' function. */ +#define HAVE_FINITE 1 + +/* Define to 1 if you have the `flock' function. */ +#define HAVE_FLOCK 1 + +/* Define to 1 if you have the `fork' function. */ +#define HAVE_FORK 1 + +/* Define to 1 if you have the `forkpty' function. */ +/* #undef HAVE_FORKPTY */ + +/* Define to 1 if you have the `fpathconf' function. */ +#define HAVE_FPATHCONF 1 + +/* Define to 1 if you have the `fseek64' function. */ +/* #undef HAVE_FSEEK64 */ + +/* Define to 1 if you have the `fseeko' function. */ +#define HAVE_FSEEKO 1 + +/* Define to 1 if you have the `fstatvfs' function. */ +#define HAVE_FSTATVFS 1 + +/* Define if you have the 'fsync' function. */ +#define HAVE_FSYNC 1 + +/* Define to 1 if you have the `ftell64' function. */ +/* #undef HAVE_FTELL64 */ + +/* Define to 1 if you have the `ftello' function. */ +#define HAVE_FTELLO 1 + +/* Define to 1 if you have the `ftime' function. */ +/* #undef HAVE_FTIME */ + +/* Define to 1 if you have the `ftruncate' function. */ +#define HAVE_FTRUNCATE 1 + +/* Define to 1 if you have the `gai_strerror' function. */ +#define HAVE_GAI_STRERROR 1 + +/* Define to 1 if you have the `gamma' function. */ +/* #undef HAVE_GAMMA */ + +/* Define if we can use gcc inline assembler to get and set x87 control word + */ +#define HAVE_GCC_ASM_FOR_X87 1 + +/* Define if you have the getaddrinfo function. */ +#define HAVE_GETADDRINFO 1 + +/* Define to 1 if you have the `getcwd' function. */ +#define HAVE_GETCWD 1 + +/* Define this if you have flockfile(), getc_unlocked(), and funlockfile() */ +#define HAVE_GETC_UNLOCKED 1 + +/* Define to 1 if you have the `getentropy' function. */ +/* #undef HAVE_GETENTROPY */ + +/* Define to 1 if you have the `getgroups' function. */ +#define HAVE_GETGROUPS 1 + +/* Define to 1 if you have the `gethostbyname' function. */ +#define HAVE_GETHOSTBYNAME 1 + +/* Define this if you have some version of gethostbyname_r() */ +/* #undef HAVE_GETHOSTBYNAME_R */ + +/* Define this if you have the 3-arg version of gethostbyname_r(). */ +/* #undef HAVE_GETHOSTBYNAME_R_3_ARG */ + +/* Define this if you have the 5-arg version of gethostbyname_r(). */ +/* #undef HAVE_GETHOSTBYNAME_R_5_ARG */ + +/* Define this if you have the 6-arg version of gethostbyname_r(). */ +/* #undef HAVE_GETHOSTBYNAME_R_6_ARG */ + +/* Define to 1 if you have the `getitimer' function. */ +#define HAVE_GETITIMER 1 + +/* Define to 1 if you have the `getloadavg' function. */ +#define HAVE_GETLOADAVG 1 + +/* Define to 1 if you have the `getlogin' function. */ +#define HAVE_GETLOGIN 1 + +/* Define to 1 if you have the `getnameinfo' function. */ +#define HAVE_GETNAMEINFO 1 + +/* Define if you have the 'getpagesize' function. */ +#define HAVE_GETPAGESIZE 1 + +/* Define to 1 if you have the `getpeername' function. */ +#define HAVE_GETPEERNAME 1 + +/* Define to 1 if you have the `getpgid' function. */ +#define HAVE_GETPGID 1 + +/* Define to 1 if you have the `getpgrp' function. */ +#define HAVE_GETPGRP 1 + +/* Define to 1 if you have the `getpid' function. */ +#define HAVE_GETPID 1 + +/* Define to 1 if you have the `getpriority' function. */ +#define HAVE_GETPRIORITY 1 + +/* Define to 1 if you have the `getpwent' function. */ +#define HAVE_GETPWENT 1 + +/* Define to 1 if you have the `getresgid' function. */ +#define HAVE_GETRESGID 1 + +/* Define to 1 if you have the `getresuid' function. */ +#define HAVE_GETRESUID 1 + +/* Define to 1 if you have the `getsid' function. */ +#define HAVE_GETSID 1 + +/* Define to 1 if you have the `getspent' function. */ +/* #undef HAVE_GETSPENT */ + +/* Define to 1 if you have the `getspnam' function. */ +/* #undef HAVE_GETSPNAM */ + +/* Define to 1 if you have the `gettimeofday' function. */ +#define HAVE_GETTIMEOFDAY 1 + +/* Define to 1 if you have the `getwd' function. */ +/* #undef HAVE_GETWD */ + +/* Define to 1 if you have the header file. */ +#define HAVE_GRP_H 1 + +/* Define if you have the 'hstrerror' function. */ +#define HAVE_HSTRERROR 1 + +/* Define to 1 if you have the `hypot' function. */ +#define HAVE_HYPOT 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_IEEEFP_H */ + +/* Define if you have the 'inet_aton' function. */ +#define HAVE_INET_ATON 1 + +/* Define if you have the 'inet_pton' function. */ +#define HAVE_INET_PTON 1 + +/* Define to 1 if you have the `initgroups' function. */ +#define HAVE_INITGROUPS 1 + +/* Define if your compiler provides int32_t. */ +#define HAVE_INT32_T 1 + +/* Define if your compiler provides int64_t. */ +#define HAVE_INT64_T 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_IO_H */ + +/* Define to 1 if you have the `kill' function. */ +#define HAVE_KILL 1 + +/* Define to 1 if you have the `killpg' function. */ +#define HAVE_KILLPG 1 + +/* Define if you have the 'kqueue' functions. */ +#define HAVE_KQUEUE 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_LANGINFO_H 1 + +/* Defined to enable large file support when an off_t is bigger than a long + and long long is available and at least as big as an off_t. You may need to + add some flags for configuration and compilation to enable this mode. (For + Solaris and Linux, the necessary defines are already defined.) */ +/* #undef HAVE_LARGEFILE_SUPPORT */ + +/* Define to 1 if you have the 'lchflags' function. */ +/* #undef HAVE_LCHFLAGS */ + +/* Define to 1 if you have the `lchmod' function. */ +/* #undef HAVE_LCHMOD */ + +/* Define to 1 if you have the `lchown' function. */ +#define HAVE_LCHOWN 1 + +/* Define to 1 if you have the `lgamma' function. */ +#define HAVE_LGAMMA 1 + +/* Define to 1 if you have the `dl' library (-ldl). */ +#define HAVE_LIBDL 1 + +/* Define to 1 if you have the `dld' library (-ldld). */ +/* #undef HAVE_LIBDLD */ + +/* Define to 1 if you have the `ieee' library (-lieee). */ +/* #undef HAVE_LIBIEEE */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LIBINTL_H */ + +/* Define if you have the readline library (-lreadline). */ +/* #undef HAVE_LIBREADLINE */ + +/* Define to 1 if you have the `resolv' library (-lresolv). */ +/* #undef HAVE_LIBRESOLV */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LIBUTIL_H */ + +/* Define if you have the 'link' function. */ +#define HAVE_LINK 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_LINUX_NETLINK_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_LINUX_TIPC_H 1 + +/* Define to 1 if you have the `log1p' function. */ +#define HAVE_LOG1P 1 + +/* Define this if you have the type long double. */ +#define HAVE_LONG_DOUBLE 1 + +/* Define this if you have the type long long. */ +#define HAVE_LONG_LONG 1 + +/* Define to 1 if you have the `lstat' function. */ +#define HAVE_LSTAT 1 + +/* Define this if you have the makedev macro. */ +#define HAVE_MAKEDEV 1 + +/* Define to 1 if you have the `memmove' function. */ +#define HAVE_MEMMOVE 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `mkfifo' function. */ +#define HAVE_MKFIFO 1 + +/* Define to 1 if you have the `mknod' function. */ +#define HAVE_MKNOD 1 + +/* Define to 1 if you have the `mktime' function. */ +#define HAVE_MKTIME 1 + +/* Define to 1 if you have the `mmap' function. */ +#define HAVE_MMAP 1 + +/* Define to 1 if you have the `mremap' function. */ +#define HAVE_MREMAP 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NCURSES_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. */ +/* #undef HAVE_NDIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_NETPACKET_PACKET_H 1 + +/* Define to 1 if you have the `nice' function. */ +#define HAVE_NICE 1 + +/* Define to 1 if you have the `openpty' function. */ +/* #undef HAVE_OPENPTY */ + +/* Define if compiling using MacOS X 10.5 SDK or later. */ +/* #undef HAVE_OSX105_SDK */ + +/* Define to 1 if you have the `pathconf' function. */ +#define HAVE_PATHCONF 1 + +/* Define to 1 if you have the `pause' function. */ +#define HAVE_PAUSE 1 + +/* Define to 1 if you have the `plock' function. */ +/* #undef HAVE_PLOCK */ + +/* Define to 1 if you have the `poll' function. */ +#define HAVE_POLL 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_POLL_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PROCESS_H */ + +/* Define if your compiler supports function prototype */ +#define HAVE_PROTOTYPES 1 + +/* Define if you have GNU PTH threads. */ +/* #undef HAVE_PTH */ + +/* Define to 1 if you have the `pthread_atfork' function. */ +#define HAVE_PTHREAD_ATFORK 1 + +/* Defined for Solaris 2.6 bug in pthread header. */ +/* #undef HAVE_PTHREAD_DESTRUCTOR */ + +/* Define to 1 if you have the header file. */ +#define HAVE_PTHREAD_H 1 + +/* Define to 1 if you have the `pthread_init' function. */ +/* #undef HAVE_PTHREAD_INIT */ + +/* Define to 1 if you have the `pthread_sigmask' function. */ +#define HAVE_PTHREAD_SIGMASK 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PTY_H */ + +/* Define to 1 if you have the `putenv' function. */ +#define HAVE_PUTENV 1 + +/* Define if the libcrypto has RAND_egd */ +/* #undef HAVE_RAND_EGD */ + +/* Define to 1 if you have the `readlink' function. */ +#define HAVE_READLINK 1 + +/* Define to 1 if you have the `realpath' function. */ +#define HAVE_REALPATH 1 + +/* Define if you have readline 2.1 */ +/* #undef HAVE_RL_CALLBACK */ + +/* Define if you can turn off readline's signal handling. */ +/* #undef HAVE_RL_CATCH_SIGNAL */ + +/* Define if you have readline 2.2 */ +/* #undef HAVE_RL_COMPLETION_APPEND_CHARACTER */ + +/* Define if you have readline 4.0 */ +/* #undef HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK */ + +/* Define if you have readline 4.2 */ +/* #undef HAVE_RL_COMPLETION_MATCHES */ + +/* Define if you have rl_completion_suppress_append */ +/* #undef HAVE_RL_COMPLETION_SUPPRESS_APPEND */ + +/* Define if you have readline 4.0 */ +/* #undef HAVE_RL_PRE_INPUT_HOOK */ + +/* Define to 1 if you have the `round' function. */ +#define HAVE_ROUND 1 + +/* Define to 1 if you have the `select' function. */ +#define HAVE_SELECT 1 + +/* Define to 1 if you have the `sem_getvalue' function. */ +#define HAVE_SEM_GETVALUE 1 + +/* Define to 1 if you have the `sem_open' function. */ +#define HAVE_SEM_OPEN 1 + +/* Define to 1 if you have the `sem_timedwait' function. */ +#define HAVE_SEM_TIMEDWAIT 1 + +/* Define to 1 if you have the `sem_unlink' function. */ +#define HAVE_SEM_UNLINK 1 + +/* Define to 1 if you have the `setegid' function. */ +#define HAVE_SETEGID 1 + +/* Define to 1 if you have the `seteuid' function. */ +#define HAVE_SETEUID 1 + +/* Define to 1 if you have the `setgid' function. */ +#define HAVE_SETGID 1 + +/* Define if you have the 'setgroups' function. */ +#define HAVE_SETGROUPS 1 + +/* Define to 1 if you have the `setitimer' function. */ +#define HAVE_SETITIMER 1 + +/* Define to 1 if you have the `setlocale' function. */ +#define HAVE_SETLOCALE 1 + +/* Define to 1 if you have the `setpgid' function. */ +#define HAVE_SETPGID 1 + +/* Define to 1 if you have the `setpgrp' function. */ +#define HAVE_SETPGRP 1 + +/* Define to 1 if you have the `setregid' function. */ +#define HAVE_SETREGID 1 + +/* Define to 1 if you have the `setresgid' function. */ +#define HAVE_SETRESGID 1 + +/* Define to 1 if you have the `setresuid' function. */ +#define HAVE_SETRESUID 1 + +/* Define to 1 if you have the `setreuid' function. */ +#define HAVE_SETREUID 1 + +/* Define to 1 if you have the `setsid' function. */ +#define HAVE_SETSID 1 + +/* Define to 1 if you have the `setuid' function. */ +#define HAVE_SETUID 1 + +/* Define to 1 if you have the `setvbuf' function. */ +#define HAVE_SETVBUF 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SHADOW_H */ + +/* Define to 1 if you have the `sigaction' function. */ +#define HAVE_SIGACTION 1 + +/* Define to 1 if you have the `siginterrupt' function. */ +#define HAVE_SIGINTERRUPT 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SIGNAL_H 1 + +/* Define to 1 if you have the `sigrelse' function. */ +/* #undef HAVE_SIGRELSE */ + +/* Define to 1 if you have the `snprintf' function. */ +#define HAVE_SNPRINTF 1 + +/* Define if sockaddr has sa_len member */ +/* #undef HAVE_SOCKADDR_SA_LEN */ + +/* struct sockaddr_storage (sys/socket.h) */ +#define HAVE_SOCKADDR_STORAGE 1 + +/* Define if you have the 'socketpair' function. */ +#define HAVE_SOCKETPAIR 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SPAWN_H */ + +/* Define if your compiler provides ssize_t */ +#define HAVE_SSIZE_T 1 + +/* Define to 1 if you have the `statvfs' function. */ +#define HAVE_STATVFS 1 + +/* Define if you have struct stat.st_mtim.tv_nsec */ +/* #undef HAVE_STAT_TV_NSEC */ + +/* Define if you have struct stat.st_mtimensec */ +/* #undef HAVE_STAT_TV_NSEC2 */ + +/* Define if your compiler supports variable length function prototypes (e.g. + void fprintf(FILE *, char *, ...);) *and* */ +#define HAVE_STDARG_PROTOTYPES 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the `strdup' function. */ +#define HAVE_STRDUP 1 + +/* Define to 1 if you have the `strftime' function. */ +#define HAVE_STRFTIME 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_STROPTS_H */ + +/* Define to 1 if `st_birthtime' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_BIRTHTIME */ + +/* Define to 1 if `st_blksize' is a member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_BLKSIZE 1 + +/* Define to 1 if `st_blocks' is a member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_BLOCKS 1 + +/* Define to 1 if `st_flags' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_FLAGS */ + +/* Define to 1 if `st_gen' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_GEN */ + +/* Define to 1 if `st_rdev' is a member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_RDEV 1 + +/* Define to 1 if `tm_zone' is a member of `struct tm'. */ +#define HAVE_STRUCT_TM_TM_ZONE 1 + +/* Define to 1 if your `struct stat' has `st_blocks'. Deprecated, use + `HAVE_STRUCT_STAT_ST_BLOCKS' instead. */ +#define HAVE_ST_BLOCKS 1 + +/* Define if you have the 'symlink' function. */ +#define HAVE_SYMLINK 1 + +/* Define to 1 if you have the `sysconf' function. */ +#define HAVE_SYSCONF 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYSEXITS_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_AUDIOIO_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_BSDTTY_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +/* #undef HAVE_SYS_DIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_EPOLL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_EVENT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_FILE_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_LOADAVG_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_LOCK_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_MKDEV_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_MODEM_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +/* #undef HAVE_SYS_NDIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_PARAM_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_POLL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_RESOURCE_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SELECT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SOCKET_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STATVFS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_TERMIO_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIMES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UN_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UTSNAME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_WAIT_H 1 + +/* Define to 1 if you have the `tcgetpgrp' function. */ +#define HAVE_TCGETPGRP 1 + +/* Define to 1 if you have the `tcsetpgrp' function. */ +#define HAVE_TCSETPGRP 1 + +/* Define to 1 if you have the `tempnam' function. */ +#define HAVE_TEMPNAM 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_TERMIOS_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_TERM_H */ + +/* Define to 1 if you have the `tgamma' function. */ +#define HAVE_TGAMMA 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_THREAD_H */ + +/* Define to 1 if you have the `timegm' function. */ +#define HAVE_TIMEGM 1 + +/* Define to 1 if you have the `times' function. */ +#define HAVE_TIMES 1 + +/* Define to 1 if you have the `tmpfile' function. */ +#define HAVE_TMPFILE 1 + +/* Define to 1 if you have the `tmpnam' function. */ +#define HAVE_TMPNAM 1 + +/* Define to 1 if you have the `tmpnam_r' function. */ +/* #undef HAVE_TMPNAM_R */ + +/* Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use + `HAVE_STRUCT_TM_TM_ZONE' instead. */ +#define HAVE_TM_ZONE 1 + +/* Define to 1 if you have the `truncate' function. */ +#define HAVE_TRUNCATE 1 + +/* Define to 1 if you don't have `tm_zone' but do have the external array + `tzname'. */ +/* #undef HAVE_TZNAME */ + +/* Define this if you have tcl and TCL_UTF_MAX==6 */ +/* #undef HAVE_UCS4_TCL */ + +/* Define if your compiler provides uint32_t. */ +#define HAVE_UINT32_T 1 + +/* Define if your compiler provides uint64_t. */ +#define HAVE_UINT64_T 1 + +/* Define to 1 if the system has the type `uintptr_t'. */ +#define HAVE_UINTPTR_T 1 + +/* Define to 1 if you have the `uname' function. */ +#define HAVE_UNAME 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you have the `unsetenv' function. */ +#define HAVE_UNSETENV 1 + +/* Define if you have a useable wchar_t type defined in wchar.h; useable means + wchar_t must be an unsigned type with at least 16 bits. (see + Include/unicodeobject.h). */ +/* #undef HAVE_USABLE_WCHAR_T */ + +/* Define to 1 if you have the header file. */ +#define HAVE_UTIL_H 1 + +/* Define to 1 if you have the `utimes' function. */ +#define HAVE_UTIMES 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UTIME_H 1 + +/* Define to 1 if you have the `wait3' function. */ +/* #undef HAVE_WAIT3 */ + +/* Define to 1 if you have the `wait4' function. */ +#define HAVE_WAIT4 1 + +/* Define to 1 if you have the `waitpid' function. */ +#define HAVE_WAITPID 1 + +/* Define if the compiler provides a wchar.h header file. */ +#define HAVE_WCHAR_H 1 + +/* Define to 1 if you have the `wcscoll' function. */ +#define HAVE_WCSCOLL 1 + +/* Define if tzset() actually switches the local timezone in a meaningful way. + */ +/* #undef HAVE_WORKING_TZSET */ + +/* Define if the zlib library has inflateCopy */ +#define HAVE_ZLIB_COPY 1 + +/* Define to 1 if you have the `_getpty' function. */ +/* #undef HAVE__GETPTY */ + +/* Define if you are using Mach cthreads directly under /include */ +/* #undef HURD_C_THREADS */ + +/* Define if you are using Mach cthreads under mach / */ +/* #undef MACH_C_THREADS */ + +/* Define to 1 if `major', `minor', and `makedev' are declared in . + */ +/* #undef MAJOR_IN_MKDEV */ + +/* Define to 1 if `major', `minor', and `makedev' are declared in + . */ +#define MAJOR_IN_SYSMACROS 1 + +/* Define if mvwdelch in curses.h is an expression. */ +/* #undef MVWDELCH_IS_EXPRESSION */ + +/* Define to the address where bug reports for this package should be sent. */ +/* #undef PACKAGE_BUGREPORT */ + +/* Define to the full name of this package. */ +/* #undef PACKAGE_NAME */ + +/* Define to the full name and version of this package. */ +/* #undef PACKAGE_STRING */ + +/* Define to the one symbol short name of this package. */ +/* #undef PACKAGE_TARNAME */ + +/* Define to the home page for this package. */ +/* #undef PACKAGE_URL */ + +/* Define to the version of this package. */ +/* #undef PACKAGE_VERSION */ + +/* Define if POSIX semaphores aren't enabled on your system */ +/* #undef POSIX_SEMAPHORES_NOT_ENABLED */ + +/* Defined if PTHREAD_SCOPE_SYSTEM supported. */ +/* #undef PTHREAD_SYSTEM_SCHED_SUPPORTED */ + +/* Define as the preferred size in bits of long digits */ +/* #undef PYLONG_BITS_IN_DIGIT */ + +/* Define to printf format modifier for long long type */ +#define PY_FORMAT_LONG_LONG "ll" + +/* Define to printf format modifier for Py_ssize_t */ +#define PY_FORMAT_SIZE_T "z" + +/* Define as the integral type used for Unicode representation. */ +/* #undef PY_UNICODE_TYPE */ + +/* Define if you want to build an interpreter with many run-time checks. */ +/* #undef Py_DEBUG */ + +/* Defined if Python is built as a shared library. */ +#define Py_ENABLE_SHARED 1 + +/* Define as the size of the unicode type. */ +#define Py_UNICODE_SIZE 4 + +/* Define if you want to have a Unicode type. */ +#define Py_USING_UNICODE 1 + +/* assume C89 semantics that RETSIGTYPE is always void */ +#define RETSIGTYPE void + +/* Define if setpgrp() must be called as setpgrp(0, 0). */ +/* #undef SETPGRP_HAVE_ARG */ + +/* Define this to be extension of shared libraries (including the dot!). */ +#define SHLIB_EXT ".so" + +/* Define if i>>j for signed int i does not extend the sign bit when i < 0 */ +/* #undef SIGNED_RIGHT_SHIFT_ZERO_FILLS */ + +/* The size of `double', as computed by sizeof. */ +#define SIZEOF_DOUBLE 8 + +/* The size of `float', as computed by sizeof. */ +#define SIZEOF_FLOAT 4 + +/* The size of `fpos_t', as computed by sizeof. */ +#define SIZEOF_FPOS_T 8 + +/* The size of `int', as computed by sizeof. */ +#define SIZEOF_INT 4 + +/* The size of `long', as computed by sizeof. */ +#define SIZEOF_LONG 8 + +/* The size of `long double', as computed by sizeof. */ +#define SIZEOF_LONG_DOUBLE 16 + +/* The size of `long long', as computed by sizeof. */ +#define SIZEOF_LONG_LONG 8 + +/* The size of `off_t', as computed by sizeof. */ +#define SIZEOF_OFF_T 8 + +/* The size of `pid_t', as computed by sizeof. */ +#define SIZEOF_PID_T 4 + +/* The size of `pthread_t', as computed by sizeof. */ +#define SIZEOF_PTHREAD_T 8 + +/* The size of `short', as computed by sizeof. */ +#define SIZEOF_SHORT 2 + +/* The size of `size_t', as computed by sizeof. */ +#define SIZEOF_SIZE_T 8 + +/* The size of `time_t', as computed by sizeof. */ +#define SIZEOF_TIME_T 8 + +/* The size of `uintptr_t', as computed by sizeof. */ +#define SIZEOF_UINTPTR_T 8 + +/* The size of `void *', as computed by sizeof. */ +#define SIZEOF_VOID_P 8 + +/* The size of `wchar_t', as computed by sizeof. */ +#define SIZEOF_WCHAR_T 4 + +/* The size of `_Bool', as computed by sizeof. */ +#define SIZEOF__BOOL 1 + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define if you can safely include both and + (which you can't on SCO ODT 3.0). */ +#define SYS_SELECT_WITH_SYS_TIME 1 + +/* Define if tanh(-0.) is -0., or if platform doesn't have signed zeros */ +/* #undef TANH_PRESERVES_ZERO_SIGN */ + +/* Define to 1 if you can safely include both and . */ +#define TIME_WITH_SYS_TIME 1 + +/* Define to 1 if your declares `struct tm'. */ +/* #undef TM_IN_SYS_TIME */ + +/* Enable extensions on AIX 3, Interix. */ +#ifndef _ALL_SOURCE +# define _ALL_SOURCE 1 +#endif +/* Enable GNU extensions on systems that have them. */ +#ifndef _GNU_SOURCE +# define _GNU_SOURCE 1 +#endif +/* Enable threading extensions on Solaris. */ +#ifndef _POSIX_PTHREAD_SEMANTICS +# define _POSIX_PTHREAD_SEMANTICS 1 +#endif +/* Enable extensions on HP NonStop. */ +#ifndef _TANDEM_SOURCE +# define _TANDEM_SOURCE 1 +#endif +/* Enable general extensions on Solaris. */ +#ifndef __EXTENSIONS__ +# define __EXTENSIONS__ 1 +#endif + + +/* Define if you want to use MacPython modules on MacOSX in unix-Python. */ +/* #undef USE_TOOLBOX_OBJECT_GLUE */ + +/* Define if a va_list is an array of some kind */ +#define VA_LIST_IS_ARRAY 1 + +/* Define if you want SIGFPE handled (see Include/pyfpe.h). */ +/* #undef WANT_SIGFPE_HANDLER */ + +/* Define if you want wctype.h functions to be used instead of the one + supplied by Python itself. (see Include/unicodectype.h). */ +/* #undef WANT_WCTYPE_FUNCTIONS */ + +/* Define if WINDOW in curses.h offers a field _flags. */ +/* #undef WINDOW_HAS_FLAGS */ + +/* Define if you want documentation strings in extension modules */ +#define WITH_DOC_STRINGS 1 + +/* Define if you want to use the new-style (Openstep, Rhapsody, MacOS) dynamic + linker (dyld) instead of the old-style (NextStep) dynamic linker (rld). + Dyld is necessary to support frameworks. */ +/* #undef WITH_DYLD */ + +/* Define to 1 if libintl is needed for locale functions. */ +/* #undef WITH_LIBINTL */ + +/* Define if you want to produce an OpenStep/Rhapsody framework (shared + library plus accessory files). */ +/* #undef WITH_NEXT_FRAMEWORK */ + +/* Define if you want to compile in Python-specific mallocs */ +#define WITH_PYMALLOC 1 + +/* Define if you want to compile in rudimentary thread support */ +#define WITH_THREAD 1 + +/* Define to profile with the Pentium timestamp counter */ +/* #undef WITH_TSC */ + +/* Define if you want pymalloc to be disabled when running under valgrind */ +/* #undef WITH_VALGRIND */ + +/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most + significant byte first (like Motorola and SPARC, unlike Intel). */ +#if defined AC_APPLE_UNIVERSAL_BUILD +# if defined __BIG_ENDIAN__ +# define WORDS_BIGENDIAN 1 +# endif +#else +# ifndef WORDS_BIGENDIAN +/* # undef WORDS_BIGENDIAN */ +# endif +#endif + +/* Define if arithmetic is subject to x87-style double rounding issue */ +/* #undef X87_DOUBLE_ROUNDING */ + +/* Define on OpenBSD to activate all library features */ +/* #undef _BSD_SOURCE */ + +/* Define on Irix to enable u_int */ +#define _BSD_TYPES 1 + +/* Define on Darwin to activate all library features */ +#define _DARWIN_C_SOURCE 1 + +/* This must be set to 64 on some systems to enable large file support. */ +#define _FILE_OFFSET_BITS 64 + +/* Define on Linux to activate all library features */ +#define _GNU_SOURCE 1 + +/* This must be defined on some systems to enable large file support. */ +#define _LARGEFILE_SOURCE 1 + +/* This must be defined on AIX systems to enable large file support. */ +/* #undef _LARGE_FILES */ + +/* Define to 1 if on MINIX. */ +/* #undef _MINIX */ + +/* Define on NetBSD to activate all library features */ +#define _NETBSD_SOURCE 1 + +/* Define _OSF_SOURCE to get the makedev macro. */ +/* #undef _OSF_SOURCE */ + +/* Define to 2 if the system does not provide POSIX.1 features except with + this defined. */ +/* #undef _POSIX_1_SOURCE */ + +/* Define to activate features from IEEE Stds 1003.1-2001 */ +#define _POSIX_C_SOURCE 200112L + +/* Define to 1 if you need to in order for `stat' and other things to work. */ +/* #undef _POSIX_SOURCE */ + +/* Define if you have POSIX threads, and your system does not define that. */ +/* #undef _POSIX_THREADS */ + +/* Define to force use of thread-safe errno, h_errno, and other functions */ +#define _REENTRANT 1 + +/* Define for Solaris 2.5.1 so the uint32_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +/* #undef _UINT32_T */ + +/* Define for Solaris 2.5.1 so the uint64_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +/* #undef _UINT64_T */ + +/* Define to the level of X/Open that your system supports */ +#define _XOPEN_SOURCE 600 + +/* Define to activate Unix95-and-earlier features */ +#define _XOPEN_SOURCE_EXTENDED 1 + +/* Define on FreeBSD to activate all library features */ +#define __BSD_VISIBLE 1 + +/* Define to 1 if type `char' is unsigned and you are not using gcc. */ +#ifndef __CHAR_UNSIGNED__ +/* # undef __CHAR_UNSIGNED__ */ +#endif + +/* Defined on Solaris to see additional function prototypes. */ +#define __EXTENSIONS__ 1 + +/* Define to 'long' if doesn't define. */ +/* #undef clock_t */ + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ + +/* Define to `int' if doesn't define. */ +/* #undef gid_t */ + +/* Define to the type of a signed integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +/* #undef int32_t */ + +/* Define to the type of a signed integer type of width exactly 64 bits if + such a type exists and the standard includes do not define it. */ +/* #undef int64_t */ + +/* Define to `int' if does not define. */ +/* #undef mode_t */ + +/* Define to `long int' if does not define. */ +/* #undef off_t */ + +/* Define to `int' if does not define. */ +/* #undef pid_t */ + +/* Define to empty if the keyword does not work. */ +/* #undef signed */ + +/* Define to `unsigned int' if does not define. */ +/* #undef size_t */ + +/* Define to `int' if does not define. */ +/* #undef socklen_t */ + +/* Define to `int' if doesn't define. */ +/* #undef uid_t */ + +/* Define to the type of an unsigned integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint32_t */ + +/* Define to the type of an unsigned integer type of width exactly 64 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint64_t */ + +/* Define to empty if the keyword does not work. */ +/* #undef volatile */ + + +/* Define the macros needed if on a UnixWare 7.x system. */ +#if defined(__USLC__) && defined(__SCO_VERSION__) +#define STRICT_SYSV_CURSES /* Don't use ncurses extensions */ +#endif + +#endif /*Py_PYCONFIG_H*/ + diff --git a/android/python27/include/pyctype.h b/android/python27/include/pyctype.h new file mode 100644 index 000000000..673cf2eb0 --- /dev/null +++ b/android/python27/include/pyctype.h @@ -0,0 +1,31 @@ +#ifndef PYCTYPE_H +#define PYCTYPE_H + +#define PY_CTF_LOWER 0x01 +#define PY_CTF_UPPER 0x02 +#define PY_CTF_ALPHA (PY_CTF_LOWER|PY_CTF_UPPER) +#define PY_CTF_DIGIT 0x04 +#define PY_CTF_ALNUM (PY_CTF_ALPHA|PY_CTF_DIGIT) +#define PY_CTF_SPACE 0x08 +#define PY_CTF_XDIGIT 0x10 + +PyAPI_DATA(const unsigned int) _Py_ctype_table[256]; + +/* Unlike their C counterparts, the following macros are not meant to + * handle an int with any of the values [EOF, 0-UCHAR_MAX]. The argument + * must be a signed/unsigned char. */ +#define Py_ISLOWER(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_LOWER) +#define Py_ISUPPER(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_UPPER) +#define Py_ISALPHA(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_ALPHA) +#define Py_ISDIGIT(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_DIGIT) +#define Py_ISXDIGIT(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_XDIGIT) +#define Py_ISALNUM(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_ALNUM) +#define Py_ISSPACE(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_SPACE) + +PyAPI_DATA(const unsigned char) _Py_ctype_tolower[256]; +PyAPI_DATA(const unsigned char) _Py_ctype_toupper[256]; + +#define Py_TOLOWER(c) (_Py_ctype_tolower[Py_CHARMASK(c)]) +#define Py_TOUPPER(c) (_Py_ctype_toupper[Py_CHARMASK(c)]) + +#endif /* !PYCTYPE_H */ diff --git a/android/python27/include/pydebug.h b/android/python27/include/pydebug.h new file mode 100644 index 000000000..0f45960f9 --- /dev/null +++ b/android/python27/include/pydebug.h @@ -0,0 +1,41 @@ + +#ifndef Py_PYDEBUG_H +#define Py_PYDEBUG_H +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_DATA(int) Py_DebugFlag; +PyAPI_DATA(int) Py_VerboseFlag; +PyAPI_DATA(int) Py_InteractiveFlag; +PyAPI_DATA(int) Py_InspectFlag; +PyAPI_DATA(int) Py_OptimizeFlag; +PyAPI_DATA(int) Py_NoSiteFlag; +PyAPI_DATA(int) Py_BytesWarningFlag; +PyAPI_DATA(int) Py_UseClassExceptionsFlag; +PyAPI_DATA(int) Py_FrozenFlag; +PyAPI_DATA(int) Py_TabcheckFlag; +PyAPI_DATA(int) Py_UnicodeFlag; +PyAPI_DATA(int) Py_IgnoreEnvironmentFlag; +PyAPI_DATA(int) Py_DivisionWarningFlag; +PyAPI_DATA(int) Py_DontWriteBytecodeFlag; +PyAPI_DATA(int) Py_NoUserSiteDirectory; +/* _XXX Py_QnewFlag should go away in 3.0. It's true iff -Qnew is passed, + on the command line, and is used in 2.2 by ceval.c to make all "/" divisions + true divisions (which they will be in 3.0). */ +PyAPI_DATA(int) _Py_QnewFlag; +/* Warn about 3.x issues */ +PyAPI_DATA(int) Py_Py3kWarningFlag; +PyAPI_DATA(int) Py_HashRandomizationFlag; + +/* this is a wrapper around getenv() that pays attention to + Py_IgnoreEnvironmentFlag. It should be used for getting variables like + PYTHONPATH and PYTHONHOME from the environment */ +#define Py_GETENV(s) (Py_IgnoreEnvironmentFlag ? NULL : getenv(s)) + +PyAPI_FUNC(void) Py_FatalError(const char *message); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_PYDEBUG_H */ diff --git a/android/python27/include/pyerrors.h b/android/python27/include/pyerrors.h new file mode 100644 index 000000000..2ef205ea4 --- /dev/null +++ b/android/python27/include/pyerrors.h @@ -0,0 +1,329 @@ +#ifndef Py_ERRORS_H +#define Py_ERRORS_H +#ifdef __cplusplus +extern "C" { +#endif + +/* Error objects */ + +typedef struct { + PyObject_HEAD + PyObject *dict; + PyObject *args; + PyObject *message; +} PyBaseExceptionObject; + +typedef struct { + PyObject_HEAD + PyObject *dict; + PyObject *args; + PyObject *message; + PyObject *msg; + PyObject *filename; + PyObject *lineno; + PyObject *offset; + PyObject *text; + PyObject *print_file_and_line; +} PySyntaxErrorObject; + +#ifdef Py_USING_UNICODE +typedef struct { + PyObject_HEAD + PyObject *dict; + PyObject *args; + PyObject *message; + PyObject *encoding; + PyObject *object; + Py_ssize_t start; + Py_ssize_t end; + PyObject *reason; +} PyUnicodeErrorObject; +#endif + +typedef struct { + PyObject_HEAD + PyObject *dict; + PyObject *args; + PyObject *message; + PyObject *code; +} PySystemExitObject; + +typedef struct { + PyObject_HEAD + PyObject *dict; + PyObject *args; + PyObject *message; + PyObject *myerrno; + PyObject *strerror; + PyObject *filename; +} PyEnvironmentErrorObject; + +#ifdef MS_WINDOWS +typedef struct { + PyObject_HEAD + PyObject *dict; + PyObject *args; + PyObject *message; + PyObject *myerrno; + PyObject *strerror; + PyObject *filename; + PyObject *winerror; +} PyWindowsErrorObject; +#endif + +/* Error handling definitions */ + +PyAPI_FUNC(void) PyErr_SetNone(PyObject *); +PyAPI_FUNC(void) PyErr_SetObject(PyObject *, PyObject *); +PyAPI_FUNC(void) PyErr_SetString(PyObject *, const char *); +PyAPI_FUNC(PyObject *) PyErr_Occurred(void); +PyAPI_FUNC(void) PyErr_Clear(void); +PyAPI_FUNC(void) PyErr_Fetch(PyObject **, PyObject **, PyObject **); +PyAPI_FUNC(void) PyErr_Restore(PyObject *, PyObject *, PyObject *); + +#ifdef Py_DEBUG +#define _PyErr_OCCURRED() PyErr_Occurred() +#else +#define _PyErr_OCCURRED() (_PyThreadState_Current->curexc_type) +#endif + +/* Error testing and normalization */ +PyAPI_FUNC(int) PyErr_GivenExceptionMatches(PyObject *, PyObject *); +PyAPI_FUNC(int) PyErr_ExceptionMatches(PyObject *); +PyAPI_FUNC(void) PyErr_NormalizeException(PyObject**, PyObject**, PyObject**); +PyAPI_FUNC(void) _PyErr_ReplaceException(PyObject *, PyObject *, PyObject *); + +/* */ + +#define PyExceptionClass_Check(x) \ + (PyClass_Check((x)) || (PyType_Check((x)) && \ + PyType_FastSubclass((PyTypeObject*)(x), Py_TPFLAGS_BASE_EXC_SUBCLASS))) + +#define PyExceptionInstance_Check(x) \ + (PyInstance_Check((x)) || \ + PyType_FastSubclass((x)->ob_type, Py_TPFLAGS_BASE_EXC_SUBCLASS)) + +#define PyExceptionClass_Name(x) \ + (PyClass_Check((x)) \ + ? PyString_AS_STRING(((PyClassObject*)(x))->cl_name) \ + : (char *)(((PyTypeObject*)(x))->tp_name)) + +#define PyExceptionInstance_Class(x) \ + ((PyInstance_Check((x)) \ + ? (PyObject*)((PyInstanceObject*)(x))->in_class \ + : (PyObject*)((x)->ob_type))) + + +/* Predefined exceptions */ + +PyAPI_DATA(PyObject *) PyExc_BaseException; +PyAPI_DATA(PyObject *) PyExc_Exception; +PyAPI_DATA(PyObject *) PyExc_StopIteration; +PyAPI_DATA(PyObject *) PyExc_GeneratorExit; +PyAPI_DATA(PyObject *) PyExc_StandardError; +PyAPI_DATA(PyObject *) PyExc_ArithmeticError; +PyAPI_DATA(PyObject *) PyExc_LookupError; + +PyAPI_DATA(PyObject *) PyExc_AssertionError; +PyAPI_DATA(PyObject *) PyExc_AttributeError; +PyAPI_DATA(PyObject *) PyExc_EOFError; +PyAPI_DATA(PyObject *) PyExc_FloatingPointError; +PyAPI_DATA(PyObject *) PyExc_EnvironmentError; +PyAPI_DATA(PyObject *) PyExc_IOError; +PyAPI_DATA(PyObject *) PyExc_OSError; +PyAPI_DATA(PyObject *) PyExc_ImportError; +PyAPI_DATA(PyObject *) PyExc_IndexError; +PyAPI_DATA(PyObject *) PyExc_KeyError; +PyAPI_DATA(PyObject *) PyExc_KeyboardInterrupt; +PyAPI_DATA(PyObject *) PyExc_MemoryError; +PyAPI_DATA(PyObject *) PyExc_NameError; +PyAPI_DATA(PyObject *) PyExc_OverflowError; +PyAPI_DATA(PyObject *) PyExc_RuntimeError; +PyAPI_DATA(PyObject *) PyExc_NotImplementedError; +PyAPI_DATA(PyObject *) PyExc_SyntaxError; +PyAPI_DATA(PyObject *) PyExc_IndentationError; +PyAPI_DATA(PyObject *) PyExc_TabError; +PyAPI_DATA(PyObject *) PyExc_ReferenceError; +PyAPI_DATA(PyObject *) PyExc_SystemError; +PyAPI_DATA(PyObject *) PyExc_SystemExit; +PyAPI_DATA(PyObject *) PyExc_TypeError; +PyAPI_DATA(PyObject *) PyExc_UnboundLocalError; +PyAPI_DATA(PyObject *) PyExc_UnicodeError; +PyAPI_DATA(PyObject *) PyExc_UnicodeEncodeError; +PyAPI_DATA(PyObject *) PyExc_UnicodeDecodeError; +PyAPI_DATA(PyObject *) PyExc_UnicodeTranslateError; +PyAPI_DATA(PyObject *) PyExc_ValueError; +PyAPI_DATA(PyObject *) PyExc_ZeroDivisionError; +#ifdef MS_WINDOWS +PyAPI_DATA(PyObject *) PyExc_WindowsError; +#endif +#ifdef __VMS +PyAPI_DATA(PyObject *) PyExc_VMSError; +#endif + +PyAPI_DATA(PyObject *) PyExc_BufferError; + +PyAPI_DATA(PyObject *) PyExc_MemoryErrorInst; +PyAPI_DATA(PyObject *) PyExc_RecursionErrorInst; + +/* Predefined warning categories */ +PyAPI_DATA(PyObject *) PyExc_Warning; +PyAPI_DATA(PyObject *) PyExc_UserWarning; +PyAPI_DATA(PyObject *) PyExc_DeprecationWarning; +PyAPI_DATA(PyObject *) PyExc_PendingDeprecationWarning; +PyAPI_DATA(PyObject *) PyExc_SyntaxWarning; +PyAPI_DATA(PyObject *) PyExc_RuntimeWarning; +PyAPI_DATA(PyObject *) PyExc_FutureWarning; +PyAPI_DATA(PyObject *) PyExc_ImportWarning; +PyAPI_DATA(PyObject *) PyExc_UnicodeWarning; +PyAPI_DATA(PyObject *) PyExc_BytesWarning; + + +/* Convenience functions */ + +PyAPI_FUNC(int) PyErr_BadArgument(void); +PyAPI_FUNC(PyObject *) PyErr_NoMemory(void); +PyAPI_FUNC(PyObject *) PyErr_SetFromErrno(PyObject *); +PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithFilenameObject( + PyObject *, PyObject *); +PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithFilename( + PyObject *, const char *); +#ifdef MS_WINDOWS +PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithUnicodeFilename( + PyObject *, const Py_UNICODE *); +#endif /* MS_WINDOWS */ + +PyAPI_FUNC(PyObject *) PyErr_Format(PyObject *, const char *, ...) + Py_GCC_ATTRIBUTE((format(printf, 2, 3))); + +#ifdef MS_WINDOWS +PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithFilenameObject( + int, const char *); +PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithFilename( + int, const char *); +PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithUnicodeFilename( + int, const Py_UNICODE *); +PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErr(int); +PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithFilenameObject( + PyObject *,int, PyObject *); +PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithFilename( + PyObject *,int, const char *); +PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithUnicodeFilename( + PyObject *,int, const Py_UNICODE *); +PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErr(PyObject *, int); +#endif /* MS_WINDOWS */ + +/* Export the old function so that the existing API remains available: */ +PyAPI_FUNC(void) PyErr_BadInternalCall(void); +PyAPI_FUNC(void) _PyErr_BadInternalCall(char *filename, int lineno); +/* Mask the old API with a call to the new API for code compiled under + Python 2.0: */ +#define PyErr_BadInternalCall() _PyErr_BadInternalCall(__FILE__, __LINE__) + +/* Function to create a new exception */ +PyAPI_FUNC(PyObject *) PyErr_NewException( + char *name, PyObject *base, PyObject *dict); +PyAPI_FUNC(PyObject *) PyErr_NewExceptionWithDoc( + char *name, char *doc, PyObject *base, PyObject *dict); +PyAPI_FUNC(void) PyErr_WriteUnraisable(PyObject *); + +/* In sigcheck.c or signalmodule.c */ +PyAPI_FUNC(int) PyErr_CheckSignals(void); +PyAPI_FUNC(void) PyErr_SetInterrupt(void); + +/* In signalmodule.c */ +int PySignal_SetWakeupFd(int fd); + +/* Support for adding program text to SyntaxErrors */ +PyAPI_FUNC(void) PyErr_SyntaxLocation(const char *, int); +PyAPI_FUNC(PyObject *) PyErr_ProgramText(const char *, int); + +#ifdef Py_USING_UNICODE +/* The following functions are used to create and modify unicode + exceptions from C */ + +/* create a UnicodeDecodeError object */ +PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_Create( + const char *, const char *, Py_ssize_t, Py_ssize_t, Py_ssize_t, const char *); + +/* create a UnicodeEncodeError object */ +PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_Create( + const char *, const Py_UNICODE *, Py_ssize_t, Py_ssize_t, Py_ssize_t, const char *); + +/* create a UnicodeTranslateError object */ +PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_Create( + const Py_UNICODE *, Py_ssize_t, Py_ssize_t, Py_ssize_t, const char *); + +/* get the encoding attribute */ +PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_GetEncoding(PyObject *); +PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_GetEncoding(PyObject *); + +/* get the object attribute */ +PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_GetObject(PyObject *); +PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_GetObject(PyObject *); +PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_GetObject(PyObject *); + +/* get the value of the start attribute (the int * may not be NULL) + return 0 on success, -1 on failure */ +PyAPI_FUNC(int) PyUnicodeEncodeError_GetStart(PyObject *, Py_ssize_t *); +PyAPI_FUNC(int) PyUnicodeDecodeError_GetStart(PyObject *, Py_ssize_t *); +PyAPI_FUNC(int) PyUnicodeTranslateError_GetStart(PyObject *, Py_ssize_t *); + +/* assign a new value to the start attribute + return 0 on success, -1 on failure */ +PyAPI_FUNC(int) PyUnicodeEncodeError_SetStart(PyObject *, Py_ssize_t); +PyAPI_FUNC(int) PyUnicodeDecodeError_SetStart(PyObject *, Py_ssize_t); +PyAPI_FUNC(int) PyUnicodeTranslateError_SetStart(PyObject *, Py_ssize_t); + +/* get the value of the end attribute (the int *may not be NULL) + return 0 on success, -1 on failure */ +PyAPI_FUNC(int) PyUnicodeEncodeError_GetEnd(PyObject *, Py_ssize_t *); +PyAPI_FUNC(int) PyUnicodeDecodeError_GetEnd(PyObject *, Py_ssize_t *); +PyAPI_FUNC(int) PyUnicodeTranslateError_GetEnd(PyObject *, Py_ssize_t *); + +/* assign a new value to the end attribute + return 0 on success, -1 on failure */ +PyAPI_FUNC(int) PyUnicodeEncodeError_SetEnd(PyObject *, Py_ssize_t); +PyAPI_FUNC(int) PyUnicodeDecodeError_SetEnd(PyObject *, Py_ssize_t); +PyAPI_FUNC(int) PyUnicodeTranslateError_SetEnd(PyObject *, Py_ssize_t); + +/* get the value of the reason attribute */ +PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_GetReason(PyObject *); +PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_GetReason(PyObject *); +PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_GetReason(PyObject *); + +/* assign a new value to the reason attribute + return 0 on success, -1 on failure */ +PyAPI_FUNC(int) PyUnicodeEncodeError_SetReason( + PyObject *, const char *); +PyAPI_FUNC(int) PyUnicodeDecodeError_SetReason( + PyObject *, const char *); +PyAPI_FUNC(int) PyUnicodeTranslateError_SetReason( + PyObject *, const char *); +#endif + + +/* These APIs aren't really part of the error implementation, but + often needed to format error messages; the native C lib APIs are + not available on all platforms, which is why we provide emulations + for those platforms in Python/mysnprintf.c, + WARNING: The return value of snprintf varies across platforms; do + not rely on any particular behavior; eventually the C99 defn may + be reliable. +*/ +#if defined(MS_WIN32) && !defined(HAVE_SNPRINTF) +# define HAVE_SNPRINTF +# define snprintf _snprintf +# define vsnprintf _vsnprintf +#endif + +#include +PyAPI_FUNC(int) PyOS_snprintf(char *str, size_t size, const char *format, ...) + Py_GCC_ATTRIBUTE((format(printf, 3, 4))); +PyAPI_FUNC(int) PyOS_vsnprintf(char *str, size_t size, const char *format, va_list va) + Py_GCC_ATTRIBUTE((format(printf, 3, 0))); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_ERRORS_H */ diff --git a/android/python27/include/pyexpat.h b/android/python27/include/pyexpat.h new file mode 100644 index 000000000..5340ef5fa --- /dev/null +++ b/android/python27/include/pyexpat.h @@ -0,0 +1,48 @@ +/* Stuff to export relevant 'expat' entry points from pyexpat to other + * parser modules, such as cElementTree. */ + +/* note: you must import expat.h before importing this module! */ + +#define PyExpat_CAPI_MAGIC "pyexpat.expat_CAPI 1.0" +#define PyExpat_CAPSULE_NAME "pyexpat.expat_CAPI" + +struct PyExpat_CAPI +{ + char* magic; /* set to PyExpat_CAPI_MAGIC */ + int size; /* set to sizeof(struct PyExpat_CAPI) */ + int MAJOR_VERSION; + int MINOR_VERSION; + int MICRO_VERSION; + /* pointers to selected expat functions. add new functions at + the end, if needed */ + const XML_LChar * (*ErrorString)(enum XML_Error code); + enum XML_Error (*GetErrorCode)(XML_Parser parser); + XML_Size (*GetErrorColumnNumber)(XML_Parser parser); + XML_Size (*GetErrorLineNumber)(XML_Parser parser); + enum XML_Status (*Parse)( + XML_Parser parser, const char *s, int len, int isFinal); + XML_Parser (*ParserCreate_MM)( + const XML_Char *encoding, const XML_Memory_Handling_Suite *memsuite, + const XML_Char *namespaceSeparator); + void (*ParserFree)(XML_Parser parser); + void (*SetCharacterDataHandler)( + XML_Parser parser, XML_CharacterDataHandler handler); + void (*SetCommentHandler)( + XML_Parser parser, XML_CommentHandler handler); + void (*SetDefaultHandlerExpand)( + XML_Parser parser, XML_DefaultHandler handler); + void (*SetElementHandler)( + XML_Parser parser, XML_StartElementHandler start, + XML_EndElementHandler end); + void (*SetNamespaceDeclHandler)( + XML_Parser parser, XML_StartNamespaceDeclHandler start, + XML_EndNamespaceDeclHandler end); + void (*SetProcessingInstructionHandler)( + XML_Parser parser, XML_ProcessingInstructionHandler handler); + void (*SetUnknownEncodingHandler)( + XML_Parser parser, XML_UnknownEncodingHandler handler, + void *encodingHandlerData); + void (*SetUserData)(XML_Parser parser, void *userData); + /* always add new stuff to the end! */ +}; + diff --git a/android/python27/include/pyfpe.h b/android/python27/include/pyfpe.h new file mode 100644 index 000000000..e957119dd --- /dev/null +++ b/android/python27/include/pyfpe.h @@ -0,0 +1,176 @@ +#ifndef Py_PYFPE_H +#define Py_PYFPE_H +#ifdef __cplusplus +extern "C" { +#endif +/* + --------------------------------------------------------------------- + / Copyright (c) 1996. \ + | The Regents of the University of California. | + | All rights reserved. | + | | + | Permission to use, copy, modify, and distribute this software for | + | any purpose without fee is hereby granted, provided that this en- | + | tire notice is included in all copies of any software which is or | + | includes a copy or modification of this software and in all | + | copies of the supporting documentation for such software. | + | | + | This work was produced at the University of California, Lawrence | + | Livermore National Laboratory under contract no. W-7405-ENG-48 | + | between the U.S. Department of Energy and The Regents of the | + | University of California for the operation of UC LLNL. | + | | + | DISCLAIMER | + | | + | This software was prepared as an account of work sponsored by an | + | agency of the United States Government. Neither the United States | + | Government nor the University of California nor any of their em- | + | ployees, makes any warranty, express or implied, or assumes any | + | liability or responsibility for the accuracy, completeness, or | + | usefulness of any information, apparatus, product, or process | + | disclosed, or represents that its use would not infringe | + | privately-owned rights. Reference herein to any specific commer- | + | cial products, process, or service by trade name, trademark, | + | manufacturer, or otherwise, does not necessarily constitute or | + | imply its endorsement, recommendation, or favoring by the United | + | States Government or the University of California. The views and | + | opinions of authors expressed herein do not necessarily state or | + | reflect those of the United States Government or the University | + | of California, and shall not be used for advertising or product | + \ endorsement purposes. / + --------------------------------------------------------------------- +*/ + +/* + * Define macros for handling SIGFPE. + * Lee Busby, LLNL, November, 1996 + * busby1@llnl.gov + * + ********************************************* + * Overview of the system for handling SIGFPE: + * + * This file (Include/pyfpe.h) defines a couple of "wrapper" macros for + * insertion into your Python C code of choice. Their proper use is + * discussed below. The file Python/pyfpe.c defines a pair of global + * variables PyFPE_jbuf and PyFPE_counter which are used by the signal + * handler for SIGFPE to decide if a particular exception was protected + * by the macros. The signal handler itself, and code for enabling the + * generation of SIGFPE in the first place, is in a (new) Python module + * named fpectl. This module is standard in every respect. It can be loaded + * either statically or dynamically as you choose, and like any other + * Python module, has no effect until you import it. + * + * In the general case, there are three steps toward handling SIGFPE in any + * Python code: + * + * 1) Add the *_PROTECT macros to your C code as required to protect + * dangerous floating point sections. + * + * 2) Turn on the inclusion of the code by adding the ``--with-fpectl'' + * flag at the time you run configure. If the fpectl or other modules + * which use the *_PROTECT macros are to be dynamically loaded, be + * sure they are compiled with WANT_SIGFPE_HANDLER defined. + * + * 3) When python is built and running, import fpectl, and execute + * fpectl.turnon_sigfpe(). This sets up the signal handler and enables + * generation of SIGFPE whenever an exception occurs. From this point + * on, any properly trapped SIGFPE should result in the Python + * FloatingPointError exception. + * + * Step 1 has been done already for the Python kernel code, and should be + * done soon for the NumPy array package. Step 2 is usually done once at + * python install time. Python's behavior with respect to SIGFPE is not + * changed unless you also do step 3. Thus you can control this new + * facility at compile time, or run time, or both. + * + ******************************** + * Using the macros in your code: + * + * static PyObject *foobar(PyObject *self,PyObject *args) + * { + * .... + * PyFPE_START_PROTECT("Error in foobar", return 0) + * result = dangerous_op(somearg1, somearg2, ...); + * PyFPE_END_PROTECT(result) + * .... + * } + * + * If a floating point error occurs in dangerous_op, foobar returns 0 (NULL), + * after setting the associated value of the FloatingPointError exception to + * "Error in foobar". ``Dangerous_op'' can be a single operation, or a block + * of code, function calls, or any combination, so long as no alternate + * return is possible before the PyFPE_END_PROTECT macro is reached. + * + * The macros can only be used in a function context where an error return + * can be recognized as signaling a Python exception. (Generally, most + * functions that return a PyObject * will qualify.) + * + * Guido's original design suggestion for PyFPE_START_PROTECT and + * PyFPE_END_PROTECT had them open and close a local block, with a locally + * defined jmp_buf and jmp_buf pointer. This would allow recursive nesting + * of the macros. The Ansi C standard makes it clear that such local + * variables need to be declared with the "volatile" type qualifier to keep + * setjmp from corrupting their values. Some current implementations seem + * to be more restrictive. For example, the HPUX man page for setjmp says + * + * Upon the return from a setjmp() call caused by a longjmp(), the + * values of any non-static local variables belonging to the routine + * from which setjmp() was called are undefined. Code which depends on + * such values is not guaranteed to be portable. + * + * I therefore decided on a more limited form of nesting, using a counter + * variable (PyFPE_counter) to keep track of any recursion. If an exception + * occurs in an ``inner'' pair of macros, the return will apparently + * come from the outermost level. + * + */ + +#ifdef WANT_SIGFPE_HANDLER +#include +#include +#include +extern jmp_buf PyFPE_jbuf; +extern int PyFPE_counter; +extern double PyFPE_dummy(void *); + +#define PyFPE_START_PROTECT(err_string, leave_stmt) \ +if (!PyFPE_counter++ && setjmp(PyFPE_jbuf)) { \ + PyErr_SetString(PyExc_FloatingPointError, err_string); \ + PyFPE_counter = 0; \ + leave_stmt; \ +} + +/* + * This (following) is a heck of a way to decrement a counter. However, + * unless the macro argument is provided, code optimizers will sometimes move + * this statement so that it gets executed *before* the unsafe expression + * which we're trying to protect. That pretty well messes things up, + * of course. + * + * If the expression(s) you're trying to protect don't happen to return a + * value, you will need to manufacture a dummy result just to preserve the + * correct ordering of statements. Note that the macro passes the address + * of its argument (so you need to give it something which is addressable). + * If your expression returns multiple results, pass the last such result + * to PyFPE_END_PROTECT. + * + * Note that PyFPE_dummy returns a double, which is cast to int. + * This seeming insanity is to tickle the Floating Point Unit (FPU). + * If an exception has occurred in a preceding floating point operation, + * some architectures (notably Intel 80x86) will not deliver the interrupt + * until the *next* floating point operation. This is painful if you've + * already decremented PyFPE_counter. + */ +#define PyFPE_END_PROTECT(v) PyFPE_counter -= (int)PyFPE_dummy(&(v)); + +#else + +#define PyFPE_START_PROTECT(err_string, leave_stmt) +#define PyFPE_END_PROTECT(v) + +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_PYFPE_H */ diff --git a/android/python27/include/pygetopt.h b/android/python27/include/pygetopt.h new file mode 100644 index 000000000..9860d360e --- /dev/null +++ b/android/python27/include/pygetopt.h @@ -0,0 +1,18 @@ + +#ifndef Py_PYGETOPT_H +#define Py_PYGETOPT_H +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_DATA(int) _PyOS_opterr; +PyAPI_DATA(int) _PyOS_optind; +PyAPI_DATA(char *) _PyOS_optarg; + +PyAPI_FUNC(void) _PyOS_ResetGetOpt(void); +PyAPI_FUNC(int) _PyOS_GetOpt(int argc, char **argv, char *optstring); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_PYGETOPT_H */ diff --git a/android/python27/include/pymacconfig.h b/android/python27/include/pymacconfig.h new file mode 100644 index 000000000..24e7b8dac --- /dev/null +++ b/android/python27/include/pymacconfig.h @@ -0,0 +1,102 @@ +#ifndef PYMACCONFIG_H +#define PYMACCONFIG_H + /* + * This file moves some of the autoconf magic to compile-time + * when building on MacOSX. This is needed for building 4-way + * universal binaries and for 64-bit universal binaries because + * the values redefined below aren't configure-time constant but + * only compile-time constant in these scenarios. + */ + +#if defined(__APPLE__) + +# undef SIZEOF_LONG +# undef SIZEOF_PTHREAD_T +# undef SIZEOF_SIZE_T +# undef SIZEOF_TIME_T +# undef SIZEOF_VOID_P +# undef SIZEOF__BOOL +# undef SIZEOF_UINTPTR_T +# undef SIZEOF_PTHREAD_T +# undef WORDS_BIGENDIAN +# undef DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754 +# undef DOUBLE_IS_BIG_ENDIAN_IEEE754 +# undef DOUBLE_IS_LITTLE_ENDIAN_IEEE754 +# undef HAVE_GCC_ASM_FOR_X87 + +# undef VA_LIST_IS_ARRAY +# if defined(__LP64__) && defined(__x86_64__) +# define VA_LIST_IS_ARRAY 1 +# endif + +# undef HAVE_LARGEFILE_SUPPORT +# ifndef __LP64__ +# define HAVE_LARGEFILE_SUPPORT 1 +# endif + +# undef SIZEOF_LONG +# ifdef __LP64__ +# define SIZEOF__BOOL 1 +# define SIZEOF__BOOL 1 +# define SIZEOF_LONG 8 +# define SIZEOF_PTHREAD_T 8 +# define SIZEOF_SIZE_T 8 +# define SIZEOF_TIME_T 8 +# define SIZEOF_VOID_P 8 +# define SIZEOF_UINTPTR_T 8 +# define SIZEOF_PTHREAD_T 8 +# else +# ifdef __ppc__ +# define SIZEOF__BOOL 4 +# else +# define SIZEOF__BOOL 1 +# endif +# define SIZEOF_LONG 4 +# define SIZEOF_PTHREAD_T 4 +# define SIZEOF_SIZE_T 4 +# define SIZEOF_TIME_T 4 +# define SIZEOF_VOID_P 4 +# define SIZEOF_UINTPTR_T 4 +# define SIZEOF_PTHREAD_T 4 +# endif + +# if defined(__LP64__) + /* MacOSX 10.4 (the first release to support 64-bit code + * at all) only supports 64-bit in the UNIX layer. + * Therefore surpress the toolbox-glue in 64-bit mode. + */ + + /* In 64-bit mode setpgrp always has no argments, in 32-bit + * mode that depends on the compilation environment + */ +# undef SETPGRP_HAVE_ARG + +# endif + +#ifdef __BIG_ENDIAN__ +#define WORDS_BIGENDIAN 1 +#define DOUBLE_IS_BIG_ENDIAN_IEEE754 +#else +#define DOUBLE_IS_LITTLE_ENDIAN_IEEE754 +#endif /* __BIG_ENDIAN */ + +#ifdef __i386__ +# define HAVE_GCC_ASM_FOR_X87 +#endif + + /* + * The definition in pyconfig.h is only valid on the OS release + * where configure ran on and not necessarily for all systems where + * the executable can be used on. + * + * Specifically: OSX 10.4 has limited supported for '%zd', while + * 10.5 has full support for '%zd'. A binary built on 10.5 won't + * work properly on 10.4 unless we surpress the definition + * of PY_FORMAT_SIZE_T + */ +#undef PY_FORMAT_SIZE_T + + +#endif /* defined(_APPLE__) */ + +#endif /* PYMACCONFIG_H */ diff --git a/android/python27/include/pymactoolbox.h b/android/python27/include/pymactoolbox.h new file mode 100644 index 000000000..fd1597527 --- /dev/null +++ b/android/python27/include/pymactoolbox.h @@ -0,0 +1,217 @@ +/* +** pymactoolbox.h - globals defined in mactoolboxglue.c +*/ +#ifndef Py_PYMACTOOLBOX_H +#define Py_PYMACTOOLBOX_H +#ifdef __cplusplus + extern "C" { +#endif + +#include + +#ifndef __LP64__ +#include +#endif /* !__LP64__ */ + +/* +** Helper routines for error codes and such. +*/ +char *PyMac_StrError(int); /* strerror with mac errors */ +extern PyObject *PyMac_OSErrException; /* Exception for OSErr */ +PyObject *PyMac_GetOSErrException(void); /* Initialize & return it */ +PyObject *PyErr_Mac(PyObject *, int); /* Exception with a mac error */ +PyObject *PyMac_Error(OSErr); /* Uses PyMac_GetOSErrException */ +#ifndef __LP64__ +extern OSErr PyMac_GetFullPathname(FSSpec *, char *, int); /* convert + fsspec->path */ +#endif /* __LP64__ */ + +/* +** These conversion routines are defined in mactoolboxglue.c itself. +*/ +int PyMac_GetOSType(PyObject *, OSType *); /* argument parser for OSType */ +PyObject *PyMac_BuildOSType(OSType); /* Convert OSType to PyObject */ + +PyObject *PyMac_BuildNumVersion(NumVersion);/* Convert NumVersion to PyObject */ + +int PyMac_GetStr255(PyObject *, Str255); /* argument parser for Str255 */ +PyObject *PyMac_BuildStr255(Str255); /* Convert Str255 to PyObject */ +PyObject *PyMac_BuildOptStr255(Str255); /* Convert Str255 to PyObject, + NULL to None */ + +int PyMac_GetRect(PyObject *, Rect *); /* argument parser for Rect */ +PyObject *PyMac_BuildRect(Rect *); /* Convert Rect to PyObject */ + +int PyMac_GetPoint(PyObject *, Point *); /* argument parser for Point */ +PyObject *PyMac_BuildPoint(Point); /* Convert Point to PyObject */ + +int PyMac_GetEventRecord(PyObject *, EventRecord *); /* argument parser for + EventRecord */ +PyObject *PyMac_BuildEventRecord(EventRecord *); /* Convert EventRecord to + PyObject */ + +int PyMac_GetFixed(PyObject *, Fixed *); /* argument parser for Fixed */ +PyObject *PyMac_BuildFixed(Fixed); /* Convert Fixed to PyObject */ +int PyMac_Getwide(PyObject *, wide *); /* argument parser for wide */ +PyObject *PyMac_Buildwide(wide *); /* Convert wide to PyObject */ + +/* +** The rest of the routines are implemented by extension modules. If they are +** dynamically loaded mactoolboxglue will contain a stub implementation of the +** routine, which imports the module, whereupon the module's init routine will +** communicate the routine pointer back to the stub. +** If USE_TOOLBOX_OBJECT_GLUE is not defined there is no glue code, and the +** extension modules simply declare the routine. This is the case for static +** builds (and could be the case for MacPython CFM builds, because CFM extension +** modules can reference each other without problems). +*/ + +#ifdef USE_TOOLBOX_OBJECT_GLUE +/* +** These macros are used in the module init code. If we use toolbox object glue +** it sets the function pointer to point to the real function. +*/ +#define PyMac_INIT_TOOLBOX_OBJECT_NEW(object, rtn) { \ + extern PyObject *(*PyMacGluePtr_##rtn)(object); \ + PyMacGluePtr_##rtn = _##rtn; \ +} +#define PyMac_INIT_TOOLBOX_OBJECT_CONVERT(object, rtn) { \ + extern int (*PyMacGluePtr_##rtn)(PyObject *, object *); \ + PyMacGluePtr_##rtn = _##rtn; \ +} +#else +/* +** If we don't use toolbox object glue the init macros are empty. Moreover, we define +** _xxx_New to be the same as xxx_New, and the code in mactoolboxglue isn't included. +*/ +#define PyMac_INIT_TOOLBOX_OBJECT_NEW(object, rtn) +#define PyMac_INIT_TOOLBOX_OBJECT_CONVERT(object, rtn) +#endif /* USE_TOOLBOX_OBJECT_GLUE */ + +/* macfs exports */ +#ifndef __LP64__ +int PyMac_GetFSSpec(PyObject *, FSSpec *); /* argument parser for FSSpec */ +PyObject *PyMac_BuildFSSpec(FSSpec *); /* Convert FSSpec to PyObject */ +#endif /* !__LP64__ */ + +int PyMac_GetFSRef(PyObject *, FSRef *); /* argument parser for FSRef */ +PyObject *PyMac_BuildFSRef(FSRef *); /* Convert FSRef to PyObject */ + +/* AE exports */ +extern PyObject *AEDesc_New(AppleEvent *); /* XXXX Why passed by address?? */ +extern PyObject *AEDesc_NewBorrowed(AppleEvent *); +extern int AEDesc_Convert(PyObject *, AppleEvent *); + +/* Cm exports */ +extern PyObject *CmpObj_New(Component); +extern int CmpObj_Convert(PyObject *, Component *); +extern PyObject *CmpInstObj_New(ComponentInstance); +extern int CmpInstObj_Convert(PyObject *, ComponentInstance *); + +/* Ctl exports */ +#ifndef __LP64__ +extern PyObject *CtlObj_New(ControlHandle); +extern int CtlObj_Convert(PyObject *, ControlHandle *); +#endif /* !__LP64__ */ + +/* Dlg exports */ +#ifndef __LP64__ +extern PyObject *DlgObj_New(DialogPtr); +extern int DlgObj_Convert(PyObject *, DialogPtr *); +extern PyObject *DlgObj_WhichDialog(DialogPtr); +#endif /* !__LP64__ */ + +/* Drag exports */ +#ifndef __LP64__ +extern PyObject *DragObj_New(DragReference); +extern int DragObj_Convert(PyObject *, DragReference *); +#endif /* !__LP64__ */ + +/* List exports */ +#ifndef __LP64__ +extern PyObject *ListObj_New(ListHandle); +extern int ListObj_Convert(PyObject *, ListHandle *); +#endif /* !__LP64__ */ + +/* Menu exports */ +#ifndef __LP64__ +extern PyObject *MenuObj_New(MenuHandle); +extern int MenuObj_Convert(PyObject *, MenuHandle *); +#endif /* !__LP64__ */ + +/* Qd exports */ +#ifndef __LP64__ +extern PyObject *GrafObj_New(GrafPtr); +extern int GrafObj_Convert(PyObject *, GrafPtr *); +extern PyObject *BMObj_New(BitMapPtr); +extern int BMObj_Convert(PyObject *, BitMapPtr *); +extern PyObject *QdRGB_New(RGBColor *); +extern int QdRGB_Convert(PyObject *, RGBColor *); +#endif /* !__LP64__ */ + +/* Qdoffs exports */ +#ifndef __LP64__ +extern PyObject *GWorldObj_New(GWorldPtr); +extern int GWorldObj_Convert(PyObject *, GWorldPtr *); +#endif /* !__LP64__ */ + +/* Qt exports */ +#ifndef __LP64__ +extern PyObject *TrackObj_New(Track); +extern int TrackObj_Convert(PyObject *, Track *); +extern PyObject *MovieObj_New(Movie); +extern int MovieObj_Convert(PyObject *, Movie *); +extern PyObject *MovieCtlObj_New(MovieController); +extern int MovieCtlObj_Convert(PyObject *, MovieController *); +extern PyObject *TimeBaseObj_New(TimeBase); +extern int TimeBaseObj_Convert(PyObject *, TimeBase *); +extern PyObject *UserDataObj_New(UserData); +extern int UserDataObj_Convert(PyObject *, UserData *); +extern PyObject *MediaObj_New(Media); +extern int MediaObj_Convert(PyObject *, Media *); +#endif /* !__LP64__ */ + +/* Res exports */ +extern PyObject *ResObj_New(Handle); +extern int ResObj_Convert(PyObject *, Handle *); +extern PyObject *OptResObj_New(Handle); +extern int OptResObj_Convert(PyObject *, Handle *); + +/* TE exports */ +#ifndef __LP64__ +extern PyObject *TEObj_New(TEHandle); +extern int TEObj_Convert(PyObject *, TEHandle *); +#endif /* !__LP64__ */ + +/* Win exports */ +#ifndef __LP64__ +extern PyObject *WinObj_New(WindowPtr); +extern int WinObj_Convert(PyObject *, WindowPtr *); +extern PyObject *WinObj_WhichWindow(WindowPtr); +#endif /* !__LP64__ */ + +/* CF exports */ +extern PyObject *CFObj_New(CFTypeRef); +extern int CFObj_Convert(PyObject *, CFTypeRef *); +extern PyObject *CFTypeRefObj_New(CFTypeRef); +extern int CFTypeRefObj_Convert(PyObject *, CFTypeRef *); +extern PyObject *CFStringRefObj_New(CFStringRef); +extern int CFStringRefObj_Convert(PyObject *, CFStringRef *); +extern PyObject *CFMutableStringRefObj_New(CFMutableStringRef); +extern int CFMutableStringRefObj_Convert(PyObject *, CFMutableStringRef *); +extern PyObject *CFArrayRefObj_New(CFArrayRef); +extern int CFArrayRefObj_Convert(PyObject *, CFArrayRef *); +extern PyObject *CFMutableArrayRefObj_New(CFMutableArrayRef); +extern int CFMutableArrayRefObj_Convert(PyObject *, CFMutableArrayRef *); +extern PyObject *CFDictionaryRefObj_New(CFDictionaryRef); +extern int CFDictionaryRefObj_Convert(PyObject *, CFDictionaryRef *); +extern PyObject *CFMutableDictionaryRefObj_New(CFMutableDictionaryRef); +extern int CFMutableDictionaryRefObj_Convert(PyObject *, CFMutableDictionaryRef *); +extern PyObject *CFURLRefObj_New(CFURLRef); +extern int CFURLRefObj_Convert(PyObject *, CFURLRef *); +extern int OptionalCFURLRefObj_Convert(PyObject *, CFURLRef *); + +#ifdef __cplusplus + } +#endif +#endif diff --git a/android/python27/include/pymath.h b/android/python27/include/pymath.h new file mode 100644 index 000000000..e3cf22b82 --- /dev/null +++ b/android/python27/include/pymath.h @@ -0,0 +1,192 @@ +#ifndef Py_PYMATH_H +#define Py_PYMATH_H + +#include "pyconfig.h" /* include for defines */ + +/************************************************************************** +Symbols and macros to supply platform-independent interfaces to mathematical +functions and constants +**************************************************************************/ + +/* Python provides implementations for copysign, round and hypot in + * Python/pymath.c just in case your math library doesn't provide the + * functions. + * + *Note: PC/pyconfig.h defines copysign as _copysign + */ +#ifndef HAVE_COPYSIGN +extern double copysign(double, double); +#endif + +#ifndef HAVE_ROUND +extern double round(double); +#endif + +#ifndef HAVE_HYPOT +extern double hypot(double, double); +#endif + +/* extra declarations */ +#ifndef _MSC_VER +#ifndef __STDC__ +extern double fmod (double, double); +extern double frexp (double, int *); +extern double ldexp (double, int); +extern double modf (double, double *); +extern double pow(double, double); +#endif /* __STDC__ */ +#endif /* _MSC_VER */ + +#ifdef _OSF_SOURCE +/* OSF1 5.1 doesn't make these available with XOPEN_SOURCE_EXTENDED defined */ +extern int finite(double); +extern double copysign(double, double); +#endif + +/* High precision defintion of pi and e (Euler) + * The values are taken from libc6's math.h. + */ +#ifndef Py_MATH_PIl +#define Py_MATH_PIl 3.1415926535897932384626433832795029L +#endif +#ifndef Py_MATH_PI +#define Py_MATH_PI 3.14159265358979323846 +#endif + +#ifndef Py_MATH_El +#define Py_MATH_El 2.7182818284590452353602874713526625L +#endif + +#ifndef Py_MATH_E +#define Py_MATH_E 2.7182818284590452354 +#endif + +/* On x86, Py_FORCE_DOUBLE forces a floating-point number out of an x87 FPU + register and into a 64-bit memory location, rounding from extended + precision to double precision in the process. On other platforms it does + nothing. */ + +/* we take double rounding as evidence of x87 usage */ +#ifndef Py_FORCE_DOUBLE +# ifdef X87_DOUBLE_ROUNDING +PyAPI_FUNC(double) _Py_force_double(double); +# define Py_FORCE_DOUBLE(X) (_Py_force_double(X)) +# else +# define Py_FORCE_DOUBLE(X) (X) +# endif +#endif + +#ifdef HAVE_GCC_ASM_FOR_X87 +PyAPI_FUNC(unsigned short) _Py_get_387controlword(void); +PyAPI_FUNC(void) _Py_set_387controlword(unsigned short); +#endif + +/* Py_IS_NAN(X) + * Return 1 if float or double arg is a NaN, else 0. + * Caution: + * X is evaluated more than once. + * This may not work on all platforms. Each platform has *some* + * way to spell this, though -- override in pyconfig.h if you have + * a platform where it doesn't work. + * Note: PC/pyconfig.h defines Py_IS_NAN as _isnan + */ +#ifndef Py_IS_NAN +#if defined HAVE_DECL_ISNAN && HAVE_DECL_ISNAN == 1 +#define Py_IS_NAN(X) isnan(X) +#else +#define Py_IS_NAN(X) ((X) != (X)) +#endif +#endif + +/* Py_IS_INFINITY(X) + * Return 1 if float or double arg is an infinity, else 0. + * Caution: + * X is evaluated more than once. + * This implementation may set the underflow flag if |X| is very small; + * it really can't be implemented correctly (& easily) before C99. + * Override in pyconfig.h if you have a better spelling on your platform. + * Py_FORCE_DOUBLE is used to avoid getting false negatives from a + * non-infinite value v sitting in an 80-bit x87 register such that + * v becomes infinite when spilled from the register to 64-bit memory. + * Note: PC/pyconfig.h defines Py_IS_INFINITY as _isinf + */ +#ifndef Py_IS_INFINITY +# if defined HAVE_DECL_ISINF && HAVE_DECL_ISINF == 1 +# define Py_IS_INFINITY(X) isinf(X) +# else +# define Py_IS_INFINITY(X) ((X) && \ + (Py_FORCE_DOUBLE(X)*0.5 == Py_FORCE_DOUBLE(X))) +# endif +#endif + +/* Py_IS_FINITE(X) + * Return 1 if float or double arg is neither infinite nor NAN, else 0. + * Some compilers (e.g. VisualStudio) have intrisics for this, so a special + * macro for this particular test is useful + * Note: PC/pyconfig.h defines Py_IS_FINITE as _finite + */ +#ifndef Py_IS_FINITE +#if defined HAVE_DECL_ISFINITE && HAVE_DECL_ISFINITE == 1 +#define Py_IS_FINITE(X) isfinite(X) +#elif defined HAVE_FINITE +#define Py_IS_FINITE(X) finite(X) +#else +#define Py_IS_FINITE(X) (!Py_IS_INFINITY(X) && !Py_IS_NAN(X)) +#endif +#endif + +/* HUGE_VAL is supposed to expand to a positive double infinity. Python + * uses Py_HUGE_VAL instead because some platforms are broken in this + * respect. We used to embed code in pyport.h to try to worm around that, + * but different platforms are broken in conflicting ways. If you're on + * a platform where HUGE_VAL is defined incorrectly, fiddle your Python + * config to #define Py_HUGE_VAL to something that works on your platform. + */ +#ifndef Py_HUGE_VAL +#define Py_HUGE_VAL HUGE_VAL +#endif + +/* Py_NAN + * A value that evaluates to a NaN. On IEEE 754 platforms INF*0 or + * INF/INF works. Define Py_NO_NAN in pyconfig.h if your platform + * doesn't support NaNs. + */ +#if !defined(Py_NAN) && !defined(Py_NO_NAN) +#define Py_NAN (Py_HUGE_VAL * 0.) +#endif + +/* Py_OVERFLOWED(X) + * Return 1 iff a libm function overflowed. Set errno to 0 before calling + * a libm function, and invoke this macro after, passing the function + * result. + * Caution: + * This isn't reliable. C99 no longer requires libm to set errno under + * any exceptional condition, but does require +- HUGE_VAL return + * values on overflow. A 754 box *probably* maps HUGE_VAL to a + * double infinity, and we're cool if that's so, unless the input + * was an infinity and an infinity is the expected result. A C89 + * system sets errno to ERANGE, so we check for that too. We're + * out of luck if a C99 754 box doesn't map HUGE_VAL to +Inf, or + * if the returned result is a NaN, or if a C89 box returns HUGE_VAL + * in non-overflow cases. + * X is evaluated more than once. + * Some platforms have better way to spell this, so expect some #ifdef'ery. + * + * OpenBSD uses 'isinf()' because a compiler bug on that platform causes + * the longer macro version to be mis-compiled. This isn't optimal, and + * should be removed once a newer compiler is available on that platform. + * The system that had the failure was running OpenBSD 3.2 on Intel, with + * gcc 2.95.3. + * + * According to Tim's checkin, the FreeBSD systems use isinf() to work + * around a FPE bug on that platform. + */ +#if defined(__FreeBSD__) || defined(__OpenBSD__) +#define Py_OVERFLOWED(X) isinf(X) +#else +#define Py_OVERFLOWED(X) ((X) != 0.0 && (errno == ERANGE || \ + (X) == Py_HUGE_VAL || \ + (X) == -Py_HUGE_VAL)) +#endif + +#endif /* Py_PYMATH_H */ diff --git a/android/python27/include/pymem.h b/android/python27/include/pymem.h new file mode 100644 index 000000000..10b5bea5e --- /dev/null +++ b/android/python27/include/pymem.h @@ -0,0 +1,122 @@ +/* The PyMem_ family: low-level memory allocation interfaces. + See objimpl.h for the PyObject_ memory family. +*/ + +#ifndef Py_PYMEM_H +#define Py_PYMEM_H + +#include "pyport.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* BEWARE: + + Each interface exports both functions and macros. Extension modules should + use the functions, to ensure binary compatibility across Python versions. + Because the Python implementation is free to change internal details, and + the macros may (or may not) expose details for speed, if you do use the + macros you must recompile your extensions with each Python release. + + Never mix calls to PyMem_ with calls to the platform malloc/realloc/ + calloc/free. For example, on Windows different DLLs may end up using + different heaps, and if you use PyMem_Malloc you'll get the memory from the + heap used by the Python DLL; it could be a disaster if you free()'ed that + directly in your own extension. Using PyMem_Free instead ensures Python + can return the memory to the proper heap. As another example, in + PYMALLOC_DEBUG mode, Python wraps all calls to all PyMem_ and PyObject_ + memory functions in special debugging wrappers that add additional + debugging info to dynamic memory blocks. The system routines have no idea + what to do with that stuff, and the Python wrappers have no idea what to do + with raw blocks obtained directly by the system routines then. + + The GIL must be held when using these APIs. +*/ + +/* + * Raw memory interface + * ==================== + */ + +/* Functions + + Functions supplying platform-independent semantics for malloc/realloc/ + free. These functions make sure that allocating 0 bytes returns a distinct + non-NULL pointer (whenever possible -- if we're flat out of memory, NULL + may be returned), even if the platform malloc and realloc don't. + Returned pointers must be checked for NULL explicitly. No action is + performed on failure (no exception is set, no warning is printed, etc). +*/ + +PyAPI_FUNC(void *) PyMem_Malloc(size_t); +PyAPI_FUNC(void *) PyMem_Realloc(void *, size_t); +PyAPI_FUNC(void) PyMem_Free(void *); + +/* Starting from Python 1.6, the wrappers Py_{Malloc,Realloc,Free} are + no longer supported. They used to call PyErr_NoMemory() on failure. */ + +/* Macros. */ +#ifdef PYMALLOC_DEBUG +/* Redirect all memory operations to Python's debugging allocator. */ +#define PyMem_MALLOC _PyMem_DebugMalloc +#define PyMem_REALLOC _PyMem_DebugRealloc +#define PyMem_FREE _PyMem_DebugFree + +#else /* ! PYMALLOC_DEBUG */ + +/* PyMem_MALLOC(0) means malloc(1). Some systems would return NULL + for malloc(0), which would be treated as an error. Some platforms + would return a pointer with no memory behind it, which would break + pymalloc. To solve these problems, allocate an extra byte. */ +/* Returns NULL to indicate error if a negative size or size larger than + Py_ssize_t can represent is supplied. Helps prevents security holes. */ +#define PyMem_MALLOC(n) ((size_t)(n) > (size_t)PY_SSIZE_T_MAX ? NULL \ + : malloc((n) ? (n) : 1)) +#define PyMem_REALLOC(p, n) ((size_t)(n) > (size_t)PY_SSIZE_T_MAX ? NULL \ + : realloc((p), (n) ? (n) : 1)) +#define PyMem_FREE free + +#endif /* PYMALLOC_DEBUG */ + +/* + * Type-oriented memory interface + * ============================== + * + * Allocate memory for n objects of the given type. Returns a new pointer + * or NULL if the request was too large or memory allocation failed. Use + * these macros rather than doing the multiplication yourself so that proper + * overflow checking is always done. + */ + +#define PyMem_New(type, n) \ + ( ((size_t)(n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \ + ( (type *) PyMem_Malloc((n) * sizeof(type)) ) ) +#define PyMem_NEW(type, n) \ + ( ((size_t)(n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \ + ( (type *) PyMem_MALLOC((n) * sizeof(type)) ) ) + +/* + * The value of (p) is always clobbered by this macro regardless of success. + * The caller MUST check if (p) is NULL afterwards and deal with the memory + * error if so. This means the original value of (p) MUST be saved for the + * caller's memory error handler to not lose track of it. + */ +#define PyMem_Resize(p, type, n) \ + ( (p) = ((size_t)(n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \ + (type *) PyMem_Realloc((p), (n) * sizeof(type)) ) +#define PyMem_RESIZE(p, type, n) \ + ( (p) = ((size_t)(n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \ + (type *) PyMem_REALLOC((p), (n) * sizeof(type)) ) + +/* PyMem{Del,DEL} are left over from ancient days, and shouldn't be used + * anymore. They're just confusing aliases for PyMem_{Free,FREE} now. + */ +#define PyMem_Del PyMem_Free +#define PyMem_DEL PyMem_FREE + +#ifdef __cplusplus +} +#endif + +#endif /* !Py_PYMEM_H */ diff --git a/android/python27/include/pyport.h b/android/python27/include/pyport.h new file mode 100644 index 000000000..85e852f8b --- /dev/null +++ b/android/python27/include/pyport.h @@ -0,0 +1,941 @@ +#ifndef Py_PYPORT_H +#define Py_PYPORT_H + +#include "pyconfig.h" /* include for defines */ + +/* Some versions of HP-UX & Solaris need inttypes.h for int32_t, + INT32_MAX, etc. */ +#ifdef HAVE_INTTYPES_H +#include +#endif + +#ifdef HAVE_STDINT_H +#include +#endif + +/************************************************************************** +Symbols and macros to supply platform-independent interfaces to basic +C language & library operations whose spellings vary across platforms. + +Please try to make documentation here as clear as possible: by definition, +the stuff here is trying to illuminate C's darkest corners. + +Config #defines referenced here: + +SIGNED_RIGHT_SHIFT_ZERO_FILLS +Meaning: To be defined iff i>>j does not extend the sign bit when i is a + signed integral type and i < 0. +Used in: Py_ARITHMETIC_RIGHT_SHIFT + +Py_DEBUG +Meaning: Extra checks compiled in for debug mode. +Used in: Py_SAFE_DOWNCAST + +HAVE_UINTPTR_T +Meaning: The C9X type uintptr_t is supported by the compiler +Used in: Py_uintptr_t + +HAVE_LONG_LONG +Meaning: The compiler supports the C type "long long" +Used in: PY_LONG_LONG + +**************************************************************************/ + + +/* For backward compatibility only. Obsolete, do not use. */ +#ifdef HAVE_PROTOTYPES +#define Py_PROTO(x) x +#else +#define Py_PROTO(x) () +#endif +#ifndef Py_FPROTO +#define Py_FPROTO(x) Py_PROTO(x) +#endif + +/* typedefs for some C9X-defined synonyms for integral types. + * + * The names in Python are exactly the same as the C9X names, except with a + * Py_ prefix. Until C9X is universally implemented, this is the only way + * to ensure that Python gets reliable names that don't conflict with names + * in non-Python code that are playing their own tricks to define the C9X + * names. + * + * NOTE: don't go nuts here! Python has no use for *most* of the C9X + * integral synonyms. Only define the ones we actually need. + */ + +#ifdef HAVE_LONG_LONG +#ifndef PY_LONG_LONG +#define PY_LONG_LONG long long +#if defined(LLONG_MAX) +/* If LLONG_MAX is defined in limits.h, use that. */ +#define PY_LLONG_MIN LLONG_MIN +#define PY_LLONG_MAX LLONG_MAX +#define PY_ULLONG_MAX ULLONG_MAX +#elif defined(__LONG_LONG_MAX__) +/* Otherwise, if GCC has a builtin define, use that. */ +#define PY_LLONG_MAX __LONG_LONG_MAX__ +#define PY_LLONG_MIN (-PY_LLONG_MAX-1) +#define PY_ULLONG_MAX (__LONG_LONG_MAX__*2ULL + 1ULL) +#else +/* Otherwise, rely on two's complement. */ +#define PY_ULLONG_MAX (~0ULL) +#define PY_LLONG_MAX ((long long)(PY_ULLONG_MAX>>1)) +#define PY_LLONG_MIN (-PY_LLONG_MAX-1) +#endif /* LLONG_MAX */ +#endif +#endif /* HAVE_LONG_LONG */ + +/* a build with 30-bit digits for Python long integers needs an exact-width + * 32-bit unsigned integer type to store those digits. (We could just use + * type 'unsigned long', but that would be wasteful on a system where longs + * are 64-bits.) On Unix systems, the autoconf macro AC_TYPE_UINT32_T defines + * uint32_t to be such a type unless stdint.h or inttypes.h defines uint32_t. + * However, it doesn't set HAVE_UINT32_T, so we do that here. + */ +#ifdef uint32_t +#define HAVE_UINT32_T 1 +#endif + +#ifdef HAVE_UINT32_T +#ifndef PY_UINT32_T +#define PY_UINT32_T uint32_t +#endif +#endif + +/* Macros for a 64-bit unsigned integer type; used for type 'twodigits' in the + * long integer implementation, when 30-bit digits are enabled. + */ +#ifdef uint64_t +#define HAVE_UINT64_T 1 +#endif + +#ifdef HAVE_UINT64_T +#ifndef PY_UINT64_T +#define PY_UINT64_T uint64_t +#endif +#endif + +/* Signed variants of the above */ +#ifdef int32_t +#define HAVE_INT32_T 1 +#endif + +#ifdef HAVE_INT32_T +#ifndef PY_INT32_T +#define PY_INT32_T int32_t +#endif +#endif + +#ifdef int64_t +#define HAVE_INT64_T 1 +#endif + +#ifdef HAVE_INT64_T +#ifndef PY_INT64_T +#define PY_INT64_T int64_t +#endif +#endif + +/* If PYLONG_BITS_IN_DIGIT is not defined then we'll use 30-bit digits if all + the necessary integer types are available, and we're on a 64-bit platform + (as determined by SIZEOF_VOID_P); otherwise we use 15-bit digits. */ + +#ifndef PYLONG_BITS_IN_DIGIT +#if (defined HAVE_UINT64_T && defined HAVE_INT64_T && \ + defined HAVE_UINT32_T && defined HAVE_INT32_T && SIZEOF_VOID_P >= 8) +#define PYLONG_BITS_IN_DIGIT 30 +#else +#define PYLONG_BITS_IN_DIGIT 15 +#endif +#endif + +/* uintptr_t is the C9X name for an unsigned integral type such that a + * legitimate void* can be cast to uintptr_t and then back to void* again + * without loss of information. Similarly for intptr_t, wrt a signed + * integral type. + */ +#ifdef HAVE_UINTPTR_T +typedef uintptr_t Py_uintptr_t; +typedef intptr_t Py_intptr_t; + +#elif SIZEOF_VOID_P <= SIZEOF_INT +typedef unsigned int Py_uintptr_t; +typedef int Py_intptr_t; + +#elif SIZEOF_VOID_P <= SIZEOF_LONG +typedef unsigned long Py_uintptr_t; +typedef long Py_intptr_t; + +#elif defined(HAVE_LONG_LONG) && (SIZEOF_VOID_P <= SIZEOF_LONG_LONG) +typedef unsigned PY_LONG_LONG Py_uintptr_t; +typedef PY_LONG_LONG Py_intptr_t; + +#else +# error "Python needs a typedef for Py_uintptr_t in pyport.h." +#endif /* HAVE_UINTPTR_T */ + +/* Py_ssize_t is a signed integral type such that sizeof(Py_ssize_t) == + * sizeof(size_t). C99 doesn't define such a thing directly (size_t is an + * unsigned integral type). See PEP 353 for details. + */ +#ifdef HAVE_SSIZE_T +typedef ssize_t Py_ssize_t; +#elif SIZEOF_VOID_P == SIZEOF_SIZE_T +typedef Py_intptr_t Py_ssize_t; +#else +# error "Python needs a typedef for Py_ssize_t in pyport.h." +#endif + +/* Largest possible value of size_t. + SIZE_MAX is part of C99, so it might be defined on some + platforms. If it is not defined, (size_t)-1 is a portable + definition for C89, due to the way signed->unsigned + conversion is defined. */ +#ifdef SIZE_MAX +#define PY_SIZE_MAX SIZE_MAX +#else +#define PY_SIZE_MAX ((size_t)-1) +#endif + +/* Largest positive value of type Py_ssize_t. */ +#define PY_SSIZE_T_MAX ((Py_ssize_t)(((size_t)-1)>>1)) +/* Smallest negative value of type Py_ssize_t. */ +#define PY_SSIZE_T_MIN (-PY_SSIZE_T_MAX-1) + +#if SIZEOF_PID_T > SIZEOF_LONG +# error "Python doesn't support sizeof(pid_t) > sizeof(long)" +#endif + +/* PY_FORMAT_SIZE_T is a platform-specific modifier for use in a printf + * format to convert an argument with the width of a size_t or Py_ssize_t. + * C99 introduced "z" for this purpose, but not all platforms support that; + * e.g., MS compilers use "I" instead. + * + * These "high level" Python format functions interpret "z" correctly on + * all platforms (Python interprets the format string itself, and does whatever + * the platform C requires to convert a size_t/Py_ssize_t argument): + * + * PyString_FromFormat + * PyErr_Format + * PyString_FromFormatV + * + * Lower-level uses require that you interpolate the correct format modifier + * yourself (e.g., calling printf, fprintf, sprintf, PyOS_snprintf); for + * example, + * + * Py_ssize_t index; + * fprintf(stderr, "index %" PY_FORMAT_SIZE_T "d sucks\n", index); + * + * That will expand to %ld, or %Id, or to something else correct for a + * Py_ssize_t on the platform. + */ +#ifndef PY_FORMAT_SIZE_T +# if SIZEOF_SIZE_T == SIZEOF_INT && !defined(__APPLE__) +# define PY_FORMAT_SIZE_T "" +# elif SIZEOF_SIZE_T == SIZEOF_LONG +# define PY_FORMAT_SIZE_T "l" +# elif defined(MS_WINDOWS) +# define PY_FORMAT_SIZE_T "I" +# else +# error "This platform's pyconfig.h needs to define PY_FORMAT_SIZE_T" +# endif +#endif + +/* PY_FORMAT_LONG_LONG is analogous to PY_FORMAT_SIZE_T above, but for + * the long long type instead of the size_t type. It's only available + * when HAVE_LONG_LONG is defined. The "high level" Python format + * functions listed above will interpret "lld" or "llu" correctly on + * all platforms. + */ +#ifdef HAVE_LONG_LONG +# ifndef PY_FORMAT_LONG_LONG +# if defined(MS_WIN64) || defined(MS_WINDOWS) +# define PY_FORMAT_LONG_LONG "I64" +# else +# error "This platform's pyconfig.h needs to define PY_FORMAT_LONG_LONG" +# endif +# endif +#endif + +/* Py_LOCAL can be used instead of static to get the fastest possible calling + * convention for functions that are local to a given module. + * + * Py_LOCAL_INLINE does the same thing, and also explicitly requests inlining, + * for platforms that support that. + * + * If PY_LOCAL_AGGRESSIVE is defined before python.h is included, more + * "aggressive" inlining/optimizaion is enabled for the entire module. This + * may lead to code bloat, and may slow things down for those reasons. It may + * also lead to errors, if the code relies on pointer aliasing. Use with + * care. + * + * NOTE: You can only use this for functions that are entirely local to a + * module; functions that are exported via method tables, callbacks, etc, + * should keep using static. + */ + +#undef USE_INLINE /* XXX - set via configure? */ + +#if defined(_MSC_VER) +#if defined(PY_LOCAL_AGGRESSIVE) +/* enable more aggressive optimization for visual studio */ +#pragma optimize("agtw", on) +#endif +/* ignore warnings if the compiler decides not to inline a function */ +#pragma warning(disable: 4710) +/* fastest possible local call under MSVC */ +#define Py_LOCAL(type) static type __fastcall +#define Py_LOCAL_INLINE(type) static __inline type __fastcall +#elif defined(USE_INLINE) +#define Py_LOCAL(type) static type +#define Py_LOCAL_INLINE(type) static inline type +#else +#define Py_LOCAL(type) static type +#define Py_LOCAL_INLINE(type) static type +#endif + +/* Py_MEMCPY can be used instead of memcpy in cases where the copied blocks + * are often very short. While most platforms have highly optimized code for + * large transfers, the setup costs for memcpy are often quite high. MEMCPY + * solves this by doing short copies "in line". + */ + +#if defined(_MSC_VER) +#define Py_MEMCPY(target, source, length) do { \ + size_t i_, n_ = (length); \ + char *t_ = (void*) (target); \ + const char *s_ = (void*) (source); \ + if (n_ >= 16) \ + memcpy(t_, s_, n_); \ + else \ + for (i_ = 0; i_ < n_; i_++) \ + t_[i_] = s_[i_]; \ + } while (0) +#else +#define Py_MEMCPY memcpy +#endif + +#include + +#ifdef HAVE_IEEEFP_H +#include /* needed for 'finite' declaration on some platforms */ +#endif + +#include /* Moved here from the math section, before extern "C" */ + +/******************************************** + * WRAPPER FOR and/or * + ********************************************/ + +#ifdef TIME_WITH_SYS_TIME +#include +#include +#else /* !TIME_WITH_SYS_TIME */ +#ifdef HAVE_SYS_TIME_H +#include +#else /* !HAVE_SYS_TIME_H */ +#include +#endif /* !HAVE_SYS_TIME_H */ +#endif /* !TIME_WITH_SYS_TIME */ + + +/****************************** + * WRAPPER FOR * + ******************************/ + +/* NB caller must include */ + +#ifdef HAVE_SYS_SELECT_H + +#include + +#endif /* !HAVE_SYS_SELECT_H */ + +/******************************* + * stat() and fstat() fiddling * + *******************************/ + +/* We expect that stat and fstat exist on most systems. + * It's confirmed on Unix, Mac and Windows. + * If you don't have them, add + * #define DONT_HAVE_STAT + * and/or + * #define DONT_HAVE_FSTAT + * to your pyconfig.h. Python code beyond this should check HAVE_STAT and + * HAVE_FSTAT instead. + * Also + * #define HAVE_SYS_STAT_H + * if exists on your platform, and + * #define HAVE_STAT_H + * if does. + */ +#ifndef DONT_HAVE_STAT +#define HAVE_STAT +#endif + +#ifndef DONT_HAVE_FSTAT +#define HAVE_FSTAT +#endif + +#ifdef RISCOS +#include +#include "unixstuff.h" +#endif + +#ifdef HAVE_SYS_STAT_H +#if defined(PYOS_OS2) && defined(PYCC_GCC) +#include +#endif +#include +#elif defined(HAVE_STAT_H) +#include +#endif + +#if defined(PYCC_VACPP) +/* VisualAge C/C++ Failed to Define MountType Field in sys/stat.h */ +#define S_IFMT (S_IFDIR|S_IFCHR|S_IFREG) +#endif + +#ifndef S_ISREG +#define S_ISREG(x) (((x) & S_IFMT) == S_IFREG) +#endif + +#ifndef S_ISDIR +#define S_ISDIR(x) (((x) & S_IFMT) == S_IFDIR) +#endif + + +#ifdef __cplusplus +/* Move this down here since some C++ #include's don't like to be included + inside an extern "C" */ +extern "C" { +#endif + + +/* Py_ARITHMETIC_RIGHT_SHIFT + * C doesn't define whether a right-shift of a signed integer sign-extends + * or zero-fills. Here a macro to force sign extension: + * Py_ARITHMETIC_RIGHT_SHIFT(TYPE, I, J) + * Return I >> J, forcing sign extension. Arithmetically, return the + * floor of I/2**J. + * Requirements: + * I should have signed integer type. In the terminology of C99, this can + * be either one of the five standard signed integer types (signed char, + * short, int, long, long long) or an extended signed integer type. + * J is an integer >= 0 and strictly less than the number of bits in the + * type of I (because C doesn't define what happens for J outside that + * range either). + * TYPE used to specify the type of I, but is now ignored. It's been left + * in for backwards compatibility with versions <= 2.6 or 3.0. + * Caution: + * I may be evaluated more than once. + */ +#ifdef SIGNED_RIGHT_SHIFT_ZERO_FILLS +#define Py_ARITHMETIC_RIGHT_SHIFT(TYPE, I, J) \ + ((I) < 0 ? -1-((-1-(I)) >> (J)) : (I) >> (J)) +#else +#define Py_ARITHMETIC_RIGHT_SHIFT(TYPE, I, J) ((I) >> (J)) +#endif + +/* Py_FORCE_EXPANSION(X) + * "Simply" returns its argument. However, macro expansions within the + * argument are evaluated. This unfortunate trickery is needed to get + * token-pasting to work as desired in some cases. + */ +#define Py_FORCE_EXPANSION(X) X + +/* Py_SAFE_DOWNCAST(VALUE, WIDE, NARROW) + * Cast VALUE to type NARROW from type WIDE. In Py_DEBUG mode, this + * assert-fails if any information is lost. + * Caution: + * VALUE may be evaluated more than once. + */ +#ifdef Py_DEBUG +#define Py_SAFE_DOWNCAST(VALUE, WIDE, NARROW) \ + (assert((WIDE)(NARROW)(VALUE) == (VALUE)), (NARROW)(VALUE)) +#else +#define Py_SAFE_DOWNCAST(VALUE, WIDE, NARROW) (NARROW)(VALUE) +#endif + +/* Py_SET_ERRNO_ON_MATH_ERROR(x) + * If a libm function did not set errno, but it looks like the result + * overflowed or not-a-number, set errno to ERANGE or EDOM. Set errno + * to 0 before calling a libm function, and invoke this macro after, + * passing the function result. + * Caution: + * This isn't reliable. See Py_OVERFLOWED comments. + * X is evaluated more than once. + */ +#if defined(__FreeBSD__) || defined(__OpenBSD__) || (defined(__hpux) && defined(__ia64)) +#define _Py_SET_EDOM_FOR_NAN(X) if (isnan(X)) errno = EDOM; +#else +#define _Py_SET_EDOM_FOR_NAN(X) ; +#endif +#define Py_SET_ERRNO_ON_MATH_ERROR(X) \ + do { \ + if (errno == 0) { \ + if ((X) == Py_HUGE_VAL || (X) == -Py_HUGE_VAL) \ + errno = ERANGE; \ + else _Py_SET_EDOM_FOR_NAN(X) \ + } \ + } while(0) + +/* Py_SET_ERANGE_ON_OVERFLOW(x) + * An alias of Py_SET_ERRNO_ON_MATH_ERROR for backward-compatibility. + */ +#define Py_SET_ERANGE_IF_OVERFLOW(X) Py_SET_ERRNO_ON_MATH_ERROR(X) + +/* Py_ADJUST_ERANGE1(x) + * Py_ADJUST_ERANGE2(x, y) + * Set errno to 0 before calling a libm function, and invoke one of these + * macros after, passing the function result(s) (Py_ADJUST_ERANGE2 is useful + * for functions returning complex results). This makes two kinds of + * adjustments to errno: (A) If it looks like the platform libm set + * errno=ERANGE due to underflow, clear errno. (B) If it looks like the + * platform libm overflowed but didn't set errno, force errno to ERANGE. In + * effect, we're trying to force a useful implementation of C89 errno + * behavior. + * Caution: + * This isn't reliable. See Py_OVERFLOWED comments. + * X and Y may be evaluated more than once. + */ +#define Py_ADJUST_ERANGE1(X) \ + do { \ + if (errno == 0) { \ + if ((X) == Py_HUGE_VAL || (X) == -Py_HUGE_VAL) \ + errno = ERANGE; \ + } \ + else if (errno == ERANGE && (X) == 0.0) \ + errno = 0; \ + } while(0) + +#define Py_ADJUST_ERANGE2(X, Y) \ + do { \ + if ((X) == Py_HUGE_VAL || (X) == -Py_HUGE_VAL || \ + (Y) == Py_HUGE_VAL || (Y) == -Py_HUGE_VAL) { \ + if (errno == 0) \ + errno = ERANGE; \ + } \ + else if (errno == ERANGE) \ + errno = 0; \ + } while(0) + +/* The functions _Py_dg_strtod and _Py_dg_dtoa in Python/dtoa.c (which are + * required to support the short float repr introduced in Python 3.1) require + * that the floating-point unit that's being used for arithmetic operations + * on C doubles is set to use 53-bit precision. It also requires that the + * FPU rounding mode is round-half-to-even, but that's less often an issue. + * + * If your FPU isn't already set to 53-bit precision/round-half-to-even, and + * you want to make use of _Py_dg_strtod and _Py_dg_dtoa, then you should + * + * #define HAVE_PY_SET_53BIT_PRECISION 1 + * + * and also give appropriate definitions for the following three macros: + * + * _PY_SET_53BIT_PRECISION_START : store original FPU settings, and + * set FPU to 53-bit precision/round-half-to-even + * _PY_SET_53BIT_PRECISION_END : restore original FPU settings + * _PY_SET_53BIT_PRECISION_HEADER : any variable declarations needed to + * use the two macros above. + * + * The macros are designed to be used within a single C function: see + * Python/pystrtod.c for an example of their use. + */ + +/* get and set x87 control word for gcc/x86 */ +#ifdef HAVE_GCC_ASM_FOR_X87 +#define HAVE_PY_SET_53BIT_PRECISION 1 +/* _Py_get/set_387controlword functions are defined in Python/pymath.c */ +#define _Py_SET_53BIT_PRECISION_HEADER \ + unsigned short old_387controlword, new_387controlword +#define _Py_SET_53BIT_PRECISION_START \ + do { \ + old_387controlword = _Py_get_387controlword(); \ + new_387controlword = (old_387controlword & ~0x0f00) | 0x0200; \ + if (new_387controlword != old_387controlword) \ + _Py_set_387controlword(new_387controlword); \ + } while (0) +#define _Py_SET_53BIT_PRECISION_END \ + if (new_387controlword != old_387controlword) \ + _Py_set_387controlword(old_387controlword) +#endif + +/* get and set x87 control word for VisualStudio/x86 */ +#if defined(_MSC_VER) && !defined(_WIN64) /* x87 not supported in 64-bit */ +#define HAVE_PY_SET_53BIT_PRECISION 1 +#define _Py_SET_53BIT_PRECISION_HEADER \ + unsigned int old_387controlword, new_387controlword, out_387controlword +/* We use the __control87_2 function to set only the x87 control word. + The SSE control word is unaffected. */ +#define _Py_SET_53BIT_PRECISION_START \ + do { \ + __control87_2(0, 0, &old_387controlword, NULL); \ + new_387controlword = \ + (old_387controlword & ~(_MCW_PC | _MCW_RC)) | (_PC_53 | _RC_NEAR); \ + if (new_387controlword != old_387controlword) \ + __control87_2(new_387controlword, _MCW_PC | _MCW_RC, \ + &out_387controlword, NULL); \ + } while (0) +#define _Py_SET_53BIT_PRECISION_END \ + do { \ + if (new_387controlword != old_387controlword) \ + __control87_2(old_387controlword, _MCW_PC | _MCW_RC, \ + &out_387controlword, NULL); \ + } while (0) +#endif + +/* default definitions are empty */ +#ifndef HAVE_PY_SET_53BIT_PRECISION +#define _Py_SET_53BIT_PRECISION_HEADER +#define _Py_SET_53BIT_PRECISION_START +#define _Py_SET_53BIT_PRECISION_END +#endif + +/* If we can't guarantee 53-bit precision, don't use the code + in Python/dtoa.c, but fall back to standard code. This + means that repr of a float will be long (17 sig digits). + + Realistically, there are two things that could go wrong: + + (1) doubles aren't IEEE 754 doubles, or + (2) we're on x86 with the rounding precision set to 64-bits + (extended precision), and we don't know how to change + the rounding precision. + */ + +#if !defined(DOUBLE_IS_LITTLE_ENDIAN_IEEE754) && \ + !defined(DOUBLE_IS_BIG_ENDIAN_IEEE754) && \ + !defined(DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754) +#define PY_NO_SHORT_FLOAT_REPR +#endif + +/* double rounding is symptomatic of use of extended precision on x86. If + we're seeing double rounding, and we don't have any mechanism available for + changing the FPU rounding precision, then don't use Python/dtoa.c. */ +#if defined(X87_DOUBLE_ROUNDING) && !defined(HAVE_PY_SET_53BIT_PRECISION) +#define PY_NO_SHORT_FLOAT_REPR +#endif + +/* Py_DEPRECATED(version) + * Declare a variable, type, or function deprecated. + * Usage: + * extern int old_var Py_DEPRECATED(2.3); + * typedef int T1 Py_DEPRECATED(2.4); + * extern int x() Py_DEPRECATED(2.5); + */ +#if defined(__GNUC__) && ((__GNUC__ >= 4) || \ + (__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)) +#define Py_DEPRECATED(VERSION_UNUSED) __attribute__((__deprecated__)) +#else +#define Py_DEPRECATED(VERSION_UNUSED) +#endif + +/************************************************************************** +Prototypes that are missing from the standard include files on some systems +(and possibly only some versions of such systems.) + +Please be conservative with adding new ones, document them and enclose them +in platform-specific #ifdefs. +**************************************************************************/ + +#ifdef SOLARIS +/* Unchecked */ +extern int gethostname(char *, int); +#endif + +#ifdef __BEOS__ +/* Unchecked */ +/* It's in the libs, but not the headers... - [cjh] */ +int shutdown( int, int ); +#endif + +#ifdef HAVE__GETPTY +#include /* we need to import mode_t */ +extern char * _getpty(int *, int, mode_t, int); +#endif + +/* On QNX 6, struct termio must be declared by including sys/termio.h + if TCGETA, TCSETA, TCSETAW, or TCSETAF are used. sys/termio.h must + be included before termios.h or it will generate an error. */ +#if defined(HAVE_SYS_TERMIO_H) && !defined(__hpux) +#include +#endif + +#if defined(HAVE_OPENPTY) || defined(HAVE_FORKPTY) +#if !defined(HAVE_PTY_H) && !defined(HAVE_LIBUTIL_H) && !defined(HAVE_UTIL_H) +/* BSDI does not supply a prototype for the 'openpty' and 'forkpty' + functions, even though they are included in libutil. */ +#include +extern int openpty(int *, int *, char *, struct termios *, struct winsize *); +extern pid_t forkpty(int *, char *, struct termios *, struct winsize *); +#endif /* !defined(HAVE_PTY_H) && !defined(HAVE_LIBUTIL_H) */ +#endif /* defined(HAVE_OPENPTY) || defined(HAVE_FORKPTY) */ + + +/* These are pulled from various places. It isn't obvious on what platforms + they are necessary, nor what the exact prototype should look like (which + is likely to vary between platforms!) If you find you need one of these + declarations, please move them to a platform-specific block and include + proper prototypes. */ +#if 0 + +/* From Modules/resource.c */ +extern int getrusage(); +extern int getpagesize(); + +/* From Python/sysmodule.c and Modules/posixmodule.c */ +extern int fclose(FILE *); + +/* From Modules/posixmodule.c */ +extern int fdatasync(int); +#endif /* 0 */ + + +/* On 4.4BSD-descendants, ctype functions serves the whole range of + * wchar_t character set rather than single byte code points only. + * This characteristic can break some operations of string object + * including str.upper() and str.split() on UTF-8 locales. This + * workaround was provided by Tim Robbins of FreeBSD project. + */ + +#ifdef __FreeBSD__ +#include +#if __FreeBSD_version > 500039 +# define _PY_PORT_CTYPE_UTF8_ISSUE +#endif +#endif + + +#if defined(__APPLE__) +# define _PY_PORT_CTYPE_UTF8_ISSUE +#endif + +#ifdef _PY_PORT_CTYPE_UTF8_ISSUE +#include +#include +#undef isalnum +#define isalnum(c) iswalnum(btowc(c)) +#undef isalpha +#define isalpha(c) iswalpha(btowc(c)) +#undef islower +#define islower(c) iswlower(btowc(c)) +#undef isspace +#define isspace(c) iswspace(btowc(c)) +#undef isupper +#define isupper(c) iswupper(btowc(c)) +#undef tolower +#define tolower(c) towlower(btowc(c)) +#undef toupper +#define toupper(c) towupper(btowc(c)) +#endif + + +/* Declarations for symbol visibility. + + PyAPI_FUNC(type): Declares a public Python API function and return type + PyAPI_DATA(type): Declares public Python data and its type + PyMODINIT_FUNC: A Python module init function. If these functions are + inside the Python core, they are private to the core. + If in an extension module, it may be declared with + external linkage depending on the platform. + + As a number of platforms support/require "__declspec(dllimport/dllexport)", + we support a HAVE_DECLSPEC_DLL macro to save duplication. +*/ + +/* + All windows ports, except cygwin, are handled in PC/pyconfig.h. + + BeOS and cygwin are the only other autoconf platform requiring special + linkage handling and both of these use __declspec(). +*/ +#if defined(__CYGWIN__) || defined(__BEOS__) +# define HAVE_DECLSPEC_DLL +#endif + +/* only get special linkage if built as shared or platform is Cygwin */ +#if defined(Py_ENABLE_SHARED) || defined(__CYGWIN__) +# if defined(HAVE_DECLSPEC_DLL) +# ifdef Py_BUILD_CORE +# define PyAPI_FUNC(RTYPE) __declspec(dllexport) RTYPE +# define PyAPI_DATA(RTYPE) extern __declspec(dllexport) RTYPE + /* module init functions inside the core need no external linkage */ + /* except for Cygwin to handle embedding (FIXME: BeOS too?) */ +# if defined(__CYGWIN__) +# define PyMODINIT_FUNC __declspec(dllexport) void +# else /* __CYGWIN__ */ +# define PyMODINIT_FUNC void +# endif /* __CYGWIN__ */ +# else /* Py_BUILD_CORE */ + /* Building an extension module, or an embedded situation */ + /* public Python functions and data are imported */ + /* Under Cygwin, auto-import functions to prevent compilation */ + /* failures similar to those described at the bottom of 4.1: */ + /* http://docs.python.org/extending/windows.html#a-cookbook-approach */ +# if !defined(__CYGWIN__) +# define PyAPI_FUNC(RTYPE) __declspec(dllimport) RTYPE +# endif /* !__CYGWIN__ */ +# define PyAPI_DATA(RTYPE) extern __declspec(dllimport) RTYPE + /* module init functions outside the core must be exported */ +# if defined(__cplusplus) +# define PyMODINIT_FUNC extern "C" __declspec(dllexport) void +# else /* __cplusplus */ +# define PyMODINIT_FUNC __declspec(dllexport) void +# endif /* __cplusplus */ +# endif /* Py_BUILD_CORE */ +# endif /* HAVE_DECLSPEC */ +#endif /* Py_ENABLE_SHARED */ + +/* If no external linkage macros defined by now, create defaults */ +#ifndef PyAPI_FUNC +# define PyAPI_FUNC(RTYPE) RTYPE +#endif +#ifndef PyAPI_DATA +# define PyAPI_DATA(RTYPE) extern RTYPE +#endif +#ifndef PyMODINIT_FUNC +# if defined(__cplusplus) +# define PyMODINIT_FUNC extern "C" void +# else /* __cplusplus */ +# define PyMODINIT_FUNC void +# endif /* __cplusplus */ +#endif + +/* Deprecated DL_IMPORT and DL_EXPORT macros */ +#if defined(Py_ENABLE_SHARED) && defined (HAVE_DECLSPEC_DLL) +# if defined(Py_BUILD_CORE) +# define DL_IMPORT(RTYPE) __declspec(dllexport) RTYPE +# define DL_EXPORT(RTYPE) __declspec(dllexport) RTYPE +# else +# define DL_IMPORT(RTYPE) __declspec(dllimport) RTYPE +# define DL_EXPORT(RTYPE) __declspec(dllexport) RTYPE +# endif +#endif +#ifndef DL_EXPORT +# define DL_EXPORT(RTYPE) RTYPE +#endif +#ifndef DL_IMPORT +# define DL_IMPORT(RTYPE) RTYPE +#endif +/* End of deprecated DL_* macros */ + +/* If the fd manipulation macros aren't defined, + here is a set that should do the job */ + +#if 0 /* disabled and probably obsolete */ + +#ifndef FD_SETSIZE +#define FD_SETSIZE 256 +#endif + +#ifndef FD_SET + +typedef long fd_mask; + +#define NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mask */ +#ifndef howmany +#define howmany(x, y) (((x)+((y)-1))/(y)) +#endif /* howmany */ + +typedef struct fd_set { + fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)]; +} fd_set; + +#define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS))) +#define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS))) +#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS))) +#define FD_ZERO(p) memset((char *)(p), '\0', sizeof(*(p))) + +#endif /* FD_SET */ + +#endif /* fd manipulation macros */ + + +/* limits.h constants that may be missing */ + +#ifndef INT_MAX +#define INT_MAX 2147483647 +#endif + +#ifndef LONG_MAX +#if SIZEOF_LONG == 4 +#define LONG_MAX 0X7FFFFFFFL +#elif SIZEOF_LONG == 8 +#define LONG_MAX 0X7FFFFFFFFFFFFFFFL +#else +#error "could not set LONG_MAX in pyport.h" +#endif +#endif + +#ifndef LONG_MIN +#define LONG_MIN (-LONG_MAX-1) +#endif + +#ifndef LONG_BIT +#define LONG_BIT (8 * SIZEOF_LONG) +#endif + +#if LONG_BIT != 8 * SIZEOF_LONG +/* 04-Oct-2000 LONG_BIT is apparently (mis)defined as 64 on some recent + * 32-bit platforms using gcc. We try to catch that here at compile-time + * rather than waiting for integer multiplication to trigger bogus + * overflows. + */ +#error "LONG_BIT definition appears wrong for platform (bad gcc/glibc config?)." +#endif + +#ifdef __cplusplus +} +#endif + +/* + * Hide GCC attributes from compilers that don't support them. + */ +#if (!defined(__GNUC__) || __GNUC__ < 2 || \ + (__GNUC__ == 2 && __GNUC_MINOR__ < 7) ) && \ + !defined(RISCOS) +#define Py_GCC_ATTRIBUTE(x) +#else +#define Py_GCC_ATTRIBUTE(x) __attribute__(x) +#endif + +/* + * Add PyArg_ParseTuple format where available. + */ +#ifdef HAVE_ATTRIBUTE_FORMAT_PARSETUPLE +#define Py_FORMAT_PARSETUPLE(func,p1,p2) __attribute__((format(func,p1,p2))) +#else +#define Py_FORMAT_PARSETUPLE(func,p1,p2) +#endif + +/* + * Specify alignment on compilers that support it. + */ +#if defined(__GNUC__) && __GNUC__ >= 3 +#define Py_ALIGNED(x) __attribute__((aligned(x))) +#else +#define Py_ALIGNED(x) +#endif + +/* Eliminate end-of-loop code not reached warnings from SunPro C + * when using do{...}while(0) macros + */ +#ifdef __SUNPRO_C +#pragma error_messages (off,E_END_OF_LOOP_CODE_NOT_REACHED) +#endif + +/* + * Older Microsoft compilers don't support the C99 long long literal suffixes, + * so these will be defined in PC/pyconfig.h for those compilers. + */ +#ifndef Py_LL +#define Py_LL(x) x##LL +#endif + +#ifndef Py_ULL +#define Py_ULL(x) Py_LL(x##U) +#endif + +#endif /* Py_PYPORT_H */ diff --git a/android/python27/include/pystate.h b/android/python27/include/pystate.h new file mode 100644 index 000000000..f2cfc3020 --- /dev/null +++ b/android/python27/include/pystate.h @@ -0,0 +1,200 @@ + +/* Thread and interpreter state structures and their interfaces */ + + +#ifndef Py_PYSTATE_H +#define Py_PYSTATE_H +#ifdef __cplusplus +extern "C" { +#endif + +/* State shared between threads */ + +struct _ts; /* Forward */ +struct _is; /* Forward */ + +typedef struct _is { + + struct _is *next; + struct _ts *tstate_head; + + PyObject *modules; + PyObject *sysdict; + PyObject *builtins; + PyObject *modules_reloading; + + PyObject *codec_search_path; + PyObject *codec_search_cache; + PyObject *codec_error_registry; + +#ifdef HAVE_DLOPEN + int dlopenflags; +#endif +#ifdef WITH_TSC + int tscdump; +#endif + +} PyInterpreterState; + + +/* State unique per thread */ + +struct _frame; /* Avoid including frameobject.h */ + +/* Py_tracefunc return -1 when raising an exception, or 0 for success. */ +typedef int (*Py_tracefunc)(PyObject *, struct _frame *, int, PyObject *); + +/* The following values are used for 'what' for tracefunc functions: */ +#define PyTrace_CALL 0 +#define PyTrace_EXCEPTION 1 +#define PyTrace_LINE 2 +#define PyTrace_RETURN 3 +#define PyTrace_C_CALL 4 +#define PyTrace_C_EXCEPTION 5 +#define PyTrace_C_RETURN 6 + +typedef struct _ts { + /* See Python/ceval.c for comments explaining most fields */ + + struct _ts *next; + PyInterpreterState *interp; + + struct _frame *frame; + int recursion_depth; + /* 'tracing' keeps track of the execution depth when tracing/profiling. + This is to prevent the actual trace/profile code from being recorded in + the trace/profile. */ + int tracing; + int use_tracing; + + Py_tracefunc c_profilefunc; + Py_tracefunc c_tracefunc; + PyObject *c_profileobj; + PyObject *c_traceobj; + + PyObject *curexc_type; + PyObject *curexc_value; + PyObject *curexc_traceback; + + PyObject *exc_type; + PyObject *exc_value; + PyObject *exc_traceback; + + PyObject *dict; /* Stores per-thread state */ + + /* tick_counter is incremented whenever the check_interval ticker + * reaches zero. The purpose is to give a useful measure of the number + * of interpreted bytecode instructions in a given thread. This + * extremely lightweight statistic collector may be of interest to + * profilers (like psyco.jit()), although nothing in the core uses it. + */ + int tick_counter; + + int gilstate_counter; + + PyObject *async_exc; /* Asynchronous exception to raise */ + long thread_id; /* Thread id where this tstate was created */ + + int trash_delete_nesting; + PyObject *trash_delete_later; + + /* XXX signal handlers should also be here */ + +} PyThreadState; + + +PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_New(void); +PyAPI_FUNC(void) PyInterpreterState_Clear(PyInterpreterState *); +PyAPI_FUNC(void) PyInterpreterState_Delete(PyInterpreterState *); + +PyAPI_FUNC(PyThreadState *) PyThreadState_New(PyInterpreterState *); +PyAPI_FUNC(PyThreadState *) _PyThreadState_Prealloc(PyInterpreterState *); +PyAPI_FUNC(void) _PyThreadState_Init(PyThreadState *); +PyAPI_FUNC(void) PyThreadState_Clear(PyThreadState *); +PyAPI_FUNC(void) PyThreadState_Delete(PyThreadState *); +#ifdef WITH_THREAD +PyAPI_FUNC(void) PyThreadState_DeleteCurrent(void); +#endif + +PyAPI_FUNC(PyThreadState *) PyThreadState_Get(void); +PyAPI_FUNC(PyThreadState *) PyThreadState_Swap(PyThreadState *); +PyAPI_FUNC(PyObject *) PyThreadState_GetDict(void); +PyAPI_FUNC(int) PyThreadState_SetAsyncExc(long, PyObject *); + + +/* Variable and macro for in-line access to current thread state */ + +PyAPI_DATA(PyThreadState *) _PyThreadState_Current; + +#ifdef Py_DEBUG +#define PyThreadState_GET() PyThreadState_Get() +#else +#define PyThreadState_GET() (_PyThreadState_Current) +#endif + +typedef + enum {PyGILState_LOCKED, PyGILState_UNLOCKED} + PyGILState_STATE; + +/* Ensure that the current thread is ready to call the Python + C API, regardless of the current state of Python, or of its + thread lock. This may be called as many times as desired + by a thread so long as each call is matched with a call to + PyGILState_Release(). In general, other thread-state APIs may + be used between _Ensure() and _Release() calls, so long as the + thread-state is restored to its previous state before the Release(). + For example, normal use of the Py_BEGIN_ALLOW_THREADS/ + Py_END_ALLOW_THREADS macros are acceptable. + + The return value is an opaque "handle" to the thread state when + PyGILState_Ensure() was called, and must be passed to + PyGILState_Release() to ensure Python is left in the same state. Even + though recursive calls are allowed, these handles can *not* be shared - + each unique call to PyGILState_Ensure must save the handle for its + call to PyGILState_Release. + + When the function returns, the current thread will hold the GIL. + + Failure is a fatal error. +*/ +PyAPI_FUNC(PyGILState_STATE) PyGILState_Ensure(void); + +/* Release any resources previously acquired. After this call, Python's + state will be the same as it was prior to the corresponding + PyGILState_Ensure() call (but generally this state will be unknown to + the caller, hence the use of the GILState API.) + + Every call to PyGILState_Ensure must be matched by a call to + PyGILState_Release on the same thread. +*/ +PyAPI_FUNC(void) PyGILState_Release(PyGILState_STATE); + +/* Helper/diagnostic function - get the current thread state for + this thread. May return NULL if no GILState API has been used + on the current thread. Note that the main thread always has such a + thread-state, even if no auto-thread-state call has been made + on the main thread. +*/ +PyAPI_FUNC(PyThreadState *) PyGILState_GetThisThreadState(void); + +/* The implementation of sys._current_frames() Returns a dict mapping + thread id to that thread's current frame. +*/ +PyAPI_FUNC(PyObject *) _PyThread_CurrentFrames(void); + +/* Routines for advanced debuggers, requested by David Beazley. + Don't use unless you know what you are doing! */ +PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_Head(void); +PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_Next(PyInterpreterState *); +PyAPI_FUNC(PyThreadState *) PyInterpreterState_ThreadHead(PyInterpreterState *); +PyAPI_FUNC(PyThreadState *) PyThreadState_Next(PyThreadState *); + +typedef struct _frame *(*PyThreadFrameGetter)(PyThreadState *self_); + +/* hook for PyEval_GetFrame(), requested for Psyco */ +PyAPI_DATA(PyThreadFrameGetter) _PyThreadState_GetFrame; + +#ifdef __cplusplus +} +#endif +#endif /* !Py_PYSTATE_H */ diff --git a/android/python27/include/pystrcmp.h b/android/python27/include/pystrcmp.h new file mode 100644 index 000000000..369c7e77f --- /dev/null +++ b/android/python27/include/pystrcmp.h @@ -0,0 +1,23 @@ +#ifndef Py_STRCMP_H +#define Py_STRCMP_H + +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_FUNC(int) PyOS_mystrnicmp(const char *, const char *, Py_ssize_t); +PyAPI_FUNC(int) PyOS_mystricmp(const char *, const char *); + +#if defined(MS_WINDOWS) || defined(PYOS_OS2) +#define PyOS_strnicmp strnicmp +#define PyOS_stricmp stricmp +#else +#define PyOS_strnicmp PyOS_mystrnicmp +#define PyOS_stricmp PyOS_mystricmp +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* !Py_STRCMP_H */ diff --git a/android/python27/include/pystrtod.h b/android/python27/include/pystrtod.h new file mode 100644 index 000000000..eec434f1b --- /dev/null +++ b/android/python27/include/pystrtod.h @@ -0,0 +1,45 @@ +#ifndef Py_STRTOD_H +#define Py_STRTOD_H + +#ifdef __cplusplus +extern "C" { +#endif + + +PyAPI_FUNC(double) PyOS_ascii_strtod(const char *str, char **ptr); +PyAPI_FUNC(double) PyOS_ascii_atof(const char *str); + +/* Deprecated in 2.7 and 3.1. Will disappear in 2.8 (if it exists) and 3.2 */ +PyAPI_FUNC(char *) PyOS_ascii_formatd(char *buffer, size_t buf_len, + const char *format, double d); +PyAPI_FUNC(double) PyOS_string_to_double(const char *str, + char **endptr, + PyObject *overflow_exception); + +/* The caller is responsible for calling PyMem_Free to free the buffer + that's is returned. */ +PyAPI_FUNC(char *) PyOS_double_to_string(double val, + char format_code, + int precision, + int flags, + int *type); + +PyAPI_FUNC(double) _Py_parse_inf_or_nan(const char *p, char **endptr); + + +/* PyOS_double_to_string's "flags" parameter can be set to 0 or more of: */ +#define Py_DTSF_SIGN 0x01 /* always add the sign */ +#define Py_DTSF_ADD_DOT_0 0x02 /* if the result is an integer add ".0" */ +#define Py_DTSF_ALT 0x04 /* "alternate" formatting. it's format_code + specific */ + +/* PyOS_double_to_string's "type", if non-NULL, will be set to one of: */ +#define Py_DTST_FINITE 0 +#define Py_DTST_INFINITE 1 +#define Py_DTST_NAN 2 + +#ifdef __cplusplus +} +#endif + +#endif /* !Py_STRTOD_H */ diff --git a/android/python27/include/pythonrun.h b/android/python27/include/pythonrun.h new file mode 100644 index 000000000..2151ddaf3 --- /dev/null +++ b/android/python27/include/pythonrun.h @@ -0,0 +1,182 @@ + +/* Interfaces to parse and execute pieces of python code */ + +#ifndef Py_PYTHONRUN_H +#define Py_PYTHONRUN_H +#ifdef __cplusplus +extern "C" { +#endif + +#define PyCF_MASK (CO_FUTURE_DIVISION | CO_FUTURE_ABSOLUTE_IMPORT | \ + CO_FUTURE_WITH_STATEMENT | CO_FUTURE_PRINT_FUNCTION | \ + CO_FUTURE_UNICODE_LITERALS) +#define PyCF_MASK_OBSOLETE (CO_NESTED) +#define PyCF_SOURCE_IS_UTF8 0x0100 +#define PyCF_DONT_IMPLY_DEDENT 0x0200 +#define PyCF_ONLY_AST 0x0400 + +typedef struct { + int cf_flags; /* bitmask of CO_xxx flags relevant to future */ +} PyCompilerFlags; + +PyAPI_FUNC(void) Py_SetProgramName(char *); +PyAPI_FUNC(char *) Py_GetProgramName(void); + +PyAPI_FUNC(void) Py_SetPythonHome(char *); +PyAPI_FUNC(char *) Py_GetPythonHome(void); + +PyAPI_FUNC(void) Py_Initialize(void); +PyAPI_FUNC(void) Py_InitializeEx(int); +PyAPI_FUNC(void) Py_Finalize(void); +PyAPI_FUNC(int) Py_IsInitialized(void); +PyAPI_FUNC(PyThreadState *) Py_NewInterpreter(void); +PyAPI_FUNC(void) Py_EndInterpreter(PyThreadState *); + +PyAPI_FUNC(int) PyRun_AnyFileFlags(FILE *, const char *, PyCompilerFlags *); +PyAPI_FUNC(int) PyRun_AnyFileExFlags(FILE *, const char *, int, PyCompilerFlags *); +PyAPI_FUNC(int) PyRun_SimpleStringFlags(const char *, PyCompilerFlags *); +PyAPI_FUNC(int) PyRun_SimpleFileExFlags(FILE *, const char *, int, PyCompilerFlags *); +PyAPI_FUNC(int) PyRun_InteractiveOneFlags(FILE *, const char *, PyCompilerFlags *); +PyAPI_FUNC(int) PyRun_InteractiveLoopFlags(FILE *, const char *, PyCompilerFlags *); + +PyAPI_FUNC(struct _mod *) PyParser_ASTFromString(const char *, const char *, + int, PyCompilerFlags *flags, + PyArena *); +PyAPI_FUNC(struct _mod *) PyParser_ASTFromFile(FILE *, const char *, int, + char *, char *, + PyCompilerFlags *, int *, + PyArena *); +#define PyParser_SimpleParseString(S, B) \ + PyParser_SimpleParseStringFlags(S, B, 0) +#define PyParser_SimpleParseFile(FP, S, B) \ + PyParser_SimpleParseFileFlags(FP, S, B, 0) +PyAPI_FUNC(struct _node *) PyParser_SimpleParseStringFlags(const char *, int, + int); +PyAPI_FUNC(struct _node *) PyParser_SimpleParseFileFlags(FILE *, const char *, + int, int); + +PyAPI_FUNC(PyObject *) PyRun_StringFlags(const char *, int, PyObject *, + PyObject *, PyCompilerFlags *); + +PyAPI_FUNC(PyObject *) PyRun_FileExFlags(FILE *, const char *, int, + PyObject *, PyObject *, int, + PyCompilerFlags *); + +#define Py_CompileString(str, p, s) Py_CompileStringFlags(str, p, s, NULL) +PyAPI_FUNC(PyObject *) Py_CompileStringFlags(const char *, const char *, int, + PyCompilerFlags *); +PyAPI_FUNC(struct symtable *) Py_SymtableString(const char *, const char *, int); + +PyAPI_FUNC(void) PyErr_Print(void); +PyAPI_FUNC(void) PyErr_PrintEx(int); +PyAPI_FUNC(void) PyErr_Display(PyObject *, PyObject *, PyObject *); + +PyAPI_FUNC(int) Py_AtExit(void (*func)(void)); + +PyAPI_FUNC(void) Py_Exit(int); + +PyAPI_FUNC(int) Py_FdIsInteractive(FILE *, const char *); + +/* Bootstrap */ +PyAPI_FUNC(int) Py_Main(int argc, char **argv); + +/* Use macros for a bunch of old variants */ +#define PyRun_String(str, s, g, l) PyRun_StringFlags(str, s, g, l, NULL) +#define PyRun_AnyFile(fp, name) PyRun_AnyFileExFlags(fp, name, 0, NULL) +#define PyRun_AnyFileEx(fp, name, closeit) \ + PyRun_AnyFileExFlags(fp, name, closeit, NULL) +#define PyRun_AnyFileFlags(fp, name, flags) \ + PyRun_AnyFileExFlags(fp, name, 0, flags) +#define PyRun_SimpleString(s) PyRun_SimpleStringFlags(s, NULL) +#define PyRun_SimpleFile(f, p) PyRun_SimpleFileExFlags(f, p, 0, NULL) +#define PyRun_SimpleFileEx(f, p, c) PyRun_SimpleFileExFlags(f, p, c, NULL) +#define PyRun_InteractiveOne(f, p) PyRun_InteractiveOneFlags(f, p, NULL) +#define PyRun_InteractiveLoop(f, p) PyRun_InteractiveLoopFlags(f, p, NULL) +#define PyRun_File(fp, p, s, g, l) \ + PyRun_FileExFlags(fp, p, s, g, l, 0, NULL) +#define PyRun_FileEx(fp, p, s, g, l, c) \ + PyRun_FileExFlags(fp, p, s, g, l, c, NULL) +#define PyRun_FileFlags(fp, p, s, g, l, flags) \ + PyRun_FileExFlags(fp, p, s, g, l, 0, flags) + +/* In getpath.c */ +PyAPI_FUNC(char *) Py_GetProgramFullPath(void); +PyAPI_FUNC(char *) Py_GetPrefix(void); +PyAPI_FUNC(char *) Py_GetExecPrefix(void); +PyAPI_FUNC(char *) Py_GetPath(void); + +/* In their own files */ +PyAPI_FUNC(const char *) Py_GetVersion(void); +PyAPI_FUNC(const char *) Py_GetPlatform(void); +PyAPI_FUNC(const char *) Py_GetCopyright(void); +PyAPI_FUNC(const char *) Py_GetCompiler(void); +PyAPI_FUNC(const char *) Py_GetBuildInfo(void); +PyAPI_FUNC(const char *) _Py_svnversion(void); +PyAPI_FUNC(const char *) Py_SubversionRevision(void); +PyAPI_FUNC(const char *) Py_SubversionShortBranch(void); +PyAPI_FUNC(const char *) _Py_hgidentifier(void); +PyAPI_FUNC(const char *) _Py_hgversion(void); + +/* Internal -- various one-time initializations */ +PyAPI_FUNC(PyObject *) _PyBuiltin_Init(void); +PyAPI_FUNC(PyObject *) _PySys_Init(void); +PyAPI_FUNC(void) _PyImport_Init(void); +PyAPI_FUNC(void) _PyExc_Init(void); +PyAPI_FUNC(void) _PyImportHooks_Init(void); +PyAPI_FUNC(int) _PyFrame_Init(void); +PyAPI_FUNC(int) _PyInt_Init(void); +PyAPI_FUNC(int) _PyLong_Init(void); +PyAPI_FUNC(void) _PyFloat_Init(void); +PyAPI_FUNC(int) PyByteArray_Init(void); +PyAPI_FUNC(void) _PyRandom_Init(void); + +/* Various internal finalizers */ +PyAPI_FUNC(void) _PyExc_Fini(void); +PyAPI_FUNC(void) _PyImport_Fini(void); +PyAPI_FUNC(void) PyMethod_Fini(void); +PyAPI_FUNC(void) PyFrame_Fini(void); +PyAPI_FUNC(void) PyCFunction_Fini(void); +PyAPI_FUNC(void) PyDict_Fini(void); +PyAPI_FUNC(void) PyTuple_Fini(void); +PyAPI_FUNC(void) PyList_Fini(void); +PyAPI_FUNC(void) PySet_Fini(void); +PyAPI_FUNC(void) PyString_Fini(void); +PyAPI_FUNC(void) PyInt_Fini(void); +PyAPI_FUNC(void) PyFloat_Fini(void); +PyAPI_FUNC(void) PyOS_FiniInterrupts(void); +PyAPI_FUNC(void) PyByteArray_Fini(void); +PyAPI_FUNC(void) _PyRandom_Fini(void); + +/* Stuff with no proper home (yet) */ +PyAPI_FUNC(char *) PyOS_Readline(FILE *, FILE *, char *); +PyAPI_DATA(int) (*PyOS_InputHook)(void); +PyAPI_DATA(char) *(*PyOS_ReadlineFunctionPointer)(FILE *, FILE *, char *); +PyAPI_DATA(PyThreadState*) _PyOS_ReadlineTState; + +/* Stack size, in "pointers" (so we get extra safety margins + on 64-bit platforms). On a 32-bit platform, this translates + to a 8k margin. */ +#define PYOS_STACK_MARGIN 2048 + +#if defined(WIN32) && !defined(MS_WIN64) && defined(_MSC_VER) && _MSC_VER >= 1300 +/* Enable stack checking under Microsoft C */ +#define USE_STACKCHECK +#endif + +#ifdef USE_STACKCHECK +/* Check that we aren't overflowing our stack */ +PyAPI_FUNC(int) PyOS_CheckStack(void); +#endif + +/* Signals */ +typedef void (*PyOS_sighandler_t)(int); +PyAPI_FUNC(PyOS_sighandler_t) PyOS_getsig(int); +PyAPI_FUNC(PyOS_sighandler_t) PyOS_setsig(int, PyOS_sighandler_t); + +/* Random */ +PyAPI_FUNC(int) _PyOS_URandom (void *buffer, Py_ssize_t size); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_PYTHONRUN_H */ diff --git a/android/python27/include/pythread.h b/android/python27/include/pythread.h new file mode 100644 index 000000000..dfd61575e --- /dev/null +++ b/android/python27/include/pythread.h @@ -0,0 +1,41 @@ + +#ifndef Py_PYTHREAD_H +#define Py_PYTHREAD_H + +typedef void *PyThread_type_lock; +typedef void *PyThread_type_sema; + +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_FUNC(void) PyThread_init_thread(void); +PyAPI_FUNC(long) PyThread_start_new_thread(void (*)(void *), void *); +PyAPI_FUNC(void) PyThread_exit_thread(void); +PyAPI_FUNC(long) PyThread_get_thread_ident(void); + +PyAPI_FUNC(PyThread_type_lock) PyThread_allocate_lock(void); +PyAPI_FUNC(void) PyThread_free_lock(PyThread_type_lock); +PyAPI_FUNC(int) PyThread_acquire_lock(PyThread_type_lock, int); +#define WAIT_LOCK 1 +#define NOWAIT_LOCK 0 +PyAPI_FUNC(void) PyThread_release_lock(PyThread_type_lock); + +PyAPI_FUNC(size_t) PyThread_get_stacksize(void); +PyAPI_FUNC(int) PyThread_set_stacksize(size_t); + +/* Thread Local Storage (TLS) API */ +PyAPI_FUNC(int) PyThread_create_key(void); +PyAPI_FUNC(void) PyThread_delete_key(int); +PyAPI_FUNC(int) PyThread_set_key_value(int, void *); +PyAPI_FUNC(void *) PyThread_get_key_value(int); +PyAPI_FUNC(void) PyThread_delete_key_value(int key); + +/* Cleanup after a fork */ +PyAPI_FUNC(void) PyThread_ReInitTLS(void); + +#ifdef __cplusplus +} +#endif + +#endif /* !Py_PYTHREAD_H */ diff --git a/android/python27/include/rangeobject.h b/android/python27/include/rangeobject.h new file mode 100644 index 000000000..36c9cee5a --- /dev/null +++ b/android/python27/include/rangeobject.h @@ -0,0 +1,28 @@ + +/* Range object interface */ + +#ifndef Py_RANGEOBJECT_H +#define Py_RANGEOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +/* This is about the type 'xrange', not the built-in function range(), which + returns regular lists. */ + +/* +A range object represents an integer range. This is an immutable object; +a range cannot change its value after creation. + +Range objects behave like the corresponding tuple objects except that +they are represented by a start, stop, and step datamembers. +*/ + +PyAPI_DATA(PyTypeObject) PyRange_Type; + +#define PyRange_Check(op) (Py_TYPE(op) == &PyRange_Type) + +#ifdef __cplusplus +} +#endif +#endif /* !Py_RANGEOBJECT_H */ diff --git a/android/python27/include/setobject.h b/android/python27/include/setobject.h new file mode 100644 index 000000000..52b07d52d --- /dev/null +++ b/android/python27/include/setobject.h @@ -0,0 +1,99 @@ +/* Set object interface */ + +#ifndef Py_SETOBJECT_H +#define Py_SETOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + + +/* +There are three kinds of slots in the table: + +1. Unused: key == NULL +2. Active: key != NULL and key != dummy +3. Dummy: key == dummy + +Note: .pop() abuses the hash field of an Unused or Dummy slot to +hold a search finger. The hash field of Unused or Dummy slots has +no meaning otherwise. +*/ + +#define PySet_MINSIZE 8 + +typedef struct { + long hash; /* cached hash code for the entry key */ + PyObject *key; +} setentry; + + +/* +This data structure is shared by set and frozenset objects. +*/ + +typedef struct _setobject PySetObject; +struct _setobject { + PyObject_HEAD + + Py_ssize_t fill; /* # Active + # Dummy */ + Py_ssize_t used; /* # Active */ + + /* The table contains mask + 1 slots, and that's a power of 2. + * We store the mask instead of the size because the mask is more + * frequently needed. + */ + Py_ssize_t mask; + + /* table points to smalltable for small tables, else to + * additional malloc'ed memory. table is never NULL! This rule + * saves repeated runtime null-tests. + */ + setentry *table; + setentry *(*lookup)(PySetObject *so, PyObject *key, long hash); + setentry smalltable[PySet_MINSIZE]; + + long hash; /* only used by frozenset objects */ + PyObject *weakreflist; /* List of weak references */ +}; + +PyAPI_DATA(PyTypeObject) PySet_Type; +PyAPI_DATA(PyTypeObject) PyFrozenSet_Type; + +/* Invariants for frozensets: + * data is immutable. + * hash is the hash of the frozenset or -1 if not computed yet. + * Invariants for sets: + * hash is -1 + */ + +#define PyFrozenSet_CheckExact(ob) (Py_TYPE(ob) == &PyFrozenSet_Type) +#define PyAnySet_CheckExact(ob) \ + (Py_TYPE(ob) == &PySet_Type || Py_TYPE(ob) == &PyFrozenSet_Type) +#define PyAnySet_Check(ob) \ + (Py_TYPE(ob) == &PySet_Type || Py_TYPE(ob) == &PyFrozenSet_Type || \ + PyType_IsSubtype(Py_TYPE(ob), &PySet_Type) || \ + PyType_IsSubtype(Py_TYPE(ob), &PyFrozenSet_Type)) +#define PySet_Check(ob) \ + (Py_TYPE(ob) == &PySet_Type || \ + PyType_IsSubtype(Py_TYPE(ob), &PySet_Type)) +#define PyFrozenSet_Check(ob) \ + (Py_TYPE(ob) == &PyFrozenSet_Type || \ + PyType_IsSubtype(Py_TYPE(ob), &PyFrozenSet_Type)) + +PyAPI_FUNC(PyObject *) PySet_New(PyObject *); +PyAPI_FUNC(PyObject *) PyFrozenSet_New(PyObject *); +PyAPI_FUNC(Py_ssize_t) PySet_Size(PyObject *anyset); +#define PySet_GET_SIZE(so) (((PySetObject *)(so))->used) +PyAPI_FUNC(int) PySet_Clear(PyObject *set); +PyAPI_FUNC(int) PySet_Contains(PyObject *anyset, PyObject *key); +PyAPI_FUNC(int) PySet_Discard(PyObject *set, PyObject *key); +PyAPI_FUNC(int) PySet_Add(PyObject *set, PyObject *key); +PyAPI_FUNC(int) _PySet_Next(PyObject *set, Py_ssize_t *pos, PyObject **key); +PyAPI_FUNC(int) _PySet_NextEntry(PyObject *set, Py_ssize_t *pos, PyObject **key, long *hash); +PyAPI_FUNC(PyObject *) PySet_Pop(PyObject *set); +PyAPI_FUNC(int) _PySet_Update(PyObject *set, PyObject *iterable); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_SETOBJECT_H */ diff --git a/android/python27/include/sliceobject.h b/android/python27/include/sliceobject.h new file mode 100644 index 000000000..8ab62dd4f --- /dev/null +++ b/android/python27/include/sliceobject.h @@ -0,0 +1,44 @@ +#ifndef Py_SLICEOBJECT_H +#define Py_SLICEOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +/* The unique ellipsis object "..." */ + +PyAPI_DATA(PyObject) _Py_EllipsisObject; /* Don't use this directly */ + +#define Py_Ellipsis (&_Py_EllipsisObject) + +/* Slice object interface */ + +/* + +A slice object containing start, stop, and step data members (the +names are from range). After much talk with Guido, it was decided to +let these be any arbitrary python type. Py_None stands for omitted values. +*/ + +typedef struct { + PyObject_HEAD + PyObject *start, *stop, *step; /* not NULL */ +} PySliceObject; + +PyAPI_DATA(PyTypeObject) PySlice_Type; +PyAPI_DATA(PyTypeObject) PyEllipsis_Type; + +#define PySlice_Check(op) (Py_TYPE(op) == &PySlice_Type) + +PyAPI_FUNC(PyObject *) PySlice_New(PyObject* start, PyObject* stop, + PyObject* step); +PyAPI_FUNC(PyObject *) _PySlice_FromIndices(Py_ssize_t start, Py_ssize_t stop); +PyAPI_FUNC(int) PySlice_GetIndices(PySliceObject *r, Py_ssize_t length, + Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step); +PyAPI_FUNC(int) PySlice_GetIndicesEx(PySliceObject *r, Py_ssize_t length, + Py_ssize_t *start, Py_ssize_t *stop, + Py_ssize_t *step, Py_ssize_t *slicelength); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_SLICEOBJECT_H */ diff --git a/android/python27/include/stringobject.h b/android/python27/include/stringobject.h new file mode 100644 index 000000000..18b5b411a --- /dev/null +++ b/android/python27/include/stringobject.h @@ -0,0 +1,210 @@ + +/* String (str/bytes) object interface */ + +#ifndef Py_STRINGOBJECT_H +#define Py_STRINGOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/* +Type PyStringObject represents a character string. An extra zero byte is +reserved at the end to ensure it is zero-terminated, but a size is +present so strings with null bytes in them can be represented. This +is an immutable object type. + +There are functions to create new string objects, to test +an object for string-ness, and to get the +string value. The latter function returns a null pointer +if the object is not of the proper type. +There is a variant that takes an explicit size as well as a +variant that assumes a zero-terminated string. Note that none of the +functions should be applied to nil objects. +*/ + +/* Caching the hash (ob_shash) saves recalculation of a string's hash value. + Interning strings (ob_sstate) tries to ensure that only one string + object with a given value exists, so equality tests can be one pointer + comparison. This is generally restricted to strings that "look like" + Python identifiers, although the intern() builtin can be used to force + interning of any string. + Together, these sped the interpreter by up to 20%. */ + +typedef struct { + PyObject_VAR_HEAD + long ob_shash; + int ob_sstate; + char ob_sval[1]; + + /* Invariants: + * ob_sval contains space for 'ob_size+1' elements. + * ob_sval[ob_size] == 0. + * ob_shash is the hash of the string or -1 if not computed yet. + * ob_sstate != 0 iff the string object is in stringobject.c's + * 'interned' dictionary; in this case the two references + * from 'interned' to this object are *not counted* in ob_refcnt. + */ +} PyStringObject; + +#define SSTATE_NOT_INTERNED 0 +#define SSTATE_INTERNED_MORTAL 1 +#define SSTATE_INTERNED_IMMORTAL 2 + +PyAPI_DATA(PyTypeObject) PyBaseString_Type; +PyAPI_DATA(PyTypeObject) PyString_Type; + +#define PyString_Check(op) \ + PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_STRING_SUBCLASS) +#define PyString_CheckExact(op) (Py_TYPE(op) == &PyString_Type) + +PyAPI_FUNC(PyObject *) PyString_FromStringAndSize(const char *, Py_ssize_t); +PyAPI_FUNC(PyObject *) PyString_FromString(const char *); +PyAPI_FUNC(PyObject *) PyString_FromFormatV(const char*, va_list) + Py_GCC_ATTRIBUTE((format(printf, 1, 0))); +PyAPI_FUNC(PyObject *) PyString_FromFormat(const char*, ...) + Py_GCC_ATTRIBUTE((format(printf, 1, 2))); +PyAPI_FUNC(Py_ssize_t) PyString_Size(PyObject *); +PyAPI_FUNC(char *) PyString_AsString(PyObject *); +PyAPI_FUNC(PyObject *) PyString_Repr(PyObject *, int); +PyAPI_FUNC(void) PyString_Concat(PyObject **, PyObject *); +PyAPI_FUNC(void) PyString_ConcatAndDel(PyObject **, PyObject *); +PyAPI_FUNC(int) _PyString_Resize(PyObject **, Py_ssize_t); +PyAPI_FUNC(int) _PyString_Eq(PyObject *, PyObject*); +PyAPI_FUNC(PyObject *) PyString_Format(PyObject *, PyObject *); +PyAPI_FUNC(PyObject *) _PyString_FormatLong(PyObject*, int, int, + int, char**, int*); +PyAPI_FUNC(PyObject *) PyString_DecodeEscape(const char *, Py_ssize_t, + const char *, Py_ssize_t, + const char *); + +PyAPI_FUNC(void) PyString_InternInPlace(PyObject **); +PyAPI_FUNC(void) PyString_InternImmortal(PyObject **); +PyAPI_FUNC(PyObject *) PyString_InternFromString(const char *); +PyAPI_FUNC(void) _Py_ReleaseInternedStrings(void); + +/* Use only if you know it's a string */ +#define PyString_CHECK_INTERNED(op) (((PyStringObject *)(op))->ob_sstate) + +/* Macro, trading safety for speed */ +#define PyString_AS_STRING(op) (((PyStringObject *)(op))->ob_sval) +#define PyString_GET_SIZE(op) Py_SIZE(op) + +/* _PyString_Join(sep, x) is like sep.join(x). sep must be PyStringObject*, + x must be an iterable object. */ +PyAPI_FUNC(PyObject *) _PyString_Join(PyObject *sep, PyObject *x); + +/* --- Generic Codecs ----------------------------------------------------- */ + +/* Create an object by decoding the encoded string s of the + given size. */ + +PyAPI_FUNC(PyObject*) PyString_Decode( + const char *s, /* encoded string */ + Py_ssize_t size, /* size of buffer */ + const char *encoding, /* encoding */ + const char *errors /* error handling */ + ); + +/* Encodes a char buffer of the given size and returns a + Python object. */ + +PyAPI_FUNC(PyObject*) PyString_Encode( + const char *s, /* string char buffer */ + Py_ssize_t size, /* number of chars to encode */ + const char *encoding, /* encoding */ + const char *errors /* error handling */ + ); + +/* Encodes a string object and returns the result as Python + object. */ + +PyAPI_FUNC(PyObject*) PyString_AsEncodedObject( + PyObject *str, /* string object */ + const char *encoding, /* encoding */ + const char *errors /* error handling */ + ); + +/* Encodes a string object and returns the result as Python string + object. + + If the codec returns an Unicode object, the object is converted + back to a string using the default encoding. + + DEPRECATED - use PyString_AsEncodedObject() instead. */ + +PyAPI_FUNC(PyObject*) PyString_AsEncodedString( + PyObject *str, /* string object */ + const char *encoding, /* encoding */ + const char *errors /* error handling */ + ); + +/* Decodes a string object and returns the result as Python + object. */ + +PyAPI_FUNC(PyObject*) PyString_AsDecodedObject( + PyObject *str, /* string object */ + const char *encoding, /* encoding */ + const char *errors /* error handling */ + ); + +/* Decodes a string object and returns the result as Python string + object. + + If the codec returns an Unicode object, the object is converted + back to a string using the default encoding. + + DEPRECATED - use PyString_AsDecodedObject() instead. */ + +PyAPI_FUNC(PyObject*) PyString_AsDecodedString( + PyObject *str, /* string object */ + const char *encoding, /* encoding */ + const char *errors /* error handling */ + ); + +/* Provides access to the internal data buffer and size of a string + object or the default encoded version of an Unicode object. Passing + NULL as *len parameter will force the string buffer to be + 0-terminated (passing a string with embedded NULL characters will + cause an exception). */ + +PyAPI_FUNC(int) PyString_AsStringAndSize( + register PyObject *obj, /* string or Unicode object */ + register char **s, /* pointer to buffer variable */ + register Py_ssize_t *len /* pointer to length variable or NULL + (only possible for 0-terminated + strings) */ + ); + + +/* Using the current locale, insert the thousands grouping + into the string pointed to by buffer. For the argument descriptions, + see Objects/stringlib/localeutil.h */ +PyAPI_FUNC(Py_ssize_t) _PyString_InsertThousandsGroupingLocale(char *buffer, + Py_ssize_t n_buffer, + char *digits, + Py_ssize_t n_digits, + Py_ssize_t min_width); + +/* Using explicit passed-in values, insert the thousands grouping + into the string pointed to by buffer. For the argument descriptions, + see Objects/stringlib/localeutil.h */ +PyAPI_FUNC(Py_ssize_t) _PyString_InsertThousandsGrouping(char *buffer, + Py_ssize_t n_buffer, + char *digits, + Py_ssize_t n_digits, + Py_ssize_t min_width, + const char *grouping, + const char *thousands_sep); + +/* Format the object based on the format_spec, as defined in PEP 3101 + (Advanced String Formatting). */ +PyAPI_FUNC(PyObject *) _PyBytes_FormatAdvanced(PyObject *obj, + char *format_spec, + Py_ssize_t format_spec_len); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_STRINGOBJECT_H */ diff --git a/android/python27/include/structmember.h b/android/python27/include/structmember.h new file mode 100644 index 000000000..fe5b44ea3 --- /dev/null +++ b/android/python27/include/structmember.h @@ -0,0 +1,99 @@ +#ifndef Py_STRUCTMEMBER_H +#define Py_STRUCTMEMBER_H +#ifdef __cplusplus +extern "C" { +#endif + + +/* Interface to map C struct members to Python object attributes */ + +#include /* For offsetof */ + +/* The offsetof() macro calculates the offset of a structure member + in its structure. Unfortunately this cannot be written down + portably, hence it is provided by a Standard C header file. + For pre-Standard C compilers, here is a version that usually works + (but watch out!): */ + +#ifndef offsetof +#define offsetof(type, member) ( (int) & ((type*)0) -> member ) +#endif + +/* An array of memberlist structures defines the name, type and offset + of selected members of a C structure. These can be read by + PyMember_Get() and set by PyMember_Set() (except if their READONLY flag + is set). The array must be terminated with an entry whose name + pointer is NULL. */ + +struct memberlist { + /* Obsolete version, for binary backwards compatibility */ + char *name; + int type; + int offset; + int flags; +}; + +typedef struct PyMemberDef { + /* Current version, use this */ + char *name; + int type; + Py_ssize_t offset; + int flags; + char *doc; +} PyMemberDef; + +/* Types */ +#define T_SHORT 0 +#define T_INT 1 +#define T_LONG 2 +#define T_FLOAT 3 +#define T_DOUBLE 4 +#define T_STRING 5 +#define T_OBJECT 6 +/* XXX the ordering here is weird for binary compatibility */ +#define T_CHAR 7 /* 1-character string */ +#define T_BYTE 8 /* 8-bit signed int */ +/* unsigned variants: */ +#define T_UBYTE 9 +#define T_USHORT 10 +#define T_UINT 11 +#define T_ULONG 12 + +/* Added by Jack: strings contained in the structure */ +#define T_STRING_INPLACE 13 + +/* Added by Lillo: bools contained in the structure (assumed char) */ +#define T_BOOL 14 + +#define T_OBJECT_EX 16 /* Like T_OBJECT, but raises AttributeError + when the value is NULL, instead of + converting to None. */ +#ifdef HAVE_LONG_LONG +#define T_LONGLONG 17 +#define T_ULONGLONG 18 +#endif /* HAVE_LONG_LONG */ + +#define T_PYSSIZET 19 /* Py_ssize_t */ + + +/* Flags */ +#define READONLY 1 +#define RO READONLY /* Shorthand */ +#define READ_RESTRICTED 2 +#define PY_WRITE_RESTRICTED 4 +#define RESTRICTED (READ_RESTRICTED | PY_WRITE_RESTRICTED) + + +/* Obsolete API, for binary backwards compatibility */ +PyAPI_FUNC(PyObject *) PyMember_Get(const char *, struct memberlist *, const char *); +PyAPI_FUNC(int) PyMember_Set(char *, struct memberlist *, const char *, PyObject *); + +/* Current API, use this */ +PyAPI_FUNC(PyObject *) PyMember_GetOne(const char *, struct PyMemberDef *); +PyAPI_FUNC(int) PyMember_SetOne(char *, struct PyMemberDef *, PyObject *); + + +#ifdef __cplusplus +} +#endif +#endif /* !Py_STRUCTMEMBER_H */ diff --git a/android/python27/include/structseq.h b/android/python27/include/structseq.h new file mode 100644 index 000000000..e662916fe --- /dev/null +++ b/android/python27/include/structseq.h @@ -0,0 +1,41 @@ + +/* Tuple object interface */ + +#ifndef Py_STRUCTSEQ_H +#define Py_STRUCTSEQ_H +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct PyStructSequence_Field { + char *name; + char *doc; +} PyStructSequence_Field; + +typedef struct PyStructSequence_Desc { + char *name; + char *doc; + struct PyStructSequence_Field *fields; + int n_in_sequence; +} PyStructSequence_Desc; + +extern char* PyStructSequence_UnnamedField; + +PyAPI_FUNC(void) PyStructSequence_InitType(PyTypeObject *type, + PyStructSequence_Desc *desc); + +PyAPI_FUNC(PyObject *) PyStructSequence_New(PyTypeObject* type); + +typedef struct { + PyObject_VAR_HEAD + PyObject *ob_item[1]; +} PyStructSequence; + +/* Macro, *only* to be used to fill in brand new objects */ +#define PyStructSequence_SET_ITEM(op, i, v) \ + (((PyStructSequence *)(op))->ob_item[i] = v) + +#ifdef __cplusplus +} +#endif +#endif /* !Py_STRUCTSEQ_H */ diff --git a/android/python27/include/symtable.h b/android/python27/include/symtable.h new file mode 100644 index 000000000..e0a0be41b --- /dev/null +++ b/android/python27/include/symtable.h @@ -0,0 +1,98 @@ +#ifndef Py_SYMTABLE_H +#define Py_SYMTABLE_H + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum _block_type { FunctionBlock, ClassBlock, ModuleBlock } + _Py_block_ty; + +struct _symtable_entry; + +struct symtable { + const char *st_filename; /* name of file being compiled */ + struct _symtable_entry *st_cur; /* current symbol table entry */ + struct _symtable_entry *st_top; /* module entry */ + PyObject *st_symbols; /* dictionary of symbol table entries */ + PyObject *st_stack; /* stack of namespace info */ + PyObject *st_global; /* borrowed ref to MODULE in st_symbols */ + int st_nblocks; /* number of blocks */ + PyObject *st_private; /* name of current class or NULL */ + PyFutureFeatures *st_future; /* module's future features */ +}; + +typedef struct _symtable_entry { + PyObject_HEAD + PyObject *ste_id; /* int: key in st_symbols */ + PyObject *ste_symbols; /* dict: name to flags */ + PyObject *ste_name; /* string: name of block */ + PyObject *ste_varnames; /* list of variable names */ + PyObject *ste_children; /* list of child ids */ + _Py_block_ty ste_type; /* module, class, or function */ + int ste_unoptimized; /* false if namespace is optimized */ + int ste_nested; /* true if block is nested */ + unsigned ste_free : 1; /* true if block has free variables */ + unsigned ste_child_free : 1; /* true if a child block has free vars, + including free refs to globals */ + unsigned ste_generator : 1; /* true if namespace is a generator */ + unsigned ste_varargs : 1; /* true if block has varargs */ + unsigned ste_varkeywords : 1; /* true if block has varkeywords */ + unsigned ste_returns_value : 1; /* true if namespace uses return with + an argument */ + int ste_lineno; /* first line of block */ + int ste_opt_lineno; /* lineno of last exec or import * */ + int ste_tmpname; /* counter for listcomp temp vars */ + struct symtable *ste_table; +} PySTEntryObject; + +PyAPI_DATA(PyTypeObject) PySTEntry_Type; + +#define PySTEntry_Check(op) (Py_TYPE(op) == &PySTEntry_Type) + +PyAPI_FUNC(int) PyST_GetScope(PySTEntryObject *, PyObject *); + +PyAPI_FUNC(struct symtable *) PySymtable_Build(mod_ty, const char *, + PyFutureFeatures *); +PyAPI_FUNC(PySTEntryObject *) PySymtable_Lookup(struct symtable *, void *); + +PyAPI_FUNC(void) PySymtable_Free(struct symtable *); + +/* Flags for def-use information */ + +#define DEF_GLOBAL 1 /* global stmt */ +#define DEF_LOCAL 2 /* assignment in code block */ +#define DEF_PARAM 2<<1 /* formal parameter */ +#define USE 2<<2 /* name is used */ +#define DEF_FREE 2<<3 /* name used but not defined in nested block */ +#define DEF_FREE_CLASS 2<<4 /* free variable from class's method */ +#define DEF_IMPORT 2<<5 /* assignment occurred via import */ + +#define DEF_BOUND (DEF_LOCAL | DEF_PARAM | DEF_IMPORT) + +/* GLOBAL_EXPLICIT and GLOBAL_IMPLICIT are used internally by the symbol + table. GLOBAL is returned from PyST_GetScope() for either of them. + It is stored in ste_symbols at bits 12-14. +*/ +#define SCOPE_OFF 11 +#define SCOPE_MASK 7 + +#define LOCAL 1 +#define GLOBAL_EXPLICIT 2 +#define GLOBAL_IMPLICIT 3 +#define FREE 4 +#define CELL 5 + +/* The following three names are used for the ste_unoptimized bit field */ +#define OPT_IMPORT_STAR 1 +#define OPT_EXEC 2 +#define OPT_BARE_EXEC 4 +#define OPT_TOPLEVEL 8 /* top-level names, including eval and exec */ + +#define GENERATOR 1 +#define GENERATOR_EXPRESSION 2 + +#ifdef __cplusplus +} +#endif +#endif /* !Py_SYMTABLE_H */ diff --git a/android/python27/include/sysmodule.h b/android/python27/include/sysmodule.h new file mode 100644 index 000000000..678797805 --- /dev/null +++ b/android/python27/include/sysmodule.h @@ -0,0 +1,31 @@ + +/* System module interface */ + +#ifndef Py_SYSMODULE_H +#define Py_SYSMODULE_H +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_FUNC(PyObject *) PySys_GetObject(char *); +PyAPI_FUNC(int) PySys_SetObject(char *, PyObject *); +PyAPI_FUNC(FILE *) PySys_GetFile(char *, FILE *); +PyAPI_FUNC(void) PySys_SetArgv(int, char **); +PyAPI_FUNC(void) PySys_SetArgvEx(int, char **, int); +PyAPI_FUNC(void) PySys_SetPath(char *); + +PyAPI_FUNC(void) PySys_WriteStdout(const char *format, ...) + Py_GCC_ATTRIBUTE((format(printf, 1, 2))); +PyAPI_FUNC(void) PySys_WriteStderr(const char *format, ...) + Py_GCC_ATTRIBUTE((format(printf, 1, 2))); + +PyAPI_FUNC(void) PySys_ResetWarnOptions(void); +PyAPI_FUNC(void) PySys_AddWarnOption(char *); +PyAPI_FUNC(int) PySys_HasWarnOptions(void); + +PyAPI_FUNC(size_t) _PySys_GetSizeOf(PyObject *); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_SYSMODULE_H */ diff --git a/android/python27/include/timefuncs.h b/android/python27/include/timefuncs.h new file mode 100644 index 000000000..a9d26a77a --- /dev/null +++ b/android/python27/include/timefuncs.h @@ -0,0 +1,26 @@ +/* timefuncs.h + */ + +/* Utility function related to timemodule.c. */ + +#ifndef TIMEFUNCS_H +#define TIMEFUNCS_H +#ifdef __cplusplus +extern "C" { +#endif + + +/* Cast double x to time_t, but raise ValueError if x is too large + * to fit in a time_t. ValueError is set on return iff the return + * value is (time_t)-1 and PyErr_Occurred(). + */ +PyAPI_FUNC(time_t) _PyTime_DoubleToTimet(double x); + +/* Get the current time since the epoch in seconds */ +PyAPI_FUNC(double) _PyTime_FloatTime(void); + + +#ifdef __cplusplus +} +#endif +#endif /* TIMEFUNCS_H */ diff --git a/android/python27/include/token.h b/android/python27/include/token.h new file mode 100644 index 000000000..72659ac05 --- /dev/null +++ b/android/python27/include/token.h @@ -0,0 +1,85 @@ + +/* Token types */ + +#ifndef Py_TOKEN_H +#define Py_TOKEN_H +#ifdef __cplusplus +extern "C" { +#endif + +#undef TILDE /* Prevent clash of our definition with system macro. Ex AIX, ioctl.h */ + +#define ENDMARKER 0 +#define NAME 1 +#define NUMBER 2 +#define STRING 3 +#define NEWLINE 4 +#define INDENT 5 +#define DEDENT 6 +#define LPAR 7 +#define RPAR 8 +#define LSQB 9 +#define RSQB 10 +#define COLON 11 +#define COMMA 12 +#define SEMI 13 +#define PLUS 14 +#define MINUS 15 +#define STAR 16 +#define SLASH 17 +#define VBAR 18 +#define AMPER 19 +#define LESS 20 +#define GREATER 21 +#define EQUAL 22 +#define DOT 23 +#define PERCENT 24 +#define BACKQUOTE 25 +#define LBRACE 26 +#define RBRACE 27 +#define EQEQUAL 28 +#define NOTEQUAL 29 +#define LESSEQUAL 30 +#define GREATEREQUAL 31 +#define TILDE 32 +#define CIRCUMFLEX 33 +#define LEFTSHIFT 34 +#define RIGHTSHIFT 35 +#define DOUBLESTAR 36 +#define PLUSEQUAL 37 +#define MINEQUAL 38 +#define STAREQUAL 39 +#define SLASHEQUAL 40 +#define PERCENTEQUAL 41 +#define AMPEREQUAL 42 +#define VBAREQUAL 43 +#define CIRCUMFLEXEQUAL 44 +#define LEFTSHIFTEQUAL 45 +#define RIGHTSHIFTEQUAL 46 +#define DOUBLESTAREQUAL 47 +#define DOUBLESLASH 48 +#define DOUBLESLASHEQUAL 49 +#define AT 50 +/* Don't forget to update the table _PyParser_TokenNames in tokenizer.c! */ +#define OP 51 +#define ERRORTOKEN 52 +#define N_TOKENS 53 + +/* Special definitions for cooperation with parser */ + +#define NT_OFFSET 256 + +#define ISTERMINAL(x) ((x) < NT_OFFSET) +#define ISNONTERMINAL(x) ((x) >= NT_OFFSET) +#define ISEOF(x) ((x) == ENDMARKER) + + +PyAPI_DATA(char *) _PyParser_TokenNames[]; /* Token names */ +PyAPI_FUNC(int) PyToken_OneChar(int); +PyAPI_FUNC(int) PyToken_TwoChars(int, int); +PyAPI_FUNC(int) PyToken_ThreeChars(int, int, int); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_TOKEN_H */ diff --git a/android/python27/include/traceback.h b/android/python27/include/traceback.h new file mode 100644 index 000000000..e7943dae9 --- /dev/null +++ b/android/python27/include/traceback.h @@ -0,0 +1,31 @@ + +#ifndef Py_TRACEBACK_H +#define Py_TRACEBACK_H +#ifdef __cplusplus +extern "C" { +#endif + +struct _frame; + +/* Traceback interface */ + +typedef struct _traceback { + PyObject_HEAD + struct _traceback *tb_next; + struct _frame *tb_frame; + int tb_lasti; + int tb_lineno; +} PyTracebackObject; + +PyAPI_FUNC(int) PyTraceBack_Here(struct _frame *); +PyAPI_FUNC(int) PyTraceBack_Print(PyObject *, PyObject *); +PyAPI_FUNC(int) _Py_DisplaySourceLine(PyObject *, const char *, int, int); + +/* Reveal traceback type so we can typecheck traceback objects */ +PyAPI_DATA(PyTypeObject) PyTraceBack_Type; +#define PyTraceBack_Check(v) (Py_TYPE(v) == &PyTraceBack_Type) + +#ifdef __cplusplus +} +#endif +#endif /* !Py_TRACEBACK_H */ diff --git a/android/python27/include/tupleobject.h b/android/python27/include/tupleobject.h new file mode 100644 index 000000000..a5ab73320 --- /dev/null +++ b/android/python27/include/tupleobject.h @@ -0,0 +1,61 @@ + +/* Tuple object interface */ + +#ifndef Py_TUPLEOBJECT_H +#define Py_TUPLEOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +/* +Another generally useful object type is a tuple of object pointers. +For Python, this is an immutable type. C code can change the tuple items +(but not their number), and even use tuples are general-purpose arrays of +object references, but in general only brand new tuples should be mutated, +not ones that might already have been exposed to Python code. + +*** WARNING *** PyTuple_SetItem does not increment the new item's reference +count, but does decrement the reference count of the item it replaces, +if not nil. It does *decrement* the reference count if it is *not* +inserted in the tuple. Similarly, PyTuple_GetItem does not increment the +returned item's reference count. +*/ + +typedef struct { + PyObject_VAR_HEAD + PyObject *ob_item[1]; + + /* ob_item contains space for 'ob_size' elements. + * Items must normally not be NULL, except during construction when + * the tuple is not yet visible outside the function that builds it. + */ +} PyTupleObject; + +PyAPI_DATA(PyTypeObject) PyTuple_Type; + +#define PyTuple_Check(op) \ + PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_TUPLE_SUBCLASS) +#define PyTuple_CheckExact(op) (Py_TYPE(op) == &PyTuple_Type) + +PyAPI_FUNC(PyObject *) PyTuple_New(Py_ssize_t size); +PyAPI_FUNC(Py_ssize_t) PyTuple_Size(PyObject *); +PyAPI_FUNC(PyObject *) PyTuple_GetItem(PyObject *, Py_ssize_t); +PyAPI_FUNC(int) PyTuple_SetItem(PyObject *, Py_ssize_t, PyObject *); +PyAPI_FUNC(PyObject *) PyTuple_GetSlice(PyObject *, Py_ssize_t, Py_ssize_t); +PyAPI_FUNC(int) _PyTuple_Resize(PyObject **, Py_ssize_t); +PyAPI_FUNC(PyObject *) PyTuple_Pack(Py_ssize_t, ...); +PyAPI_FUNC(void) _PyTuple_MaybeUntrack(PyObject *); + +/* Macro, trading safety for speed */ +#define PyTuple_GET_ITEM(op, i) (((PyTupleObject *)(op))->ob_item[i]) +#define PyTuple_GET_SIZE(op) Py_SIZE(op) + +/* Macro, *only* to be used to fill in brand new tuples */ +#define PyTuple_SET_ITEM(op, i, v) (((PyTupleObject *)(op))->ob_item[i] = v) + +PyAPI_FUNC(int) PyTuple_ClearFreeList(void); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_TUPLEOBJECT_H */ diff --git a/android/python27/include/ucnhash.h b/android/python27/include/ucnhash.h new file mode 100644 index 000000000..69b7774a9 --- /dev/null +++ b/android/python27/include/ucnhash.h @@ -0,0 +1,33 @@ +/* Unicode name database interface */ + +#ifndef Py_UCNHASH_H +#define Py_UCNHASH_H +#ifdef __cplusplus +extern "C" { +#endif + +/* revised ucnhash CAPI interface (exported through a "wrapper") */ + +#define PyUnicodeData_CAPSULE_NAME "unicodedata.ucnhash_CAPI" + +typedef struct { + + /* Size of this struct */ + int size; + + /* Get name for a given character code. Returns non-zero if + success, zero if not. Does not set Python exceptions. + If self is NULL, data come from the default version of the database. + If it is not NULL, it should be a unicodedata.ucd_X_Y_Z object */ + int (*getname)(PyObject *self, Py_UCS4 code, char* buffer, int buflen); + + /* Get character code for a given name. Same error handling + as for getname. */ + int (*getcode)(PyObject *self, const char* name, int namelen, Py_UCS4* code); + +} _PyUnicode_Name_CAPI; + +#ifdef __cplusplus +} +#endif +#endif /* !Py_UCNHASH_H */ diff --git a/android/python27/include/unicodeobject.h b/android/python27/include/unicodeobject.h new file mode 100644 index 000000000..9ab724aa6 --- /dev/null +++ b/android/python27/include/unicodeobject.h @@ -0,0 +1,1413 @@ +#ifndef Py_UNICODEOBJECT_H +#define Py_UNICODEOBJECT_H + +#include + +/* + +Unicode implementation based on original code by Fredrik Lundh, +modified by Marc-Andre Lemburg (mal@lemburg.com) according to the +Unicode Integration Proposal (see file Misc/unicode.txt). + +Copyright (c) Corporation for National Research Initiatives. + + + Original header: + -------------------------------------------------------------------- + + * Yet another Unicode string type for Python. This type supports the + * 16-bit Basic Multilingual Plane (BMP) only. + * + * Written by Fredrik Lundh, January 1999. + * + * Copyright (c) 1999 by Secret Labs AB. + * Copyright (c) 1999 by Fredrik Lundh. + * + * fredrik@pythonware.com + * http://www.pythonware.com + * + * -------------------------------------------------------------------- + * This Unicode String Type is + * + * Copyright (c) 1999 by Secret Labs AB + * Copyright (c) 1999 by Fredrik Lundh + * + * By obtaining, using, and/or copying this software and/or its + * associated documentation, you agree that you have read, understood, + * and will comply with the following terms and conditions: + * + * Permission to use, copy, modify, and distribute this software and its + * associated documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appears in all + * copies, and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of Secret Labs + * AB or the author not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. + * + * SECRET LABS AB AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS. IN NO EVENT SHALL SECRET LABS AB OR THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * -------------------------------------------------------------------- */ + +#include + +/* === Internal API ======================================================= */ + +/* --- Internal Unicode Format -------------------------------------------- */ + +#ifndef Py_USING_UNICODE + +#define PyUnicode_Check(op) 0 +#define PyUnicode_CheckExact(op) 0 + +#else + +/* FIXME: MvL's new implementation assumes that Py_UNICODE_SIZE is + properly set, but the default rules below doesn't set it. I'll + sort this out some other day -- fredrik@pythonware.com */ + +#ifndef Py_UNICODE_SIZE +#error Must define Py_UNICODE_SIZE +#endif + +/* Setting Py_UNICODE_WIDE enables UCS-4 storage. Otherwise, Unicode + strings are stored as UCS-2 (with limited support for UTF-16) */ + +#if Py_UNICODE_SIZE >= 4 +#define Py_UNICODE_WIDE +#endif + +/* Set these flags if the platform has "wchar.h", "wctype.h" and the + wchar_t type is a 16-bit unsigned type */ +/* #define HAVE_WCHAR_H */ +/* #define HAVE_USABLE_WCHAR_T */ + +/* Defaults for various platforms */ +#ifndef PY_UNICODE_TYPE + +/* Windows has a usable wchar_t type (unless we're using UCS-4) */ +# if defined(MS_WIN32) && Py_UNICODE_SIZE == 2 +# define HAVE_USABLE_WCHAR_T +# define PY_UNICODE_TYPE wchar_t +# endif + +# if defined(Py_UNICODE_WIDE) +# define PY_UNICODE_TYPE Py_UCS4 +# endif + +#endif + +/* If the compiler provides a wchar_t type we try to support it + through the interface functions PyUnicode_FromWideChar() and + PyUnicode_AsWideChar(). */ + +#ifdef HAVE_USABLE_WCHAR_T +# ifndef HAVE_WCHAR_H +# define HAVE_WCHAR_H +# endif +#endif + +#ifdef HAVE_WCHAR_H +/* Work around a cosmetic bug in BSDI 4.x wchar.h; thanks to Thomas Wouters */ +# ifdef _HAVE_BSDI +# include +# endif +# include +#endif + +/* + * Use this typedef when you need to represent a UTF-16 surrogate pair + * as single unsigned integer. + */ +#if SIZEOF_INT >= 4 +typedef unsigned int Py_UCS4; +#elif SIZEOF_LONG >= 4 +typedef unsigned long Py_UCS4; +#endif + +/* Py_UNICODE is the native Unicode storage format (code unit) used by + Python and represents a single Unicode element in the Unicode + type. */ + +typedef PY_UNICODE_TYPE Py_UNICODE; + +/* --- UCS-2/UCS-4 Name Mangling ------------------------------------------ */ + +/* Unicode API names are mangled to assure that UCS-2 and UCS-4 builds + produce different external names and thus cause import errors in + case Python interpreters and extensions with mixed compiled in + Unicode width assumptions are combined. */ + +#ifndef Py_UNICODE_WIDE + +# define PyUnicode_AsASCIIString PyUnicodeUCS2_AsASCIIString +# define PyUnicode_AsCharmapString PyUnicodeUCS2_AsCharmapString +# define PyUnicode_AsEncodedObject PyUnicodeUCS2_AsEncodedObject +# define PyUnicode_AsEncodedString PyUnicodeUCS2_AsEncodedString +# define PyUnicode_AsLatin1String PyUnicodeUCS2_AsLatin1String +# define PyUnicode_AsRawUnicodeEscapeString PyUnicodeUCS2_AsRawUnicodeEscapeString +# define PyUnicode_AsUTF32String PyUnicodeUCS2_AsUTF32String +# define PyUnicode_AsUTF16String PyUnicodeUCS2_AsUTF16String +# define PyUnicode_AsUTF8String PyUnicodeUCS2_AsUTF8String +# define PyUnicode_AsUnicode PyUnicodeUCS2_AsUnicode +# define PyUnicode_AsUnicodeEscapeString PyUnicodeUCS2_AsUnicodeEscapeString +# define PyUnicode_AsWideChar PyUnicodeUCS2_AsWideChar +# define PyUnicode_ClearFreeList PyUnicodeUCS2_ClearFreelist +# define PyUnicode_Compare PyUnicodeUCS2_Compare +# define PyUnicode_Concat PyUnicodeUCS2_Concat +# define PyUnicode_Contains PyUnicodeUCS2_Contains +# define PyUnicode_Count PyUnicodeUCS2_Count +# define PyUnicode_Decode PyUnicodeUCS2_Decode +# define PyUnicode_DecodeASCII PyUnicodeUCS2_DecodeASCII +# define PyUnicode_DecodeCharmap PyUnicodeUCS2_DecodeCharmap +# define PyUnicode_DecodeLatin1 PyUnicodeUCS2_DecodeLatin1 +# define PyUnicode_DecodeRawUnicodeEscape PyUnicodeUCS2_DecodeRawUnicodeEscape +# define PyUnicode_DecodeUTF32 PyUnicodeUCS2_DecodeUTF32 +# define PyUnicode_DecodeUTF32Stateful PyUnicodeUCS2_DecodeUTF32Stateful +# define PyUnicode_DecodeUTF16 PyUnicodeUCS2_DecodeUTF16 +# define PyUnicode_DecodeUTF16Stateful PyUnicodeUCS2_DecodeUTF16Stateful +# define PyUnicode_DecodeUTF8 PyUnicodeUCS2_DecodeUTF8 +# define PyUnicode_DecodeUTF8Stateful PyUnicodeUCS2_DecodeUTF8Stateful +# define PyUnicode_DecodeUnicodeEscape PyUnicodeUCS2_DecodeUnicodeEscape +# define PyUnicode_Encode PyUnicodeUCS2_Encode +# define PyUnicode_EncodeASCII PyUnicodeUCS2_EncodeASCII +# define PyUnicode_EncodeCharmap PyUnicodeUCS2_EncodeCharmap +# define PyUnicode_EncodeDecimal PyUnicodeUCS2_EncodeDecimal +# define PyUnicode_EncodeLatin1 PyUnicodeUCS2_EncodeLatin1 +# define PyUnicode_EncodeRawUnicodeEscape PyUnicodeUCS2_EncodeRawUnicodeEscape +# define PyUnicode_EncodeUTF32 PyUnicodeUCS2_EncodeUTF32 +# define PyUnicode_EncodeUTF16 PyUnicodeUCS2_EncodeUTF16 +# define PyUnicode_EncodeUTF8 PyUnicodeUCS2_EncodeUTF8 +# define PyUnicode_EncodeUnicodeEscape PyUnicodeUCS2_EncodeUnicodeEscape +# define PyUnicode_Find PyUnicodeUCS2_Find +# define PyUnicode_Format PyUnicodeUCS2_Format +# define PyUnicode_FromEncodedObject PyUnicodeUCS2_FromEncodedObject +# define PyUnicode_FromFormat PyUnicodeUCS2_FromFormat +# define PyUnicode_FromFormatV PyUnicodeUCS2_FromFormatV +# define PyUnicode_FromObject PyUnicodeUCS2_FromObject +# define PyUnicode_FromOrdinal PyUnicodeUCS2_FromOrdinal +# define PyUnicode_FromString PyUnicodeUCS2_FromString +# define PyUnicode_FromStringAndSize PyUnicodeUCS2_FromStringAndSize +# define PyUnicode_FromUnicode PyUnicodeUCS2_FromUnicode +# define PyUnicode_FromWideChar PyUnicodeUCS2_FromWideChar +# define PyUnicode_GetDefaultEncoding PyUnicodeUCS2_GetDefaultEncoding +# define PyUnicode_GetMax PyUnicodeUCS2_GetMax +# define PyUnicode_GetSize PyUnicodeUCS2_GetSize +# define PyUnicode_Join PyUnicodeUCS2_Join +# define PyUnicode_Partition PyUnicodeUCS2_Partition +# define PyUnicode_RPartition PyUnicodeUCS2_RPartition +# define PyUnicode_RSplit PyUnicodeUCS2_RSplit +# define PyUnicode_Replace PyUnicodeUCS2_Replace +# define PyUnicode_Resize PyUnicodeUCS2_Resize +# define PyUnicode_RichCompare PyUnicodeUCS2_RichCompare +# define PyUnicode_SetDefaultEncoding PyUnicodeUCS2_SetDefaultEncoding +# define PyUnicode_Split PyUnicodeUCS2_Split +# define PyUnicode_Splitlines PyUnicodeUCS2_Splitlines +# define PyUnicode_Tailmatch PyUnicodeUCS2_Tailmatch +# define PyUnicode_Translate PyUnicodeUCS2_Translate +# define PyUnicode_TranslateCharmap PyUnicodeUCS2_TranslateCharmap +# define _PyUnicode_AsDefaultEncodedString _PyUnicodeUCS2_AsDefaultEncodedString +# define _PyUnicode_Fini _PyUnicodeUCS2_Fini +# define _PyUnicode_Init _PyUnicodeUCS2_Init +# define _PyUnicode_IsAlpha _PyUnicodeUCS2_IsAlpha +# define _PyUnicode_IsDecimalDigit _PyUnicodeUCS2_IsDecimalDigit +# define _PyUnicode_IsDigit _PyUnicodeUCS2_IsDigit +# define _PyUnicode_IsLinebreak _PyUnicodeUCS2_IsLinebreak +# define _PyUnicode_IsLowercase _PyUnicodeUCS2_IsLowercase +# define _PyUnicode_IsNumeric _PyUnicodeUCS2_IsNumeric +# define _PyUnicode_IsTitlecase _PyUnicodeUCS2_IsTitlecase +# define _PyUnicode_IsUppercase _PyUnicodeUCS2_IsUppercase +# define _PyUnicode_IsWhitespace _PyUnicodeUCS2_IsWhitespace +# define _PyUnicode_ToDecimalDigit _PyUnicodeUCS2_ToDecimalDigit +# define _PyUnicode_ToDigit _PyUnicodeUCS2_ToDigit +# define _PyUnicode_ToLowercase _PyUnicodeUCS2_ToLowercase +# define _PyUnicode_ToNumeric _PyUnicodeUCS2_ToNumeric +# define _PyUnicode_ToTitlecase _PyUnicodeUCS2_ToTitlecase +# define _PyUnicode_ToUppercase _PyUnicodeUCS2_ToUppercase + +#else + +# define PyUnicode_AsASCIIString PyUnicodeUCS4_AsASCIIString +# define PyUnicode_AsCharmapString PyUnicodeUCS4_AsCharmapString +# define PyUnicode_AsEncodedObject PyUnicodeUCS4_AsEncodedObject +# define PyUnicode_AsEncodedString PyUnicodeUCS4_AsEncodedString +# define PyUnicode_AsLatin1String PyUnicodeUCS4_AsLatin1String +# define PyUnicode_AsRawUnicodeEscapeString PyUnicodeUCS4_AsRawUnicodeEscapeString +# define PyUnicode_AsUTF32String PyUnicodeUCS4_AsUTF32String +# define PyUnicode_AsUTF16String PyUnicodeUCS4_AsUTF16String +# define PyUnicode_AsUTF8String PyUnicodeUCS4_AsUTF8String +# define PyUnicode_AsUnicode PyUnicodeUCS4_AsUnicode +# define PyUnicode_AsUnicodeEscapeString PyUnicodeUCS4_AsUnicodeEscapeString +# define PyUnicode_AsWideChar PyUnicodeUCS4_AsWideChar +# define PyUnicode_ClearFreeList PyUnicodeUCS4_ClearFreelist +# define PyUnicode_Compare PyUnicodeUCS4_Compare +# define PyUnicode_Concat PyUnicodeUCS4_Concat +# define PyUnicode_Contains PyUnicodeUCS4_Contains +# define PyUnicode_Count PyUnicodeUCS4_Count +# define PyUnicode_Decode PyUnicodeUCS4_Decode +# define PyUnicode_DecodeASCII PyUnicodeUCS4_DecodeASCII +# define PyUnicode_DecodeCharmap PyUnicodeUCS4_DecodeCharmap +# define PyUnicode_DecodeLatin1 PyUnicodeUCS4_DecodeLatin1 +# define PyUnicode_DecodeRawUnicodeEscape PyUnicodeUCS4_DecodeRawUnicodeEscape +# define PyUnicode_DecodeUTF32 PyUnicodeUCS4_DecodeUTF32 +# define PyUnicode_DecodeUTF32Stateful PyUnicodeUCS4_DecodeUTF32Stateful +# define PyUnicode_DecodeUTF16 PyUnicodeUCS4_DecodeUTF16 +# define PyUnicode_DecodeUTF16Stateful PyUnicodeUCS4_DecodeUTF16Stateful +# define PyUnicode_DecodeUTF8 PyUnicodeUCS4_DecodeUTF8 +# define PyUnicode_DecodeUTF8Stateful PyUnicodeUCS4_DecodeUTF8Stateful +# define PyUnicode_DecodeUnicodeEscape PyUnicodeUCS4_DecodeUnicodeEscape +# define PyUnicode_Encode PyUnicodeUCS4_Encode +# define PyUnicode_EncodeASCII PyUnicodeUCS4_EncodeASCII +# define PyUnicode_EncodeCharmap PyUnicodeUCS4_EncodeCharmap +# define PyUnicode_EncodeDecimal PyUnicodeUCS4_EncodeDecimal +# define PyUnicode_EncodeLatin1 PyUnicodeUCS4_EncodeLatin1 +# define PyUnicode_EncodeRawUnicodeEscape PyUnicodeUCS4_EncodeRawUnicodeEscape +# define PyUnicode_EncodeUTF32 PyUnicodeUCS4_EncodeUTF32 +# define PyUnicode_EncodeUTF16 PyUnicodeUCS4_EncodeUTF16 +# define PyUnicode_EncodeUTF8 PyUnicodeUCS4_EncodeUTF8 +# define PyUnicode_EncodeUnicodeEscape PyUnicodeUCS4_EncodeUnicodeEscape +# define PyUnicode_Find PyUnicodeUCS4_Find +# define PyUnicode_Format PyUnicodeUCS4_Format +# define PyUnicode_FromEncodedObject PyUnicodeUCS4_FromEncodedObject +# define PyUnicode_FromFormat PyUnicodeUCS4_FromFormat +# define PyUnicode_FromFormatV PyUnicodeUCS4_FromFormatV +# define PyUnicode_FromObject PyUnicodeUCS4_FromObject +# define PyUnicode_FromOrdinal PyUnicodeUCS4_FromOrdinal +# define PyUnicode_FromString PyUnicodeUCS4_FromString +# define PyUnicode_FromStringAndSize PyUnicodeUCS4_FromStringAndSize +# define PyUnicode_FromUnicode PyUnicodeUCS4_FromUnicode +# define PyUnicode_FromWideChar PyUnicodeUCS4_FromWideChar +# define PyUnicode_GetDefaultEncoding PyUnicodeUCS4_GetDefaultEncoding +# define PyUnicode_GetMax PyUnicodeUCS4_GetMax +# define PyUnicode_GetSize PyUnicodeUCS4_GetSize +# define PyUnicode_Join PyUnicodeUCS4_Join +# define PyUnicode_Partition PyUnicodeUCS4_Partition +# define PyUnicode_RPartition PyUnicodeUCS4_RPartition +# define PyUnicode_RSplit PyUnicodeUCS4_RSplit +# define PyUnicode_Replace PyUnicodeUCS4_Replace +# define PyUnicode_Resize PyUnicodeUCS4_Resize +# define PyUnicode_RichCompare PyUnicodeUCS4_RichCompare +# define PyUnicode_SetDefaultEncoding PyUnicodeUCS4_SetDefaultEncoding +# define PyUnicode_Split PyUnicodeUCS4_Split +# define PyUnicode_Splitlines PyUnicodeUCS4_Splitlines +# define PyUnicode_Tailmatch PyUnicodeUCS4_Tailmatch +# define PyUnicode_Translate PyUnicodeUCS4_Translate +# define PyUnicode_TranslateCharmap PyUnicodeUCS4_TranslateCharmap +# define _PyUnicode_AsDefaultEncodedString _PyUnicodeUCS4_AsDefaultEncodedString +# define _PyUnicode_Fini _PyUnicodeUCS4_Fini +# define _PyUnicode_Init _PyUnicodeUCS4_Init +# define _PyUnicode_IsAlpha _PyUnicodeUCS4_IsAlpha +# define _PyUnicode_IsDecimalDigit _PyUnicodeUCS4_IsDecimalDigit +# define _PyUnicode_IsDigit _PyUnicodeUCS4_IsDigit +# define _PyUnicode_IsLinebreak _PyUnicodeUCS4_IsLinebreak +# define _PyUnicode_IsLowercase _PyUnicodeUCS4_IsLowercase +# define _PyUnicode_IsNumeric _PyUnicodeUCS4_IsNumeric +# define _PyUnicode_IsTitlecase _PyUnicodeUCS4_IsTitlecase +# define _PyUnicode_IsUppercase _PyUnicodeUCS4_IsUppercase +# define _PyUnicode_IsWhitespace _PyUnicodeUCS4_IsWhitespace +# define _PyUnicode_ToDecimalDigit _PyUnicodeUCS4_ToDecimalDigit +# define _PyUnicode_ToDigit _PyUnicodeUCS4_ToDigit +# define _PyUnicode_ToLowercase _PyUnicodeUCS4_ToLowercase +# define _PyUnicode_ToNumeric _PyUnicodeUCS4_ToNumeric +# define _PyUnicode_ToTitlecase _PyUnicodeUCS4_ToTitlecase +# define _PyUnicode_ToUppercase _PyUnicodeUCS4_ToUppercase + + +#endif + +/* --- Internal Unicode Operations ---------------------------------------- */ + +/* If you want Python to use the compiler's wctype.h functions instead + of the ones supplied with Python, define WANT_WCTYPE_FUNCTIONS or + configure Python using --with-wctype-functions. This reduces the + interpreter's code size. */ + +#if defined(HAVE_USABLE_WCHAR_T) && defined(WANT_WCTYPE_FUNCTIONS) + +#include + +#define Py_UNICODE_ISSPACE(ch) iswspace(ch) + +#define Py_UNICODE_ISLOWER(ch) iswlower(ch) +#define Py_UNICODE_ISUPPER(ch) iswupper(ch) +#define Py_UNICODE_ISTITLE(ch) _PyUnicode_IsTitlecase(ch) +#define Py_UNICODE_ISLINEBREAK(ch) _PyUnicode_IsLinebreak(ch) + +#define Py_UNICODE_TOLOWER(ch) towlower(ch) +#define Py_UNICODE_TOUPPER(ch) towupper(ch) +#define Py_UNICODE_TOTITLE(ch) _PyUnicode_ToTitlecase(ch) + +#define Py_UNICODE_ISDECIMAL(ch) _PyUnicode_IsDecimalDigit(ch) +#define Py_UNICODE_ISDIGIT(ch) _PyUnicode_IsDigit(ch) +#define Py_UNICODE_ISNUMERIC(ch) _PyUnicode_IsNumeric(ch) + +#define Py_UNICODE_TODECIMAL(ch) _PyUnicode_ToDecimalDigit(ch) +#define Py_UNICODE_TODIGIT(ch) _PyUnicode_ToDigit(ch) +#define Py_UNICODE_TONUMERIC(ch) _PyUnicode_ToNumeric(ch) + +#define Py_UNICODE_ISALPHA(ch) iswalpha(ch) + +#else + +/* Since splitting on whitespace is an important use case, and + whitespace in most situations is solely ASCII whitespace, we + optimize for the common case by using a quick look-up table + _Py_ascii_whitespace (see below) with an inlined check. + + */ +#define Py_UNICODE_ISSPACE(ch) \ + ((ch) < 128U ? _Py_ascii_whitespace[(ch)] : _PyUnicode_IsWhitespace(ch)) + +#define Py_UNICODE_ISLOWER(ch) _PyUnicode_IsLowercase(ch) +#define Py_UNICODE_ISUPPER(ch) _PyUnicode_IsUppercase(ch) +#define Py_UNICODE_ISTITLE(ch) _PyUnicode_IsTitlecase(ch) +#define Py_UNICODE_ISLINEBREAK(ch) _PyUnicode_IsLinebreak(ch) + +#define Py_UNICODE_TOLOWER(ch) _PyUnicode_ToLowercase(ch) +#define Py_UNICODE_TOUPPER(ch) _PyUnicode_ToUppercase(ch) +#define Py_UNICODE_TOTITLE(ch) _PyUnicode_ToTitlecase(ch) + +#define Py_UNICODE_ISDECIMAL(ch) _PyUnicode_IsDecimalDigit(ch) +#define Py_UNICODE_ISDIGIT(ch) _PyUnicode_IsDigit(ch) +#define Py_UNICODE_ISNUMERIC(ch) _PyUnicode_IsNumeric(ch) + +#define Py_UNICODE_TODECIMAL(ch) _PyUnicode_ToDecimalDigit(ch) +#define Py_UNICODE_TODIGIT(ch) _PyUnicode_ToDigit(ch) +#define Py_UNICODE_TONUMERIC(ch) _PyUnicode_ToNumeric(ch) + +#define Py_UNICODE_ISALPHA(ch) _PyUnicode_IsAlpha(ch) + +#endif + +#define Py_UNICODE_ISALNUM(ch) \ + (Py_UNICODE_ISALPHA(ch) || \ + Py_UNICODE_ISDECIMAL(ch) || \ + Py_UNICODE_ISDIGIT(ch) || \ + Py_UNICODE_ISNUMERIC(ch)) + +#define Py_UNICODE_COPY(target, source, length) \ + Py_MEMCPY((target), (source), (length)*sizeof(Py_UNICODE)) + +#define Py_UNICODE_FILL(target, value, length) \ + do {Py_ssize_t i_; Py_UNICODE *t_ = (target); Py_UNICODE v_ = (value);\ + for (i_ = 0; i_ < (length); i_++) t_[i_] = v_;\ + } while (0) + +/* Check if substring matches at given offset. the offset must be + valid, and the substring must not be empty */ + +#define Py_UNICODE_MATCH(string, offset, substring) \ + ((*((string)->str + (offset)) == *((substring)->str)) && \ + ((*((string)->str + (offset) + (substring)->length-1) == *((substring)->str + (substring)->length-1))) && \ + !memcmp((string)->str + (offset), (substring)->str, (substring)->length*sizeof(Py_UNICODE))) + +#ifdef __cplusplus +extern "C" { +#endif + +/* --- Unicode Type ------------------------------------------------------- */ + +typedef struct { + PyObject_HEAD + Py_ssize_t length; /* Length of raw Unicode data in buffer */ + Py_UNICODE *str; /* Raw Unicode buffer */ + long hash; /* Hash value; -1 if not set */ + PyObject *defenc; /* (Default) Encoded version as Python + string, or NULL; this is used for + implementing the buffer protocol */ +} PyUnicodeObject; + +PyAPI_DATA(PyTypeObject) PyUnicode_Type; + +#define PyUnicode_Check(op) \ + PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_UNICODE_SUBCLASS) +#define PyUnicode_CheckExact(op) (Py_TYPE(op) == &PyUnicode_Type) + +/* Fast access macros */ +#define PyUnicode_GET_SIZE(op) \ + (((PyUnicodeObject *)(op))->length) +#define PyUnicode_GET_DATA_SIZE(op) \ + (((PyUnicodeObject *)(op))->length * sizeof(Py_UNICODE)) +#define PyUnicode_AS_UNICODE(op) \ + (((PyUnicodeObject *)(op))->str) +#define PyUnicode_AS_DATA(op) \ + ((const char *)((PyUnicodeObject *)(op))->str) + +/* --- Constants ---------------------------------------------------------- */ + +/* This Unicode character will be used as replacement character during + decoding if the errors argument is set to "replace". Note: the + Unicode character U+FFFD is the official REPLACEMENT CHARACTER in + Unicode 3.0. */ + +#define Py_UNICODE_REPLACEMENT_CHARACTER ((Py_UNICODE) 0xFFFD) + +/* === Public API ========================================================= */ + +/* --- Plain Py_UNICODE --------------------------------------------------- */ + +/* Create a Unicode Object from the Py_UNICODE buffer u of the given + size. + + u may be NULL which causes the contents to be undefined. It is the + user's responsibility to fill in the needed data afterwards. Note + that modifying the Unicode object contents after construction is + only allowed if u was set to NULL. + + The buffer is copied into the new object. */ + +PyAPI_FUNC(PyObject*) PyUnicode_FromUnicode( + const Py_UNICODE *u, /* Unicode buffer */ + Py_ssize_t size /* size of buffer */ + ); + +/* Similar to PyUnicode_FromUnicode(), but u points to Latin-1 encoded bytes */ +PyAPI_FUNC(PyObject*) PyUnicode_FromStringAndSize( + const char *u, /* char buffer */ + Py_ssize_t size /* size of buffer */ + ); + +/* Similar to PyUnicode_FromUnicode(), but u points to null-terminated + Latin-1 encoded bytes */ +PyAPI_FUNC(PyObject*) PyUnicode_FromString( + const char *u /* string */ + ); + +/* Return a read-only pointer to the Unicode object's internal + Py_UNICODE buffer. */ + +PyAPI_FUNC(Py_UNICODE *) PyUnicode_AsUnicode( + PyObject *unicode /* Unicode object */ + ); + +/* Get the length of the Unicode object. */ + +PyAPI_FUNC(Py_ssize_t) PyUnicode_GetSize( + PyObject *unicode /* Unicode object */ + ); + +/* Get the maximum ordinal for a Unicode character. */ +PyAPI_FUNC(Py_UNICODE) PyUnicode_GetMax(void); + +/* Resize an already allocated Unicode object to the new size length. + + *unicode is modified to point to the new (resized) object and 0 + returned on success. + + This API may only be called by the function which also called the + Unicode constructor. The refcount on the object must be 1. Otherwise, + an error is returned. + + Error handling is implemented as follows: an exception is set, -1 + is returned and *unicode left untouched. + +*/ + +PyAPI_FUNC(int) PyUnicode_Resize( + PyObject **unicode, /* Pointer to the Unicode object */ + Py_ssize_t length /* New length */ + ); + +/* Coerce obj to an Unicode object and return a reference with + *incremented* refcount. + + Coercion is done in the following way: + + 1. String and other char buffer compatible objects are decoded + under the assumptions that they contain data using the current + default encoding. Decoding is done in "strict" mode. + + 2. All other objects (including Unicode objects) raise an + exception. + + The API returns NULL in case of an error. The caller is responsible + for decref'ing the returned objects. + +*/ + +PyAPI_FUNC(PyObject*) PyUnicode_FromEncodedObject( + register PyObject *obj, /* Object */ + const char *encoding, /* encoding */ + const char *errors /* error handling */ + ); + +/* Coerce obj to an Unicode object and return a reference with + *incremented* refcount. + + Unicode objects are passed back as-is (subclasses are converted to + true Unicode objects), all other objects are delegated to + PyUnicode_FromEncodedObject(obj, NULL, "strict") which results in + using the default encoding as basis for decoding the object. + + The API returns NULL in case of an error. The caller is responsible + for decref'ing the returned objects. + +*/ + +PyAPI_FUNC(PyObject*) PyUnicode_FromObject( + register PyObject *obj /* Object */ + ); + +PyAPI_FUNC(PyObject *) PyUnicode_FromFormatV(const char*, va_list); +PyAPI_FUNC(PyObject *) PyUnicode_FromFormat(const char*, ...); + +/* Format the object based on the format_spec, as defined in PEP 3101 + (Advanced String Formatting). */ +PyAPI_FUNC(PyObject *) _PyUnicode_FormatAdvanced(PyObject *obj, + Py_UNICODE *format_spec, + Py_ssize_t format_spec_len); + +/* --- wchar_t support for platforms which support it --------------------- */ + +#ifdef HAVE_WCHAR_H + +/* Create a Unicode Object from the whcar_t buffer w of the given + size. + + The buffer is copied into the new object. */ + +PyAPI_FUNC(PyObject*) PyUnicode_FromWideChar( + register const wchar_t *w, /* wchar_t buffer */ + Py_ssize_t size /* size of buffer */ + ); + +/* Copies the Unicode Object contents into the wchar_t buffer w. At + most size wchar_t characters are copied. + + Note that the resulting wchar_t string may or may not be + 0-terminated. It is the responsibility of the caller to make sure + that the wchar_t string is 0-terminated in case this is required by + the application. + + Returns the number of wchar_t characters copied (excluding a + possibly trailing 0-termination character) or -1 in case of an + error. */ + +PyAPI_FUNC(Py_ssize_t) PyUnicode_AsWideChar( + PyUnicodeObject *unicode, /* Unicode object */ + register wchar_t *w, /* wchar_t buffer */ + Py_ssize_t size /* size of buffer */ + ); + +#endif + +/* --- Unicode ordinals --------------------------------------------------- */ + +/* Create a Unicode Object from the given Unicode code point ordinal. + + The ordinal must be in range(0x10000) on narrow Python builds + (UCS2), and range(0x110000) on wide builds (UCS4). A ValueError is + raised in case it is not. + +*/ + +PyAPI_FUNC(PyObject*) PyUnicode_FromOrdinal(int ordinal); + +/* --- Free-list management ----------------------------------------------- */ + +/* Clear the free list used by the Unicode implementation. + + This can be used to release memory used for objects on the free + list back to the Python memory allocator. + +*/ + +PyAPI_FUNC(int) PyUnicode_ClearFreeList(void); + +/* === Builtin Codecs ===================================================== + + Many of these APIs take two arguments encoding and errors. These + parameters encoding and errors have the same semantics as the ones + of the builtin unicode() API. + + Setting encoding to NULL causes the default encoding to be used. + + Error handling is set by errors which may also be set to NULL + meaning to use the default handling defined for the codec. Default + error handling for all builtin codecs is "strict" (ValueErrors are + raised). + + The codecs all use a similar interface. Only deviation from the + generic ones are documented. + +*/ + +/* --- Manage the default encoding ---------------------------------------- */ + +/* Return a Python string holding the default encoded value of the + Unicode object. + + The resulting string is cached in the Unicode object for subsequent + usage by this function. The cached version is needed to implement + the character buffer interface and will live (at least) as long as + the Unicode object itself. + + The refcount of the string is *not* incremented. + + *** Exported for internal use by the interpreter only !!! *** + +*/ + +PyAPI_FUNC(PyObject *) _PyUnicode_AsDefaultEncodedString( + PyObject *, const char *); + +/* Returns the currently active default encoding. + + The default encoding is currently implemented as run-time settable + process global. This may change in future versions of the + interpreter to become a parameter which is managed on a per-thread + basis. + + */ + +PyAPI_FUNC(const char*) PyUnicode_GetDefaultEncoding(void); + +/* Sets the currently active default encoding. + + Returns 0 on success, -1 in case of an error. + + */ + +PyAPI_FUNC(int) PyUnicode_SetDefaultEncoding( + const char *encoding /* Encoding name in standard form */ + ); + +/* --- Generic Codecs ----------------------------------------------------- */ + +/* Create a Unicode object by decoding the encoded string s of the + given size. */ + +PyAPI_FUNC(PyObject*) PyUnicode_Decode( + const char *s, /* encoded string */ + Py_ssize_t size, /* size of buffer */ + const char *encoding, /* encoding */ + const char *errors /* error handling */ + ); + +/* Encodes a Py_UNICODE buffer of the given size and returns a + Python string object. */ + +PyAPI_FUNC(PyObject*) PyUnicode_Encode( + const Py_UNICODE *s, /* Unicode char buffer */ + Py_ssize_t size, /* number of Py_UNICODE chars to encode */ + const char *encoding, /* encoding */ + const char *errors /* error handling */ + ); + +/* Encodes a Unicode object and returns the result as Python + object. */ + +PyAPI_FUNC(PyObject*) PyUnicode_AsEncodedObject( + PyObject *unicode, /* Unicode object */ + const char *encoding, /* encoding */ + const char *errors /* error handling */ + ); + +/* Encodes a Unicode object and returns the result as Python string + object. */ + +PyAPI_FUNC(PyObject*) PyUnicode_AsEncodedString( + PyObject *unicode, /* Unicode object */ + const char *encoding, /* encoding */ + const char *errors /* error handling */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_BuildEncodingMap( + PyObject* string /* 256 character map */ + ); + + +/* --- UTF-7 Codecs ------------------------------------------------------- */ + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF7( + const char *string, /* UTF-7 encoded string */ + Py_ssize_t length, /* size of string */ + const char *errors /* error handling */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF7Stateful( + const char *string, /* UTF-7 encoded string */ + Py_ssize_t length, /* size of string */ + const char *errors, /* error handling */ + Py_ssize_t *consumed /* bytes consumed */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF7( + const Py_UNICODE *data, /* Unicode char buffer */ + Py_ssize_t length, /* number of Py_UNICODE chars to encode */ + int base64SetO, /* Encode RFC2152 Set O characters in base64 */ + int base64WhiteSpace, /* Encode whitespace (sp, ht, nl, cr) in base64 */ + const char *errors /* error handling */ + ); + +/* --- UTF-8 Codecs ------------------------------------------------------- */ + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF8( + const char *string, /* UTF-8 encoded string */ + Py_ssize_t length, /* size of string */ + const char *errors /* error handling */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF8Stateful( + const char *string, /* UTF-8 encoded string */ + Py_ssize_t length, /* size of string */ + const char *errors, /* error handling */ + Py_ssize_t *consumed /* bytes consumed */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_AsUTF8String( + PyObject *unicode /* Unicode object */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF8( + const Py_UNICODE *data, /* Unicode char buffer */ + Py_ssize_t length, /* number of Py_UNICODE chars to encode */ + const char *errors /* error handling */ + ); + +/* --- UTF-32 Codecs ------------------------------------------------------ */ + +/* Decodes length bytes from a UTF-32 encoded buffer string and returns + the corresponding Unicode object. + + errors (if non-NULL) defines the error handling. It defaults + to "strict". + + If byteorder is non-NULL, the decoder starts decoding using the + given byte order: + + *byteorder == -1: little endian + *byteorder == 0: native order + *byteorder == 1: big endian + + In native mode, the first four bytes of the stream are checked for a + BOM mark. If found, the BOM mark is analysed, the byte order + adjusted and the BOM skipped. In the other modes, no BOM mark + interpretation is done. After completion, *byteorder is set to the + current byte order at the end of input data. + + If byteorder is NULL, the codec starts in native order mode. + +*/ + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF32( + const char *string, /* UTF-32 encoded string */ + Py_ssize_t length, /* size of string */ + const char *errors, /* error handling */ + int *byteorder /* pointer to byteorder to use + 0=native;-1=LE,1=BE; updated on + exit */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF32Stateful( + const char *string, /* UTF-32 encoded string */ + Py_ssize_t length, /* size of string */ + const char *errors, /* error handling */ + int *byteorder, /* pointer to byteorder to use + 0=native;-1=LE,1=BE; updated on + exit */ + Py_ssize_t *consumed /* bytes consumed */ + ); + +/* Returns a Python string using the UTF-32 encoding in native byte + order. The string always starts with a BOM mark. */ + +PyAPI_FUNC(PyObject*) PyUnicode_AsUTF32String( + PyObject *unicode /* Unicode object */ + ); + +/* Returns a Python string object holding the UTF-32 encoded value of + the Unicode data. + + If byteorder is not 0, output is written according to the following + byte order: + + byteorder == -1: little endian + byteorder == 0: native byte order (writes a BOM mark) + byteorder == 1: big endian + + If byteorder is 0, the output string will always start with the + Unicode BOM mark (U+FEFF). In the other two modes, no BOM mark is + prepended. + +*/ + +PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF32( + const Py_UNICODE *data, /* Unicode char buffer */ + Py_ssize_t length, /* number of Py_UNICODE chars to encode */ + const char *errors, /* error handling */ + int byteorder /* byteorder to use 0=BOM+native;-1=LE,1=BE */ + ); + +/* --- UTF-16 Codecs ------------------------------------------------------ */ + +/* Decodes length bytes from a UTF-16 encoded buffer string and returns + the corresponding Unicode object. + + errors (if non-NULL) defines the error handling. It defaults + to "strict". + + If byteorder is non-NULL, the decoder starts decoding using the + given byte order: + + *byteorder == -1: little endian + *byteorder == 0: native order + *byteorder == 1: big endian + + In native mode, the first two bytes of the stream are checked for a + BOM mark. If found, the BOM mark is analysed, the byte order + adjusted and the BOM skipped. In the other modes, no BOM mark + interpretation is done. After completion, *byteorder is set to the + current byte order at the end of input data. + + If byteorder is NULL, the codec starts in native order mode. + +*/ + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF16( + const char *string, /* UTF-16 encoded string */ + Py_ssize_t length, /* size of string */ + const char *errors, /* error handling */ + int *byteorder /* pointer to byteorder to use + 0=native;-1=LE,1=BE; updated on + exit */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF16Stateful( + const char *string, /* UTF-16 encoded string */ + Py_ssize_t length, /* size of string */ + const char *errors, /* error handling */ + int *byteorder, /* pointer to byteorder to use + 0=native;-1=LE,1=BE; updated on + exit */ + Py_ssize_t *consumed /* bytes consumed */ + ); + +/* Returns a Python string using the UTF-16 encoding in native byte + order. The string always starts with a BOM mark. */ + +PyAPI_FUNC(PyObject*) PyUnicode_AsUTF16String( + PyObject *unicode /* Unicode object */ + ); + +/* Returns a Python string object holding the UTF-16 encoded value of + the Unicode data. + + If byteorder is not 0, output is written according to the following + byte order: + + byteorder == -1: little endian + byteorder == 0: native byte order (writes a BOM mark) + byteorder == 1: big endian + + If byteorder is 0, the output string will always start with the + Unicode BOM mark (U+FEFF). In the other two modes, no BOM mark is + prepended. + + Note that Py_UNICODE data is being interpreted as UTF-16 reduced to + UCS-2. This trick makes it possible to add full UTF-16 capabilities + at a later point without compromising the APIs. + +*/ + +PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF16( + const Py_UNICODE *data, /* Unicode char buffer */ + Py_ssize_t length, /* number of Py_UNICODE chars to encode */ + const char *errors, /* error handling */ + int byteorder /* byteorder to use 0=BOM+native;-1=LE,1=BE */ + ); + +/* --- Unicode-Escape Codecs ---------------------------------------------- */ + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeUnicodeEscape( + const char *string, /* Unicode-Escape encoded string */ + Py_ssize_t length, /* size of string */ + const char *errors /* error handling */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_AsUnicodeEscapeString( + PyObject *unicode /* Unicode object */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_EncodeUnicodeEscape( + const Py_UNICODE *data, /* Unicode char buffer */ + Py_ssize_t length /* Number of Py_UNICODE chars to encode */ + ); + +/* --- Raw-Unicode-Escape Codecs ------------------------------------------ */ + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeRawUnicodeEscape( + const char *string, /* Raw-Unicode-Escape encoded string */ + Py_ssize_t length, /* size of string */ + const char *errors /* error handling */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_AsRawUnicodeEscapeString( + PyObject *unicode /* Unicode object */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_EncodeRawUnicodeEscape( + const Py_UNICODE *data, /* Unicode char buffer */ + Py_ssize_t length /* Number of Py_UNICODE chars to encode */ + ); + +/* --- Unicode Internal Codec --------------------------------------------- + + Only for internal use in _codecsmodule.c */ + +PyObject *_PyUnicode_DecodeUnicodeInternal( + const char *string, + Py_ssize_t length, + const char *errors + ); + +/* --- Latin-1 Codecs ----------------------------------------------------- + + Note: Latin-1 corresponds to the first 256 Unicode ordinals. + +*/ + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeLatin1( + const char *string, /* Latin-1 encoded string */ + Py_ssize_t length, /* size of string */ + const char *errors /* error handling */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_AsLatin1String( + PyObject *unicode /* Unicode object */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_EncodeLatin1( + const Py_UNICODE *data, /* Unicode char buffer */ + Py_ssize_t length, /* Number of Py_UNICODE chars to encode */ + const char *errors /* error handling */ + ); + +/* --- ASCII Codecs ------------------------------------------------------- + + Only 7-bit ASCII data is excepted. All other codes generate errors. + +*/ + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeASCII( + const char *string, /* ASCII encoded string */ + Py_ssize_t length, /* size of string */ + const char *errors /* error handling */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_AsASCIIString( + PyObject *unicode /* Unicode object */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_EncodeASCII( + const Py_UNICODE *data, /* Unicode char buffer */ + Py_ssize_t length, /* Number of Py_UNICODE chars to encode */ + const char *errors /* error handling */ + ); + +/* --- Character Map Codecs ----------------------------------------------- + + This codec uses mappings to encode and decode characters. + + Decoding mappings must map single string characters to single + Unicode characters, integers (which are then interpreted as Unicode + ordinals) or None (meaning "undefined mapping" and causing an + error). + + Encoding mappings must map single Unicode characters to single + string characters, integers (which are then interpreted as Latin-1 + ordinals) or None (meaning "undefined mapping" and causing an + error). + + If a character lookup fails with a LookupError, the character is + copied as-is meaning that its ordinal value will be interpreted as + Unicode or Latin-1 ordinal resp. Because of this mappings only need + to contain those mappings which map characters to different code + points. + +*/ + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeCharmap( + const char *string, /* Encoded string */ + Py_ssize_t length, /* size of string */ + PyObject *mapping, /* character mapping + (char ordinal -> unicode ordinal) */ + const char *errors /* error handling */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_AsCharmapString( + PyObject *unicode, /* Unicode object */ + PyObject *mapping /* character mapping + (unicode ordinal -> char ordinal) */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_EncodeCharmap( + const Py_UNICODE *data, /* Unicode char buffer */ + Py_ssize_t length, /* Number of Py_UNICODE chars to encode */ + PyObject *mapping, /* character mapping + (unicode ordinal -> char ordinal) */ + const char *errors /* error handling */ + ); + +/* Translate a Py_UNICODE buffer of the given length by applying a + character mapping table to it and return the resulting Unicode + object. + + The mapping table must map Unicode ordinal integers to Unicode + ordinal integers or None (causing deletion of the character). + + Mapping tables may be dictionaries or sequences. Unmapped character + ordinals (ones which cause a LookupError) are left untouched and + are copied as-is. + +*/ + +PyAPI_FUNC(PyObject *) PyUnicode_TranslateCharmap( + const Py_UNICODE *data, /* Unicode char buffer */ + Py_ssize_t length, /* Number of Py_UNICODE chars to encode */ + PyObject *table, /* Translate table */ + const char *errors /* error handling */ + ); + +#ifdef MS_WIN32 + +/* --- MBCS codecs for Windows -------------------------------------------- */ + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeMBCS( + const char *string, /* MBCS encoded string */ + Py_ssize_t length, /* size of string */ + const char *errors /* error handling */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeMBCSStateful( + const char *string, /* MBCS encoded string */ + Py_ssize_t length, /* size of string */ + const char *errors, /* error handling */ + Py_ssize_t *consumed /* bytes consumed */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_AsMBCSString( + PyObject *unicode /* Unicode object */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_EncodeMBCS( + const Py_UNICODE *data, /* Unicode char buffer */ + Py_ssize_t length, /* Number of Py_UNICODE chars to encode */ + const char *errors /* error handling */ + ); + +#endif /* MS_WIN32 */ + +/* --- Decimal Encoder ---------------------------------------------------- */ + +/* Takes a Unicode string holding a decimal value and writes it into + an output buffer using standard ASCII digit codes. + + The output buffer has to provide at least length+1 bytes of storage + area. The output string is 0-terminated. + + The encoder converts whitespace to ' ', decimal characters to their + corresponding ASCII digit and all other Latin-1 characters except + \0 as-is. Characters outside this range (Unicode ordinals 1-256) + are treated as errors. This includes embedded NULL bytes. + + Error handling is defined by the errors argument: + + NULL or "strict": raise a ValueError + "ignore": ignore the wrong characters (these are not copied to the + output buffer) + "replace": replaces illegal characters with '?' + + Returns 0 on success, -1 on failure. + +*/ + +PyAPI_FUNC(int) PyUnicode_EncodeDecimal( + Py_UNICODE *s, /* Unicode buffer */ + Py_ssize_t length, /* Number of Py_UNICODE chars to encode */ + char *output, /* Output buffer; must have size >= length */ + const char *errors /* error handling */ + ); + +/* --- Methods & Slots ---------------------------------------------------- + + These are capable of handling Unicode objects and strings on input + (we refer to them as strings in the descriptions) and return + Unicode objects or integers as apporpriate. */ + +/* Concat two strings giving a new Unicode string. */ + +PyAPI_FUNC(PyObject*) PyUnicode_Concat( + PyObject *left, /* Left string */ + PyObject *right /* Right string */ + ); + +/* Split a string giving a list of Unicode strings. + + If sep is NULL, splitting will be done at all whitespace + substrings. Otherwise, splits occur at the given separator. + + At most maxsplit splits will be done. If negative, no limit is set. + + Separators are not included in the resulting list. + +*/ + +PyAPI_FUNC(PyObject*) PyUnicode_Split( + PyObject *s, /* String to split */ + PyObject *sep, /* String separator */ + Py_ssize_t maxsplit /* Maxsplit count */ + ); + +/* Dito, but split at line breaks. + + CRLF is considered to be one line break. Line breaks are not + included in the resulting list. */ + +PyAPI_FUNC(PyObject*) PyUnicode_Splitlines( + PyObject *s, /* String to split */ + int keepends /* If true, line end markers are included */ + ); + +/* Partition a string using a given separator. */ + +PyAPI_FUNC(PyObject*) PyUnicode_Partition( + PyObject *s, /* String to partition */ + PyObject *sep /* String separator */ + ); + +/* Partition a string using a given separator, searching from the end of the + string. */ + +PyAPI_FUNC(PyObject*) PyUnicode_RPartition( + PyObject *s, /* String to partition */ + PyObject *sep /* String separator */ + ); + +/* Split a string giving a list of Unicode strings. + + If sep is NULL, splitting will be done at all whitespace + substrings. Otherwise, splits occur at the given separator. + + At most maxsplit splits will be done. But unlike PyUnicode_Split + PyUnicode_RSplit splits from the end of the string. If negative, + no limit is set. + + Separators are not included in the resulting list. + +*/ + +PyAPI_FUNC(PyObject*) PyUnicode_RSplit( + PyObject *s, /* String to split */ + PyObject *sep, /* String separator */ + Py_ssize_t maxsplit /* Maxsplit count */ + ); + +/* Translate a string by applying a character mapping table to it and + return the resulting Unicode object. + + The mapping table must map Unicode ordinal integers to Unicode + ordinal integers or None (causing deletion of the character). + + Mapping tables may be dictionaries or sequences. Unmapped character + ordinals (ones which cause a LookupError) are left untouched and + are copied as-is. + +*/ + +PyAPI_FUNC(PyObject *) PyUnicode_Translate( + PyObject *str, /* String */ + PyObject *table, /* Translate table */ + const char *errors /* error handling */ + ); + +/* Join a sequence of strings using the given separator and return + the resulting Unicode string. */ + +PyAPI_FUNC(PyObject*) PyUnicode_Join( + PyObject *separator, /* Separator string */ + PyObject *seq /* Sequence object */ + ); + +/* Return 1 if substr matches str[start:end] at the given tail end, 0 + otherwise. */ + +PyAPI_FUNC(Py_ssize_t) PyUnicode_Tailmatch( + PyObject *str, /* String */ + PyObject *substr, /* Prefix or Suffix string */ + Py_ssize_t start, /* Start index */ + Py_ssize_t end, /* Stop index */ + int direction /* Tail end: -1 prefix, +1 suffix */ + ); + +/* Return the first position of substr in str[start:end] using the + given search direction or -1 if not found. -2 is returned in case + an error occurred and an exception is set. */ + +PyAPI_FUNC(Py_ssize_t) PyUnicode_Find( + PyObject *str, /* String */ + PyObject *substr, /* Substring to find */ + Py_ssize_t start, /* Start index */ + Py_ssize_t end, /* Stop index */ + int direction /* Find direction: +1 forward, -1 backward */ + ); + +/* Count the number of occurrences of substr in str[start:end]. */ + +PyAPI_FUNC(Py_ssize_t) PyUnicode_Count( + PyObject *str, /* String */ + PyObject *substr, /* Substring to count */ + Py_ssize_t start, /* Start index */ + Py_ssize_t end /* Stop index */ + ); + +/* Replace at most maxcount occurrences of substr in str with replstr + and return the resulting Unicode object. */ + +PyAPI_FUNC(PyObject *) PyUnicode_Replace( + PyObject *str, /* String */ + PyObject *substr, /* Substring to find */ + PyObject *replstr, /* Substring to replace */ + Py_ssize_t maxcount /* Max. number of replacements to apply; + -1 = all */ + ); + +/* Compare two strings and return -1, 0, 1 for less than, equal, + greater than resp. */ + +PyAPI_FUNC(int) PyUnicode_Compare( + PyObject *left, /* Left string */ + PyObject *right /* Right string */ + ); + +/* Rich compare two strings and return one of the following: + + - NULL in case an exception was raised + - Py_True or Py_False for successfuly comparisons + - Py_NotImplemented in case the type combination is unknown + + Note that Py_EQ and Py_NE comparisons can cause a UnicodeWarning in + case the conversion of the arguments to Unicode fails with a + UnicodeDecodeError. + + Possible values for op: + + Py_GT, Py_GE, Py_EQ, Py_NE, Py_LT, Py_LE + +*/ + +PyAPI_FUNC(PyObject *) PyUnicode_RichCompare( + PyObject *left, /* Left string */ + PyObject *right, /* Right string */ + int op /* Operation: Py_EQ, Py_NE, Py_GT, etc. */ + ); + +/* Apply a argument tuple or dictionary to a format string and return + the resulting Unicode string. */ + +PyAPI_FUNC(PyObject *) PyUnicode_Format( + PyObject *format, /* Format string */ + PyObject *args /* Argument tuple or dictionary */ + ); + +/* Checks whether element is contained in container and return 1/0 + accordingly. + + element has to coerce to an one element Unicode string. -1 is + returned in case of an error. */ + +PyAPI_FUNC(int) PyUnicode_Contains( + PyObject *container, /* Container string */ + PyObject *element /* Element string */ + ); + +/* Externally visible for str.strip(unicode) */ +PyAPI_FUNC(PyObject *) _PyUnicode_XStrip( + PyUnicodeObject *self, + int striptype, + PyObject *sepobj + ); + +/* === Characters Type APIs =============================================== */ + +/* Helper array used by Py_UNICODE_ISSPACE(). */ + +PyAPI_DATA(const unsigned char) _Py_ascii_whitespace[]; + +/* These should not be used directly. Use the Py_UNICODE_IS* and + Py_UNICODE_TO* macros instead. + + These APIs are implemented in Objects/unicodectype.c. + +*/ + +PyAPI_FUNC(int) _PyUnicode_IsLowercase( + Py_UNICODE ch /* Unicode character */ + ); + +PyAPI_FUNC(int) _PyUnicode_IsUppercase( + Py_UNICODE ch /* Unicode character */ + ); + +PyAPI_FUNC(int) _PyUnicode_IsTitlecase( + Py_UNICODE ch /* Unicode character */ + ); + +PyAPI_FUNC(int) _PyUnicode_IsWhitespace( + const Py_UNICODE ch /* Unicode character */ + ); + +PyAPI_FUNC(int) _PyUnicode_IsLinebreak( + const Py_UNICODE ch /* Unicode character */ + ); + +PyAPI_FUNC(Py_UNICODE) _PyUnicode_ToLowercase( + Py_UNICODE ch /* Unicode character */ + ); + +PyAPI_FUNC(Py_UNICODE) _PyUnicode_ToUppercase( + Py_UNICODE ch /* Unicode character */ + ); + +PyAPI_FUNC(Py_UNICODE) _PyUnicode_ToTitlecase( + Py_UNICODE ch /* Unicode character */ + ); + +PyAPI_FUNC(int) _PyUnicode_ToDecimalDigit( + Py_UNICODE ch /* Unicode character */ + ); + +PyAPI_FUNC(int) _PyUnicode_ToDigit( + Py_UNICODE ch /* Unicode character */ + ); + +PyAPI_FUNC(double) _PyUnicode_ToNumeric( + Py_UNICODE ch /* Unicode character */ + ); + +PyAPI_FUNC(int) _PyUnicode_IsDecimalDigit( + Py_UNICODE ch /* Unicode character */ + ); + +PyAPI_FUNC(int) _PyUnicode_IsDigit( + Py_UNICODE ch /* Unicode character */ + ); + +PyAPI_FUNC(int) _PyUnicode_IsNumeric( + Py_UNICODE ch /* Unicode character */ + ); + +PyAPI_FUNC(int) _PyUnicode_IsAlpha( + Py_UNICODE ch /* Unicode character */ + ); + +#ifdef __cplusplus +} +#endif +#endif /* Py_USING_UNICODE */ +#endif /* !Py_UNICODEOBJECT_H */ diff --git a/android/python27/include/warnings.h b/android/python27/include/warnings.h new file mode 100644 index 000000000..0818d7a11 --- /dev/null +++ b/android/python27/include/warnings.h @@ -0,0 +1,23 @@ +#ifndef Py_WARNINGS_H +#define Py_WARNINGS_H +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_FUNC(void) _PyWarnings_Init(void); + +PyAPI_FUNC(int) PyErr_WarnEx(PyObject *, const char *, Py_ssize_t); +PyAPI_FUNC(int) PyErr_WarnExplicit(PyObject *, const char *, const char *, int, + const char *, PyObject *); + +#define PyErr_WarnPy3k(msg, stacklevel) \ + (Py_Py3kWarningFlag ? PyErr_WarnEx(PyExc_DeprecationWarning, msg, stacklevel) : 0) + +/* DEPRECATED: Use PyErr_WarnEx() instead. */ +#define PyErr_Warn(category, msg) PyErr_WarnEx(category, msg, 1) + +#ifdef __cplusplus +} +#endif +#endif /* !Py_WARNINGS_H */ + diff --git a/android/python27/include/weakrefobject.h b/android/python27/include/weakrefobject.h new file mode 100644 index 000000000..e7c0eae53 --- /dev/null +++ b/android/python27/include/weakrefobject.h @@ -0,0 +1,82 @@ +/* Weak references objects for Python. */ + +#ifndef Py_WEAKREFOBJECT_H +#define Py_WEAKREFOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + + +typedef struct _PyWeakReference PyWeakReference; + +/* PyWeakReference is the base struct for the Python ReferenceType, ProxyType, + * and CallableProxyType. + */ +struct _PyWeakReference { + PyObject_HEAD + + /* The object to which this is a weak reference, or Py_None if none. + * Note that this is a stealth reference: wr_object's refcount is + * not incremented to reflect this pointer. + */ + PyObject *wr_object; + + /* A callable to invoke when wr_object dies, or NULL if none. */ + PyObject *wr_callback; + + /* A cache for wr_object's hash code. As usual for hashes, this is -1 + * if the hash code isn't known yet. + */ + long hash; + + /* If wr_object is weakly referenced, wr_object has a doubly-linked NULL- + * terminated list of weak references to it. These are the list pointers. + * If wr_object goes away, wr_object is set to Py_None, and these pointers + * have no meaning then. + */ + PyWeakReference *wr_prev; + PyWeakReference *wr_next; +}; + +PyAPI_DATA(PyTypeObject) _PyWeakref_RefType; +PyAPI_DATA(PyTypeObject) _PyWeakref_ProxyType; +PyAPI_DATA(PyTypeObject) _PyWeakref_CallableProxyType; + +#define PyWeakref_CheckRef(op) PyObject_TypeCheck(op, &_PyWeakref_RefType) +#define PyWeakref_CheckRefExact(op) \ + (Py_TYPE(op) == &_PyWeakref_RefType) +#define PyWeakref_CheckProxy(op) \ + ((Py_TYPE(op) == &_PyWeakref_ProxyType) || \ + (Py_TYPE(op) == &_PyWeakref_CallableProxyType)) + +#define PyWeakref_Check(op) \ + (PyWeakref_CheckRef(op) || PyWeakref_CheckProxy(op)) + + +PyAPI_FUNC(PyObject *) PyWeakref_NewRef(PyObject *ob, + PyObject *callback); +PyAPI_FUNC(PyObject *) PyWeakref_NewProxy(PyObject *ob, + PyObject *callback); +PyAPI_FUNC(PyObject *) PyWeakref_GetObject(PyObject *ref); + +PyAPI_FUNC(Py_ssize_t) _PyWeakref_GetWeakrefCount(PyWeakReference *head); + +PyAPI_FUNC(void) _PyWeakref_ClearRef(PyWeakReference *self); + +/* Explanation for the Py_REFCNT() check: when a weakref's target is part + of a long chain of deallocations which triggers the trashcan mechanism, + clearing the weakrefs can be delayed long after the target's refcount + has dropped to zero. In the meantime, code accessing the weakref will + be able to "see" the target object even though it is supposed to be + unreachable. See issue #16602. */ + +#define PyWeakref_GET_OBJECT(ref) \ + (Py_REFCNT(((PyWeakReference *)(ref))->wr_object) > 0 \ + ? ((PyWeakReference *)(ref))->wr_object \ + : Py_None) + + +#ifdef __cplusplus +} +#endif +#endif /* !Py_WEAKREFOBJECT_H */ diff --git a/android/python27/stdlib.zip b/android/python27/stdlib.zip new file mode 100644 index 000000000..d9b7adb0a Binary files /dev/null and b/android/python27/stdlib.zip differ diff --git a/android/python35/include/Python-ast.h b/android/python35/include/Python-ast.h new file mode 100644 index 000000000..3bc015fe7 --- /dev/null +++ b/android/python35/include/Python-ast.h @@ -0,0 +1,600 @@ +/* File automatically generated by Parser/asdl_c.py. */ + +#include "asdl.h" + +typedef struct _mod *mod_ty; + +typedef struct _stmt *stmt_ty; + +typedef struct _expr *expr_ty; + +typedef enum _expr_context { Load=1, Store=2, Del=3, AugLoad=4, AugStore=5, + Param=6 } expr_context_ty; + +typedef struct _slice *slice_ty; + +typedef enum _boolop { And=1, Or=2 } boolop_ty; + +typedef enum _operator { Add=1, Sub=2, Mult=3, MatMult=4, Div=5, Mod=6, Pow=7, + LShift=8, RShift=9, BitOr=10, BitXor=11, BitAnd=12, + FloorDiv=13 } operator_ty; + +typedef enum _unaryop { Invert=1, Not=2, UAdd=3, USub=4 } unaryop_ty; + +typedef enum _cmpop { Eq=1, NotEq=2, Lt=3, LtE=4, Gt=5, GtE=6, Is=7, IsNot=8, + In=9, NotIn=10 } cmpop_ty; + +typedef struct _comprehension *comprehension_ty; + +typedef struct _excepthandler *excepthandler_ty; + +typedef struct _arguments *arguments_ty; + +typedef struct _arg *arg_ty; + +typedef struct _keyword *keyword_ty; + +typedef struct _alias *alias_ty; + +typedef struct _withitem *withitem_ty; + + +enum _mod_kind {Module_kind=1, Interactive_kind=2, Expression_kind=3, + Suite_kind=4}; +struct _mod { + enum _mod_kind kind; + union { + struct { + asdl_seq *body; + } Module; + + struct { + asdl_seq *body; + } Interactive; + + struct { + expr_ty body; + } Expression; + + struct { + asdl_seq *body; + } Suite; + + } v; +}; + +enum _stmt_kind {FunctionDef_kind=1, AsyncFunctionDef_kind=2, ClassDef_kind=3, + Return_kind=4, Delete_kind=5, Assign_kind=6, + AugAssign_kind=7, For_kind=8, AsyncFor_kind=9, While_kind=10, + If_kind=11, With_kind=12, AsyncWith_kind=13, Raise_kind=14, + Try_kind=15, Assert_kind=16, Import_kind=17, + ImportFrom_kind=18, Global_kind=19, Nonlocal_kind=20, + Expr_kind=21, Pass_kind=22, Break_kind=23, Continue_kind=24}; +struct _stmt { + enum _stmt_kind kind; + union { + struct { + identifier name; + arguments_ty args; + asdl_seq *body; + asdl_seq *decorator_list; + expr_ty returns; + } FunctionDef; + + struct { + identifier name; + arguments_ty args; + asdl_seq *body; + asdl_seq *decorator_list; + expr_ty returns; + } AsyncFunctionDef; + + struct { + identifier name; + asdl_seq *bases; + asdl_seq *keywords; + asdl_seq *body; + asdl_seq *decorator_list; + } ClassDef; + + struct { + expr_ty value; + } Return; + + struct { + asdl_seq *targets; + } Delete; + + struct { + asdl_seq *targets; + expr_ty value; + } Assign; + + struct { + expr_ty target; + operator_ty op; + expr_ty value; + } AugAssign; + + struct { + expr_ty target; + expr_ty iter; + asdl_seq *body; + asdl_seq *orelse; + } For; + + struct { + expr_ty target; + expr_ty iter; + asdl_seq *body; + asdl_seq *orelse; + } AsyncFor; + + struct { + expr_ty test; + asdl_seq *body; + asdl_seq *orelse; + } While; + + struct { + expr_ty test; + asdl_seq *body; + asdl_seq *orelse; + } If; + + struct { + asdl_seq *items; + asdl_seq *body; + } With; + + struct { + asdl_seq *items; + asdl_seq *body; + } AsyncWith; + + struct { + expr_ty exc; + expr_ty cause; + } Raise; + + struct { + asdl_seq *body; + asdl_seq *handlers; + asdl_seq *orelse; + asdl_seq *finalbody; + } Try; + + struct { + expr_ty test; + expr_ty msg; + } Assert; + + struct { + asdl_seq *names; + } Import; + + struct { + identifier module; + asdl_seq *names; + int level; + } ImportFrom; + + struct { + asdl_seq *names; + } Global; + + struct { + asdl_seq *names; + } Nonlocal; + + struct { + expr_ty value; + } Expr; + + } v; + int lineno; + int col_offset; +}; + +enum _expr_kind {BoolOp_kind=1, BinOp_kind=2, UnaryOp_kind=3, Lambda_kind=4, + IfExp_kind=5, Dict_kind=6, Set_kind=7, ListComp_kind=8, + SetComp_kind=9, DictComp_kind=10, GeneratorExp_kind=11, + Await_kind=12, Yield_kind=13, YieldFrom_kind=14, + Compare_kind=15, Call_kind=16, Num_kind=17, Str_kind=18, + Bytes_kind=19, NameConstant_kind=20, Ellipsis_kind=21, + Attribute_kind=22, Subscript_kind=23, Starred_kind=24, + Name_kind=25, List_kind=26, Tuple_kind=27}; +struct _expr { + enum _expr_kind kind; + union { + struct { + boolop_ty op; + asdl_seq *values; + } BoolOp; + + struct { + expr_ty left; + operator_ty op; + expr_ty right; + } BinOp; + + struct { + unaryop_ty op; + expr_ty operand; + } UnaryOp; + + struct { + arguments_ty args; + expr_ty body; + } Lambda; + + struct { + expr_ty test; + expr_ty body; + expr_ty orelse; + } IfExp; + + struct { + asdl_seq *keys; + asdl_seq *values; + } Dict; + + struct { + asdl_seq *elts; + } Set; + + struct { + expr_ty elt; + asdl_seq *generators; + } ListComp; + + struct { + expr_ty elt; + asdl_seq *generators; + } SetComp; + + struct { + expr_ty key; + expr_ty value; + asdl_seq *generators; + } DictComp; + + struct { + expr_ty elt; + asdl_seq *generators; + } GeneratorExp; + + struct { + expr_ty value; + } Await; + + struct { + expr_ty value; + } Yield; + + struct { + expr_ty value; + } YieldFrom; + + struct { + expr_ty left; + asdl_int_seq *ops; + asdl_seq *comparators; + } Compare; + + struct { + expr_ty func; + asdl_seq *args; + asdl_seq *keywords; + } Call; + + struct { + object n; + } Num; + + struct { + string s; + } Str; + + struct { + bytes s; + } Bytes; + + struct { + singleton value; + } NameConstant; + + struct { + expr_ty value; + identifier attr; + expr_context_ty ctx; + } Attribute; + + struct { + expr_ty value; + slice_ty slice; + expr_context_ty ctx; + } Subscript; + + struct { + expr_ty value; + expr_context_ty ctx; + } Starred; + + struct { + identifier id; + expr_context_ty ctx; + } Name; + + struct { + asdl_seq *elts; + expr_context_ty ctx; + } List; + + struct { + asdl_seq *elts; + expr_context_ty ctx; + } Tuple; + + } v; + int lineno; + int col_offset; +}; + +enum _slice_kind {Slice_kind=1, ExtSlice_kind=2, Index_kind=3}; +struct _slice { + enum _slice_kind kind; + union { + struct { + expr_ty lower; + expr_ty upper; + expr_ty step; + } Slice; + + struct { + asdl_seq *dims; + } ExtSlice; + + struct { + expr_ty value; + } Index; + + } v; +}; + +struct _comprehension { + expr_ty target; + expr_ty iter; + asdl_seq *ifs; +}; + +enum _excepthandler_kind {ExceptHandler_kind=1}; +struct _excepthandler { + enum _excepthandler_kind kind; + union { + struct { + expr_ty type; + identifier name; + asdl_seq *body; + } ExceptHandler; + + } v; + int lineno; + int col_offset; +}; + +struct _arguments { + asdl_seq *args; + arg_ty vararg; + asdl_seq *kwonlyargs; + asdl_seq *kw_defaults; + arg_ty kwarg; + asdl_seq *defaults; +}; + +struct _arg { + identifier arg; + expr_ty annotation; + int lineno; + int col_offset; +}; + +struct _keyword { + identifier arg; + expr_ty value; +}; + +struct _alias { + identifier name; + identifier asname; +}; + +struct _withitem { + expr_ty context_expr; + expr_ty optional_vars; +}; + + +#define Module(a0, a1) _Py_Module(a0, a1) +mod_ty _Py_Module(asdl_seq * body, PyArena *arena); +#define Interactive(a0, a1) _Py_Interactive(a0, a1) +mod_ty _Py_Interactive(asdl_seq * body, PyArena *arena); +#define Expression(a0, a1) _Py_Expression(a0, a1) +mod_ty _Py_Expression(expr_ty body, PyArena *arena); +#define Suite(a0, a1) _Py_Suite(a0, a1) +mod_ty _Py_Suite(asdl_seq * body, PyArena *arena); +#define FunctionDef(a0, a1, a2, a3, a4, a5, a6, a7) _Py_FunctionDef(a0, a1, a2, a3, a4, a5, a6, a7) +stmt_ty _Py_FunctionDef(identifier name, arguments_ty args, asdl_seq * body, + asdl_seq * decorator_list, expr_ty returns, int lineno, + int col_offset, PyArena *arena); +#define AsyncFunctionDef(a0, a1, a2, a3, a4, a5, a6, a7) _Py_AsyncFunctionDef(a0, a1, a2, a3, a4, a5, a6, a7) +stmt_ty _Py_AsyncFunctionDef(identifier name, arguments_ty args, asdl_seq * + body, asdl_seq * decorator_list, expr_ty returns, + int lineno, int col_offset, PyArena *arena); +#define ClassDef(a0, a1, a2, a3, a4, a5, a6, a7) _Py_ClassDef(a0, a1, a2, a3, a4, a5, a6, a7) +stmt_ty _Py_ClassDef(identifier name, asdl_seq * bases, asdl_seq * keywords, + asdl_seq * body, asdl_seq * decorator_list, int lineno, + int col_offset, PyArena *arena); +#define Return(a0, a1, a2, a3) _Py_Return(a0, a1, a2, a3) +stmt_ty _Py_Return(expr_ty value, int lineno, int col_offset, PyArena *arena); +#define Delete(a0, a1, a2, a3) _Py_Delete(a0, a1, a2, a3) +stmt_ty _Py_Delete(asdl_seq * targets, int lineno, int col_offset, PyArena + *arena); +#define Assign(a0, a1, a2, a3, a4) _Py_Assign(a0, a1, a2, a3, a4) +stmt_ty _Py_Assign(asdl_seq * targets, expr_ty value, int lineno, int + col_offset, PyArena *arena); +#define AugAssign(a0, a1, a2, a3, a4, a5) _Py_AugAssign(a0, a1, a2, a3, a4, a5) +stmt_ty _Py_AugAssign(expr_ty target, operator_ty op, expr_ty value, int + lineno, int col_offset, PyArena *arena); +#define For(a0, a1, a2, a3, a4, a5, a6) _Py_For(a0, a1, a2, a3, a4, a5, a6) +stmt_ty _Py_For(expr_ty target, expr_ty iter, asdl_seq * body, asdl_seq * + orelse, int lineno, int col_offset, PyArena *arena); +#define AsyncFor(a0, a1, a2, a3, a4, a5, a6) _Py_AsyncFor(a0, a1, a2, a3, a4, a5, a6) +stmt_ty _Py_AsyncFor(expr_ty target, expr_ty iter, asdl_seq * body, asdl_seq * + orelse, int lineno, int col_offset, PyArena *arena); +#define While(a0, a1, a2, a3, a4, a5) _Py_While(a0, a1, a2, a3, a4, a5) +stmt_ty _Py_While(expr_ty test, asdl_seq * body, asdl_seq * orelse, int lineno, + int col_offset, PyArena *arena); +#define If(a0, a1, a2, a3, a4, a5) _Py_If(a0, a1, a2, a3, a4, a5) +stmt_ty _Py_If(expr_ty test, asdl_seq * body, asdl_seq * orelse, int lineno, + int col_offset, PyArena *arena); +#define With(a0, a1, a2, a3, a4) _Py_With(a0, a1, a2, a3, a4) +stmt_ty _Py_With(asdl_seq * items, asdl_seq * body, int lineno, int col_offset, + PyArena *arena); +#define AsyncWith(a0, a1, a2, a3, a4) _Py_AsyncWith(a0, a1, a2, a3, a4) +stmt_ty _Py_AsyncWith(asdl_seq * items, asdl_seq * body, int lineno, int + col_offset, PyArena *arena); +#define Raise(a0, a1, a2, a3, a4) _Py_Raise(a0, a1, a2, a3, a4) +stmt_ty _Py_Raise(expr_ty exc, expr_ty cause, int lineno, int col_offset, + PyArena *arena); +#define Try(a0, a1, a2, a3, a4, a5, a6) _Py_Try(a0, a1, a2, a3, a4, a5, a6) +stmt_ty _Py_Try(asdl_seq * body, asdl_seq * handlers, asdl_seq * orelse, + asdl_seq * finalbody, int lineno, int col_offset, PyArena + *arena); +#define Assert(a0, a1, a2, a3, a4) _Py_Assert(a0, a1, a2, a3, a4) +stmt_ty _Py_Assert(expr_ty test, expr_ty msg, int lineno, int col_offset, + PyArena *arena); +#define Import(a0, a1, a2, a3) _Py_Import(a0, a1, a2, a3) +stmt_ty _Py_Import(asdl_seq * names, int lineno, int col_offset, PyArena + *arena); +#define ImportFrom(a0, a1, a2, a3, a4, a5) _Py_ImportFrom(a0, a1, a2, a3, a4, a5) +stmt_ty _Py_ImportFrom(identifier module, asdl_seq * names, int level, int + lineno, int col_offset, PyArena *arena); +#define Global(a0, a1, a2, a3) _Py_Global(a0, a1, a2, a3) +stmt_ty _Py_Global(asdl_seq * names, int lineno, int col_offset, PyArena + *arena); +#define Nonlocal(a0, a1, a2, a3) _Py_Nonlocal(a0, a1, a2, a3) +stmt_ty _Py_Nonlocal(asdl_seq * names, int lineno, int col_offset, PyArena + *arena); +#define Expr(a0, a1, a2, a3) _Py_Expr(a0, a1, a2, a3) +stmt_ty _Py_Expr(expr_ty value, int lineno, int col_offset, PyArena *arena); +#define Pass(a0, a1, a2) _Py_Pass(a0, a1, a2) +stmt_ty _Py_Pass(int lineno, int col_offset, PyArena *arena); +#define Break(a0, a1, a2) _Py_Break(a0, a1, a2) +stmt_ty _Py_Break(int lineno, int col_offset, PyArena *arena); +#define Continue(a0, a1, a2) _Py_Continue(a0, a1, a2) +stmt_ty _Py_Continue(int lineno, int col_offset, PyArena *arena); +#define BoolOp(a0, a1, a2, a3, a4) _Py_BoolOp(a0, a1, a2, a3, a4) +expr_ty _Py_BoolOp(boolop_ty op, asdl_seq * values, int lineno, int col_offset, + PyArena *arena); +#define BinOp(a0, a1, a2, a3, a4, a5) _Py_BinOp(a0, a1, a2, a3, a4, a5) +expr_ty _Py_BinOp(expr_ty left, operator_ty op, expr_ty right, int lineno, int + col_offset, PyArena *arena); +#define UnaryOp(a0, a1, a2, a3, a4) _Py_UnaryOp(a0, a1, a2, a3, a4) +expr_ty _Py_UnaryOp(unaryop_ty op, expr_ty operand, int lineno, int col_offset, + PyArena *arena); +#define Lambda(a0, a1, a2, a3, a4) _Py_Lambda(a0, a1, a2, a3, a4) +expr_ty _Py_Lambda(arguments_ty args, expr_ty body, int lineno, int col_offset, + PyArena *arena); +#define IfExp(a0, a1, a2, a3, a4, a5) _Py_IfExp(a0, a1, a2, a3, a4, a5) +expr_ty _Py_IfExp(expr_ty test, expr_ty body, expr_ty orelse, int lineno, int + col_offset, PyArena *arena); +#define Dict(a0, a1, a2, a3, a4) _Py_Dict(a0, a1, a2, a3, a4) +expr_ty _Py_Dict(asdl_seq * keys, asdl_seq * values, int lineno, int + col_offset, PyArena *arena); +#define Set(a0, a1, a2, a3) _Py_Set(a0, a1, a2, a3) +expr_ty _Py_Set(asdl_seq * elts, int lineno, int col_offset, PyArena *arena); +#define ListComp(a0, a1, a2, a3, a4) _Py_ListComp(a0, a1, a2, a3, a4) +expr_ty _Py_ListComp(expr_ty elt, asdl_seq * generators, int lineno, int + col_offset, PyArena *arena); +#define SetComp(a0, a1, a2, a3, a4) _Py_SetComp(a0, a1, a2, a3, a4) +expr_ty _Py_SetComp(expr_ty elt, asdl_seq * generators, int lineno, int + col_offset, PyArena *arena); +#define DictComp(a0, a1, a2, a3, a4, a5) _Py_DictComp(a0, a1, a2, a3, a4, a5) +expr_ty _Py_DictComp(expr_ty key, expr_ty value, asdl_seq * generators, int + lineno, int col_offset, PyArena *arena); +#define GeneratorExp(a0, a1, a2, a3, a4) _Py_GeneratorExp(a0, a1, a2, a3, a4) +expr_ty _Py_GeneratorExp(expr_ty elt, asdl_seq * generators, int lineno, int + col_offset, PyArena *arena); +#define Await(a0, a1, a2, a3) _Py_Await(a0, a1, a2, a3) +expr_ty _Py_Await(expr_ty value, int lineno, int col_offset, PyArena *arena); +#define Yield(a0, a1, a2, a3) _Py_Yield(a0, a1, a2, a3) +expr_ty _Py_Yield(expr_ty value, int lineno, int col_offset, PyArena *arena); +#define YieldFrom(a0, a1, a2, a3) _Py_YieldFrom(a0, a1, a2, a3) +expr_ty _Py_YieldFrom(expr_ty value, int lineno, int col_offset, PyArena + *arena); +#define Compare(a0, a1, a2, a3, a4, a5) _Py_Compare(a0, a1, a2, a3, a4, a5) +expr_ty _Py_Compare(expr_ty left, asdl_int_seq * ops, asdl_seq * comparators, + int lineno, int col_offset, PyArena *arena); +#define Call(a0, a1, a2, a3, a4, a5) _Py_Call(a0, a1, a2, a3, a4, a5) +expr_ty _Py_Call(expr_ty func, asdl_seq * args, asdl_seq * keywords, int + lineno, int col_offset, PyArena *arena); +#define Num(a0, a1, a2, a3) _Py_Num(a0, a1, a2, a3) +expr_ty _Py_Num(object n, int lineno, int col_offset, PyArena *arena); +#define Str(a0, a1, a2, a3) _Py_Str(a0, a1, a2, a3) +expr_ty _Py_Str(string s, int lineno, int col_offset, PyArena *arena); +#define Bytes(a0, a1, a2, a3) _Py_Bytes(a0, a1, a2, a3) +expr_ty _Py_Bytes(bytes s, int lineno, int col_offset, PyArena *arena); +#define NameConstant(a0, a1, a2, a3) _Py_NameConstant(a0, a1, a2, a3) +expr_ty _Py_NameConstant(singleton value, int lineno, int col_offset, PyArena + *arena); +#define Ellipsis(a0, a1, a2) _Py_Ellipsis(a0, a1, a2) +expr_ty _Py_Ellipsis(int lineno, int col_offset, PyArena *arena); +#define Attribute(a0, a1, a2, a3, a4, a5) _Py_Attribute(a0, a1, a2, a3, a4, a5) +expr_ty _Py_Attribute(expr_ty value, identifier attr, expr_context_ty ctx, int + lineno, int col_offset, PyArena *arena); +#define Subscript(a0, a1, a2, a3, a4, a5) _Py_Subscript(a0, a1, a2, a3, a4, a5) +expr_ty _Py_Subscript(expr_ty value, slice_ty slice, expr_context_ty ctx, int + lineno, int col_offset, PyArena *arena); +#define Starred(a0, a1, a2, a3, a4) _Py_Starred(a0, a1, a2, a3, a4) +expr_ty _Py_Starred(expr_ty value, expr_context_ty ctx, int lineno, int + col_offset, PyArena *arena); +#define Name(a0, a1, a2, a3, a4) _Py_Name(a0, a1, a2, a3, a4) +expr_ty _Py_Name(identifier id, expr_context_ty ctx, int lineno, int + col_offset, PyArena *arena); +#define List(a0, a1, a2, a3, a4) _Py_List(a0, a1, a2, a3, a4) +expr_ty _Py_List(asdl_seq * elts, expr_context_ty ctx, int lineno, int + col_offset, PyArena *arena); +#define Tuple(a0, a1, a2, a3, a4) _Py_Tuple(a0, a1, a2, a3, a4) +expr_ty _Py_Tuple(asdl_seq * elts, expr_context_ty ctx, int lineno, int + col_offset, PyArena *arena); +#define Slice(a0, a1, a2, a3) _Py_Slice(a0, a1, a2, a3) +slice_ty _Py_Slice(expr_ty lower, expr_ty upper, expr_ty step, PyArena *arena); +#define ExtSlice(a0, a1) _Py_ExtSlice(a0, a1) +slice_ty _Py_ExtSlice(asdl_seq * dims, PyArena *arena); +#define Index(a0, a1) _Py_Index(a0, a1) +slice_ty _Py_Index(expr_ty value, PyArena *arena); +#define comprehension(a0, a1, a2, a3) _Py_comprehension(a0, a1, a2, a3) +comprehension_ty _Py_comprehension(expr_ty target, expr_ty iter, asdl_seq * + ifs, PyArena *arena); +#define ExceptHandler(a0, a1, a2, a3, a4, a5) _Py_ExceptHandler(a0, a1, a2, a3, a4, a5) +excepthandler_ty _Py_ExceptHandler(expr_ty type, identifier name, asdl_seq * + body, int lineno, int col_offset, PyArena + *arena); +#define arguments(a0, a1, a2, a3, a4, a5, a6) _Py_arguments(a0, a1, a2, a3, a4, a5, a6) +arguments_ty _Py_arguments(asdl_seq * args, arg_ty vararg, asdl_seq * + kwonlyargs, asdl_seq * kw_defaults, arg_ty kwarg, + asdl_seq * defaults, PyArena *arena); +#define arg(a0, a1, a2) _Py_arg(a0, a1, a2) +arg_ty _Py_arg(identifier arg, expr_ty annotation, PyArena *arena); +#define keyword(a0, a1, a2) _Py_keyword(a0, a1, a2) +keyword_ty _Py_keyword(identifier arg, expr_ty value, PyArena *arena); +#define alias(a0, a1, a2) _Py_alias(a0, a1, a2) +alias_ty _Py_alias(identifier name, identifier asname, PyArena *arena); +#define withitem(a0, a1, a2) _Py_withitem(a0, a1, a2) +withitem_ty _Py_withitem(expr_ty context_expr, expr_ty optional_vars, PyArena + *arena); + +PyObject* PyAST_mod2obj(mod_ty t); +mod_ty PyAST_obj2mod(PyObject* ast, PyArena* arena, int mode); +int PyAST_Check(PyObject* obj); diff --git a/android/python35/include/Python.h b/android/python35/include/Python.h new file mode 100644 index 000000000..858dbd1a6 --- /dev/null +++ b/android/python35/include/Python.h @@ -0,0 +1,135 @@ +#ifndef Py_PYTHON_H +#define Py_PYTHON_H +/* Since this is a "meta-include" file, no #ifdef __cplusplus / extern "C" { */ + +/* Include nearly all Python header files */ + +#include "patchlevel.h" +#include "pyconfig.h" +#include "pymacconfig.h" + +#include + +#ifndef UCHAR_MAX +#error "Something's broken. UCHAR_MAX should be defined in limits.h." +#endif + +#if UCHAR_MAX != 255 +#error "Python's source code assumes C's unsigned char is an 8-bit type." +#endif + +#if defined(__sgi) && defined(WITH_THREAD) && !defined(_SGI_MP_SOURCE) +#define _SGI_MP_SOURCE +#endif + +#include +#ifndef NULL +# error "Python.h requires that stdio.h define NULL." +#endif + +#include +#ifdef HAVE_ERRNO_H +#include +#endif +#include +#ifdef HAVE_UNISTD_H +#include +#endif + +/* For size_t? */ +#ifdef HAVE_STDDEF_H +#include +#endif + +/* CAUTION: Build setups should ensure that NDEBUG is defined on the + * compiler command line when building Python in release mode; else + * assert() calls won't be removed. + */ +#include + +#include "pyport.h" +#include "pymacro.h" + +#include "pyatomic.h" + +/* Debug-mode build with pymalloc implies PYMALLOC_DEBUG. + * PYMALLOC_DEBUG is in error if pymalloc is not in use. + */ +#if defined(Py_DEBUG) && defined(WITH_PYMALLOC) && !defined(PYMALLOC_DEBUG) +#define PYMALLOC_DEBUG +#endif +#if defined(PYMALLOC_DEBUG) && !defined(WITH_PYMALLOC) +#error "PYMALLOC_DEBUG requires WITH_PYMALLOC" +#endif +#include "pymath.h" +#include "pytime.h" +#include "pymem.h" + +#include "object.h" +#include "objimpl.h" +#include "typeslots.h" +#include "pyhash.h" + +#include "pydebug.h" + +#include "bytearrayobject.h" +#include "bytesobject.h" +#include "unicodeobject.h" +#include "longobject.h" +#include "longintrepr.h" +#include "boolobject.h" +#include "floatobject.h" +#include "complexobject.h" +#include "rangeobject.h" +#include "memoryobject.h" +#include "tupleobject.h" +#include "listobject.h" +#include "dictobject.h" +#include "odictobject.h" +#include "enumobject.h" +#include "setobject.h" +#include "methodobject.h" +#include "moduleobject.h" +#include "funcobject.h" +#include "classobject.h" +#include "fileobject.h" +#include "pycapsule.h" +#include "traceback.h" +#include "sliceobject.h" +#include "cellobject.h" +#include "iterobject.h" +#include "genobject.h" +#include "descrobject.h" +#include "warnings.h" +#include "weakrefobject.h" +#include "structseq.h" +#include "namespaceobject.h" + +#include "codecs.h" +#include "pyerrors.h" + +#include "pystate.h" + +#include "pyarena.h" +#include "modsupport.h" +#include "pythonrun.h" +#include "pylifecycle.h" +#include "ceval.h" +#include "sysmodule.h" +#include "intrcheck.h" +#include "import.h" + +#include "abstract.h" +#include "bltinmodule.h" + +#include "compile.h" +#include "eval.h" + +#include "pyctype.h" +#include "pystrtod.h" +#include "pystrcmp.h" +#include "dtoa.h" +#include "fileutils.h" +#include "pyfpe.h" + +#endif /* !Py_PYTHON_H */ diff --git a/android/python35/include/abstract.h b/android/python35/include/abstract.h new file mode 100644 index 000000000..83dbf94f6 --- /dev/null +++ b/android/python35/include/abstract.h @@ -0,0 +1,1285 @@ +#ifndef Py_ABSTRACTOBJECT_H +#define Py_ABSTRACTOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef PY_SSIZE_T_CLEAN +#define PyObject_CallFunction _PyObject_CallFunction_SizeT +#define PyObject_CallMethod _PyObject_CallMethod_SizeT +#define _PyObject_CallMethodId _PyObject_CallMethodId_SizeT +#endif + +/* Abstract Object Interface (many thanks to Jim Fulton) */ + +/* + PROPOSAL: A Generic Python Object Interface for Python C Modules + +Problem + + Python modules written in C that must access Python objects must do + so through routines whose interfaces are described by a set of + include files. Unfortunately, these routines vary according to the + object accessed. To use these routines, the C programmer must check + the type of the object being used and must call a routine based on + the object type. For example, to access an element of a sequence, + the programmer must determine whether the sequence is a list or a + tuple: + + if(is_tupleobject(o)) + e=gettupleitem(o,i) + else if(is_listitem(o)) + e=getlistitem(o,i) + + If the programmer wants to get an item from another type of object + that provides sequence behavior, there is no clear way to do it + correctly. + + The persistent programmer may peruse object.h and find that the + _typeobject structure provides a means of invoking up to (currently + about) 41 special operators. So, for example, a routine can get an + item from any object that provides sequence behavior. However, to + use this mechanism, the programmer must make their code dependent on + the current Python implementation. + + Also, certain semantics, especially memory management semantics, may + differ by the type of object being used. Unfortunately, these + semantics are not clearly described in the current include files. + An abstract interface providing more consistent semantics is needed. + +Proposal + + I propose the creation of a standard interface (with an associated + library of routines and/or macros) for generically obtaining the + services of Python objects. This proposal can be viewed as one + components of a Python C interface consisting of several components. + + From the viewpoint of C access to Python services, we have (as + suggested by Guido in off-line discussions): + + - "Very high level layer": two or three functions that let you exec or + eval arbitrary Python code given as a string in a module whose name is + given, passing C values in and getting C values out using + mkvalue/getargs style format strings. This does not require the user + to declare any variables of type "PyObject *". This should be enough + to write a simple application that gets Python code from the user, + execs it, and returns the output or errors. (Error handling must also + be part of this API.) + + - "Abstract objects layer": which is the subject of this proposal. + It has many functions operating on objects, and lest you do many + things from C that you can also write in Python, without going + through the Python parser. + + - "Concrete objects layer": This is the public type-dependent + interface provided by the standard built-in types, such as floats, + strings, and lists. This interface exists and is currently + documented by the collection of include files provided with the + Python distributions. + + From the point of view of Python accessing services provided by C + modules: + + - "Python module interface": this interface consist of the basic + routines used to define modules and their members. Most of the + current extensions-writing guide deals with this interface. + + - "Built-in object interface": this is the interface that a new + built-in type must provide and the mechanisms and rules that a + developer of a new built-in type must use and follow. + + This proposal is a "first-cut" that is intended to spur + discussion. See especially the lists of notes. + + The Python C object interface will provide four protocols: object, + numeric, sequence, and mapping. Each protocol consists of a + collection of related operations. If an operation that is not + provided by a particular type is invoked, then a standard exception, + NotImplementedError is raised with a operation name as an argument. + In addition, for convenience this interface defines a set of + constructors for building objects of built-in types. This is needed + so new objects can be returned from C functions that otherwise treat + objects generically. + +Memory Management + + For all of the functions described in this proposal, if a function + retains a reference to a Python object passed as an argument, then the + function will increase the reference count of the object. It is + unnecessary for the caller to increase the reference count of an + argument in anticipation of the object's retention. + + All Python objects returned from functions should be treated as new + objects. Functions that return objects assume that the caller will + retain a reference and the reference count of the object has already + been incremented to account for this fact. A caller that does not + retain a reference to an object that is returned from a function + must decrement the reference count of the object (using + DECREF(object)) to prevent memory leaks. + + Note that the behavior mentioned here is different from the current + behavior for some objects (e.g. lists and tuples) when certain + type-specific routines are called directly (e.g. setlistitem). The + proposed abstraction layer will provide a consistent memory + management interface, correcting for inconsistent behavior for some + built-in types. + +Protocols + +xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx*/ + +/* Object Protocol: */ + + /* Implemented elsewhere: + + int PyObject_Print(PyObject *o, FILE *fp, int flags); + + Print an object, o, on file, fp. Returns -1 on + error. The flags argument is used to enable certain printing + options. The only option currently supported is Py_Print_RAW. + + (What should be said about Py_Print_RAW?) + + */ + + /* Implemented elsewhere: + + int PyObject_HasAttrString(PyObject *o, const char *attr_name); + + Returns 1 if o has the attribute attr_name, and 0 otherwise. + This is equivalent to the Python expression: + hasattr(o,attr_name). + + This function always succeeds. + + */ + + /* Implemented elsewhere: + + PyObject* PyObject_GetAttrString(PyObject *o, const char *attr_name); + + Retrieve an attributed named attr_name form object o. + Returns the attribute value on success, or NULL on failure. + This is the equivalent of the Python expression: o.attr_name. + + */ + + /* Implemented elsewhere: + + int PyObject_HasAttr(PyObject *o, PyObject *attr_name); + + Returns 1 if o has the attribute attr_name, and 0 otherwise. + This is equivalent to the Python expression: + hasattr(o,attr_name). + + This function always succeeds. + + */ + + /* Implemented elsewhere: + + PyObject* PyObject_GetAttr(PyObject *o, PyObject *attr_name); + + Retrieve an attributed named attr_name form object o. + Returns the attribute value on success, or NULL on failure. + This is the equivalent of the Python expression: o.attr_name. + + */ + + + /* Implemented elsewhere: + + int PyObject_SetAttrString(PyObject *o, const char *attr_name, PyObject *v); + + Set the value of the attribute named attr_name, for object o, + to the value, v. Returns -1 on failure. This is + the equivalent of the Python statement: o.attr_name=v. + + */ + + /* Implemented elsewhere: + + int PyObject_SetAttr(PyObject *o, PyObject *attr_name, PyObject *v); + + Set the value of the attribute named attr_name, for object o, + to the value, v. Returns -1 on failure. This is + the equivalent of the Python statement: o.attr_name=v. + + */ + + /* implemented as a macro: + + int PyObject_DelAttrString(PyObject *o, const char *attr_name); + + Delete attribute named attr_name, for object o. Returns + -1 on failure. This is the equivalent of the Python + statement: del o.attr_name. + + */ +#define PyObject_DelAttrString(O,A) PyObject_SetAttrString((O),(A),NULL) + + /* implemented as a macro: + + int PyObject_DelAttr(PyObject *o, PyObject *attr_name); + + Delete attribute named attr_name, for object o. Returns -1 + on failure. This is the equivalent of the Python + statement: del o.attr_name. + + */ +#define PyObject_DelAttr(O,A) PyObject_SetAttr((O),(A),NULL) + + /* Implemented elsewhere: + + PyObject *PyObject_Repr(PyObject *o); + + Compute the string representation of object, o. Returns the + string representation on success, NULL on failure. This is + the equivalent of the Python expression: repr(o). + + Called by the repr() built-in function. + + */ + + /* Implemented elsewhere: + + PyObject *PyObject_Str(PyObject *o); + + Compute the string representation of object, o. Returns the + string representation on success, NULL on failure. This is + the equivalent of the Python expression: str(o).) + + Called by the str() and print() built-in functions. + + */ + + /* Declared elsewhere + + PyAPI_FUNC(int) PyCallable_Check(PyObject *o); + + Determine if the object, o, is callable. Return 1 if the + object is callable and 0 otherwise. + + This function always succeeds. + */ + + PyAPI_FUNC(PyObject *) PyObject_Call(PyObject *callable_object, + PyObject *args, PyObject *kw); + +#ifndef Py_LIMITED_API + PyAPI_FUNC(PyObject *) _Py_CheckFunctionResult(PyObject *func, + PyObject *result, + const char *where); +#endif + + /* + Call a callable Python object, callable_object, with + arguments and keywords arguments. The 'args' argument can not be + NULL, but the 'kw' argument can be NULL. + */ + + PyAPI_FUNC(PyObject *) PyObject_CallObject(PyObject *callable_object, + PyObject *args); + + /* + Call a callable Python object, callable_object, with + arguments given by the tuple, args. If no arguments are + needed, then args may be NULL. Returns the result of the + call on success, or NULL on failure. This is the equivalent + of the Python expression: o(*args). + */ + + PyAPI_FUNC(PyObject *) PyObject_CallFunction(PyObject *callable_object, + const char *format, ...); + + /* + Call a callable Python object, callable_object, with a + variable number of C arguments. The C arguments are described + using a mkvalue-style format string. The format may be NULL, + indicating that no arguments are provided. Returns the + result of the call on success, or NULL on failure. This is + the equivalent of the Python expression: o(*args). + */ + + + PyAPI_FUNC(PyObject *) PyObject_CallMethod(PyObject *o, + const char *method, + const char *format, ...); + + /* + Call the method named m of object o with a variable number of + C arguments. The C arguments are described by a mkvalue + format string. The format may be NULL, indicating that no + arguments are provided. Returns the result of the call on + success, or NULL on failure. This is the equivalent of the + Python expression: o.method(args). + */ + + PyAPI_FUNC(PyObject *) _PyObject_CallMethodId(PyObject *o, + _Py_Identifier *method, + const char *format, ...); + + /* + Like PyObject_CallMethod, but expect a _Py_Identifier* as the + method name. + */ + + PyAPI_FUNC(PyObject *) _PyObject_CallFunction_SizeT(PyObject *callable, + const char *format, + ...); + PyAPI_FUNC(PyObject *) _PyObject_CallMethod_SizeT(PyObject *o, + const char *name, + const char *format, + ...); + PyAPI_FUNC(PyObject *) _PyObject_CallMethodId_SizeT(PyObject *o, + _Py_Identifier *name, + const char *format, + ...); + + PyAPI_FUNC(PyObject *) PyObject_CallFunctionObjArgs(PyObject *callable, + ...); + + /* + Call a callable Python object, callable_object, with a + variable number of C arguments. The C arguments are provided + as PyObject * values, terminated by a NULL. Returns the + result of the call on success, or NULL on failure. This is + the equivalent of the Python expression: o(*args). + */ + + + PyAPI_FUNC(PyObject *) PyObject_CallMethodObjArgs(PyObject *o, + PyObject *method, ...); + PyAPI_FUNC(PyObject *) _PyObject_CallMethodIdObjArgs(PyObject *o, + struct _Py_Identifier *method, + ...); + + /* + Call the method named m of object o with a variable number of + C arguments. The C arguments are provided as PyObject * + values, terminated by NULL. Returns the result of the call + on success, or NULL on failure. This is the equivalent of + the Python expression: o.method(args). + */ + + + /* Implemented elsewhere: + + long PyObject_Hash(PyObject *o); + + Compute and return the hash, hash_value, of an object, o. On + failure, return -1. This is the equivalent of the Python + expression: hash(o). + */ + + + /* Implemented elsewhere: + + int PyObject_IsTrue(PyObject *o); + + Returns 1 if the object, o, is considered to be true, 0 if o is + considered to be false and -1 on failure. This is equivalent to the + Python expression: not not o + */ + + /* Implemented elsewhere: + + int PyObject_Not(PyObject *o); + + Returns 0 if the object, o, is considered to be true, 1 if o is + considered to be false and -1 on failure. This is equivalent to the + Python expression: not o + */ + + PyAPI_FUNC(PyObject *) PyObject_Type(PyObject *o); + + /* + On success, returns a type object corresponding to the object + type of object o. On failure, returns NULL. This is + equivalent to the Python expression: type(o). + */ + + PyAPI_FUNC(Py_ssize_t) PyObject_Size(PyObject *o); + + /* + Return the size of object o. If the object, o, provides + both sequence and mapping protocols, the sequence size is + returned. On error, -1 is returned. This is the equivalent + to the Python expression: len(o). + */ + + /* For DLL compatibility */ +#undef PyObject_Length + PyAPI_FUNC(Py_ssize_t) PyObject_Length(PyObject *o); +#define PyObject_Length PyObject_Size + +#ifndef Py_LIMITED_API + PyAPI_FUNC(int) _PyObject_HasLen(PyObject *o); + PyAPI_FUNC(Py_ssize_t) PyObject_LengthHint(PyObject *o, Py_ssize_t); +#endif + + /* + Guess the size of object o using len(o) or o.__length_hint__(). + If neither of those return a non-negative value, then return the + default value. If one of the calls fails, this function returns -1. + */ + + PyAPI_FUNC(PyObject *) PyObject_GetItem(PyObject *o, PyObject *key); + + /* + Return element of o corresponding to the object, key, or NULL + on failure. This is the equivalent of the Python expression: + o[key]. + */ + + PyAPI_FUNC(int) PyObject_SetItem(PyObject *o, PyObject *key, PyObject *v); + + /* + Map the object, key, to the value, v. Returns + -1 on failure. This is the equivalent of the Python + statement: o[key]=v. + */ + + PyAPI_FUNC(int) PyObject_DelItemString(PyObject *o, const char *key); + + /* + Remove the mapping for object, key, from the object *o. + Returns -1 on failure. This is equivalent to + the Python statement: del o[key]. + */ + + PyAPI_FUNC(int) PyObject_DelItem(PyObject *o, PyObject *key); + + /* + Delete the mapping for key from *o. Returns -1 on failure. + This is the equivalent of the Python statement: del o[key]. + */ + + /* old buffer API + FIXME: usage of these should all be replaced in Python itself + but for backwards compatibility we will implement them. + Their usage without a corresponding "unlock" mechansim + may create issues (but they would already be there). */ + + PyAPI_FUNC(int) PyObject_AsCharBuffer(PyObject *obj, + const char **buffer, + Py_ssize_t *buffer_len); + + /* + Takes an arbitrary object which must support the (character, + single segment) buffer interface and returns a pointer to a + read-only memory location useable as character based input + for subsequent processing. + + 0 is returned on success. buffer and buffer_len are only + set in case no error occurs. Otherwise, -1 is returned and + an exception set. + */ + + PyAPI_FUNC(int) PyObject_CheckReadBuffer(PyObject *obj); + + /* + Checks whether an arbitrary object supports the (character, + single segment) buffer interface. Returns 1 on success, 0 + on failure. + */ + + PyAPI_FUNC(int) PyObject_AsReadBuffer(PyObject *obj, + const void **buffer, + Py_ssize_t *buffer_len); + + /* + Same as PyObject_AsCharBuffer() except that this API expects + (readable, single segment) buffer interface and returns a + pointer to a read-only memory location which can contain + arbitrary data. + + 0 is returned on success. buffer and buffer_len are only + set in case no error occurs. Otherwise, -1 is returned and + an exception set. + */ + + PyAPI_FUNC(int) PyObject_AsWriteBuffer(PyObject *obj, + void **buffer, + Py_ssize_t *buffer_len); + + /* + Takes an arbitrary object which must support the (writable, + single segment) buffer interface and returns a pointer to a + writable memory location in buffer of size buffer_len. + + 0 is returned on success. buffer and buffer_len are only + set in case no error occurs. Otherwise, -1 is returned and + an exception set. + */ + + /* new buffer API */ + +#ifndef Py_LIMITED_API +#define PyObject_CheckBuffer(obj) \ + (((obj)->ob_type->tp_as_buffer != NULL) && \ + ((obj)->ob_type->tp_as_buffer->bf_getbuffer != NULL)) + + /* Return 1 if the getbuffer function is available, otherwise + return 0 */ + + PyAPI_FUNC(int) PyObject_GetBuffer(PyObject *obj, Py_buffer *view, + int flags); + + /* This is a C-API version of the getbuffer function call. It checks + to make sure object has the required function pointer and issues the + call. Returns -1 and raises an error on failure and returns 0 on + success + */ + + + PyAPI_FUNC(void *) PyBuffer_GetPointer(Py_buffer *view, Py_ssize_t *indices); + + /* Get the memory area pointed to by the indices for the buffer given. + Note that view->ndim is the assumed size of indices + */ + + PyAPI_FUNC(int) PyBuffer_SizeFromFormat(const char *); + + /* Return the implied itemsize of the data-format area from a + struct-style description */ + + + + /* Implementation in memoryobject.c */ + PyAPI_FUNC(int) PyBuffer_ToContiguous(void *buf, Py_buffer *view, + Py_ssize_t len, char order); + + PyAPI_FUNC(int) PyBuffer_FromContiguous(Py_buffer *view, void *buf, + Py_ssize_t len, char order); + + + /* Copy len bytes of data from the contiguous chunk of memory + pointed to by buf into the buffer exported by obj. Return + 0 on success and return -1 and raise a PyBuffer_Error on + error (i.e. the object does not have a buffer interface or + it is not working). + + If fort is 'F', then if the object is multi-dimensional, + then the data will be copied into the array in + Fortran-style (first dimension varies the fastest). If + fort is 'C', then the data will be copied into the array + in C-style (last dimension varies the fastest). If fort + is 'A', then it does not matter and the copy will be made + in whatever way is more efficient. + + */ + + PyAPI_FUNC(int) PyObject_CopyData(PyObject *dest, PyObject *src); + + /* Copy the data from the src buffer to the buffer of destination + */ + + PyAPI_FUNC(int) PyBuffer_IsContiguous(const Py_buffer *view, char fort); + + + PyAPI_FUNC(void) PyBuffer_FillContiguousStrides(int ndims, + Py_ssize_t *shape, + Py_ssize_t *strides, + int itemsize, + char fort); + + /* Fill the strides array with byte-strides of a contiguous + (Fortran-style if fort is 'F' or C-style otherwise) + array of the given shape with the given number of bytes + per element. + */ + + PyAPI_FUNC(int) PyBuffer_FillInfo(Py_buffer *view, PyObject *o, void *buf, + Py_ssize_t len, int readonly, + int flags); + + /* Fills in a buffer-info structure correctly for an exporter + that can only share a contiguous chunk of memory of + "unsigned bytes" of the given length. Returns 0 on success + and -1 (with raising an error) on error. + */ + + PyAPI_FUNC(void) PyBuffer_Release(Py_buffer *view); + + /* Releases a Py_buffer obtained from getbuffer ParseTuple's s*. + */ +#endif /* Py_LIMITED_API */ + + PyAPI_FUNC(PyObject *) PyObject_Format(PyObject* obj, + PyObject *format_spec); + /* + Takes an arbitrary object and returns the result of + calling obj.__format__(format_spec). + */ + +/* Iterators */ + + PyAPI_FUNC(PyObject *) PyObject_GetIter(PyObject *); + /* Takes an object and returns an iterator for it. + This is typically a new iterator but if the argument + is an iterator, this returns itself. */ + +#define PyIter_Check(obj) \ + ((obj)->ob_type->tp_iternext != NULL && \ + (obj)->ob_type->tp_iternext != &_PyObject_NextNotImplemented) + + PyAPI_FUNC(PyObject *) PyIter_Next(PyObject *); + /* Takes an iterator object and calls its tp_iternext slot, + returning the next value. If the iterator is exhausted, + this returns NULL without setting an exception. + NULL with an exception means an error occurred. */ + +/* Number Protocol:*/ + + PyAPI_FUNC(int) PyNumber_Check(PyObject *o); + + /* + Returns 1 if the object, o, provides numeric protocols, and + false otherwise. + + This function always succeeds. + */ + + PyAPI_FUNC(PyObject *) PyNumber_Add(PyObject *o1, PyObject *o2); + + /* + Returns the result of adding o1 and o2, or null on failure. + This is the equivalent of the Python expression: o1+o2. + */ + + PyAPI_FUNC(PyObject *) PyNumber_Subtract(PyObject *o1, PyObject *o2); + + /* + Returns the result of subtracting o2 from o1, or null on + failure. This is the equivalent of the Python expression: + o1-o2. + */ + + PyAPI_FUNC(PyObject *) PyNumber_Multiply(PyObject *o1, PyObject *o2); + + /* + Returns the result of multiplying o1 and o2, or null on + failure. This is the equivalent of the Python expression: + o1*o2. + */ + + PyAPI_FUNC(PyObject *) PyNumber_MatrixMultiply(PyObject *o1, PyObject *o2); + + /* + This is the equivalent of the Python expression: o1 @ o2. + */ + + PyAPI_FUNC(PyObject *) PyNumber_FloorDivide(PyObject *o1, PyObject *o2); + + /* + Returns the result of dividing o1 by o2 giving an integral result, + or null on failure. + This is the equivalent of the Python expression: o1//o2. + */ + + PyAPI_FUNC(PyObject *) PyNumber_TrueDivide(PyObject *o1, PyObject *o2); + + /* + Returns the result of dividing o1 by o2 giving a float result, + or null on failure. + This is the equivalent of the Python expression: o1/o2. + */ + + PyAPI_FUNC(PyObject *) PyNumber_Remainder(PyObject *o1, PyObject *o2); + + /* + Returns the remainder of dividing o1 by o2, or null on + failure. This is the equivalent of the Python expression: + o1%o2. + */ + + PyAPI_FUNC(PyObject *) PyNumber_Divmod(PyObject *o1, PyObject *o2); + + /* + See the built-in function divmod. Returns NULL on failure. + This is the equivalent of the Python expression: + divmod(o1,o2). + */ + + PyAPI_FUNC(PyObject *) PyNumber_Power(PyObject *o1, PyObject *o2, + PyObject *o3); + + /* + See the built-in function pow. Returns NULL on failure. + This is the equivalent of the Python expression: + pow(o1,o2,o3), where o3 is optional. + */ + + PyAPI_FUNC(PyObject *) PyNumber_Negative(PyObject *o); + + /* + Returns the negation of o on success, or null on failure. + This is the equivalent of the Python expression: -o. + */ + + PyAPI_FUNC(PyObject *) PyNumber_Positive(PyObject *o); + + /* + Returns the (what?) of o on success, or NULL on failure. + This is the equivalent of the Python expression: +o. + */ + + PyAPI_FUNC(PyObject *) PyNumber_Absolute(PyObject *o); + + /* + Returns the absolute value of o, or null on failure. This is + the equivalent of the Python expression: abs(o). + */ + + PyAPI_FUNC(PyObject *) PyNumber_Invert(PyObject *o); + + /* + Returns the bitwise negation of o on success, or NULL on + failure. This is the equivalent of the Python expression: + ~o. + */ + + PyAPI_FUNC(PyObject *) PyNumber_Lshift(PyObject *o1, PyObject *o2); + + /* + Returns the result of left shifting o1 by o2 on success, or + NULL on failure. This is the equivalent of the Python + expression: o1 << o2. + */ + + PyAPI_FUNC(PyObject *) PyNumber_Rshift(PyObject *o1, PyObject *o2); + + /* + Returns the result of right shifting o1 by o2 on success, or + NULL on failure. This is the equivalent of the Python + expression: o1 >> o2. + */ + + PyAPI_FUNC(PyObject *) PyNumber_And(PyObject *o1, PyObject *o2); + + /* + Returns the result of bitwise and of o1 and o2 on success, or + NULL on failure. This is the equivalent of the Python + expression: o1&o2. + + */ + + PyAPI_FUNC(PyObject *) PyNumber_Xor(PyObject *o1, PyObject *o2); + + /* + Returns the bitwise exclusive or of o1 by o2 on success, or + NULL on failure. This is the equivalent of the Python + expression: o1^o2. + */ + + PyAPI_FUNC(PyObject *) PyNumber_Or(PyObject *o1, PyObject *o2); + + /* + Returns the result of bitwise or on o1 and o2 on success, or + NULL on failure. This is the equivalent of the Python + expression: o1|o2. + */ + +#define PyIndex_Check(obj) \ + ((obj)->ob_type->tp_as_number != NULL && \ + (obj)->ob_type->tp_as_number->nb_index != NULL) + + PyAPI_FUNC(PyObject *) PyNumber_Index(PyObject *o); + + /* + Returns the object converted to a Python int + or NULL with an error raised on failure. + */ + + PyAPI_FUNC(Py_ssize_t) PyNumber_AsSsize_t(PyObject *o, PyObject *exc); + + /* + Returns the object converted to Py_ssize_t by going through + PyNumber_Index first. If an overflow error occurs while + converting the int to Py_ssize_t, then the second argument + is the error-type to return. If it is NULL, then the overflow error + is cleared and the value is clipped. + */ + + PyAPI_FUNC(PyObject *) PyNumber_Long(PyObject *o); + + /* + Returns the o converted to an integer object on success, or + NULL on failure. This is the equivalent of the Python + expression: int(o). + */ + + PyAPI_FUNC(PyObject *) PyNumber_Float(PyObject *o); + + /* + Returns the o converted to a float object on success, or NULL + on failure. This is the equivalent of the Python expression: + float(o). + */ + +/* In-place variants of (some of) the above number protocol functions */ + + PyAPI_FUNC(PyObject *) PyNumber_InPlaceAdd(PyObject *o1, PyObject *o2); + + /* + Returns the result of adding o2 to o1, possibly in-place, or null + on failure. This is the equivalent of the Python expression: + o1 += o2. + */ + + PyAPI_FUNC(PyObject *) PyNumber_InPlaceSubtract(PyObject *o1, PyObject *o2); + + /* + Returns the result of subtracting o2 from o1, possibly in-place or + null on failure. This is the equivalent of the Python expression: + o1 -= o2. + */ + + PyAPI_FUNC(PyObject *) PyNumber_InPlaceMultiply(PyObject *o1, PyObject *o2); + + /* + Returns the result of multiplying o1 by o2, possibly in-place, or + null on failure. This is the equivalent of the Python expression: + o1 *= o2. + */ + + PyAPI_FUNC(PyObject *) PyNumber_InPlaceMatrixMultiply(PyObject *o1, PyObject *o2); + + /* + This is the equivalent of the Python expression: o1 @= o2. + */ + + PyAPI_FUNC(PyObject *) PyNumber_InPlaceFloorDivide(PyObject *o1, + PyObject *o2); + + /* + Returns the result of dividing o1 by o2 giving an integral result, + possibly in-place, or null on failure. + This is the equivalent of the Python expression: + o1 /= o2. + */ + + PyAPI_FUNC(PyObject *) PyNumber_InPlaceTrueDivide(PyObject *o1, + PyObject *o2); + + /* + Returns the result of dividing o1 by o2 giving a float result, + possibly in-place, or null on failure. + This is the equivalent of the Python expression: + o1 /= o2. + */ + + PyAPI_FUNC(PyObject *) PyNumber_InPlaceRemainder(PyObject *o1, PyObject *o2); + + /* + Returns the remainder of dividing o1 by o2, possibly in-place, or + null on failure. This is the equivalent of the Python expression: + o1 %= o2. + */ + + PyAPI_FUNC(PyObject *) PyNumber_InPlacePower(PyObject *o1, PyObject *o2, + PyObject *o3); + + /* + Returns the result of raising o1 to the power of o2, possibly + in-place, or null on failure. This is the equivalent of the Python + expression: o1 **= o2, or pow(o1, o2, o3) if o3 is present. + */ + + PyAPI_FUNC(PyObject *) PyNumber_InPlaceLshift(PyObject *o1, PyObject *o2); + + /* + Returns the result of left shifting o1 by o2, possibly in-place, or + null on failure. This is the equivalent of the Python expression: + o1 <<= o2. + */ + + PyAPI_FUNC(PyObject *) PyNumber_InPlaceRshift(PyObject *o1, PyObject *o2); + + /* + Returns the result of right shifting o1 by o2, possibly in-place or + null on failure. This is the equivalent of the Python expression: + o1 >>= o2. + */ + + PyAPI_FUNC(PyObject *) PyNumber_InPlaceAnd(PyObject *o1, PyObject *o2); + + /* + Returns the result of bitwise and of o1 and o2, possibly in-place, + or null on failure. This is the equivalent of the Python + expression: o1 &= o2. + */ + + PyAPI_FUNC(PyObject *) PyNumber_InPlaceXor(PyObject *o1, PyObject *o2); + + /* + Returns the bitwise exclusive or of o1 by o2, possibly in-place, or + null on failure. This is the equivalent of the Python expression: + o1 ^= o2. + */ + + PyAPI_FUNC(PyObject *) PyNumber_InPlaceOr(PyObject *o1, PyObject *o2); + + /* + Returns the result of bitwise or of o1 and o2, possibly in-place, + or null on failure. This is the equivalent of the Python + expression: o1 |= o2. + */ + + PyAPI_FUNC(PyObject *) PyNumber_ToBase(PyObject *n, int base); + + /* + Returns the integer n converted to a string with a base, with a base + marker of 0b, 0o or 0x prefixed if applicable. + If n is not an int object, it is converted with PyNumber_Index first. + */ + + +/* Sequence protocol:*/ + + PyAPI_FUNC(int) PySequence_Check(PyObject *o); + + /* + Return 1 if the object provides sequence protocol, and zero + otherwise. + + This function always succeeds. + */ + + PyAPI_FUNC(Py_ssize_t) PySequence_Size(PyObject *o); + + /* + Return the size of sequence object o, or -1 on failure. + */ + + /* For DLL compatibility */ +#undef PySequence_Length + PyAPI_FUNC(Py_ssize_t) PySequence_Length(PyObject *o); +#define PySequence_Length PySequence_Size + + + PyAPI_FUNC(PyObject *) PySequence_Concat(PyObject *o1, PyObject *o2); + + /* + Return the concatenation of o1 and o2 on success, and NULL on + failure. This is the equivalent of the Python + expression: o1+o2. + */ + + PyAPI_FUNC(PyObject *) PySequence_Repeat(PyObject *o, Py_ssize_t count); + + /* + Return the result of repeating sequence object o count times, + or NULL on failure. This is the equivalent of the Python + expression: o1*count. + */ + + PyAPI_FUNC(PyObject *) PySequence_GetItem(PyObject *o, Py_ssize_t i); + + /* + Return the ith element of o, or NULL on failure. This is the + equivalent of the Python expression: o[i]. + */ + + PyAPI_FUNC(PyObject *) PySequence_GetSlice(PyObject *o, Py_ssize_t i1, Py_ssize_t i2); + + /* + Return the slice of sequence object o between i1 and i2, or + NULL on failure. This is the equivalent of the Python + expression: o[i1:i2]. + */ + + PyAPI_FUNC(int) PySequence_SetItem(PyObject *o, Py_ssize_t i, PyObject *v); + + /* + Assign object v to the ith element of o. Returns + -1 on failure. This is the equivalent of the Python + statement: o[i]=v. + */ + + PyAPI_FUNC(int) PySequence_DelItem(PyObject *o, Py_ssize_t i); + + /* + Delete the ith element of object v. Returns + -1 on failure. This is the equivalent of the Python + statement: del o[i]. + */ + + PyAPI_FUNC(int) PySequence_SetSlice(PyObject *o, Py_ssize_t i1, Py_ssize_t i2, + PyObject *v); + + /* + Assign the sequence object, v, to the slice in sequence + object, o, from i1 to i2. Returns -1 on failure. This is the + equivalent of the Python statement: o[i1:i2]=v. + */ + + PyAPI_FUNC(int) PySequence_DelSlice(PyObject *o, Py_ssize_t i1, Py_ssize_t i2); + + /* + Delete the slice in sequence object, o, from i1 to i2. + Returns -1 on failure. This is the equivalent of the Python + statement: del o[i1:i2]. + */ + + PyAPI_FUNC(PyObject *) PySequence_Tuple(PyObject *o); + + /* + Returns the sequence, o, as a tuple on success, and NULL on failure. + This is equivalent to the Python expression: tuple(o) + */ + + + PyAPI_FUNC(PyObject *) PySequence_List(PyObject *o); + /* + Returns the sequence, o, as a list on success, and NULL on failure. + This is equivalent to the Python expression: list(o) + */ + + PyAPI_FUNC(PyObject *) PySequence_Fast(PyObject *o, const char* m); + /* + Return the sequence, o, as a list, unless it's already a + tuple or list. Use PySequence_Fast_GET_ITEM to access the + members of this list, and PySequence_Fast_GET_SIZE to get its length. + + Returns NULL on failure. If the object does not support iteration, + raises a TypeError exception with m as the message text. + */ + +#define PySequence_Fast_GET_SIZE(o) \ + (PyList_Check(o) ? PyList_GET_SIZE(o) : PyTuple_GET_SIZE(o)) + /* + Return the size of o, assuming that o was returned by + PySequence_Fast and is not NULL. + */ + +#define PySequence_Fast_GET_ITEM(o, i)\ + (PyList_Check(o) ? PyList_GET_ITEM(o, i) : PyTuple_GET_ITEM(o, i)) + /* + Return the ith element of o, assuming that o was returned by + PySequence_Fast, and that i is within bounds. + */ + +#define PySequence_ITEM(o, i)\ + ( Py_TYPE(o)->tp_as_sequence->sq_item(o, i) ) + /* Assume tp_as_sequence and sq_item exist and that i does not + need to be corrected for a negative index + */ + +#define PySequence_Fast_ITEMS(sf) \ + (PyList_Check(sf) ? ((PyListObject *)(sf))->ob_item \ + : ((PyTupleObject *)(sf))->ob_item) + /* Return a pointer to the underlying item array for + an object retured by PySequence_Fast */ + + PyAPI_FUNC(Py_ssize_t) PySequence_Count(PyObject *o, PyObject *value); + + /* + Return the number of occurrences on value on o, that is, + return the number of keys for which o[key]==value. On + failure, return -1. This is equivalent to the Python + expression: o.count(value). + */ + + PyAPI_FUNC(int) PySequence_Contains(PyObject *seq, PyObject *ob); + /* + Return -1 if error; 1 if ob in seq; 0 if ob not in seq. + Use __contains__ if possible, else _PySequence_IterSearch(). + */ + +#ifndef Py_LIMITED_API +#define PY_ITERSEARCH_COUNT 1 +#define PY_ITERSEARCH_INDEX 2 +#define PY_ITERSEARCH_CONTAINS 3 + PyAPI_FUNC(Py_ssize_t) _PySequence_IterSearch(PyObject *seq, + PyObject *obj, int operation); +#endif + /* + Iterate over seq. Result depends on the operation: + PY_ITERSEARCH_COUNT: return # of times obj appears in seq; -1 if + error. + PY_ITERSEARCH_INDEX: return 0-based index of first occurrence of + obj in seq; set ValueError and return -1 if none found; + also return -1 on error. + PY_ITERSEARCH_CONTAINS: return 1 if obj in seq, else 0; -1 on + error. + */ + +/* For DLL-level backwards compatibility */ +#undef PySequence_In + PyAPI_FUNC(int) PySequence_In(PyObject *o, PyObject *value); + +/* For source-level backwards compatibility */ +#define PySequence_In PySequence_Contains + + /* + Determine if o contains value. If an item in o is equal to + X, return 1, otherwise return 0. On error, return -1. This + is equivalent to the Python expression: value in o. + */ + + PyAPI_FUNC(Py_ssize_t) PySequence_Index(PyObject *o, PyObject *value); + + /* + Return the first index for which o[i]=value. On error, + return -1. This is equivalent to the Python + expression: o.index(value). + */ + +/* In-place versions of some of the above Sequence functions. */ + + PyAPI_FUNC(PyObject *) PySequence_InPlaceConcat(PyObject *o1, PyObject *o2); + + /* + Append o2 to o1, in-place when possible. Return the resulting + object, which could be o1, or NULL on failure. This is the + equivalent of the Python expression: o1 += o2. + + */ + + PyAPI_FUNC(PyObject *) PySequence_InPlaceRepeat(PyObject *o, Py_ssize_t count); + + /* + Repeat o1 by count, in-place when possible. Return the resulting + object, which could be o1, or NULL on failure. This is the + equivalent of the Python expression: o1 *= count. + + */ + +/* Mapping protocol:*/ + + PyAPI_FUNC(int) PyMapping_Check(PyObject *o); + + /* + Return 1 if the object provides mapping protocol, and zero + otherwise. + + This function always succeeds. + */ + + PyAPI_FUNC(Py_ssize_t) PyMapping_Size(PyObject *o); + + /* + Returns the number of keys in object o on success, and -1 on + failure. For objects that do not provide sequence protocol, + this is equivalent to the Python expression: len(o). + */ + + /* For DLL compatibility */ +#undef PyMapping_Length + PyAPI_FUNC(Py_ssize_t) PyMapping_Length(PyObject *o); +#define PyMapping_Length PyMapping_Size + + + /* implemented as a macro: + + int PyMapping_DelItemString(PyObject *o, const char *key); + + Remove the mapping for object, key, from the object *o. + Returns -1 on failure. This is equivalent to + the Python statement: del o[key]. + */ +#define PyMapping_DelItemString(O,K) PyObject_DelItemString((O),(K)) + + /* implemented as a macro: + + int PyMapping_DelItem(PyObject *o, PyObject *key); + + Remove the mapping for object, key, from the object *o. + Returns -1 on failure. This is equivalent to + the Python statement: del o[key]. + */ +#define PyMapping_DelItem(O,K) PyObject_DelItem((O),(K)) + + PyAPI_FUNC(int) PyMapping_HasKeyString(PyObject *o, const char *key); + + /* + On success, return 1 if the mapping object has the key, key, + and 0 otherwise. This is equivalent to the Python expression: + key in o. + + This function always succeeds. + */ + + PyAPI_FUNC(int) PyMapping_HasKey(PyObject *o, PyObject *key); + + /* + Return 1 if the mapping object has the key, key, + and 0 otherwise. This is equivalent to the Python expression: + key in o. + + This function always succeeds. + + */ + + PyAPI_FUNC(PyObject *) PyMapping_Keys(PyObject *o); + + /* + On success, return a list or tuple of the keys in object o. + On failure, return NULL. + */ + + PyAPI_FUNC(PyObject *) PyMapping_Values(PyObject *o); + + /* + On success, return a list or tuple of the values in object o. + On failure, return NULL. + */ + + PyAPI_FUNC(PyObject *) PyMapping_Items(PyObject *o); + + /* + On success, return a list or tuple of the items in object o, + where each item is a tuple containing a key-value pair. + On failure, return NULL. + + */ + + PyAPI_FUNC(PyObject *) PyMapping_GetItemString(PyObject *o, + const char *key); + + /* + Return element of o corresponding to the object, key, or NULL + on failure. This is the equivalent of the Python expression: + o[key]. + */ + + PyAPI_FUNC(int) PyMapping_SetItemString(PyObject *o, const char *key, + PyObject *value); + + /* + Map the object, key, to the value, v. Returns + -1 on failure. This is the equivalent of the Python + statement: o[key]=v. + */ + + +PyAPI_FUNC(int) PyObject_IsInstance(PyObject *object, PyObject *typeorclass); + /* isinstance(object, typeorclass) */ + +PyAPI_FUNC(int) PyObject_IsSubclass(PyObject *object, PyObject *typeorclass); + /* issubclass(object, typeorclass) */ + + +#ifndef Py_LIMITED_API +PyAPI_FUNC(int) _PyObject_RealIsInstance(PyObject *inst, PyObject *cls); + +PyAPI_FUNC(int) _PyObject_RealIsSubclass(PyObject *derived, PyObject *cls); + +PyAPI_FUNC(char *const *) _PySequence_BytesToCharpArray(PyObject* self); + +PyAPI_FUNC(void) _Py_FreeCharPArray(char *const array[]); +#endif + +/* For internal use by buffer API functions */ +PyAPI_FUNC(void) _Py_add_one_to_index_F(int nd, Py_ssize_t *index, + const Py_ssize_t *shape); +PyAPI_FUNC(void) _Py_add_one_to_index_C(int nd, Py_ssize_t *index, + const Py_ssize_t *shape); + + +#ifdef __cplusplus +} +#endif +#endif /* Py_ABSTRACTOBJECT_H */ diff --git a/android/python35/include/accu.h b/android/python35/include/accu.h new file mode 100644 index 000000000..3636ea6c9 --- /dev/null +++ b/android/python35/include/accu.h @@ -0,0 +1,37 @@ +#ifndef Py_LIMITED_API +#ifndef Py_ACCU_H +#define Py_ACCU_H + +/*** This is a private API for use by the interpreter and the stdlib. + *** Its definition may be changed or removed at any moment. + ***/ + +/* + * A two-level accumulator of unicode objects that avoids both the overhead + * of keeping a huge number of small separate objects, and the quadratic + * behaviour of using a naive repeated concatenation scheme. + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#undef small /* defined by some Windows headers */ + +typedef struct { + PyObject *large; /* A list of previously accumulated large strings */ + PyObject *small; /* Pending small strings */ +} _PyAccu; + +PyAPI_FUNC(int) _PyAccu_Init(_PyAccu *acc); +PyAPI_FUNC(int) _PyAccu_Accumulate(_PyAccu *acc, PyObject *unicode); +PyAPI_FUNC(PyObject *) _PyAccu_FinishAsList(_PyAccu *acc); +PyAPI_FUNC(PyObject *) _PyAccu_Finish(_PyAccu *acc); +PyAPI_FUNC(void) _PyAccu_Destroy(_PyAccu *acc); + +#ifdef __cplusplus +} +#endif + +#endif /* Py_ACCU_H */ +#endif /* Py_LIMITED_API */ diff --git a/android/python35/include/asdl.h b/android/python35/include/asdl.h new file mode 100644 index 000000000..495153c57 --- /dev/null +++ b/android/python35/include/asdl.h @@ -0,0 +1,45 @@ +#ifndef Py_ASDL_H +#define Py_ASDL_H + +typedef PyObject * identifier; +typedef PyObject * string; +typedef PyObject * bytes; +typedef PyObject * object; +typedef PyObject * singleton; + +/* It would be nice if the code generated by asdl_c.py was completely + independent of Python, but it is a goal the requires too much work + at this stage. So, for example, I'll represent identifiers as + interned Python strings. +*/ + +/* XXX A sequence should be typed so that its use can be typechecked. */ + +typedef struct { + Py_ssize_t size; + void *elements[1]; +} asdl_seq; + +typedef struct { + Py_ssize_t size; + int elements[1]; +} asdl_int_seq; + +asdl_seq *_Py_asdl_seq_new(Py_ssize_t size, PyArena *arena); +asdl_int_seq *_Py_asdl_int_seq_new(Py_ssize_t size, PyArena *arena); + +#define asdl_seq_GET(S, I) (S)->elements[(I)] +#define asdl_seq_LEN(S) ((S) == NULL ? 0 : (S)->size) +#ifdef Py_DEBUG +#define asdl_seq_SET(S, I, V) \ + do { \ + Py_ssize_t _asdl_i = (I); \ + assert((S) != NULL); \ + assert(_asdl_i < (S)->size); \ + (S)->elements[_asdl_i] = (V); \ + } while (0) +#else +#define asdl_seq_SET(S, I, V) (S)->elements[I] = (V) +#endif + +#endif /* !Py_ASDL_H */ diff --git a/android/python35/include/ast.h b/android/python35/include/ast.h new file mode 100644 index 000000000..6a8c8165c --- /dev/null +++ b/android/python35/include/ast.h @@ -0,0 +1,22 @@ +#ifndef Py_AST_H +#define Py_AST_H +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_FUNC(int) PyAST_Validate(mod_ty); +PyAPI_FUNC(mod_ty) PyAST_FromNode( + const node *n, + PyCompilerFlags *flags, + const char *filename, /* decoded from the filesystem encoding */ + PyArena *arena); +PyAPI_FUNC(mod_ty) PyAST_FromNodeObject( + const node *n, + PyCompilerFlags *flags, + PyObject *filename, + PyArena *arena); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_AST_H */ diff --git a/android/python35/include/bitset.h b/android/python35/include/bitset.h new file mode 100644 index 000000000..faeb41913 --- /dev/null +++ b/android/python35/include/bitset.h @@ -0,0 +1,32 @@ + +#ifndef Py_BITSET_H +#define Py_BITSET_H +#ifdef __cplusplus +extern "C" { +#endif + +/* Bitset interface */ + +#define BYTE char + +typedef BYTE *bitset; + +bitset newbitset(int nbits); +void delbitset(bitset bs); +#define testbit(ss, ibit) (((ss)[BIT2BYTE(ibit)] & BIT2MASK(ibit)) != 0) +int addbit(bitset bs, int ibit); /* Returns 0 if already set */ +int samebitset(bitset bs1, bitset bs2, int nbits); +void mergebitset(bitset bs1, bitset bs2, int nbits); + +#define BITSPERBYTE (8*sizeof(BYTE)) +#define NBYTES(nbits) (((nbits) + BITSPERBYTE - 1) / BITSPERBYTE) + +#define BIT2BYTE(ibit) ((ibit) / BITSPERBYTE) +#define BIT2SHIFT(ibit) ((ibit) % BITSPERBYTE) +#define BIT2MASK(ibit) (1 << BIT2SHIFT(ibit)) +#define BYTE2BIT(ibyte) ((ibyte) * BITSPERBYTE) + +#ifdef __cplusplus +} +#endif +#endif /* !Py_BITSET_H */ diff --git a/android/python35/include/bltinmodule.h b/android/python35/include/bltinmodule.h new file mode 100644 index 000000000..868c9e644 --- /dev/null +++ b/android/python35/include/bltinmodule.h @@ -0,0 +1,14 @@ +#ifndef Py_BLTINMODULE_H +#define Py_BLTINMODULE_H +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_DATA(PyTypeObject) PyFilter_Type; +PyAPI_DATA(PyTypeObject) PyMap_Type; +PyAPI_DATA(PyTypeObject) PyZip_Type; + +#ifdef __cplusplus +} +#endif +#endif /* !Py_BLTINMODULE_H */ diff --git a/android/python35/include/boolobject.h b/android/python35/include/boolobject.h new file mode 100644 index 000000000..7cc2f1fe2 --- /dev/null +++ b/android/python35/include/boolobject.h @@ -0,0 +1,34 @@ +/* Boolean object interface */ + +#ifndef Py_BOOLOBJECT_H +#define Py_BOOLOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + + +PyAPI_DATA(PyTypeObject) PyBool_Type; + +#define PyBool_Check(x) (Py_TYPE(x) == &PyBool_Type) + +/* Py_False and Py_True are the only two bools in existence. +Don't forget to apply Py_INCREF() when returning either!!! */ + +/* Don't use these directly */ +PyAPI_DATA(struct _longobject) _Py_FalseStruct, _Py_TrueStruct; + +/* Use these macros */ +#define Py_False ((PyObject *) &_Py_FalseStruct) +#define Py_True ((PyObject *) &_Py_TrueStruct) + +/* Macros for returning Py_True or Py_False, respectively */ +#define Py_RETURN_TRUE return Py_INCREF(Py_True), Py_True +#define Py_RETURN_FALSE return Py_INCREF(Py_False), Py_False + +/* Function to return a bool from a C long */ +PyAPI_FUNC(PyObject *) PyBool_FromLong(long); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_BOOLOBJECT_H */ diff --git a/android/python35/include/bytearrayobject.h b/android/python35/include/bytearrayobject.h new file mode 100644 index 000000000..a757b8805 --- /dev/null +++ b/android/python35/include/bytearrayobject.h @@ -0,0 +1,62 @@ +/* ByteArray object interface */ + +#ifndef Py_BYTEARRAYOBJECT_H +#define Py_BYTEARRAYOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/* Type PyByteArrayObject represents a mutable array of bytes. + * The Python API is that of a sequence; + * the bytes are mapped to ints in [0, 256). + * Bytes are not characters; they may be used to encode characters. + * The only way to go between bytes and str/unicode is via encoding + * and decoding. + * For the convenience of C programmers, the bytes type is considered + * to contain a char pointer, not an unsigned char pointer. + */ + +/* Object layout */ +#ifndef Py_LIMITED_API +typedef struct { + PyObject_VAR_HEAD + Py_ssize_t ob_alloc; /* How many bytes allocated in ob_bytes */ + char *ob_bytes; /* Physical backing buffer */ + char *ob_start; /* Logical start inside ob_bytes */ + /* XXX(nnorwitz): should ob_exports be Py_ssize_t? */ + int ob_exports; /* How many buffer exports */ +} PyByteArrayObject; +#endif + +/* Type object */ +PyAPI_DATA(PyTypeObject) PyByteArray_Type; +PyAPI_DATA(PyTypeObject) PyByteArrayIter_Type; + +/* Type check macros */ +#define PyByteArray_Check(self) PyObject_TypeCheck(self, &PyByteArray_Type) +#define PyByteArray_CheckExact(self) (Py_TYPE(self) == &PyByteArray_Type) + +/* Direct API functions */ +PyAPI_FUNC(PyObject *) PyByteArray_FromObject(PyObject *); +PyAPI_FUNC(PyObject *) PyByteArray_Concat(PyObject *, PyObject *); +PyAPI_FUNC(PyObject *) PyByteArray_FromStringAndSize(const char *, Py_ssize_t); +PyAPI_FUNC(Py_ssize_t) PyByteArray_Size(PyObject *); +PyAPI_FUNC(char *) PyByteArray_AsString(PyObject *); +PyAPI_FUNC(int) PyByteArray_Resize(PyObject *, Py_ssize_t); + +/* Macros, trading safety for speed */ +#ifndef Py_LIMITED_API +#define PyByteArray_AS_STRING(self) \ + (assert(PyByteArray_Check(self)), \ + Py_SIZE(self) ? ((PyByteArrayObject *)(self))->ob_start : _PyByteArray_empty_string) +#define PyByteArray_GET_SIZE(self) (assert(PyByteArray_Check(self)), Py_SIZE(self)) + +PyAPI_DATA(char) _PyByteArray_empty_string[]; +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_BYTEARRAYOBJECT_H */ diff --git a/android/python35/include/bytes_methods.h b/android/python35/include/bytes_methods.h new file mode 100644 index 000000000..11d5f4275 --- /dev/null +++ b/android/python35/include/bytes_methods.h @@ -0,0 +1,46 @@ +#ifndef Py_LIMITED_API +#ifndef Py_BYTES_CTYPE_H +#define Py_BYTES_CTYPE_H + +/* + * The internal implementation behind PyBytes (bytes) and PyByteArray (bytearray) + * methods of the given names, they operate on ASCII byte strings. + */ +extern PyObject* _Py_bytes_isspace(const char *cptr, Py_ssize_t len); +extern PyObject* _Py_bytes_isalpha(const char *cptr, Py_ssize_t len); +extern PyObject* _Py_bytes_isalnum(const char *cptr, Py_ssize_t len); +extern PyObject* _Py_bytes_isdigit(const char *cptr, Py_ssize_t len); +extern PyObject* _Py_bytes_islower(const char *cptr, Py_ssize_t len); +extern PyObject* _Py_bytes_isupper(const char *cptr, Py_ssize_t len); +extern PyObject* _Py_bytes_istitle(const char *cptr, Py_ssize_t len); + +/* These store their len sized answer in the given preallocated *result arg. */ +extern void _Py_bytes_lower(char *result, const char *cptr, Py_ssize_t len); +extern void _Py_bytes_upper(char *result, const char *cptr, Py_ssize_t len); +extern void _Py_bytes_title(char *result, char *s, Py_ssize_t len); +extern void _Py_bytes_capitalize(char *result, char *s, Py_ssize_t len); +extern void _Py_bytes_swapcase(char *result, char *s, Py_ssize_t len); + +/* The maketrans() static method. */ +extern PyObject* _Py_bytes_maketrans(Py_buffer *frm, Py_buffer *to); + +/* Shared __doc__ strings. */ +extern const char _Py_isspace__doc__[]; +extern const char _Py_isalpha__doc__[]; +extern const char _Py_isalnum__doc__[]; +extern const char _Py_isdigit__doc__[]; +extern const char _Py_islower__doc__[]; +extern const char _Py_isupper__doc__[]; +extern const char _Py_istitle__doc__[]; +extern const char _Py_lower__doc__[]; +extern const char _Py_upper__doc__[]; +extern const char _Py_title__doc__[]; +extern const char _Py_capitalize__doc__[]; +extern const char _Py_swapcase__doc__[]; +extern const char _Py_maketrans__doc__[]; + +/* this is needed because some docs are shared from the .o, not static */ +#define PyDoc_STRVAR_shared(name,str) const char name[] = PyDoc_STR(str) + +#endif /* !Py_BYTES_CTYPE_H */ +#endif /* !Py_LIMITED_API */ diff --git a/android/python35/include/bytesobject.h b/android/python35/include/bytesobject.h new file mode 100644 index 000000000..e379bace3 --- /dev/null +++ b/android/python35/include/bytesobject.h @@ -0,0 +1,129 @@ + +/* Bytes (String) object interface */ + +#ifndef Py_BYTESOBJECT_H +#define Py_BYTESOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/* +Type PyBytesObject represents a character string. An extra zero byte is +reserved at the end to ensure it is zero-terminated, but a size is +present so strings with null bytes in them can be represented. This +is an immutable object type. + +There are functions to create new string objects, to test +an object for string-ness, and to get the +string value. The latter function returns a null pointer +if the object is not of the proper type. +There is a variant that takes an explicit size as well as a +variant that assumes a zero-terminated string. Note that none of the +functions should be applied to nil objects. +*/ + +/* Caching the hash (ob_shash) saves recalculation of a string's hash value. + This significantly speeds up dict lookups. */ + +#ifndef Py_LIMITED_API +typedef struct { + PyObject_VAR_HEAD + Py_hash_t ob_shash; + char ob_sval[1]; + + /* Invariants: + * ob_sval contains space for 'ob_size+1' elements. + * ob_sval[ob_size] == 0. + * ob_shash is the hash of the string or -1 if not computed yet. + */ +} PyBytesObject; +#endif + +PyAPI_DATA(PyTypeObject) PyBytes_Type; +PyAPI_DATA(PyTypeObject) PyBytesIter_Type; + +#define PyBytes_Check(op) \ + PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_BYTES_SUBCLASS) +#define PyBytes_CheckExact(op) (Py_TYPE(op) == &PyBytes_Type) + +PyAPI_FUNC(PyObject *) PyBytes_FromStringAndSize(const char *, Py_ssize_t); +PyAPI_FUNC(PyObject *) PyBytes_FromString(const char *); +PyAPI_FUNC(PyObject *) PyBytes_FromObject(PyObject *); +PyAPI_FUNC(PyObject *) PyBytes_FromFormatV(const char*, va_list) + Py_GCC_ATTRIBUTE((format(printf, 1, 0))); +PyAPI_FUNC(PyObject *) PyBytes_FromFormat(const char*, ...) + Py_GCC_ATTRIBUTE((format(printf, 1, 2))); +PyAPI_FUNC(Py_ssize_t) PyBytes_Size(PyObject *); +PyAPI_FUNC(char *) PyBytes_AsString(PyObject *); +PyAPI_FUNC(PyObject *) PyBytes_Repr(PyObject *, int); +PyAPI_FUNC(void) PyBytes_Concat(PyObject **, PyObject *); +PyAPI_FUNC(void) PyBytes_ConcatAndDel(PyObject **, PyObject *); +#ifndef Py_LIMITED_API +PyAPI_FUNC(int) _PyBytes_Resize(PyObject **, Py_ssize_t); +PyAPI_FUNC(PyObject *) _PyBytes_Format(PyObject *, PyObject *); +#endif +PyAPI_FUNC(PyObject *) PyBytes_DecodeEscape(const char *, Py_ssize_t, + const char *, Py_ssize_t, + const char *); + +/* Macro, trading safety for speed */ +#ifndef Py_LIMITED_API +#define PyBytes_AS_STRING(op) (assert(PyBytes_Check(op)), \ + (((PyBytesObject *)(op))->ob_sval)) +#define PyBytes_GET_SIZE(op) (assert(PyBytes_Check(op)),Py_SIZE(op)) +#endif + +/* _PyBytes_Join(sep, x) is like sep.join(x). sep must be PyBytesObject*, + x must be an iterable object. */ +#ifndef Py_LIMITED_API +PyAPI_FUNC(PyObject *) _PyBytes_Join(PyObject *sep, PyObject *x); +#endif + +/* Provides access to the internal data buffer and size of a string + object or the default encoded version of an Unicode object. Passing + NULL as *len parameter will force the string buffer to be + 0-terminated (passing a string with embedded NULL characters will + cause an exception). */ +PyAPI_FUNC(int) PyBytes_AsStringAndSize( + PyObject *obj, /* string or Unicode object */ + char **s, /* pointer to buffer variable */ + Py_ssize_t *len /* pointer to length variable or NULL + (only possible for 0-terminated + strings) */ + ); + +/* Using the current locale, insert the thousands grouping + into the string pointed to by buffer. For the argument descriptions, + see Objects/stringlib/localeutil.h */ +#ifndef Py_LIMITED_API +PyAPI_FUNC(Py_ssize_t) _PyBytes_InsertThousandsGroupingLocale(char *buffer, + Py_ssize_t n_buffer, + char *digits, + Py_ssize_t n_digits, + Py_ssize_t min_width); + +/* Using explicit passed-in values, insert the thousands grouping + into the string pointed to by buffer. For the argument descriptions, + see Objects/stringlib/localeutil.h */ +PyAPI_FUNC(Py_ssize_t) _PyBytes_InsertThousandsGrouping(char *buffer, + Py_ssize_t n_buffer, + char *digits, + Py_ssize_t n_digits, + Py_ssize_t min_width, + const char *grouping, + const char *thousands_sep); +#endif + +/* Flags used by string formatting */ +#define F_LJUST (1<<0) +#define F_SIGN (1<<1) +#define F_BLANK (1<<2) +#define F_ALT (1<<3) +#define F_ZERO (1<<4) + +#ifdef __cplusplus +} +#endif +#endif /* !Py_BYTESOBJECT_H */ diff --git a/android/python35/include/cellobject.h b/android/python35/include/cellobject.h new file mode 100644 index 000000000..a0aa4d947 --- /dev/null +++ b/android/python35/include/cellobject.h @@ -0,0 +1,29 @@ +/* Cell object interface */ +#ifndef Py_LIMITED_API +#ifndef Py_CELLOBJECT_H +#define Py_CELLOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + PyObject_HEAD + PyObject *ob_ref; /* Content of the cell or NULL when empty */ +} PyCellObject; + +PyAPI_DATA(PyTypeObject) PyCell_Type; + +#define PyCell_Check(op) (Py_TYPE(op) == &PyCell_Type) + +PyAPI_FUNC(PyObject *) PyCell_New(PyObject *); +PyAPI_FUNC(PyObject *) PyCell_Get(PyObject *); +PyAPI_FUNC(int) PyCell_Set(PyObject *, PyObject *); + +#define PyCell_GET(op) (((PyCellObject *)(op))->ob_ref) +#define PyCell_SET(op, v) (((PyCellObject *)(op))->ob_ref = v) + +#ifdef __cplusplus +} +#endif +#endif /* !Py_TUPLEOBJECT_H */ +#endif /* Py_LIMITED_API */ diff --git a/android/python35/include/ceval.h b/android/python35/include/ceval.h new file mode 100644 index 000000000..eb1ee4349 --- /dev/null +++ b/android/python35/include/ceval.h @@ -0,0 +1,207 @@ +#ifndef Py_CEVAL_H +#define Py_CEVAL_H +#ifdef __cplusplus +extern "C" { +#endif + + +/* Interface to random parts in ceval.c */ + +PyAPI_FUNC(PyObject *) PyEval_CallObjectWithKeywords( + PyObject *, PyObject *, PyObject *); + +/* Inline this */ +#define PyEval_CallObject(func,arg) \ + PyEval_CallObjectWithKeywords(func, arg, (PyObject *)NULL) + +PyAPI_FUNC(PyObject *) PyEval_CallFunction(PyObject *obj, + const char *format, ...); +PyAPI_FUNC(PyObject *) PyEval_CallMethod(PyObject *obj, + const char *methodname, + const char *format, ...); + +#ifndef Py_LIMITED_API +PyAPI_FUNC(void) PyEval_SetProfile(Py_tracefunc, PyObject *); +PyAPI_FUNC(void) PyEval_SetTrace(Py_tracefunc, PyObject *); +PyAPI_FUNC(void) _PyEval_SetCoroutineWrapper(PyObject *); +PyAPI_FUNC(PyObject *) _PyEval_GetCoroutineWrapper(void); +#endif + +struct _frame; /* Avoid including frameobject.h */ + +PyAPI_FUNC(PyObject *) PyEval_GetBuiltins(void); +PyAPI_FUNC(PyObject *) PyEval_GetGlobals(void); +PyAPI_FUNC(PyObject *) PyEval_GetLocals(void); +PyAPI_FUNC(struct _frame *) PyEval_GetFrame(void); + +/* Look at the current frame's (if any) code's co_flags, and turn on + the corresponding compiler flags in cf->cf_flags. Return 1 if any + flag was set, else return 0. */ +#ifndef Py_LIMITED_API +PyAPI_FUNC(int) PyEval_MergeCompilerFlags(PyCompilerFlags *cf); +#endif + +PyAPI_FUNC(int) Py_AddPendingCall(int (*func)(void *), void *arg); +PyAPI_FUNC(int) Py_MakePendingCalls(void); + +/* Protection against deeply nested recursive calls + + In Python 3.0, this protection has two levels: + * normal anti-recursion protection is triggered when the recursion level + exceeds the current recursion limit. It raises a RecursionError, and sets + the "overflowed" flag in the thread state structure. This flag + temporarily *disables* the normal protection; this allows cleanup code + to potentially outgrow the recursion limit while processing the + RecursionError. + * "last chance" anti-recursion protection is triggered when the recursion + level exceeds "current recursion limit + 50". By construction, this + protection can only be triggered when the "overflowed" flag is set. It + means the cleanup code has itself gone into an infinite loop, or the + RecursionError has been mistakingly ignored. When this protection is + triggered, the interpreter aborts with a Fatal Error. + + In addition, the "overflowed" flag is automatically reset when the + recursion level drops below "current recursion limit - 50". This heuristic + is meant to ensure that the normal anti-recursion protection doesn't get + disabled too long. + + Please note: this scheme has its own limitations. See: + http://mail.python.org/pipermail/python-dev/2008-August/082106.html + for some observations. +*/ +PyAPI_FUNC(void) Py_SetRecursionLimit(int); +PyAPI_FUNC(int) Py_GetRecursionLimit(void); + +#define Py_EnterRecursiveCall(where) \ + (_Py_MakeRecCheck(PyThreadState_GET()->recursion_depth) && \ + _Py_CheckRecursiveCall(where)) +#define Py_LeaveRecursiveCall() \ + do{ if(_Py_MakeEndRecCheck(PyThreadState_GET()->recursion_depth)) \ + PyThreadState_GET()->overflowed = 0; \ + } while(0) +PyAPI_FUNC(int) _Py_CheckRecursiveCall(const char *where); +PyAPI_DATA(int) _Py_CheckRecursionLimit; + +#ifdef USE_STACKCHECK +/* With USE_STACKCHECK, we artificially decrement the recursion limit in order + to trigger regular stack checks in _Py_CheckRecursiveCall(), except if + the "overflowed" flag is set, in which case we need the true value + of _Py_CheckRecursionLimit for _Py_MakeEndRecCheck() to function properly. +*/ +# define _Py_MakeRecCheck(x) \ + (++(x) > (_Py_CheckRecursionLimit += PyThreadState_GET()->overflowed - 1)) +#else +# define _Py_MakeRecCheck(x) (++(x) > _Py_CheckRecursionLimit) +#endif + +#define _Py_MakeEndRecCheck(x) \ + (--(x) < ((_Py_CheckRecursionLimit > 100) \ + ? (_Py_CheckRecursionLimit - 50) \ + : (3 * (_Py_CheckRecursionLimit >> 2)))) + +#define Py_ALLOW_RECURSION \ + do { unsigned char _old = PyThreadState_GET()->recursion_critical;\ + PyThreadState_GET()->recursion_critical = 1; + +#define Py_END_ALLOW_RECURSION \ + PyThreadState_GET()->recursion_critical = _old; \ + } while(0); + +PyAPI_FUNC(const char *) PyEval_GetFuncName(PyObject *); +PyAPI_FUNC(const char *) PyEval_GetFuncDesc(PyObject *); + +PyAPI_FUNC(PyObject *) PyEval_GetCallStats(PyObject *); +PyAPI_FUNC(PyObject *) PyEval_EvalFrame(struct _frame *); +PyAPI_FUNC(PyObject *) PyEval_EvalFrameEx(struct _frame *f, int exc); + +/* Interface for threads. + + A module that plans to do a blocking system call (or something else + that lasts a long time and doesn't touch Python data) can allow other + threads to run as follows: + + ...preparations here... + Py_BEGIN_ALLOW_THREADS + ...blocking system call here... + Py_END_ALLOW_THREADS + ...interpret result here... + + The Py_BEGIN_ALLOW_THREADS/Py_END_ALLOW_THREADS pair expands to a + {}-surrounded block. + To leave the block in the middle (e.g., with return), you must insert + a line containing Py_BLOCK_THREADS before the return, e.g. + + if (...premature_exit...) { + Py_BLOCK_THREADS + PyErr_SetFromErrno(PyExc_IOError); + return NULL; + } + + An alternative is: + + Py_BLOCK_THREADS + if (...premature_exit...) { + PyErr_SetFromErrno(PyExc_IOError); + return NULL; + } + Py_UNBLOCK_THREADS + + For convenience, that the value of 'errno' is restored across + Py_END_ALLOW_THREADS and Py_BLOCK_THREADS. + + WARNING: NEVER NEST CALLS TO Py_BEGIN_ALLOW_THREADS AND + Py_END_ALLOW_THREADS!!! + + The function PyEval_InitThreads() should be called only from + init_thread() in "_threadmodule.c". + + Note that not yet all candidates have been converted to use this + mechanism! +*/ + +PyAPI_FUNC(PyThreadState *) PyEval_SaveThread(void); +PyAPI_FUNC(void) PyEval_RestoreThread(PyThreadState *); + +#ifdef WITH_THREAD + +PyAPI_FUNC(int) PyEval_ThreadsInitialized(void); +PyAPI_FUNC(void) PyEval_InitThreads(void); +PyAPI_FUNC(void) _PyEval_FiniThreads(void); +PyAPI_FUNC(void) PyEval_AcquireLock(void); +PyAPI_FUNC(void) PyEval_ReleaseLock(void); +PyAPI_FUNC(void) PyEval_AcquireThread(PyThreadState *tstate); +PyAPI_FUNC(void) PyEval_ReleaseThread(PyThreadState *tstate); +PyAPI_FUNC(void) PyEval_ReInitThreads(void); + +#ifndef Py_LIMITED_API +PyAPI_FUNC(void) _PyEval_SetSwitchInterval(unsigned long microseconds); +PyAPI_FUNC(unsigned long) _PyEval_GetSwitchInterval(void); +#endif + +#define Py_BEGIN_ALLOW_THREADS { \ + PyThreadState *_save; \ + _save = PyEval_SaveThread(); +#define Py_BLOCK_THREADS PyEval_RestoreThread(_save); +#define Py_UNBLOCK_THREADS _save = PyEval_SaveThread(); +#define Py_END_ALLOW_THREADS PyEval_RestoreThread(_save); \ + } + +#else /* !WITH_THREAD */ + +#define Py_BEGIN_ALLOW_THREADS { +#define Py_BLOCK_THREADS +#define Py_UNBLOCK_THREADS +#define Py_END_ALLOW_THREADS } + +#endif /* !WITH_THREAD */ + +#ifndef Py_LIMITED_API +PyAPI_FUNC(int) _PyEval_SliceIndex(PyObject *, Py_ssize_t *); +PyAPI_FUNC(void) _PyEval_SignalAsyncExc(void); +#endif + + +#ifdef __cplusplus +} +#endif +#endif /* !Py_CEVAL_H */ diff --git a/android/python35/include/classobject.h b/android/python35/include/classobject.h new file mode 100644 index 000000000..eeeb3e95a --- /dev/null +++ b/android/python35/include/classobject.h @@ -0,0 +1,58 @@ +/* Former class object interface -- now only bound methods are here */ + +/* Revealing some structures (not for general use) */ + +#ifndef Py_LIMITED_API +#ifndef Py_CLASSOBJECT_H +#define Py_CLASSOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + PyObject_HEAD + PyObject *im_func; /* The callable object implementing the method */ + PyObject *im_self; /* The instance it is bound to */ + PyObject *im_weakreflist; /* List of weak references */ +} PyMethodObject; + +PyAPI_DATA(PyTypeObject) PyMethod_Type; + +#define PyMethod_Check(op) ((op)->ob_type == &PyMethod_Type) + +PyAPI_FUNC(PyObject *) PyMethod_New(PyObject *, PyObject *); + +PyAPI_FUNC(PyObject *) PyMethod_Function(PyObject *); +PyAPI_FUNC(PyObject *) PyMethod_Self(PyObject *); + +/* Macros for direct access to these values. Type checks are *not* + done, so use with care. */ +#define PyMethod_GET_FUNCTION(meth) \ + (((PyMethodObject *)meth) -> im_func) +#define PyMethod_GET_SELF(meth) \ + (((PyMethodObject *)meth) -> im_self) + +PyAPI_FUNC(int) PyMethod_ClearFreeList(void); + +typedef struct { + PyObject_HEAD + PyObject *func; +} PyInstanceMethodObject; + +PyAPI_DATA(PyTypeObject) PyInstanceMethod_Type; + +#define PyInstanceMethod_Check(op) ((op)->ob_type == &PyInstanceMethod_Type) + +PyAPI_FUNC(PyObject *) PyInstanceMethod_New(PyObject *); +PyAPI_FUNC(PyObject *) PyInstanceMethod_Function(PyObject *); + +/* Macros for direct access to these values. Type checks are *not* + done, so use with care. */ +#define PyInstanceMethod_GET_FUNCTION(meth) \ + (((PyInstanceMethodObject *)meth) -> func) + +#ifdef __cplusplus +} +#endif +#endif /* !Py_CLASSOBJECT_H */ +#endif /* Py_LIMITED_API */ diff --git a/android/python35/include/code.h b/android/python35/include/code.h new file mode 100644 index 000000000..56e6ec18a --- /dev/null +++ b/android/python35/include/code.h @@ -0,0 +1,126 @@ +/* Definitions for bytecode */ + +#ifndef Py_LIMITED_API +#ifndef Py_CODE_H +#define Py_CODE_H +#ifdef __cplusplus +extern "C" { +#endif + +/* Bytecode object */ +typedef struct { + PyObject_HEAD + int co_argcount; /* #arguments, except *args */ + int co_kwonlyargcount; /* #keyword only arguments */ + int co_nlocals; /* #local variables */ + int co_stacksize; /* #entries needed for evaluation stack */ + int co_flags; /* CO_..., see below */ + PyObject *co_code; /* instruction opcodes */ + PyObject *co_consts; /* list (constants used) */ + PyObject *co_names; /* list of strings (names used) */ + PyObject *co_varnames; /* tuple of strings (local variable names) */ + PyObject *co_freevars; /* tuple of strings (free variable names) */ + PyObject *co_cellvars; /* tuple of strings (cell variable names) */ + /* The rest aren't used in either hash or comparisons, except for + co_name (used in both) and co_firstlineno (used only in + comparisons). This is done to preserve the name and line number + for tracebacks and debuggers; otherwise, constant de-duplication + would collapse identical functions/lambdas defined on different lines. + */ + unsigned char *co_cell2arg; /* Maps cell vars which are arguments. */ + PyObject *co_filename; /* unicode (where it was loaded from) */ + PyObject *co_name; /* unicode (name, for reference) */ + int co_firstlineno; /* first source line number */ + PyObject *co_lnotab; /* string (encoding addr<->lineno mapping) See + Objects/lnotab_notes.txt for details. */ + void *co_zombieframe; /* for optimization only (see frameobject.c) */ + PyObject *co_weakreflist; /* to support weakrefs to code objects */ +} PyCodeObject; + +/* Masks for co_flags above */ +#define CO_OPTIMIZED 0x0001 +#define CO_NEWLOCALS 0x0002 +#define CO_VARARGS 0x0004 +#define CO_VARKEYWORDS 0x0008 +#define CO_NESTED 0x0010 +#define CO_GENERATOR 0x0020 +/* The CO_NOFREE flag is set if there are no free or cell variables. + This information is redundant, but it allows a single flag test + to determine whether there is any extra work to be done when the + call frame it setup. +*/ +#define CO_NOFREE 0x0040 + +/* The CO_COROUTINE flag is set for coroutine functions (defined with + ``async def`` keywords) */ +#define CO_COROUTINE 0x0080 +#define CO_ITERABLE_COROUTINE 0x0100 + +/* These are no longer used. */ +#if 0 +#define CO_GENERATOR_ALLOWED 0x1000 +#endif +#define CO_FUTURE_DIVISION 0x2000 +#define CO_FUTURE_ABSOLUTE_IMPORT 0x4000 /* do absolute imports by default */ +#define CO_FUTURE_WITH_STATEMENT 0x8000 +#define CO_FUTURE_PRINT_FUNCTION 0x10000 +#define CO_FUTURE_UNICODE_LITERALS 0x20000 + +#define CO_FUTURE_BARRY_AS_BDFL 0x40000 +#define CO_FUTURE_GENERATOR_STOP 0x80000 + +/* This value is found in the co_cell2arg array when the associated cell + variable does not correspond to an argument. The maximum number of + arguments is 255 (indexed up to 254), so 255 work as a special flag.*/ +#define CO_CELL_NOT_AN_ARG 255 + +/* This should be defined if a future statement modifies the syntax. + For example, when a keyword is added. +*/ +#define PY_PARSER_REQUIRES_FUTURE_KEYWORD + +#define CO_MAXBLOCKS 20 /* Max static block nesting within a function */ + +PyAPI_DATA(PyTypeObject) PyCode_Type; + +#define PyCode_Check(op) (Py_TYPE(op) == &PyCode_Type) +#define PyCode_GetNumFree(op) (PyTuple_GET_SIZE((op)->co_freevars)) + +/* Public interface */ +PyAPI_FUNC(PyCodeObject *) PyCode_New( + int, int, int, int, int, PyObject *, PyObject *, + PyObject *, PyObject *, PyObject *, PyObject *, + PyObject *, PyObject *, int, PyObject *); + /* same as struct above */ + +/* Creates a new empty code object with the specified source location. */ +PyAPI_FUNC(PyCodeObject *) +PyCode_NewEmpty(const char *filename, const char *funcname, int firstlineno); + +/* Return the line number associated with the specified bytecode index + in this code object. If you just need the line number of a frame, + use PyFrame_GetLineNumber() instead. */ +PyAPI_FUNC(int) PyCode_Addr2Line(PyCodeObject *, int); + +/* for internal use only */ +typedef struct _addr_pair { + int ap_lower; + int ap_upper; +} PyAddrPair; + +/* Update *bounds to describe the first and one-past-the-last instructions in the + same line as lasti. Return the number of that line. +*/ +#ifndef Py_LIMITED_API +PyAPI_FUNC(int) _PyCode_CheckLineNumber(PyCodeObject* co, + int lasti, PyAddrPair *bounds); +#endif + +PyAPI_FUNC(PyObject*) PyCode_Optimize(PyObject *code, PyObject* consts, + PyObject *names, PyObject *lineno_obj); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_CODE_H */ +#endif /* Py_LIMITED_API */ diff --git a/android/python35/include/codecs.h b/android/python35/include/codecs.h new file mode 100644 index 000000000..9e4f30509 --- /dev/null +++ b/android/python35/include/codecs.h @@ -0,0 +1,236 @@ +#ifndef Py_CODECREGISTRY_H +#define Py_CODECREGISTRY_H +#ifdef __cplusplus +extern "C" { +#endif + +/* ------------------------------------------------------------------------ + + Python Codec Registry and support functions + + +Written by Marc-Andre Lemburg (mal@lemburg.com). + +Copyright (c) Corporation for National Research Initiatives. + + ------------------------------------------------------------------------ */ + +/* Register a new codec search function. + + As side effect, this tries to load the encodings package, if not + yet done, to make sure that it is always first in the list of + search functions. + + The search_function's refcount is incremented by this function. */ + +PyAPI_FUNC(int) PyCodec_Register( + PyObject *search_function + ); + +/* Codec registry lookup API. + + Looks up the given encoding and returns a CodecInfo object with + function attributes which implement the different aspects of + processing the encoding. + + The encoding string is looked up converted to all lower-case + characters. This makes encodings looked up through this mechanism + effectively case-insensitive. + + If no codec is found, a KeyError is set and NULL returned. + + As side effect, this tries to load the encodings package, if not + yet done. This is part of the lazy load strategy for the encodings + package. + + */ + +#ifndef Py_LIMITED_API +PyAPI_FUNC(PyObject *) _PyCodec_Lookup( + const char *encoding + ); + +PyAPI_FUNC(int) _PyCodec_Forget( + const char *encoding + ); +#endif + +/* Codec registry encoding check API. + + Returns 1/0 depending on whether there is a registered codec for + the given encoding. + +*/ + +PyAPI_FUNC(int) PyCodec_KnownEncoding( + const char *encoding + ); + +/* Generic codec based encoding API. + + object is passed through the encoder function found for the given + encoding using the error handling method defined by errors. errors + may be NULL to use the default method defined for the codec. + + Raises a LookupError in case no encoder can be found. + + */ + +PyAPI_FUNC(PyObject *) PyCodec_Encode( + PyObject *object, + const char *encoding, + const char *errors + ); + +/* Generic codec based decoding API. + + object is passed through the decoder function found for the given + encoding using the error handling method defined by errors. errors + may be NULL to use the default method defined for the codec. + + Raises a LookupError in case no encoder can be found. + + */ + +PyAPI_FUNC(PyObject *) PyCodec_Decode( + PyObject *object, + const char *encoding, + const char *errors + ); + +#ifndef Py_LIMITED_API +/* Text codec specific encoding and decoding API. + + Checks the encoding against a list of codecs which do not + implement a str<->bytes encoding before attempting the + operation. + + Please note that these APIs are internal and should not + be used in Python C extensions. + + XXX (ncoghlan): should we make these, or something like them, public + in Python 3.5+? + + */ +PyAPI_FUNC(PyObject *) _PyCodec_LookupTextEncoding( + const char *encoding, + const char *alternate_command + ); + +PyAPI_FUNC(PyObject *) _PyCodec_EncodeText( + PyObject *object, + const char *encoding, + const char *errors + ); + +PyAPI_FUNC(PyObject *) _PyCodec_DecodeText( + PyObject *object, + const char *encoding, + const char *errors + ); + +/* These two aren't actually text encoding specific, but _io.TextIOWrapper + * is the only current API consumer. + */ +PyAPI_FUNC(PyObject *) _PyCodecInfo_GetIncrementalDecoder( + PyObject *codec_info, + const char *errors + ); + +PyAPI_FUNC(PyObject *) _PyCodecInfo_GetIncrementalEncoder( + PyObject *codec_info, + const char *errors + ); +#endif + + + +/* --- Codec Lookup APIs -------------------------------------------------- + + All APIs return a codec object with incremented refcount and are + based on _PyCodec_Lookup(). The same comments w/r to the encoding + name also apply to these APIs. + +*/ + +/* Get an encoder function for the given encoding. */ + +PyAPI_FUNC(PyObject *) PyCodec_Encoder( + const char *encoding + ); + +/* Get a decoder function for the given encoding. */ + +PyAPI_FUNC(PyObject *) PyCodec_Decoder( + const char *encoding + ); + +/* Get a IncrementalEncoder object for the given encoding. */ + +PyAPI_FUNC(PyObject *) PyCodec_IncrementalEncoder( + const char *encoding, + const char *errors + ); + +/* Get a IncrementalDecoder object function for the given encoding. */ + +PyAPI_FUNC(PyObject *) PyCodec_IncrementalDecoder( + const char *encoding, + const char *errors + ); + +/* Get a StreamReader factory function for the given encoding. */ + +PyAPI_FUNC(PyObject *) PyCodec_StreamReader( + const char *encoding, + PyObject *stream, + const char *errors + ); + +/* Get a StreamWriter factory function for the given encoding. */ + +PyAPI_FUNC(PyObject *) PyCodec_StreamWriter( + const char *encoding, + PyObject *stream, + const char *errors + ); + +/* Unicode encoding error handling callback registry API */ + +/* Register the error handling callback function error under the given + name. This function will be called by the codec when it encounters + unencodable characters/undecodable bytes and doesn't know the + callback name, when name is specified as the error parameter + in the call to the encode/decode function. + Return 0 on success, -1 on error */ +PyAPI_FUNC(int) PyCodec_RegisterError(const char *name, PyObject *error); + +/* Lookup the error handling callback function registered under the given + name. As a special case NULL can be passed, in which case + the error handling callback for "strict" will be returned. */ +PyAPI_FUNC(PyObject *) PyCodec_LookupError(const char *name); + +/* raise exc as an exception */ +PyAPI_FUNC(PyObject *) PyCodec_StrictErrors(PyObject *exc); + +/* ignore the unicode error, skipping the faulty input */ +PyAPI_FUNC(PyObject *) PyCodec_IgnoreErrors(PyObject *exc); + +/* replace the unicode encode error with ? or U+FFFD */ +PyAPI_FUNC(PyObject *) PyCodec_ReplaceErrors(PyObject *exc); + +/* replace the unicode encode error with XML character references */ +PyAPI_FUNC(PyObject *) PyCodec_XMLCharRefReplaceErrors(PyObject *exc); + +/* replace the unicode encode error with backslash escapes (\x, \u and \U) */ +PyAPI_FUNC(PyObject *) PyCodec_BackslashReplaceErrors(PyObject *exc); + +/* replace the unicode encode error with backslash escapes (\N, \x, \u and \U) */ +PyAPI_FUNC(PyObject *) PyCodec_NameReplaceErrors(PyObject *exc); + +PyAPI_DATA(const char *) Py_hexdigits; + +#ifdef __cplusplus +} +#endif +#endif /* !Py_CODECREGISTRY_H */ diff --git a/android/python35/include/compile.h b/android/python35/include/compile.h new file mode 100644 index 000000000..ecd8dc1d1 --- /dev/null +++ b/android/python35/include/compile.h @@ -0,0 +1,73 @@ +#ifndef Py_COMPILE_H +#define Py_COMPILE_H + +#ifndef Py_LIMITED_API +#include "code.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Public interface */ +struct _node; /* Declare the existence of this type */ +PyAPI_FUNC(PyCodeObject *) PyNode_Compile(struct _node *, const char *); + +/* Future feature support */ + +typedef struct { + int ff_features; /* flags set by future statements */ + int ff_lineno; /* line number of last future statement */ +} PyFutureFeatures; + +#define FUTURE_NESTED_SCOPES "nested_scopes" +#define FUTURE_GENERATORS "generators" +#define FUTURE_DIVISION "division" +#define FUTURE_ABSOLUTE_IMPORT "absolute_import" +#define FUTURE_WITH_STATEMENT "with_statement" +#define FUTURE_PRINT_FUNCTION "print_function" +#define FUTURE_UNICODE_LITERALS "unicode_literals" +#define FUTURE_BARRY_AS_BDFL "barry_as_FLUFL" +#define FUTURE_GENERATOR_STOP "generator_stop" + +struct _mod; /* Declare the existence of this type */ +#define PyAST_Compile(mod, s, f, ar) PyAST_CompileEx(mod, s, f, -1, ar) +PyAPI_FUNC(PyCodeObject *) PyAST_CompileEx( + struct _mod *mod, + const char *filename, /* decoded from the filesystem encoding */ + PyCompilerFlags *flags, + int optimize, + PyArena *arena); +PyAPI_FUNC(PyCodeObject *) PyAST_CompileObject( + struct _mod *mod, + PyObject *filename, + PyCompilerFlags *flags, + int optimize, + PyArena *arena); +PyAPI_FUNC(PyFutureFeatures *) PyFuture_FromAST( + struct _mod * mod, + const char *filename /* decoded from the filesystem encoding */ + ); +PyAPI_FUNC(PyFutureFeatures *) PyFuture_FromASTObject( + struct _mod * mod, + PyObject *filename + ); + +/* _Py_Mangle is defined in compile.c */ +PyAPI_FUNC(PyObject*) _Py_Mangle(PyObject *p, PyObject *name); + +#define PY_INVALID_STACK_EFFECT INT_MAX +PyAPI_FUNC(int) PyCompile_OpcodeStackEffect(int opcode, int oparg); + +#ifdef __cplusplus +} +#endif + +#endif /* !Py_LIMITED_API */ + +/* These definitions must match corresponding definitions in graminit.h. + There's code in compile.c that checks that they are the same. */ +#define Py_single_input 256 +#define Py_file_input 257 +#define Py_eval_input 258 + +#endif /* !Py_COMPILE_H */ diff --git a/android/python35/include/complexobject.h b/android/python35/include/complexobject.h new file mode 100644 index 000000000..cb8c52c58 --- /dev/null +++ b/android/python35/include/complexobject.h @@ -0,0 +1,69 @@ +/* Complex number structure */ + +#ifndef Py_COMPLEXOBJECT_H +#define Py_COMPLEXOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_LIMITED_API +typedef struct { + double real; + double imag; +} Py_complex; + +/* Operations on complex numbers from complexmodule.c */ + +PyAPI_FUNC(Py_complex) _Py_c_sum(Py_complex, Py_complex); +PyAPI_FUNC(Py_complex) _Py_c_diff(Py_complex, Py_complex); +PyAPI_FUNC(Py_complex) _Py_c_neg(Py_complex); +PyAPI_FUNC(Py_complex) _Py_c_prod(Py_complex, Py_complex); +PyAPI_FUNC(Py_complex) _Py_c_quot(Py_complex, Py_complex); +PyAPI_FUNC(Py_complex) _Py_c_pow(Py_complex, Py_complex); +PyAPI_FUNC(double) _Py_c_abs(Py_complex); +#endif + +/* Complex object interface */ + +/* +PyComplexObject represents a complex number with double-precision +real and imaginary parts. +*/ +#ifndef Py_LIMITED_API +typedef struct { + PyObject_HEAD + Py_complex cval; +} PyComplexObject; +#endif + +PyAPI_DATA(PyTypeObject) PyComplex_Type; + +#define PyComplex_Check(op) PyObject_TypeCheck(op, &PyComplex_Type) +#define PyComplex_CheckExact(op) (Py_TYPE(op) == &PyComplex_Type) + +#ifndef Py_LIMITED_API +PyAPI_FUNC(PyObject *) PyComplex_FromCComplex(Py_complex); +#endif +PyAPI_FUNC(PyObject *) PyComplex_FromDoubles(double real, double imag); + +PyAPI_FUNC(double) PyComplex_RealAsDouble(PyObject *op); +PyAPI_FUNC(double) PyComplex_ImagAsDouble(PyObject *op); +#ifndef Py_LIMITED_API +PyAPI_FUNC(Py_complex) PyComplex_AsCComplex(PyObject *op); +#endif + +/* Format the object based on the format_spec, as defined in PEP 3101 + (Advanced String Formatting). */ +#ifndef Py_LIMITED_API +PyAPI_FUNC(int) _PyComplex_FormatAdvancedWriter( + _PyUnicodeWriter *writer, + PyObject *obj, + PyObject *format_spec, + Py_ssize_t start, + Py_ssize_t end); +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_COMPLEXOBJECT_H */ diff --git a/android/python35/include/datetime.h b/android/python35/include/datetime.h new file mode 100644 index 000000000..06cbc4abb --- /dev/null +++ b/android/python35/include/datetime.h @@ -0,0 +1,243 @@ +/* datetime.h + */ +#ifndef Py_LIMITED_API +#ifndef DATETIME_H +#define DATETIME_H +#ifdef __cplusplus +extern "C" { +#endif + +/* Fields are packed into successive bytes, each viewed as unsigned and + * big-endian, unless otherwise noted: + * + * byte offset + * 0 year 2 bytes, 1-9999 + * 2 month 1 byte, 1-12 + * 3 day 1 byte, 1-31 + * 4 hour 1 byte, 0-23 + * 5 minute 1 byte, 0-59 + * 6 second 1 byte, 0-59 + * 7 usecond 3 bytes, 0-999999 + * 10 + */ + +/* # of bytes for year, month, and day. */ +#define _PyDateTime_DATE_DATASIZE 4 + +/* # of bytes for hour, minute, second, and usecond. */ +#define _PyDateTime_TIME_DATASIZE 6 + +/* # of bytes for year, month, day, hour, minute, second, and usecond. */ +#define _PyDateTime_DATETIME_DATASIZE 10 + + +typedef struct +{ + PyObject_HEAD + Py_hash_t hashcode; /* -1 when unknown */ + int days; /* -MAX_DELTA_DAYS <= days <= MAX_DELTA_DAYS */ + int seconds; /* 0 <= seconds < 24*3600 is invariant */ + int microseconds; /* 0 <= microseconds < 1000000 is invariant */ +} PyDateTime_Delta; + +typedef struct +{ + PyObject_HEAD /* a pure abstract base class */ +} PyDateTime_TZInfo; + + +/* The datetime and time types have hashcodes, and an optional tzinfo member, + * present if and only if hastzinfo is true. + */ +#define _PyTZINFO_HEAD \ + PyObject_HEAD \ + Py_hash_t hashcode; \ + char hastzinfo; /* boolean flag */ + +/* No _PyDateTime_BaseTZInfo is allocated; it's just to have something + * convenient to cast to, when getting at the hastzinfo member of objects + * starting with _PyTZINFO_HEAD. + */ +typedef struct +{ + _PyTZINFO_HEAD +} _PyDateTime_BaseTZInfo; + +/* All time objects are of PyDateTime_TimeType, but that can be allocated + * in two ways, with or without a tzinfo member. Without is the same as + * tzinfo == None, but consumes less memory. _PyDateTime_BaseTime is an + * internal struct used to allocate the right amount of space for the + * "without" case. + */ +#define _PyDateTime_TIMEHEAD \ + _PyTZINFO_HEAD \ + unsigned char data[_PyDateTime_TIME_DATASIZE]; + +typedef struct +{ + _PyDateTime_TIMEHEAD +} _PyDateTime_BaseTime; /* hastzinfo false */ + +typedef struct +{ + _PyDateTime_TIMEHEAD + PyObject *tzinfo; +} PyDateTime_Time; /* hastzinfo true */ + + +/* All datetime objects are of PyDateTime_DateTimeType, but that can be + * allocated in two ways too, just like for time objects above. In addition, + * the plain date type is a base class for datetime, so it must also have + * a hastzinfo member (although it's unused there). + */ +typedef struct +{ + _PyTZINFO_HEAD + unsigned char data[_PyDateTime_DATE_DATASIZE]; +} PyDateTime_Date; + +#define _PyDateTime_DATETIMEHEAD \ + _PyTZINFO_HEAD \ + unsigned char data[_PyDateTime_DATETIME_DATASIZE]; + +typedef struct +{ + _PyDateTime_DATETIMEHEAD +} _PyDateTime_BaseDateTime; /* hastzinfo false */ + +typedef struct +{ + _PyDateTime_DATETIMEHEAD + PyObject *tzinfo; +} PyDateTime_DateTime; /* hastzinfo true */ + + +/* Apply for date and datetime instances. */ +#define PyDateTime_GET_YEAR(o) ((((PyDateTime_Date*)o)->data[0] << 8) | \ + ((PyDateTime_Date*)o)->data[1]) +#define PyDateTime_GET_MONTH(o) (((PyDateTime_Date*)o)->data[2]) +#define PyDateTime_GET_DAY(o) (((PyDateTime_Date*)o)->data[3]) + +#define PyDateTime_DATE_GET_HOUR(o) (((PyDateTime_DateTime*)o)->data[4]) +#define PyDateTime_DATE_GET_MINUTE(o) (((PyDateTime_DateTime*)o)->data[5]) +#define PyDateTime_DATE_GET_SECOND(o) (((PyDateTime_DateTime*)o)->data[6]) +#define PyDateTime_DATE_GET_MICROSECOND(o) \ + ((((PyDateTime_DateTime*)o)->data[7] << 16) | \ + (((PyDateTime_DateTime*)o)->data[8] << 8) | \ + ((PyDateTime_DateTime*)o)->data[9]) + +/* Apply for time instances. */ +#define PyDateTime_TIME_GET_HOUR(o) (((PyDateTime_Time*)o)->data[0]) +#define PyDateTime_TIME_GET_MINUTE(o) (((PyDateTime_Time*)o)->data[1]) +#define PyDateTime_TIME_GET_SECOND(o) (((PyDateTime_Time*)o)->data[2]) +#define PyDateTime_TIME_GET_MICROSECOND(o) \ + ((((PyDateTime_Time*)o)->data[3] << 16) | \ + (((PyDateTime_Time*)o)->data[4] << 8) | \ + ((PyDateTime_Time*)o)->data[5]) + +/* Apply for time delta instances */ +#define PyDateTime_DELTA_GET_DAYS(o) (((PyDateTime_Delta*)o)->days) +#define PyDateTime_DELTA_GET_SECONDS(o) (((PyDateTime_Delta*)o)->seconds) +#define PyDateTime_DELTA_GET_MICROSECONDS(o) \ + (((PyDateTime_Delta*)o)->microseconds) + + +/* Define structure for C API. */ +typedef struct { + /* type objects */ + PyTypeObject *DateType; + PyTypeObject *DateTimeType; + PyTypeObject *TimeType; + PyTypeObject *DeltaType; + PyTypeObject *TZInfoType; + + /* constructors */ + PyObject *(*Date_FromDate)(int, int, int, PyTypeObject*); + PyObject *(*DateTime_FromDateAndTime)(int, int, int, int, int, int, int, + PyObject*, PyTypeObject*); + PyObject *(*Time_FromTime)(int, int, int, int, PyObject*, PyTypeObject*); + PyObject *(*Delta_FromDelta)(int, int, int, int, PyTypeObject*); + + /* constructors for the DB API */ + PyObject *(*DateTime_FromTimestamp)(PyObject*, PyObject*, PyObject*); + PyObject *(*Date_FromTimestamp)(PyObject*, PyObject*); + +} PyDateTime_CAPI; + +#define PyDateTime_CAPSULE_NAME "datetime.datetime_CAPI" + + +#ifdef Py_BUILD_CORE + +/* Macros for type checking when building the Python core. */ +#define PyDate_Check(op) PyObject_TypeCheck(op, &PyDateTime_DateType) +#define PyDate_CheckExact(op) (Py_TYPE(op) == &PyDateTime_DateType) + +#define PyDateTime_Check(op) PyObject_TypeCheck(op, &PyDateTime_DateTimeType) +#define PyDateTime_CheckExact(op) (Py_TYPE(op) == &PyDateTime_DateTimeType) + +#define PyTime_Check(op) PyObject_TypeCheck(op, &PyDateTime_TimeType) +#define PyTime_CheckExact(op) (Py_TYPE(op) == &PyDateTime_TimeType) + +#define PyDelta_Check(op) PyObject_TypeCheck(op, &PyDateTime_DeltaType) +#define PyDelta_CheckExact(op) (Py_TYPE(op) == &PyDateTime_DeltaType) + +#define PyTZInfo_Check(op) PyObject_TypeCheck(op, &PyDateTime_TZInfoType) +#define PyTZInfo_CheckExact(op) (Py_TYPE(op) == &PyDateTime_TZInfoType) + +#else + +/* Define global variable for the C API and a macro for setting it. */ +static PyDateTime_CAPI *PyDateTimeAPI = NULL; + +#define PyDateTime_IMPORT \ + PyDateTimeAPI = (PyDateTime_CAPI *)PyCapsule_Import(PyDateTime_CAPSULE_NAME, 0) + +/* Macros for type checking when not building the Python core. */ +#define PyDate_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->DateType) +#define PyDate_CheckExact(op) (Py_TYPE(op) == PyDateTimeAPI->DateType) + +#define PyDateTime_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->DateTimeType) +#define PyDateTime_CheckExact(op) (Py_TYPE(op) == PyDateTimeAPI->DateTimeType) + +#define PyTime_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->TimeType) +#define PyTime_CheckExact(op) (Py_TYPE(op) == PyDateTimeAPI->TimeType) + +#define PyDelta_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->DeltaType) +#define PyDelta_CheckExact(op) (Py_TYPE(op) == PyDateTimeAPI->DeltaType) + +#define PyTZInfo_Check(op) PyObject_TypeCheck(op, PyDateTimeAPI->TZInfoType) +#define PyTZInfo_CheckExact(op) (Py_TYPE(op) == PyDateTimeAPI->TZInfoType) + +/* Macros for accessing constructors in a simplified fashion. */ +#define PyDate_FromDate(year, month, day) \ + PyDateTimeAPI->Date_FromDate(year, month, day, PyDateTimeAPI->DateType) + +#define PyDateTime_FromDateAndTime(year, month, day, hour, min, sec, usec) \ + PyDateTimeAPI->DateTime_FromDateAndTime(year, month, day, hour, \ + min, sec, usec, Py_None, PyDateTimeAPI->DateTimeType) + +#define PyTime_FromTime(hour, minute, second, usecond) \ + PyDateTimeAPI->Time_FromTime(hour, minute, second, usecond, \ + Py_None, PyDateTimeAPI->TimeType) + +#define PyDelta_FromDSU(days, seconds, useconds) \ + PyDateTimeAPI->Delta_FromDelta(days, seconds, useconds, 1, \ + PyDateTimeAPI->DeltaType) + +/* Macros supporting the DB API. */ +#define PyDateTime_FromTimestamp(args) \ + PyDateTimeAPI->DateTime_FromTimestamp( \ + (PyObject*) (PyDateTimeAPI->DateTimeType), args, NULL) + +#define PyDate_FromTimestamp(args) \ + PyDateTimeAPI->Date_FromTimestamp( \ + (PyObject*) (PyDateTimeAPI->DateType), args) + +#endif /* Py_BUILD_CORE */ + +#ifdef __cplusplus +} +#endif +#endif +#endif /* !Py_LIMITED_API */ diff --git a/android/python35/include/descrobject.h b/android/python35/include/descrobject.h new file mode 100644 index 000000000..e2ba97fc8 --- /dev/null +++ b/android/python35/include/descrobject.h @@ -0,0 +1,105 @@ +/* Descriptors */ +#ifndef Py_DESCROBJECT_H +#define Py_DESCROBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +typedef PyObject *(*getter)(PyObject *, void *); +typedef int (*setter)(PyObject *, PyObject *, void *); + +typedef struct PyGetSetDef { + char *name; + getter get; + setter set; + char *doc; + void *closure; +} PyGetSetDef; + +#ifndef Py_LIMITED_API +typedef PyObject *(*wrapperfunc)(PyObject *self, PyObject *args, + void *wrapped); + +typedef PyObject *(*wrapperfunc_kwds)(PyObject *self, PyObject *args, + void *wrapped, PyObject *kwds); + +struct wrapperbase { + char *name; + int offset; + void *function; + wrapperfunc wrapper; + char *doc; + int flags; + PyObject *name_strobj; +}; + +/* Flags for above struct */ +#define PyWrapperFlag_KEYWORDS 1 /* wrapper function takes keyword args */ + +/* Various kinds of descriptor objects */ + +typedef struct { + PyObject_HEAD + PyTypeObject *d_type; + PyObject *d_name; + PyObject *d_qualname; +} PyDescrObject; + +#define PyDescr_COMMON PyDescrObject d_common + +#define PyDescr_TYPE(x) (((PyDescrObject *)(x))->d_type) +#define PyDescr_NAME(x) (((PyDescrObject *)(x))->d_name) + +typedef struct { + PyDescr_COMMON; + PyMethodDef *d_method; +} PyMethodDescrObject; + +typedef struct { + PyDescr_COMMON; + struct PyMemberDef *d_member; +} PyMemberDescrObject; + +typedef struct { + PyDescr_COMMON; + PyGetSetDef *d_getset; +} PyGetSetDescrObject; + +typedef struct { + PyDescr_COMMON; + struct wrapperbase *d_base; + void *d_wrapped; /* This can be any function pointer */ +} PyWrapperDescrObject; +#endif /* Py_LIMITED_API */ + +PyAPI_DATA(PyTypeObject) PyClassMethodDescr_Type; +PyAPI_DATA(PyTypeObject) PyGetSetDescr_Type; +PyAPI_DATA(PyTypeObject) PyMemberDescr_Type; +PyAPI_DATA(PyTypeObject) PyMethodDescr_Type; +PyAPI_DATA(PyTypeObject) PyWrapperDescr_Type; +PyAPI_DATA(PyTypeObject) PyDictProxy_Type; +PyAPI_DATA(PyTypeObject) _PyMethodWrapper_Type; + +PyAPI_FUNC(PyObject *) PyDescr_NewMethod(PyTypeObject *, PyMethodDef *); +PyAPI_FUNC(PyObject *) PyDescr_NewClassMethod(PyTypeObject *, PyMethodDef *); +struct PyMemberDef; /* forward declaration for following prototype */ +PyAPI_FUNC(PyObject *) PyDescr_NewMember(PyTypeObject *, + struct PyMemberDef *); +PyAPI_FUNC(PyObject *) PyDescr_NewGetSet(PyTypeObject *, + struct PyGetSetDef *); +#ifndef Py_LIMITED_API +PyAPI_FUNC(PyObject *) PyDescr_NewWrapper(PyTypeObject *, + struct wrapperbase *, void *); +#define PyDescr_IsData(d) (Py_TYPE(d)->tp_descr_set != NULL) +#endif + +PyAPI_FUNC(PyObject *) PyDictProxy_New(PyObject *); +PyAPI_FUNC(PyObject *) PyWrapper_New(PyObject *, PyObject *); + + +PyAPI_DATA(PyTypeObject) PyProperty_Type; +#ifdef __cplusplus +} +#endif +#endif /* !Py_DESCROBJECT_H */ + diff --git a/android/python35/include/dictobject.h b/android/python35/include/dictobject.h new file mode 100644 index 000000000..320f9ecf8 --- /dev/null +++ b/android/python35/include/dictobject.h @@ -0,0 +1,147 @@ +#ifndef Py_DICTOBJECT_H +#define Py_DICTOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + + +/* Dictionary object type -- mapping from hashable object to object */ + +/* The distribution includes a separate file, Objects/dictnotes.txt, + describing explorations into dictionary design and optimization. + It covers typical dictionary use patterns, the parameters for + tuning dictionaries, and several ideas for possible optimizations. +*/ + +#ifndef Py_LIMITED_API + +typedef struct _dictkeysobject PyDictKeysObject; + +/* The ma_values pointer is NULL for a combined table + * or points to an array of PyObject* for a split table + */ +typedef struct { + PyObject_HEAD + Py_ssize_t ma_used; + PyDictKeysObject *ma_keys; + PyObject **ma_values; +} PyDictObject; + +typedef struct { + PyObject_HEAD + PyDictObject *dv_dict; +} _PyDictViewObject; + +#endif /* Py_LIMITED_API */ + +PyAPI_DATA(PyTypeObject) PyDict_Type; +PyAPI_DATA(PyTypeObject) PyDictIterKey_Type; +PyAPI_DATA(PyTypeObject) PyDictIterValue_Type; +PyAPI_DATA(PyTypeObject) PyDictIterItem_Type; +PyAPI_DATA(PyTypeObject) PyDictKeys_Type; +PyAPI_DATA(PyTypeObject) PyDictItems_Type; +PyAPI_DATA(PyTypeObject) PyDictValues_Type; + +#define PyDict_Check(op) \ + PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_DICT_SUBCLASS) +#define PyDict_CheckExact(op) (Py_TYPE(op) == &PyDict_Type) +#define PyDictKeys_Check(op) PyObject_TypeCheck(op, &PyDictKeys_Type) +#define PyDictItems_Check(op) PyObject_TypeCheck(op, &PyDictItems_Type) +#define PyDictValues_Check(op) PyObject_TypeCheck(op, &PyDictValues_Type) +/* This excludes Values, since they are not sets. */ +# define PyDictViewSet_Check(op) \ + (PyDictKeys_Check(op) || PyDictItems_Check(op)) + + +PyAPI_FUNC(PyObject *) PyDict_New(void); +PyAPI_FUNC(PyObject *) PyDict_GetItem(PyObject *mp, PyObject *key); +#ifndef Py_LIMITED_API +PyAPI_FUNC(PyObject *) _PyDict_GetItem_KnownHash(PyObject *mp, PyObject *key, + Py_hash_t hash); +#endif +PyAPI_FUNC(PyObject *) PyDict_GetItemWithError(PyObject *mp, PyObject *key); +PyAPI_FUNC(PyObject *) _PyDict_GetItemIdWithError(PyObject *dp, + struct _Py_Identifier *key); +#ifndef Py_LIMITED_API +PyAPI_FUNC(PyObject *) PyDict_SetDefault( + PyObject *mp, PyObject *key, PyObject *defaultobj); +#endif +PyAPI_FUNC(int) PyDict_SetItem(PyObject *mp, PyObject *key, PyObject *item); +#ifndef Py_LIMITED_API +PyAPI_FUNC(int) _PyDict_SetItem_KnownHash(PyObject *mp, PyObject *key, + PyObject *item, Py_hash_t hash); +#endif +PyAPI_FUNC(int) PyDict_DelItem(PyObject *mp, PyObject *key); +PyAPI_FUNC(void) PyDict_Clear(PyObject *mp); +PyAPI_FUNC(int) PyDict_Next( + PyObject *mp, Py_ssize_t *pos, PyObject **key, PyObject **value); +#ifndef Py_LIMITED_API +PyDictKeysObject *_PyDict_NewKeysForClass(void); +PyAPI_FUNC(PyObject *) PyObject_GenericGetDict(PyObject *, void *); +PyAPI_FUNC(int) _PyDict_Next( + PyObject *mp, Py_ssize_t *pos, PyObject **key, PyObject **value, Py_hash_t *hash); +PyObject *_PyDictView_New(PyObject *, PyTypeObject *); +#endif +PyAPI_FUNC(PyObject *) PyDict_Keys(PyObject *mp); +PyAPI_FUNC(PyObject *) PyDict_Values(PyObject *mp); +PyAPI_FUNC(PyObject *) PyDict_Items(PyObject *mp); +PyAPI_FUNC(Py_ssize_t) PyDict_Size(PyObject *mp); +PyAPI_FUNC(PyObject *) PyDict_Copy(PyObject *mp); +PyAPI_FUNC(int) PyDict_Contains(PyObject *mp, PyObject *key); +#ifndef Py_LIMITED_API +PyAPI_FUNC(int) _PyDict_Contains(PyObject *mp, PyObject *key, Py_hash_t hash); +PyAPI_FUNC(PyObject *) _PyDict_NewPresized(Py_ssize_t minused); +PyAPI_FUNC(void) _PyDict_MaybeUntrack(PyObject *mp); +PyAPI_FUNC(int) _PyDict_HasOnlyStringKeys(PyObject *mp); +Py_ssize_t _PyDict_KeysSize(PyDictKeysObject *keys); +PyObject *_PyDict_SizeOf(PyDictObject *); +PyObject *_PyDict_Pop(PyDictObject *, PyObject *, PyObject *); +PyObject *_PyDict_FromKeys(PyObject *, PyObject *, PyObject *); +#define _PyDict_HasSplitTable(d) ((d)->ma_values != NULL) + +PyAPI_FUNC(int) PyDict_ClearFreeList(void); +#endif + +/* PyDict_Update(mp, other) is equivalent to PyDict_Merge(mp, other, 1). */ +PyAPI_FUNC(int) PyDict_Update(PyObject *mp, PyObject *other); + +/* PyDict_Merge updates/merges from a mapping object (an object that + supports PyMapping_Keys() and PyObject_GetItem()). If override is true, + the last occurrence of a key wins, else the first. The Python + dict.update(other) is equivalent to PyDict_Merge(dict, other, 1). +*/ +PyAPI_FUNC(int) PyDict_Merge(PyObject *mp, + PyObject *other, + int override); + +#ifndef Py_LIMITED_API +PyAPI_FUNC(PyObject *) _PyDictView_Intersect(PyObject* self, PyObject *other); +#endif + +/* PyDict_MergeFromSeq2 updates/merges from an iterable object producing + iterable objects of length 2. If override is true, the last occurrence + of a key wins, else the first. The Python dict constructor dict(seq2) + is equivalent to dict={}; PyDict_MergeFromSeq(dict, seq2, 1). +*/ +PyAPI_FUNC(int) PyDict_MergeFromSeq2(PyObject *d, + PyObject *seq2, + int override); + +PyAPI_FUNC(PyObject *) PyDict_GetItemString(PyObject *dp, const char *key); +PyAPI_FUNC(PyObject *) _PyDict_GetItemId(PyObject *dp, struct _Py_Identifier *key); +PyAPI_FUNC(int) PyDict_SetItemString(PyObject *dp, const char *key, PyObject *item); +PyAPI_FUNC(int) _PyDict_SetItemId(PyObject *dp, struct _Py_Identifier *key, PyObject *item); +PyAPI_FUNC(int) PyDict_DelItemString(PyObject *dp, const char *key); + +#ifndef Py_LIMITED_API +PyAPI_FUNC(int) _PyDict_DelItemId(PyObject *mp, struct _Py_Identifier *key); +PyAPI_FUNC(void) _PyDict_DebugMallocStats(FILE *out); + +int _PyObjectDict_SetItem(PyTypeObject *tp, PyObject **dictptr, PyObject *name, PyObject *value); +PyObject *_PyDict_LoadGlobal(PyDictObject *, PyDictObject *, PyObject *); +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_DICTOBJECT_H */ diff --git a/android/python35/include/dtoa.h b/android/python35/include/dtoa.h new file mode 100644 index 000000000..9bfb6251d --- /dev/null +++ b/android/python35/include/dtoa.h @@ -0,0 +1,19 @@ +#ifndef Py_LIMITED_API +#ifndef PY_NO_SHORT_FLOAT_REPR +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_FUNC(double) _Py_dg_strtod(const char *str, char **ptr); +PyAPI_FUNC(char *) _Py_dg_dtoa(double d, int mode, int ndigits, + int *decpt, int *sign, char **rve); +PyAPI_FUNC(void) _Py_dg_freedtoa(char *s); +PyAPI_FUNC(double) _Py_dg_stdnan(int sign); +PyAPI_FUNC(double) _Py_dg_infinity(int sign); + + +#ifdef __cplusplus +} +#endif +#endif +#endif diff --git a/android/python35/include/dynamic_annotations.h b/android/python35/include/dynamic_annotations.h new file mode 100644 index 000000000..0bd1a833c --- /dev/null +++ b/android/python35/include/dynamic_annotations.h @@ -0,0 +1,499 @@ +/* Copyright (c) 2008-2009, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * --- + * Author: Kostya Serebryany + * Copied to CPython by Jeffrey Yasskin, with all macros renamed to + * start with _Py_ to avoid colliding with users embedding Python, and + * with deprecated macros removed. + */ + +/* This file defines dynamic annotations for use with dynamic analysis + tool such as valgrind, PIN, etc. + + Dynamic annotation is a source code annotation that affects + the generated code (that is, the annotation is not a comment). + Each such annotation is attached to a particular + instruction and/or to a particular object (address) in the program. + + The annotations that should be used by users are macros in all upper-case + (e.g., _Py_ANNOTATE_NEW_MEMORY). + + Actual implementation of these macros may differ depending on the + dynamic analysis tool being used. + + See http://code.google.com/p/data-race-test/ for more information. + + This file supports the following dynamic analysis tools: + - None (DYNAMIC_ANNOTATIONS_ENABLED is not defined or zero). + Macros are defined empty. + - ThreadSanitizer, Helgrind, DRD (DYNAMIC_ANNOTATIONS_ENABLED is 1). + Macros are defined as calls to non-inlinable empty functions + that are intercepted by Valgrind. */ + +#ifndef __DYNAMIC_ANNOTATIONS_H__ +#define __DYNAMIC_ANNOTATIONS_H__ + +#ifndef DYNAMIC_ANNOTATIONS_ENABLED +# define DYNAMIC_ANNOTATIONS_ENABLED 0 +#endif + +#if DYNAMIC_ANNOTATIONS_ENABLED != 0 + + /* ------------------------------------------------------------- + Annotations useful when implementing condition variables such as CondVar, + using conditional critical sections (Await/LockWhen) and when constructing + user-defined synchronization mechanisms. + + The annotations _Py_ANNOTATE_HAPPENS_BEFORE() and + _Py_ANNOTATE_HAPPENS_AFTER() can be used to define happens-before arcs in + user-defined synchronization mechanisms: the race detector will infer an + arc from the former to the latter when they share the same argument + pointer. + + Example 1 (reference counting): + + void Unref() { + _Py_ANNOTATE_HAPPENS_BEFORE(&refcount_); + if (AtomicDecrementByOne(&refcount_) == 0) { + _Py_ANNOTATE_HAPPENS_AFTER(&refcount_); + delete this; + } + } + + Example 2 (message queue): + + void MyQueue::Put(Type *e) { + MutexLock lock(&mu_); + _Py_ANNOTATE_HAPPENS_BEFORE(e); + PutElementIntoMyQueue(e); + } + + Type *MyQueue::Get() { + MutexLock lock(&mu_); + Type *e = GetElementFromMyQueue(); + _Py_ANNOTATE_HAPPENS_AFTER(e); + return e; + } + + Note: when possible, please use the existing reference counting and message + queue implementations instead of inventing new ones. */ + + /* Report that wait on the condition variable at address "cv" has succeeded + and the lock at address "lock" is held. */ +#define _Py_ANNOTATE_CONDVAR_LOCK_WAIT(cv, lock) \ + AnnotateCondVarWait(__FILE__, __LINE__, cv, lock) + + /* Report that wait on the condition variable at "cv" has succeeded. Variant + w/o lock. */ +#define _Py_ANNOTATE_CONDVAR_WAIT(cv) \ + AnnotateCondVarWait(__FILE__, __LINE__, cv, NULL) + + /* Report that we are about to signal on the condition variable at address + "cv". */ +#define _Py_ANNOTATE_CONDVAR_SIGNAL(cv) \ + AnnotateCondVarSignal(__FILE__, __LINE__, cv) + + /* Report that we are about to signal_all on the condition variable at "cv". */ +#define _Py_ANNOTATE_CONDVAR_SIGNAL_ALL(cv) \ + AnnotateCondVarSignalAll(__FILE__, __LINE__, cv) + + /* Annotations for user-defined synchronization mechanisms. */ +#define _Py_ANNOTATE_HAPPENS_BEFORE(obj) _Py_ANNOTATE_CONDVAR_SIGNAL(obj) +#define _Py_ANNOTATE_HAPPENS_AFTER(obj) _Py_ANNOTATE_CONDVAR_WAIT(obj) + + /* Report that the bytes in the range [pointer, pointer+size) are about + to be published safely. The race checker will create a happens-before + arc from the call _Py_ANNOTATE_PUBLISH_MEMORY_RANGE(pointer, size) to + subsequent accesses to this memory. + Note: this annotation may not work properly if the race detector uses + sampling, i.e. does not observe all memory accesses. + */ +#define _Py_ANNOTATE_PUBLISH_MEMORY_RANGE(pointer, size) \ + AnnotatePublishMemoryRange(__FILE__, __LINE__, pointer, size) + + /* Instruct the tool to create a happens-before arc between mu->Unlock() and + mu->Lock(). This annotation may slow down the race detector and hide real + races. Normally it is used only when it would be difficult to annotate each + of the mutex's critical sections individually using the annotations above. + This annotation makes sense only for hybrid race detectors. For pure + happens-before detectors this is a no-op. For more details see + http://code.google.com/p/data-race-test/wiki/PureHappensBeforeVsHybrid . */ +#define _Py_ANNOTATE_PURE_HAPPENS_BEFORE_MUTEX(mu) \ + AnnotateMutexIsUsedAsCondVar(__FILE__, __LINE__, mu) + + /* ------------------------------------------------------------- + Annotations useful when defining memory allocators, or when memory that + was protected in one way starts to be protected in another. */ + + /* Report that a new memory at "address" of size "size" has been allocated. + This might be used when the memory has been retrieved from a free list and + is about to be reused, or when the locking discipline for a variable + changes. */ +#define _Py_ANNOTATE_NEW_MEMORY(address, size) \ + AnnotateNewMemory(__FILE__, __LINE__, address, size) + + /* ------------------------------------------------------------- + Annotations useful when defining FIFO queues that transfer data between + threads. */ + + /* Report that the producer-consumer queue (such as ProducerConsumerQueue) at + address "pcq" has been created. The _Py_ANNOTATE_PCQ_* annotations should + be used only for FIFO queues. For non-FIFO queues use + _Py_ANNOTATE_HAPPENS_BEFORE (for put) and _Py_ANNOTATE_HAPPENS_AFTER (for + get). */ +#define _Py_ANNOTATE_PCQ_CREATE(pcq) \ + AnnotatePCQCreate(__FILE__, __LINE__, pcq) + + /* Report that the queue at address "pcq" is about to be destroyed. */ +#define _Py_ANNOTATE_PCQ_DESTROY(pcq) \ + AnnotatePCQDestroy(__FILE__, __LINE__, pcq) + + /* Report that we are about to put an element into a FIFO queue at address + "pcq". */ +#define _Py_ANNOTATE_PCQ_PUT(pcq) \ + AnnotatePCQPut(__FILE__, __LINE__, pcq) + + /* Report that we've just got an element from a FIFO queue at address "pcq". */ +#define _Py_ANNOTATE_PCQ_GET(pcq) \ + AnnotatePCQGet(__FILE__, __LINE__, pcq) + + /* ------------------------------------------------------------- + Annotations that suppress errors. It is usually better to express the + program's synchronization using the other annotations, but these can + be used when all else fails. */ + + /* Report that we may have a benign race at "pointer", with size + "sizeof(*(pointer))". "pointer" must be a non-void* pointer. Insert at the + point where "pointer" has been allocated, preferably close to the point + where the race happens. See also _Py_ANNOTATE_BENIGN_RACE_STATIC. */ +#define _Py_ANNOTATE_BENIGN_RACE(pointer, description) \ + AnnotateBenignRaceSized(__FILE__, __LINE__, pointer, \ + sizeof(*(pointer)), description) + + /* Same as _Py_ANNOTATE_BENIGN_RACE(address, description), but applies to + the memory range [address, address+size). */ +#define _Py_ANNOTATE_BENIGN_RACE_SIZED(address, size, description) \ + AnnotateBenignRaceSized(__FILE__, __LINE__, address, size, description) + + /* Request the analysis tool to ignore all reads in the current thread + until _Py_ANNOTATE_IGNORE_READS_END is called. + Useful to ignore intentional racey reads, while still checking + other reads and all writes. + See also _Py_ANNOTATE_UNPROTECTED_READ. */ +#define _Py_ANNOTATE_IGNORE_READS_BEGIN() \ + AnnotateIgnoreReadsBegin(__FILE__, __LINE__) + + /* Stop ignoring reads. */ +#define _Py_ANNOTATE_IGNORE_READS_END() \ + AnnotateIgnoreReadsEnd(__FILE__, __LINE__) + + /* Similar to _Py_ANNOTATE_IGNORE_READS_BEGIN, but ignore writes. */ +#define _Py_ANNOTATE_IGNORE_WRITES_BEGIN() \ + AnnotateIgnoreWritesBegin(__FILE__, __LINE__) + + /* Stop ignoring writes. */ +#define _Py_ANNOTATE_IGNORE_WRITES_END() \ + AnnotateIgnoreWritesEnd(__FILE__, __LINE__) + + /* Start ignoring all memory accesses (reads and writes). */ +#define _Py_ANNOTATE_IGNORE_READS_AND_WRITES_BEGIN() \ + do {\ + _Py_ANNOTATE_IGNORE_READS_BEGIN();\ + _Py_ANNOTATE_IGNORE_WRITES_BEGIN();\ + }while(0)\ + + /* Stop ignoring all memory accesses. */ +#define _Py_ANNOTATE_IGNORE_READS_AND_WRITES_END() \ + do {\ + _Py_ANNOTATE_IGNORE_WRITES_END();\ + _Py_ANNOTATE_IGNORE_READS_END();\ + }while(0)\ + + /* Similar to _Py_ANNOTATE_IGNORE_READS_BEGIN, but ignore synchronization events: + RWLOCK* and CONDVAR*. */ +#define _Py_ANNOTATE_IGNORE_SYNC_BEGIN() \ + AnnotateIgnoreSyncBegin(__FILE__, __LINE__) + + /* Stop ignoring sync events. */ +#define _Py_ANNOTATE_IGNORE_SYNC_END() \ + AnnotateIgnoreSyncEnd(__FILE__, __LINE__) + + + /* Enable (enable!=0) or disable (enable==0) race detection for all threads. + This annotation could be useful if you want to skip expensive race analysis + during some period of program execution, e.g. during initialization. */ +#define _Py_ANNOTATE_ENABLE_RACE_DETECTION(enable) \ + AnnotateEnableRaceDetection(__FILE__, __LINE__, enable) + + /* ------------------------------------------------------------- + Annotations useful for debugging. */ + + /* Request to trace every access to "address". */ +#define _Py_ANNOTATE_TRACE_MEMORY(address) \ + AnnotateTraceMemory(__FILE__, __LINE__, address) + + /* Report the current thread name to a race detector. */ +#define _Py_ANNOTATE_THREAD_NAME(name) \ + AnnotateThreadName(__FILE__, __LINE__, name) + + /* ------------------------------------------------------------- + Annotations useful when implementing locks. They are not + normally needed by modules that merely use locks. + The "lock" argument is a pointer to the lock object. */ + + /* Report that a lock has been created at address "lock". */ +#define _Py_ANNOTATE_RWLOCK_CREATE(lock) \ + AnnotateRWLockCreate(__FILE__, __LINE__, lock) + + /* Report that the lock at address "lock" is about to be destroyed. */ +#define _Py_ANNOTATE_RWLOCK_DESTROY(lock) \ + AnnotateRWLockDestroy(__FILE__, __LINE__, lock) + + /* Report that the lock at address "lock" has been acquired. + is_w=1 for writer lock, is_w=0 for reader lock. */ +#define _Py_ANNOTATE_RWLOCK_ACQUIRED(lock, is_w) \ + AnnotateRWLockAcquired(__FILE__, __LINE__, lock, is_w) + + /* Report that the lock at address "lock" is about to be released. */ +#define _Py_ANNOTATE_RWLOCK_RELEASED(lock, is_w) \ + AnnotateRWLockReleased(__FILE__, __LINE__, lock, is_w) + + /* ------------------------------------------------------------- + Annotations useful when implementing barriers. They are not + normally needed by modules that merely use barriers. + The "barrier" argument is a pointer to the barrier object. */ + + /* Report that the "barrier" has been initialized with initial "count". + If 'reinitialization_allowed' is true, initialization is allowed to happen + multiple times w/o calling barrier_destroy() */ +#define _Py_ANNOTATE_BARRIER_INIT(barrier, count, reinitialization_allowed) \ + AnnotateBarrierInit(__FILE__, __LINE__, barrier, count, \ + reinitialization_allowed) + + /* Report that we are about to enter barrier_wait("barrier"). */ +#define _Py_ANNOTATE_BARRIER_WAIT_BEFORE(barrier) \ + AnnotateBarrierWaitBefore(__FILE__, __LINE__, barrier) + + /* Report that we just exited barrier_wait("barrier"). */ +#define _Py_ANNOTATE_BARRIER_WAIT_AFTER(barrier) \ + AnnotateBarrierWaitAfter(__FILE__, __LINE__, barrier) + + /* Report that the "barrier" has been destroyed. */ +#define _Py_ANNOTATE_BARRIER_DESTROY(barrier) \ + AnnotateBarrierDestroy(__FILE__, __LINE__, barrier) + + /* ------------------------------------------------------------- + Annotations useful for testing race detectors. */ + + /* Report that we expect a race on the variable at "address". + Use only in unit tests for a race detector. */ +#define _Py_ANNOTATE_EXPECT_RACE(address, description) \ + AnnotateExpectRace(__FILE__, __LINE__, address, description) + + /* A no-op. Insert where you like to test the interceptors. */ +#define _Py_ANNOTATE_NO_OP(arg) \ + AnnotateNoOp(__FILE__, __LINE__, arg) + + /* Force the race detector to flush its state. The actual effect depends on + * the implementation of the detector. */ +#define _Py_ANNOTATE_FLUSH_STATE() \ + AnnotateFlushState(__FILE__, __LINE__) + + +#else /* DYNAMIC_ANNOTATIONS_ENABLED == 0 */ + +#define _Py_ANNOTATE_RWLOCK_CREATE(lock) /* empty */ +#define _Py_ANNOTATE_RWLOCK_DESTROY(lock) /* empty */ +#define _Py_ANNOTATE_RWLOCK_ACQUIRED(lock, is_w) /* empty */ +#define _Py_ANNOTATE_RWLOCK_RELEASED(lock, is_w) /* empty */ +#define _Py_ANNOTATE_BARRIER_INIT(barrier, count, reinitialization_allowed) /* */ +#define _Py_ANNOTATE_BARRIER_WAIT_BEFORE(barrier) /* empty */ +#define _Py_ANNOTATE_BARRIER_WAIT_AFTER(barrier) /* empty */ +#define _Py_ANNOTATE_BARRIER_DESTROY(barrier) /* empty */ +#define _Py_ANNOTATE_CONDVAR_LOCK_WAIT(cv, lock) /* empty */ +#define _Py_ANNOTATE_CONDVAR_WAIT(cv) /* empty */ +#define _Py_ANNOTATE_CONDVAR_SIGNAL(cv) /* empty */ +#define _Py_ANNOTATE_CONDVAR_SIGNAL_ALL(cv) /* empty */ +#define _Py_ANNOTATE_HAPPENS_BEFORE(obj) /* empty */ +#define _Py_ANNOTATE_HAPPENS_AFTER(obj) /* empty */ +#define _Py_ANNOTATE_PUBLISH_MEMORY_RANGE(address, size) /* empty */ +#define _Py_ANNOTATE_UNPUBLISH_MEMORY_RANGE(address, size) /* empty */ +#define _Py_ANNOTATE_SWAP_MEMORY_RANGE(address, size) /* empty */ +#define _Py_ANNOTATE_PCQ_CREATE(pcq) /* empty */ +#define _Py_ANNOTATE_PCQ_DESTROY(pcq) /* empty */ +#define _Py_ANNOTATE_PCQ_PUT(pcq) /* empty */ +#define _Py_ANNOTATE_PCQ_GET(pcq) /* empty */ +#define _Py_ANNOTATE_NEW_MEMORY(address, size) /* empty */ +#define _Py_ANNOTATE_EXPECT_RACE(address, description) /* empty */ +#define _Py_ANNOTATE_BENIGN_RACE(address, description) /* empty */ +#define _Py_ANNOTATE_BENIGN_RACE_SIZED(address, size, description) /* empty */ +#define _Py_ANNOTATE_PURE_HAPPENS_BEFORE_MUTEX(mu) /* empty */ +#define _Py_ANNOTATE_MUTEX_IS_USED_AS_CONDVAR(mu) /* empty */ +#define _Py_ANNOTATE_TRACE_MEMORY(arg) /* empty */ +#define _Py_ANNOTATE_THREAD_NAME(name) /* empty */ +#define _Py_ANNOTATE_IGNORE_READS_BEGIN() /* empty */ +#define _Py_ANNOTATE_IGNORE_READS_END() /* empty */ +#define _Py_ANNOTATE_IGNORE_WRITES_BEGIN() /* empty */ +#define _Py_ANNOTATE_IGNORE_WRITES_END() /* empty */ +#define _Py_ANNOTATE_IGNORE_READS_AND_WRITES_BEGIN() /* empty */ +#define _Py_ANNOTATE_IGNORE_READS_AND_WRITES_END() /* empty */ +#define _Py_ANNOTATE_IGNORE_SYNC_BEGIN() /* empty */ +#define _Py_ANNOTATE_IGNORE_SYNC_END() /* empty */ +#define _Py_ANNOTATE_ENABLE_RACE_DETECTION(enable) /* empty */ +#define _Py_ANNOTATE_NO_OP(arg) /* empty */ +#define _Py_ANNOTATE_FLUSH_STATE() /* empty */ + +#endif /* DYNAMIC_ANNOTATIONS_ENABLED */ + +/* Use the macros above rather than using these functions directly. */ +#ifdef __cplusplus +extern "C" { +#endif +void AnnotateRWLockCreate(const char *file, int line, + const volatile void *lock); +void AnnotateRWLockDestroy(const char *file, int line, + const volatile void *lock); +void AnnotateRWLockAcquired(const char *file, int line, + const volatile void *lock, long is_w); +void AnnotateRWLockReleased(const char *file, int line, + const volatile void *lock, long is_w); +void AnnotateBarrierInit(const char *file, int line, + const volatile void *barrier, long count, + long reinitialization_allowed); +void AnnotateBarrierWaitBefore(const char *file, int line, + const volatile void *barrier); +void AnnotateBarrierWaitAfter(const char *file, int line, + const volatile void *barrier); +void AnnotateBarrierDestroy(const char *file, int line, + const volatile void *barrier); +void AnnotateCondVarWait(const char *file, int line, + const volatile void *cv, + const volatile void *lock); +void AnnotateCondVarSignal(const char *file, int line, + const volatile void *cv); +void AnnotateCondVarSignalAll(const char *file, int line, + const volatile void *cv); +void AnnotatePublishMemoryRange(const char *file, int line, + const volatile void *address, + long size); +void AnnotateUnpublishMemoryRange(const char *file, int line, + const volatile void *address, + long size); +void AnnotatePCQCreate(const char *file, int line, + const volatile void *pcq); +void AnnotatePCQDestroy(const char *file, int line, + const volatile void *pcq); +void AnnotatePCQPut(const char *file, int line, + const volatile void *pcq); +void AnnotatePCQGet(const char *file, int line, + const volatile void *pcq); +void AnnotateNewMemory(const char *file, int line, + const volatile void *address, + long size); +void AnnotateExpectRace(const char *file, int line, + const volatile void *address, + const char *description); +void AnnotateBenignRace(const char *file, int line, + const volatile void *address, + const char *description); +void AnnotateBenignRaceSized(const char *file, int line, + const volatile void *address, + long size, + const char *description); +void AnnotateMutexIsUsedAsCondVar(const char *file, int line, + const volatile void *mu); +void AnnotateTraceMemory(const char *file, int line, + const volatile void *arg); +void AnnotateThreadName(const char *file, int line, + const char *name); +void AnnotateIgnoreReadsBegin(const char *file, int line); +void AnnotateIgnoreReadsEnd(const char *file, int line); +void AnnotateIgnoreWritesBegin(const char *file, int line); +void AnnotateIgnoreWritesEnd(const char *file, int line); +void AnnotateEnableRaceDetection(const char *file, int line, int enable); +void AnnotateNoOp(const char *file, int line, + const volatile void *arg); +void AnnotateFlushState(const char *file, int line); + +/* Return non-zero value if running under valgrind. + + If "valgrind.h" is included into dynamic_annotations.c, + the regular valgrind mechanism will be used. + See http://valgrind.org/docs/manual/manual-core-adv.html about + RUNNING_ON_VALGRIND and other valgrind "client requests". + The file "valgrind.h" may be obtained by doing + svn co svn://svn.valgrind.org/valgrind/trunk/include + + If for some reason you can't use "valgrind.h" or want to fake valgrind, + there are two ways to make this function return non-zero: + - Use environment variable: export RUNNING_ON_VALGRIND=1 + - Make your tool intercept the function RunningOnValgrind() and + change its return value. + */ +int RunningOnValgrind(void); + +#ifdef __cplusplus +} +#endif + +#if DYNAMIC_ANNOTATIONS_ENABLED != 0 && defined(__cplusplus) + + /* _Py_ANNOTATE_UNPROTECTED_READ is the preferred way to annotate racey reads. + + Instead of doing + _Py_ANNOTATE_IGNORE_READS_BEGIN(); + ... = x; + _Py_ANNOTATE_IGNORE_READS_END(); + one can use + ... = _Py_ANNOTATE_UNPROTECTED_READ(x); */ + template + inline T _Py_ANNOTATE_UNPROTECTED_READ(const volatile T &x) { + _Py_ANNOTATE_IGNORE_READS_BEGIN(); + T res = x; + _Py_ANNOTATE_IGNORE_READS_END(); + return res; + } + /* Apply _Py_ANNOTATE_BENIGN_RACE_SIZED to a static variable. */ +#define _Py_ANNOTATE_BENIGN_RACE_STATIC(static_var, description) \ + namespace { \ + class static_var ## _annotator { \ + public: \ + static_var ## _annotator() { \ + _Py_ANNOTATE_BENIGN_RACE_SIZED(&static_var, \ + sizeof(static_var), \ + # static_var ": " description); \ + } \ + }; \ + static static_var ## _annotator the ## static_var ## _annotator;\ + } +#else /* DYNAMIC_ANNOTATIONS_ENABLED == 0 */ + +#define _Py_ANNOTATE_UNPROTECTED_READ(x) (x) +#define _Py_ANNOTATE_BENIGN_RACE_STATIC(static_var, description) /* empty */ + +#endif /* DYNAMIC_ANNOTATIONS_ENABLED */ + +#endif /* __DYNAMIC_ANNOTATIONS_H__ */ diff --git a/android/python35/include/enumobject.h b/android/python35/include/enumobject.h new file mode 100644 index 000000000..c14dbfc8c --- /dev/null +++ b/android/python35/include/enumobject.h @@ -0,0 +1,17 @@ +#ifndef Py_ENUMOBJECT_H +#define Py_ENUMOBJECT_H + +/* Enumerate Object */ + +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_DATA(PyTypeObject) PyEnum_Type; +PyAPI_DATA(PyTypeObject) PyReversed_Type; + +#ifdef __cplusplus +} +#endif + +#endif /* !Py_ENUMOBJECT_H */ diff --git a/android/python35/include/errcode.h b/android/python35/include/errcode.h new file mode 100644 index 000000000..5946686c6 --- /dev/null +++ b/android/python35/include/errcode.h @@ -0,0 +1,38 @@ +#ifndef Py_ERRCODE_H +#define Py_ERRCODE_H +#ifdef __cplusplus +extern "C" { +#endif + + +/* Error codes passed around between file input, tokenizer, parser and + interpreter. This is necessary so we can turn them into Python + exceptions at a higher level. Note that some errors have a + slightly different meaning when passed from the tokenizer to the + parser than when passed from the parser to the interpreter; e.g. + the parser only returns E_EOF when it hits EOF immediately, and it + never returns E_OK. */ + +#define E_OK 10 /* No error */ +#define E_EOF 11 /* End Of File */ +#define E_INTR 12 /* Interrupted */ +#define E_TOKEN 13 /* Bad token */ +#define E_SYNTAX 14 /* Syntax error */ +#define E_NOMEM 15 /* Ran out of memory */ +#define E_DONE 16 /* Parsing complete */ +#define E_ERROR 17 /* Execution error */ +#define E_TABSPACE 18 /* Inconsistent mixing of tabs and spaces */ +#define E_OVERFLOW 19 /* Node had too many children */ +#define E_TOODEEP 20 /* Too many indentation levels */ +#define E_DEDENT 21 /* No matching outer block for dedent */ +#define E_DECODE 22 /* Error in decoding into Unicode */ +#define E_EOFS 23 /* EOF in triple-quoted string */ +#define E_EOLS 24 /* EOL in single-quoted string */ +#define E_LINECONT 25 /* Unexpected characters after a line continuation */ +#define E_IDENTIFIER 26 /* Invalid characters in identifier */ +#define E_BADSINGLE 27 /* Ill-formed single statement input */ + +#ifdef __cplusplus +} +#endif +#endif /* !Py_ERRCODE_H */ diff --git a/android/python35/include/eval.h b/android/python35/include/eval.h new file mode 100644 index 000000000..a1c6e817d --- /dev/null +++ b/android/python35/include/eval.h @@ -0,0 +1,27 @@ + +/* Interface to execute compiled code */ + +#ifndef Py_EVAL_H +#define Py_EVAL_H +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_FUNC(PyObject *) PyEval_EvalCode(PyObject *, PyObject *, PyObject *); + +PyAPI_FUNC(PyObject *) PyEval_EvalCodeEx(PyObject *co, + PyObject *globals, + PyObject *locals, + PyObject **args, int argc, + PyObject **kwds, int kwdc, + PyObject **defs, int defc, + PyObject *kwdefs, PyObject *closure); + +#ifndef Py_LIMITED_API +PyAPI_FUNC(PyObject *) _PyEval_CallTracing(PyObject *func, PyObject *args); +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_EVAL_H */ diff --git a/android/python35/include/fileobject.h b/android/python35/include/fileobject.h new file mode 100644 index 000000000..03155d3da --- /dev/null +++ b/android/python35/include/fileobject.h @@ -0,0 +1,47 @@ +/* File object interface (what's left of it -- see io.py) */ + +#ifndef Py_FILEOBJECT_H +#define Py_FILEOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +#define PY_STDIOTEXTMODE "b" + +PyAPI_FUNC(PyObject *) PyFile_FromFd(int, const char *, const char *, int, + const char *, const char *, + const char *, int); +PyAPI_FUNC(PyObject *) PyFile_GetLine(PyObject *, int); +PyAPI_FUNC(int) PyFile_WriteObject(PyObject *, PyObject *, int); +PyAPI_FUNC(int) PyFile_WriteString(const char *, PyObject *); +PyAPI_FUNC(int) PyObject_AsFileDescriptor(PyObject *); +#ifndef Py_LIMITED_API +PyAPI_FUNC(char *) Py_UniversalNewlineFgets(char *, int, FILE*, PyObject *); +#endif + +/* The default encoding used by the platform file system APIs + If non-NULL, this is different than the default encoding for strings +*/ +PyAPI_DATA(const char *) Py_FileSystemDefaultEncoding; +PyAPI_DATA(int) Py_HasFileSystemDefaultEncoding; + +/* Internal API + + The std printer acts as a preliminary sys.stderr until the new io + infrastructure is in place. */ +#ifndef Py_LIMITED_API +PyAPI_FUNC(PyObject *) PyFile_NewStdPrinter(int); +PyAPI_DATA(PyTypeObject) PyStdPrinter_Type; +#endif /* Py_LIMITED_API */ + +/* A routine to check if a file descriptor can be select()-ed. */ +#ifdef HAVE_SELECT + #define _PyIsSelectable_fd(FD) (((FD) >= 0) && ((FD) < FD_SETSIZE)) +#else + #define _PyIsSelectable_fd(FD) (1) +#endif /* HAVE_SELECT */ + +#ifdef __cplusplus +} +#endif +#endif /* !Py_FILEOBJECT_H */ diff --git a/android/python35/include/fileutils.h b/android/python35/include/fileutils.h new file mode 100644 index 000000000..b4a683c17 --- /dev/null +++ b/android/python35/include/fileutils.h @@ -0,0 +1,142 @@ +#ifndef Py_FILEUTILS_H +#define Py_FILEUTILS_H + +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_FUNC(PyObject *) _Py_device_encoding(int); + +PyAPI_FUNC(wchar_t *) Py_DecodeLocale( + const char *arg, + size_t *size); + +PyAPI_FUNC(char*) Py_EncodeLocale( + const wchar_t *text, + size_t *error_pos); + +#ifndef Py_LIMITED_API + +#ifdef MS_WINDOWS +struct _Py_stat_struct { + unsigned long st_dev; + __int64 st_ino; + unsigned short st_mode; + int st_nlink; + int st_uid; + int st_gid; + unsigned long st_rdev; + __int64 st_size; + time_t st_atime; + int st_atime_nsec; + time_t st_mtime; + int st_mtime_nsec; + time_t st_ctime; + int st_ctime_nsec; + unsigned long st_file_attributes; +}; +#else +# define _Py_stat_struct stat +#endif + +PyAPI_FUNC(int) _Py_fstat( + int fd, + struct _Py_stat_struct *status); + +PyAPI_FUNC(int) _Py_fstat_noraise( + int fd, + struct _Py_stat_struct *status); +#endif /* Py_LIMITED_API */ + +PyAPI_FUNC(int) _Py_stat( + PyObject *path, + struct stat *status); + +#ifndef Py_LIMITED_API +PyAPI_FUNC(int) _Py_open( + const char *pathname, + int flags); + +PyAPI_FUNC(int) _Py_open_noraise( + const char *pathname, + int flags); +#endif + +PyAPI_FUNC(FILE *) _Py_wfopen( + const wchar_t *path, + const wchar_t *mode); + +PyAPI_FUNC(FILE*) _Py_fopen( + const char *pathname, + const char *mode); + +PyAPI_FUNC(FILE*) _Py_fopen_obj( + PyObject *path, + const char *mode); + +PyAPI_FUNC(Py_ssize_t) _Py_read( + int fd, + void *buf, + size_t count); + +PyAPI_FUNC(Py_ssize_t) _Py_write( + int fd, + const void *buf, + size_t count); + +PyAPI_FUNC(Py_ssize_t) _Py_write_noraise( + int fd, + const void *buf, + size_t count); + +#ifdef HAVE_READLINK +PyAPI_FUNC(int) _Py_wreadlink( + const wchar_t *path, + wchar_t *buf, + size_t bufsiz); +#endif + +#ifdef HAVE_REALPATH +PyAPI_FUNC(wchar_t*) _Py_wrealpath( + const wchar_t *path, + wchar_t *resolved_path, + size_t resolved_path_size); +#endif + +PyAPI_FUNC(wchar_t*) _Py_wgetcwd( + wchar_t *buf, + size_t size); + +#ifndef Py_LIMITED_API +PyAPI_FUNC(int) _Py_get_inheritable(int fd); + +PyAPI_FUNC(int) _Py_set_inheritable(int fd, int inheritable, + int *atomic_flag_works); + +PyAPI_FUNC(int) _Py_dup(int fd); + +#ifndef MS_WINDOWS +PyAPI_FUNC(int) _Py_get_blocking(int fd); + +PyAPI_FUNC(int) _Py_set_blocking(int fd, int blocking); +#endif /* !MS_WINDOWS */ + +#if defined _MSC_VER && _MSC_VER >= 1400 && _MSC_VER < 1900 +/* A routine to check if a file descriptor is valid on Windows. Returns 0 + * and sets errno to EBADF if it isn't. This is to avoid Assertions + * from various functions in the Windows CRT beginning with + * Visual Studio 2005 + */ +int _PyVerify_fd(int fd); + +#else +#define _PyVerify_fd(A) (1) /* dummy */ +#endif + +#endif /* Py_LIMITED_API */ + +#ifdef __cplusplus +} +#endif + +#endif /* !Py_FILEUTILS_H */ diff --git a/android/python35/include/floatobject.h b/android/python35/include/floatobject.h new file mode 100644 index 000000000..e240fdb8f --- /dev/null +++ b/android/python35/include/floatobject.h @@ -0,0 +1,128 @@ + +/* Float object interface */ + +/* +PyFloatObject represents a (double precision) floating point number. +*/ + +#ifndef Py_FLOATOBJECT_H +#define Py_FLOATOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_LIMITED_API +typedef struct { + PyObject_HEAD + double ob_fval; +} PyFloatObject; +#endif + +PyAPI_DATA(PyTypeObject) PyFloat_Type; + +#define PyFloat_Check(op) PyObject_TypeCheck(op, &PyFloat_Type) +#define PyFloat_CheckExact(op) (Py_TYPE(op) == &PyFloat_Type) + +#ifdef Py_NAN +#define Py_RETURN_NAN return PyFloat_FromDouble(Py_NAN) +#endif + +#define Py_RETURN_INF(sign) do \ + if (copysign(1., sign) == 1.) { \ + return PyFloat_FromDouble(Py_HUGE_VAL); \ + } else { \ + return PyFloat_FromDouble(-Py_HUGE_VAL); \ + } while(0) + +PyAPI_FUNC(double) PyFloat_GetMax(void); +PyAPI_FUNC(double) PyFloat_GetMin(void); +PyAPI_FUNC(PyObject *) PyFloat_GetInfo(void); + +/* Return Python float from string PyObject. */ +PyAPI_FUNC(PyObject *) PyFloat_FromString(PyObject*); + +/* Return Python float from C double. */ +PyAPI_FUNC(PyObject *) PyFloat_FromDouble(double); + +/* Extract C double from Python float. The macro version trades safety for + speed. */ +PyAPI_FUNC(double) PyFloat_AsDouble(PyObject *); +#ifndef Py_LIMITED_API +#define PyFloat_AS_DOUBLE(op) (((PyFloatObject *)(op))->ob_fval) +#endif + +#ifndef Py_LIMITED_API +/* _PyFloat_{Pack,Unpack}{4,8} + * + * The struct and pickle (at least) modules need an efficient platform- + * independent way to store floating-point values as byte strings. + * The Pack routines produce a string from a C double, and the Unpack + * routines produce a C double from such a string. The suffix (4 or 8) + * specifies the number of bytes in the string. + * + * On platforms that appear to use (see _PyFloat_Init()) IEEE-754 formats + * these functions work by copying bits. On other platforms, the formats the + * 4- byte format is identical to the IEEE-754 single precision format, and + * the 8-byte format to the IEEE-754 double precision format, although the + * packing of INFs and NaNs (if such things exist on the platform) isn't + * handled correctly, and attempting to unpack a string containing an IEEE + * INF or NaN will raise an exception. + * + * On non-IEEE platforms with more precision, or larger dynamic range, than + * 754 supports, not all values can be packed; on non-IEEE platforms with less + * precision, or smaller dynamic range, not all values can be unpacked. What + * happens in such cases is partly accidental (alas). + */ + +/* The pack routines write 4 or 8 bytes, starting at p. le is a bool + * argument, true if you want the string in little-endian format (exponent + * last, at p+3 or p+7), false if you want big-endian format (exponent + * first, at p). + * Return value: 0 if all is OK, -1 if error (and an exception is + * set, most likely OverflowError). + * There are two problems on non-IEEE platforms: + * 1): What this does is undefined if x is a NaN or infinity. + * 2): -0.0 and +0.0 produce the same string. + */ +PyAPI_FUNC(int) _PyFloat_Pack4(double x, unsigned char *p, int le); +PyAPI_FUNC(int) _PyFloat_Pack8(double x, unsigned char *p, int le); + +/* Needed for the old way for marshal to store a floating point number. + Returns the string length copied into p, -1 on error. + */ +PyAPI_FUNC(int) _PyFloat_Repr(double x, char *p, size_t len); + +/* Used to get the important decimal digits of a double */ +PyAPI_FUNC(int) _PyFloat_Digits(char *buf, double v, int *signum); +PyAPI_FUNC(void) _PyFloat_DigitsInit(void); + +/* The unpack routines read 4 or 8 bytes, starting at p. le is a bool + * argument, true if the string is in little-endian format (exponent + * last, at p+3 or p+7), false if big-endian (exponent first, at p). + * Return value: The unpacked double. On error, this is -1.0 and + * PyErr_Occurred() is true (and an exception is set, most likely + * OverflowError). Note that on a non-IEEE platform this will refuse + * to unpack a string that represents a NaN or infinity. + */ +PyAPI_FUNC(double) _PyFloat_Unpack4(const unsigned char *p, int le); +PyAPI_FUNC(double) _PyFloat_Unpack8(const unsigned char *p, int le); + +/* free list api */ +PyAPI_FUNC(int) PyFloat_ClearFreeList(void); + +PyAPI_FUNC(void) _PyFloat_DebugMallocStats(FILE* out); + +/* Format the object based on the format_spec, as defined in PEP 3101 + (Advanced String Formatting). */ +PyAPI_FUNC(int) _PyFloat_FormatAdvancedWriter( + _PyUnicodeWriter *writer, + PyObject *obj, + PyObject *format_spec, + Py_ssize_t start, + Py_ssize_t end); +#endif /* Py_LIMITED_API */ + +#ifdef __cplusplus +} +#endif +#endif /* !Py_FLOATOBJECT_H */ diff --git a/android/python35/include/frameobject.h b/android/python35/include/frameobject.h new file mode 100644 index 000000000..966ff1f6e --- /dev/null +++ b/android/python35/include/frameobject.h @@ -0,0 +1,95 @@ + +/* Frame object interface */ + +#ifndef Py_LIMITED_API +#ifndef Py_FRAMEOBJECT_H +#define Py_FRAMEOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + int b_type; /* what kind of block this is */ + int b_handler; /* where to jump to find handler */ + int b_level; /* value stack level to pop to */ +} PyTryBlock; + +typedef struct _frame { + PyObject_VAR_HEAD + struct _frame *f_back; /* previous frame, or NULL */ + PyCodeObject *f_code; /* code segment */ + PyObject *f_builtins; /* builtin symbol table (PyDictObject) */ + PyObject *f_globals; /* global symbol table (PyDictObject) */ + PyObject *f_locals; /* local symbol table (any mapping) */ + PyObject **f_valuestack; /* points after the last local */ + /* Next free slot in f_valuestack. Frame creation sets to f_valuestack. + Frame evaluation usually NULLs it, but a frame that yields sets it + to the current stack top. */ + PyObject **f_stacktop; + PyObject *f_trace; /* Trace function */ + + /* In a generator, we need to be able to swap between the exception + state inside the generator and the exception state of the calling + frame (which shouldn't be impacted when the generator "yields" + from an except handler). + These three fields exist exactly for that, and are unused for + non-generator frames. See the save_exc_state and swap_exc_state + functions in ceval.c for details of their use. */ + PyObject *f_exc_type, *f_exc_value, *f_exc_traceback; + /* Borrowed reference to a generator, or NULL */ + PyObject *f_gen; + + int f_lasti; /* Last instruction if called */ + /* Call PyFrame_GetLineNumber() instead of reading this field + directly. As of 2.3 f_lineno is only valid when tracing is + active (i.e. when f_trace is set). At other times we use + PyCode_Addr2Line to calculate the line from the current + bytecode index. */ + int f_lineno; /* Current line number */ + int f_iblock; /* index in f_blockstack */ + char f_executing; /* whether the frame is still executing */ + PyTryBlock f_blockstack[CO_MAXBLOCKS]; /* for try and loop blocks */ + PyObject *f_localsplus[1]; /* locals+stack, dynamically sized */ +} PyFrameObject; + + +/* Standard object interface */ + +PyAPI_DATA(PyTypeObject) PyFrame_Type; + +#define PyFrame_Check(op) (Py_TYPE(op) == &PyFrame_Type) + +PyAPI_FUNC(PyFrameObject *) PyFrame_New(PyThreadState *, PyCodeObject *, + PyObject *, PyObject *); + + +/* The rest of the interface is specific for frame objects */ + +/* Block management functions */ + +PyAPI_FUNC(void) PyFrame_BlockSetup(PyFrameObject *, int, int, int); +PyAPI_FUNC(PyTryBlock *) PyFrame_BlockPop(PyFrameObject *); + +/* Extend the value stack */ + +PyAPI_FUNC(PyObject **) PyFrame_ExtendStack(PyFrameObject *, int, int); + +/* Conversions between "fast locals" and locals in dictionary */ + +PyAPI_FUNC(void) PyFrame_LocalsToFast(PyFrameObject *, int); + +PyAPI_FUNC(int) PyFrame_FastToLocalsWithError(PyFrameObject *f); +PyAPI_FUNC(void) PyFrame_FastToLocals(PyFrameObject *); + +PyAPI_FUNC(int) PyFrame_ClearFreeList(void); + +PyAPI_FUNC(void) _PyFrame_DebugMallocStats(FILE *out); + +/* Return the line of code the frame is currently executing. */ +PyAPI_FUNC(int) PyFrame_GetLineNumber(PyFrameObject *); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_FRAMEOBJECT_H */ +#endif /* Py_LIMITED_API */ diff --git a/android/python35/include/funcobject.h b/android/python35/include/funcobject.h new file mode 100644 index 000000000..cc1426cdc --- /dev/null +++ b/android/python35/include/funcobject.h @@ -0,0 +1,89 @@ + +/* Function object interface */ +#ifndef Py_LIMITED_API +#ifndef Py_FUNCOBJECT_H +#define Py_FUNCOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +/* Function objects and code objects should not be confused with each other: + * + * Function objects are created by the execution of the 'def' statement. + * They reference a code object in their __code__ attribute, which is a + * purely syntactic object, i.e. nothing more than a compiled version of some + * source code lines. There is one code object per source code "fragment", + * but each code object can be referenced by zero or many function objects + * depending only on how many times the 'def' statement in the source was + * executed so far. + */ + +typedef struct { + PyObject_HEAD + PyObject *func_code; /* A code object, the __code__ attribute */ + PyObject *func_globals; /* A dictionary (other mappings won't do) */ + PyObject *func_defaults; /* NULL or a tuple */ + PyObject *func_kwdefaults; /* NULL or a dict */ + PyObject *func_closure; /* NULL or a tuple of cell objects */ + PyObject *func_doc; /* The __doc__ attribute, can be anything */ + PyObject *func_name; /* The __name__ attribute, a string object */ + PyObject *func_dict; /* The __dict__ attribute, a dict or NULL */ + PyObject *func_weakreflist; /* List of weak references */ + PyObject *func_module; /* The __module__ attribute, can be anything */ + PyObject *func_annotations; /* Annotations, a dict or NULL */ + PyObject *func_qualname; /* The qualified name */ + + /* Invariant: + * func_closure contains the bindings for func_code->co_freevars, so + * PyTuple_Size(func_closure) == PyCode_GetNumFree(func_code) + * (func_closure may be NULL if PyCode_GetNumFree(func_code) == 0). + */ +} PyFunctionObject; + +PyAPI_DATA(PyTypeObject) PyFunction_Type; + +#define PyFunction_Check(op) (Py_TYPE(op) == &PyFunction_Type) + +PyAPI_FUNC(PyObject *) PyFunction_New(PyObject *, PyObject *); +PyAPI_FUNC(PyObject *) PyFunction_NewWithQualName(PyObject *, PyObject *, PyObject *); +PyAPI_FUNC(PyObject *) PyFunction_GetCode(PyObject *); +PyAPI_FUNC(PyObject *) PyFunction_GetGlobals(PyObject *); +PyAPI_FUNC(PyObject *) PyFunction_GetModule(PyObject *); +PyAPI_FUNC(PyObject *) PyFunction_GetDefaults(PyObject *); +PyAPI_FUNC(int) PyFunction_SetDefaults(PyObject *, PyObject *); +PyAPI_FUNC(PyObject *) PyFunction_GetKwDefaults(PyObject *); +PyAPI_FUNC(int) PyFunction_SetKwDefaults(PyObject *, PyObject *); +PyAPI_FUNC(PyObject *) PyFunction_GetClosure(PyObject *); +PyAPI_FUNC(int) PyFunction_SetClosure(PyObject *, PyObject *); +PyAPI_FUNC(PyObject *) PyFunction_GetAnnotations(PyObject *); +PyAPI_FUNC(int) PyFunction_SetAnnotations(PyObject *, PyObject *); + +/* Macros for direct access to these values. Type checks are *not* + done, so use with care. */ +#define PyFunction_GET_CODE(func) \ + (((PyFunctionObject *)func) -> func_code) +#define PyFunction_GET_GLOBALS(func) \ + (((PyFunctionObject *)func) -> func_globals) +#define PyFunction_GET_MODULE(func) \ + (((PyFunctionObject *)func) -> func_module) +#define PyFunction_GET_DEFAULTS(func) \ + (((PyFunctionObject *)func) -> func_defaults) +#define PyFunction_GET_KW_DEFAULTS(func) \ + (((PyFunctionObject *)func) -> func_kwdefaults) +#define PyFunction_GET_CLOSURE(func) \ + (((PyFunctionObject *)func) -> func_closure) +#define PyFunction_GET_ANNOTATIONS(func) \ + (((PyFunctionObject *)func) -> func_annotations) + +/* The classmethod and staticmethod types lives here, too */ +PyAPI_DATA(PyTypeObject) PyClassMethod_Type; +PyAPI_DATA(PyTypeObject) PyStaticMethod_Type; + +PyAPI_FUNC(PyObject *) PyClassMethod_New(PyObject *); +PyAPI_FUNC(PyObject *) PyStaticMethod_New(PyObject *); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_FUNCOBJECT_H */ +#endif /* Py_LIMITED_API */ diff --git a/android/python35/include/genobject.h b/android/python35/include/genobject.h new file mode 100644 index 000000000..4c7186172 --- /dev/null +++ b/android/python35/include/genobject.h @@ -0,0 +1,68 @@ + +/* Generator object interface */ + +#ifndef Py_LIMITED_API +#ifndef Py_GENOBJECT_H +#define Py_GENOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +struct _frame; /* Avoid including frameobject.h */ + +/* _PyGenObject_HEAD defines the initial segment of generator + and coroutine objects. */ +#define _PyGenObject_HEAD(prefix) \ + PyObject_HEAD \ + /* Note: gi_frame can be NULL if the generator is "finished" */ \ + struct _frame *prefix##_frame; \ + /* True if generator is being executed. */ \ + char prefix##_running; \ + /* The code object backing the generator */ \ + PyObject *prefix##_code; \ + /* List of weak reference. */ \ + PyObject *prefix##_weakreflist; \ + /* Name of the generator. */ \ + PyObject *prefix##_name; \ + /* Qualified name of the generator. */ \ + PyObject *prefix##_qualname; + +typedef struct { + /* The gi_ prefix is intended to remind of generator-iterator. */ + _PyGenObject_HEAD(gi) +} PyGenObject; + +PyAPI_DATA(PyTypeObject) PyGen_Type; + +#define PyGen_Check(op) PyObject_TypeCheck(op, &PyGen_Type) +#define PyGen_CheckExact(op) (Py_TYPE(op) == &PyGen_Type) + +PyAPI_FUNC(PyObject *) PyGen_New(struct _frame *); +PyAPI_FUNC(PyObject *) PyGen_NewWithQualName(struct _frame *, + PyObject *name, PyObject *qualname); +PyAPI_FUNC(int) PyGen_NeedsFinalizing(PyGenObject *); +PyAPI_FUNC(int) _PyGen_FetchStopIterationValue(PyObject **); +PyObject *_PyGen_Send(PyGenObject *, PyObject *); +PyAPI_FUNC(void) _PyGen_Finalize(PyObject *self); + +#ifndef Py_LIMITED_API +typedef struct { + _PyGenObject_HEAD(cr) +} PyCoroObject; + +PyAPI_DATA(PyTypeObject) PyCoro_Type; +PyAPI_DATA(PyTypeObject) _PyCoroWrapper_Type; + +#define PyCoro_CheckExact(op) (Py_TYPE(op) == &PyCoro_Type) +PyObject *_PyCoro_GetAwaitableIter(PyObject *o); +PyAPI_FUNC(PyObject *) PyCoro_New(struct _frame *, + PyObject *name, PyObject *qualname); +#endif + +#undef _PyGenObject_HEAD + +#ifdef __cplusplus +} +#endif +#endif /* !Py_GENOBJECT_H */ +#endif /* Py_LIMITED_API */ diff --git a/android/python35/include/graminit.h b/android/python35/include/graminit.h new file mode 100644 index 000000000..d030bc3d2 --- /dev/null +++ b/android/python35/include/graminit.h @@ -0,0 +1,87 @@ +/* Generated by Parser/pgen */ + +#define single_input 256 +#define file_input 257 +#define eval_input 258 +#define decorator 259 +#define decorators 260 +#define decorated 261 +#define async_funcdef 262 +#define funcdef 263 +#define parameters 264 +#define typedargslist 265 +#define tfpdef 266 +#define varargslist 267 +#define vfpdef 268 +#define stmt 269 +#define simple_stmt 270 +#define small_stmt 271 +#define expr_stmt 272 +#define testlist_star_expr 273 +#define augassign 274 +#define del_stmt 275 +#define pass_stmt 276 +#define flow_stmt 277 +#define break_stmt 278 +#define continue_stmt 279 +#define return_stmt 280 +#define yield_stmt 281 +#define raise_stmt 282 +#define import_stmt 283 +#define import_name 284 +#define import_from 285 +#define import_as_name 286 +#define dotted_as_name 287 +#define import_as_names 288 +#define dotted_as_names 289 +#define dotted_name 290 +#define global_stmt 291 +#define nonlocal_stmt 292 +#define assert_stmt 293 +#define compound_stmt 294 +#define async_stmt 295 +#define if_stmt 296 +#define while_stmt 297 +#define for_stmt 298 +#define try_stmt 299 +#define with_stmt 300 +#define with_item 301 +#define except_clause 302 +#define suite 303 +#define test 304 +#define test_nocond 305 +#define lambdef 306 +#define lambdef_nocond 307 +#define or_test 308 +#define and_test 309 +#define not_test 310 +#define comparison 311 +#define comp_op 312 +#define star_expr 313 +#define expr 314 +#define xor_expr 315 +#define and_expr 316 +#define shift_expr 317 +#define arith_expr 318 +#define term 319 +#define factor 320 +#define power 321 +#define atom_expr 322 +#define atom 323 +#define testlist_comp 324 +#define trailer 325 +#define subscriptlist 326 +#define subscript 327 +#define sliceop 328 +#define exprlist 329 +#define testlist 330 +#define dictorsetmaker 331 +#define classdef 332 +#define arglist 333 +#define argument 334 +#define comp_iter 335 +#define comp_for 336 +#define comp_if 337 +#define encoding_decl 338 +#define yield_expr 339 +#define yield_arg 340 diff --git a/android/python35/include/grammar.h b/android/python35/include/grammar.h new file mode 100644 index 000000000..85120b9be --- /dev/null +++ b/android/python35/include/grammar.h @@ -0,0 +1,93 @@ + +/* Grammar interface */ + +#ifndef Py_GRAMMAR_H +#define Py_GRAMMAR_H +#ifdef __cplusplus +extern "C" { +#endif + +#include "bitset.h" /* Sigh... */ + +/* A label of an arc */ + +typedef struct { + int lb_type; + char *lb_str; +} label; + +#define EMPTY 0 /* Label number 0 is by definition the empty label */ + +/* A list of labels */ + +typedef struct { + int ll_nlabels; + label *ll_label; +} labellist; + +/* An arc from one state to another */ + +typedef struct { + short a_lbl; /* Label of this arc */ + short a_arrow; /* State where this arc goes to */ +} arc; + +/* A state in a DFA */ + +typedef struct { + int s_narcs; + arc *s_arc; /* Array of arcs */ + + /* Optional accelerators */ + int s_lower; /* Lowest label index */ + int s_upper; /* Highest label index */ + int *s_accel; /* Accelerator */ + int s_accept; /* Nonzero for accepting state */ +} state; + +/* A DFA */ + +typedef struct { + int d_type; /* Non-terminal this represents */ + char *d_name; /* For printing */ + int d_initial; /* Initial state */ + int d_nstates; + state *d_state; /* Array of states */ + bitset d_first; +} dfa; + +/* A grammar */ + +typedef struct { + int g_ndfas; + dfa *g_dfa; /* Array of DFAs */ + labellist g_ll; + int g_start; /* Start symbol of the grammar */ + int g_accel; /* Set if accelerators present */ +} grammar; + +/* FUNCTIONS */ + +grammar *newgrammar(int start); +dfa *adddfa(grammar *g, int type, const char *name); +int addstate(dfa *d); +void addarc(dfa *d, int from, int to, int lbl); +dfa *PyGrammar_FindDFA(grammar *g, int type); + +int addlabel(labellist *ll, int type, const char *str); +int findlabel(labellist *ll, int type, const char *str); +const char *PyGrammar_LabelRepr(label *lb); +void translatelabels(grammar *g); + +void addfirstsets(grammar *g); + +void PyGrammar_AddAccelerators(grammar *g); +void PyGrammar_RemoveAccelerators(grammar *); + +void printgrammar(grammar *g, FILE *fp); +void printnonterminals(grammar *g, FILE *fp); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_GRAMMAR_H */ diff --git a/android/python35/include/import.h b/android/python35/include/import.h new file mode 100644 index 000000000..afdfac2a9 --- /dev/null +++ b/android/python35/include/import.h @@ -0,0 +1,130 @@ + +/* Module definition and import interface */ + +#ifndef Py_IMPORT_H +#define Py_IMPORT_H +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_FUNC(void) _PyImportZip_Init(void); + +PyMODINIT_FUNC PyInit_imp(void); +PyAPI_FUNC(long) PyImport_GetMagicNumber(void); +PyAPI_FUNC(const char *) PyImport_GetMagicTag(void); +PyAPI_FUNC(PyObject *) PyImport_ExecCodeModule( + const char *name, /* UTF-8 encoded string */ + PyObject *co + ); +PyAPI_FUNC(PyObject *) PyImport_ExecCodeModuleEx( + const char *name, /* UTF-8 encoded string */ + PyObject *co, + const char *pathname /* decoded from the filesystem encoding */ + ); +PyAPI_FUNC(PyObject *) PyImport_ExecCodeModuleWithPathnames( + const char *name, /* UTF-8 encoded string */ + PyObject *co, + const char *pathname, /* decoded from the filesystem encoding */ + const char *cpathname /* decoded from the filesystem encoding */ + ); +PyAPI_FUNC(PyObject *) PyImport_ExecCodeModuleObject( + PyObject *name, + PyObject *co, + PyObject *pathname, + PyObject *cpathname + ); +PyAPI_FUNC(PyObject *) PyImport_GetModuleDict(void); +PyAPI_FUNC(PyObject *) PyImport_AddModuleObject( + PyObject *name + ); +PyAPI_FUNC(PyObject *) PyImport_AddModule( + const char *name /* UTF-8 encoded string */ + ); +PyAPI_FUNC(PyObject *) PyImport_ImportModule( + const char *name /* UTF-8 encoded string */ + ); +PyAPI_FUNC(PyObject *) PyImport_ImportModuleNoBlock( + const char *name /* UTF-8 encoded string */ + ); +PyAPI_FUNC(PyObject *) PyImport_ImportModuleLevel( + const char *name, /* UTF-8 encoded string */ + PyObject *globals, + PyObject *locals, + PyObject *fromlist, + int level + ); +PyAPI_FUNC(PyObject *) PyImport_ImportModuleLevelObject( + PyObject *name, + PyObject *globals, + PyObject *locals, + PyObject *fromlist, + int level + ); + +#define PyImport_ImportModuleEx(n, g, l, f) \ + PyImport_ImportModuleLevel(n, g, l, f, 0) + +PyAPI_FUNC(PyObject *) PyImport_GetImporter(PyObject *path); +PyAPI_FUNC(PyObject *) PyImport_Import(PyObject *name); +PyAPI_FUNC(PyObject *) PyImport_ReloadModule(PyObject *m); +PyAPI_FUNC(void) PyImport_Cleanup(void); +PyAPI_FUNC(int) PyImport_ImportFrozenModuleObject( + PyObject *name + ); +PyAPI_FUNC(int) PyImport_ImportFrozenModule( + const char *name /* UTF-8 encoded string */ + ); + +#ifndef Py_LIMITED_API +#ifdef WITH_THREAD +PyAPI_FUNC(void) _PyImport_AcquireLock(void); +PyAPI_FUNC(int) _PyImport_ReleaseLock(void); +#else +#define _PyImport_AcquireLock() +#define _PyImport_ReleaseLock() 1 +#endif + +PyAPI_FUNC(void) _PyImport_ReInitLock(void); + +PyAPI_FUNC(PyObject *) _PyImport_FindBuiltin( + const char *name /* UTF-8 encoded string */ + ); +PyAPI_FUNC(PyObject *) _PyImport_FindExtensionObject(PyObject *, PyObject *); +PyAPI_FUNC(int) _PyImport_FixupBuiltin( + PyObject *mod, + const char *name /* UTF-8 encoded string */ + ); +PyAPI_FUNC(int) _PyImport_FixupExtensionObject(PyObject*, PyObject *, PyObject *); + +struct _inittab { + const char *name; /* ASCII encoded string */ + PyObject* (*initfunc)(void); +}; +PyAPI_DATA(struct _inittab *) PyImport_Inittab; +PyAPI_FUNC(int) PyImport_ExtendInittab(struct _inittab *newtab); +#endif /* Py_LIMITED_API */ + +PyAPI_DATA(PyTypeObject) PyNullImporter_Type; + +PyAPI_FUNC(int) PyImport_AppendInittab( + const char *name, /* ASCII encoded string */ + PyObject* (*initfunc)(void) + ); + +#ifndef Py_LIMITED_API +struct _frozen { + const char *name; /* ASCII encoded string */ + const unsigned char *code; + int size; +}; + +/* Embedding apps may change this pointer to point to their favorite + collection of frozen modules: */ + +PyAPI_DATA(const struct _frozen *) PyImport_FrozenModules; +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_IMPORT_H */ diff --git a/android/python35/include/intrcheck.h b/android/python35/include/intrcheck.h new file mode 100644 index 000000000..f53fee1a1 --- /dev/null +++ b/android/python35/include/intrcheck.h @@ -0,0 +1,21 @@ + +#ifndef Py_INTRCHECK_H +#define Py_INTRCHECK_H +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_FUNC(int) PyOS_InterruptOccurred(void); +PyAPI_FUNC(void) PyOS_InitInterrupts(void); +PyAPI_FUNC(void) PyOS_AfterFork(void); +PyAPI_FUNC(int) _PyOS_IsMainThread(void); + +#ifdef MS_WINDOWS +/* windows.h is not included by Python.h so use void* instead of HANDLE */ +PyAPI_FUNC(void*) _PyOS_SigintEvent(void); +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_INTRCHECK_H */ diff --git a/android/python35/include/iterobject.h b/android/python35/include/iterobject.h new file mode 100644 index 000000000..f61726f1f --- /dev/null +++ b/android/python35/include/iterobject.h @@ -0,0 +1,25 @@ +#ifndef Py_ITEROBJECT_H +#define Py_ITEROBJECT_H +/* Iterators (the basic kind, over a sequence) */ +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_DATA(PyTypeObject) PySeqIter_Type; +PyAPI_DATA(PyTypeObject) PyCallIter_Type; +PyAPI_DATA(PyTypeObject) PyCmpWrapper_Type; + +#define PySeqIter_Check(op) (Py_TYPE(op) == &PySeqIter_Type) + +PyAPI_FUNC(PyObject *) PySeqIter_New(PyObject *); + + +#define PyCallIter_Check(op) (Py_TYPE(op) == &PyCallIter_Type) + +PyAPI_FUNC(PyObject *) PyCallIter_New(PyObject *, PyObject *); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_ITEROBJECT_H */ + diff --git a/android/python35/include/listobject.h b/android/python35/include/listobject.h new file mode 100644 index 000000000..daa513f15 --- /dev/null +++ b/android/python35/include/listobject.h @@ -0,0 +1,81 @@ + +/* List object interface */ + +/* +Another generally useful object type is an list of object pointers. +This is a mutable type: the list items can be changed, and items can be +added or removed. Out-of-range indices or non-list objects are ignored. + +*** WARNING *** PyList_SetItem does not increment the new item's reference +count, but does decrement the reference count of the item it replaces, +if not nil. It does *decrement* the reference count if it is *not* +inserted in the list. Similarly, PyList_GetItem does not increment the +returned item's reference count. +*/ + +#ifndef Py_LISTOBJECT_H +#define Py_LISTOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_LIMITED_API +typedef struct { + PyObject_VAR_HEAD + /* Vector of pointers to list elements. list[0] is ob_item[0], etc. */ + PyObject **ob_item; + + /* ob_item contains space for 'allocated' elements. The number + * currently in use is ob_size. + * Invariants: + * 0 <= ob_size <= allocated + * len(list) == ob_size + * ob_item == NULL implies ob_size == allocated == 0 + * list.sort() temporarily sets allocated to -1 to detect mutations. + * + * Items must normally not be NULL, except during construction when + * the list is not yet visible outside the function that builds it. + */ + Py_ssize_t allocated; +} PyListObject; +#endif + +PyAPI_DATA(PyTypeObject) PyList_Type; +PyAPI_DATA(PyTypeObject) PyListIter_Type; +PyAPI_DATA(PyTypeObject) PyListRevIter_Type; +PyAPI_DATA(PyTypeObject) PySortWrapper_Type; + +#define PyList_Check(op) \ + PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_LIST_SUBCLASS) +#define PyList_CheckExact(op) (Py_TYPE(op) == &PyList_Type) + +PyAPI_FUNC(PyObject *) PyList_New(Py_ssize_t size); +PyAPI_FUNC(Py_ssize_t) PyList_Size(PyObject *); +PyAPI_FUNC(PyObject *) PyList_GetItem(PyObject *, Py_ssize_t); +PyAPI_FUNC(int) PyList_SetItem(PyObject *, Py_ssize_t, PyObject *); +PyAPI_FUNC(int) PyList_Insert(PyObject *, Py_ssize_t, PyObject *); +PyAPI_FUNC(int) PyList_Append(PyObject *, PyObject *); +PyAPI_FUNC(PyObject *) PyList_GetSlice(PyObject *, Py_ssize_t, Py_ssize_t); +PyAPI_FUNC(int) PyList_SetSlice(PyObject *, Py_ssize_t, Py_ssize_t, PyObject *); +PyAPI_FUNC(int) PyList_Sort(PyObject *); +PyAPI_FUNC(int) PyList_Reverse(PyObject *); +PyAPI_FUNC(PyObject *) PyList_AsTuple(PyObject *); +#ifndef Py_LIMITED_API +PyAPI_FUNC(PyObject *) _PyList_Extend(PyListObject *, PyObject *); + +PyAPI_FUNC(int) PyList_ClearFreeList(void); +PyAPI_FUNC(void) _PyList_DebugMallocStats(FILE *out); +#endif + +/* Macro, trading safety for speed */ +#ifndef Py_LIMITED_API +#define PyList_GET_ITEM(op, i) (((PyListObject *)(op))->ob_item[i]) +#define PyList_SET_ITEM(op, i, v) (((PyListObject *)(op))->ob_item[i] = (v)) +#define PyList_GET_SIZE(op) Py_SIZE(op) +#define _PyList_ITEMS(op) (((PyListObject *)(op))->ob_item) +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_LISTOBJECT_H */ diff --git a/android/python35/include/longintrepr.h b/android/python35/include/longintrepr.h new file mode 100644 index 000000000..bbba4d8dd --- /dev/null +++ b/android/python35/include/longintrepr.h @@ -0,0 +1,103 @@ +#ifndef Py_LIMITED_API +#ifndef Py_LONGINTREPR_H +#define Py_LONGINTREPR_H +#ifdef __cplusplus +extern "C" { +#endif + + +/* This is published for the benefit of "friends" marshal.c and _decimal.c. */ + +/* Parameters of the integer representation. There are two different + sets of parameters: one set for 30-bit digits, stored in an unsigned 32-bit + integer type, and one set for 15-bit digits with each digit stored in an + unsigned short. The value of PYLONG_BITS_IN_DIGIT, defined either at + configure time or in pyport.h, is used to decide which digit size to use. + + Type 'digit' should be able to hold 2*PyLong_BASE-1, and type 'twodigits' + should be an unsigned integer type able to hold all integers up to + PyLong_BASE*PyLong_BASE-1. x_sub assumes that 'digit' is an unsigned type, + and that overflow is handled by taking the result modulo 2**N for some N > + PyLong_SHIFT. The majority of the code doesn't care about the precise + value of PyLong_SHIFT, but there are some notable exceptions: + + - long_pow() requires that PyLong_SHIFT be divisible by 5 + + - PyLong_{As,From}ByteArray require that PyLong_SHIFT be at least 8 + + - long_hash() requires that PyLong_SHIFT is *strictly* less than the number + of bits in an unsigned long, as do the PyLong <-> long (or unsigned long) + conversion functions + + - the Python int <-> size_t/Py_ssize_t conversion functions expect that + PyLong_SHIFT is strictly less than the number of bits in a size_t + + - the marshal code currently expects that PyLong_SHIFT is a multiple of 15 + + - NSMALLNEGINTS and NSMALLPOSINTS should be small enough to fit in a single + digit; with the current values this forces PyLong_SHIFT >= 9 + + The values 15 and 30 should fit all of the above requirements, on any + platform. +*/ + +#if PYLONG_BITS_IN_DIGIT == 30 +#if !(defined HAVE_UINT64_T && defined HAVE_UINT32_T && \ + defined HAVE_INT64_T && defined HAVE_INT32_T) +#error "30-bit long digits requested, but the necessary types are not available on this platform" +#endif +typedef PY_UINT32_T digit; +typedef PY_INT32_T sdigit; /* signed variant of digit */ +typedef PY_UINT64_T twodigits; +typedef PY_INT64_T stwodigits; /* signed variant of twodigits */ +#define PyLong_SHIFT 30 +#define _PyLong_DECIMAL_SHIFT 9 /* max(e such that 10**e fits in a digit) */ +#define _PyLong_DECIMAL_BASE ((digit)1000000000) /* 10 ** DECIMAL_SHIFT */ +#elif PYLONG_BITS_IN_DIGIT == 15 +typedef unsigned short digit; +typedef short sdigit; /* signed variant of digit */ +typedef unsigned long twodigits; +typedef long stwodigits; /* signed variant of twodigits */ +#define PyLong_SHIFT 15 +#define _PyLong_DECIMAL_SHIFT 4 /* max(e such that 10**e fits in a digit) */ +#define _PyLong_DECIMAL_BASE ((digit)10000) /* 10 ** DECIMAL_SHIFT */ +#else +#error "PYLONG_BITS_IN_DIGIT should be 15 or 30" +#endif +#define PyLong_BASE ((digit)1 << PyLong_SHIFT) +#define PyLong_MASK ((digit)(PyLong_BASE - 1)) + +#if PyLong_SHIFT % 5 != 0 +#error "longobject.c requires that PyLong_SHIFT be divisible by 5" +#endif + +/* Long integer representation. + The absolute value of a number is equal to + SUM(for i=0 through abs(ob_size)-1) ob_digit[i] * 2**(SHIFT*i) + Negative numbers are represented with ob_size < 0; + zero is represented by ob_size == 0. + In a normalized number, ob_digit[abs(ob_size)-1] (the most significant + digit) is never zero. Also, in all cases, for all valid i, + 0 <= ob_digit[i] <= MASK. + The allocation function takes care of allocating extra memory + so that ob_digit[0] ... ob_digit[abs(ob_size)-1] are actually available. + + CAUTION: Generic code manipulating subtypes of PyVarObject has to + aware that ints abuse ob_size's sign bit. +*/ + +struct _longobject { + PyObject_VAR_HEAD + digit ob_digit[1]; +}; + +PyAPI_FUNC(PyLongObject *) _PyLong_New(Py_ssize_t); + +/* Return a copy of src. */ +PyAPI_FUNC(PyObject *) _PyLong_Copy(PyLongObject *src); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_LONGINTREPR_H */ +#endif /* Py_LIMITED_API */ diff --git a/android/python35/include/longobject.h b/android/python35/include/longobject.h new file mode 100644 index 000000000..aed59ce01 --- /dev/null +++ b/android/python35/include/longobject.h @@ -0,0 +1,207 @@ +#ifndef Py_LONGOBJECT_H +#define Py_LONGOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + + +/* Long (arbitrary precision) integer object interface */ + +typedef struct _longobject PyLongObject; /* Revealed in longintrepr.h */ + +PyAPI_DATA(PyTypeObject) PyLong_Type; + +#define PyLong_Check(op) \ + PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_LONG_SUBCLASS) +#define PyLong_CheckExact(op) (Py_TYPE(op) == &PyLong_Type) + +PyAPI_FUNC(PyObject *) PyLong_FromLong(long); +PyAPI_FUNC(PyObject *) PyLong_FromUnsignedLong(unsigned long); +PyAPI_FUNC(PyObject *) PyLong_FromSize_t(size_t); +PyAPI_FUNC(PyObject *) PyLong_FromSsize_t(Py_ssize_t); +PyAPI_FUNC(PyObject *) PyLong_FromDouble(double); +PyAPI_FUNC(long) PyLong_AsLong(PyObject *); +PyAPI_FUNC(long) PyLong_AsLongAndOverflow(PyObject *, int *); +PyAPI_FUNC(Py_ssize_t) PyLong_AsSsize_t(PyObject *); +PyAPI_FUNC(size_t) PyLong_AsSize_t(PyObject *); +PyAPI_FUNC(unsigned long) PyLong_AsUnsignedLong(PyObject *); +PyAPI_FUNC(unsigned long) PyLong_AsUnsignedLongMask(PyObject *); +#ifndef Py_LIMITED_API +PyAPI_FUNC(int) _PyLong_AsInt(PyObject *); +#endif +PyAPI_FUNC(PyObject *) PyLong_GetInfo(void); + +/* It may be useful in the future. I've added it in the PyInt -> PyLong + cleanup to keep the extra information. [CH] */ +#define PyLong_AS_LONG(op) PyLong_AsLong(op) + +/* Issue #1983: pid_t can be longer than a C long on some systems */ +#if !defined(SIZEOF_PID_T) || SIZEOF_PID_T == SIZEOF_INT +#define _Py_PARSE_PID "i" +#define PyLong_FromPid PyLong_FromLong +#define PyLong_AsPid PyLong_AsLong +#elif SIZEOF_PID_T == SIZEOF_LONG +#define _Py_PARSE_PID "l" +#define PyLong_FromPid PyLong_FromLong +#define PyLong_AsPid PyLong_AsLong +#elif defined(SIZEOF_LONG_LONG) && SIZEOF_PID_T == SIZEOF_LONG_LONG +#define _Py_PARSE_PID "L" +#define PyLong_FromPid PyLong_FromLongLong +#define PyLong_AsPid PyLong_AsLongLong +#else +#error "sizeof(pid_t) is neither sizeof(int), sizeof(long) or sizeof(long long)" +#endif /* SIZEOF_PID_T */ + +#if SIZEOF_VOID_P == SIZEOF_INT +# define _Py_PARSE_INTPTR "i" +# define _Py_PARSE_UINTPTR "I" +#elif SIZEOF_VOID_P == SIZEOF_LONG +# define _Py_PARSE_INTPTR "l" +# define _Py_PARSE_UINTPTR "k" +#elif defined(SIZEOF_LONG_LONG) && SIZEOF_VOID_P == SIZEOF_LONG_LONG +# define _Py_PARSE_INTPTR "L" +# define _Py_PARSE_UINTPTR "K" +#else +# error "void* different in size from int, long and long long" +#endif /* SIZEOF_VOID_P */ + +/* Used by Python/mystrtoul.c. */ +#ifndef Py_LIMITED_API +PyAPI_DATA(unsigned char) _PyLong_DigitValue[256]; +#endif + +/* _PyLong_Frexp returns a double x and an exponent e such that the + true value is approximately equal to x * 2**e. e is >= 0. x is + 0.0 if and only if the input is 0 (in which case, e and x are both + zeroes); otherwise, 0.5 <= abs(x) < 1.0. On overflow, which is + possible if the number of bits doesn't fit into a Py_ssize_t, sets + OverflowError and returns -1.0 for x, 0 for e. */ +#ifndef Py_LIMITED_API +PyAPI_FUNC(double) _PyLong_Frexp(PyLongObject *a, Py_ssize_t *e); +#endif + +PyAPI_FUNC(double) PyLong_AsDouble(PyObject *); +PyAPI_FUNC(PyObject *) PyLong_FromVoidPtr(void *); +PyAPI_FUNC(void *) PyLong_AsVoidPtr(PyObject *); + +#ifdef HAVE_LONG_LONG +PyAPI_FUNC(PyObject *) PyLong_FromLongLong(PY_LONG_LONG); +PyAPI_FUNC(PyObject *) PyLong_FromUnsignedLongLong(unsigned PY_LONG_LONG); +PyAPI_FUNC(PY_LONG_LONG) PyLong_AsLongLong(PyObject *); +PyAPI_FUNC(unsigned PY_LONG_LONG) PyLong_AsUnsignedLongLong(PyObject *); +PyAPI_FUNC(unsigned PY_LONG_LONG) PyLong_AsUnsignedLongLongMask(PyObject *); +PyAPI_FUNC(PY_LONG_LONG) PyLong_AsLongLongAndOverflow(PyObject *, int *); +#endif /* HAVE_LONG_LONG */ + +PyAPI_FUNC(PyObject *) PyLong_FromString(const char *, char **, int); +#ifndef Py_LIMITED_API +PyAPI_FUNC(PyObject *) PyLong_FromUnicode(Py_UNICODE*, Py_ssize_t, int); +PyAPI_FUNC(PyObject *) PyLong_FromUnicodeObject(PyObject *u, int base); +PyAPI_FUNC(PyObject *) _PyLong_FromBytes(const char *, Py_ssize_t, int); +#endif + +#ifndef Py_LIMITED_API +/* _PyLong_Sign. Return 0 if v is 0, -1 if v < 0, +1 if v > 0. + v must not be NULL, and must be a normalized long. + There are no error cases. +*/ +PyAPI_FUNC(int) _PyLong_Sign(PyObject *v); + + +/* _PyLong_NumBits. Return the number of bits needed to represent the + absolute value of a long. For example, this returns 1 for 1 and -1, 2 + for 2 and -2, and 2 for 3 and -3. It returns 0 for 0. + v must not be NULL, and must be a normalized long. + (size_t)-1 is returned and OverflowError set if the true result doesn't + fit in a size_t. +*/ +PyAPI_FUNC(size_t) _PyLong_NumBits(PyObject *v); + +/* _PyLong_DivmodNear. Given integers a and b, compute the nearest + integer q to the exact quotient a / b, rounding to the nearest even integer + in the case of a tie. Return (q, r), where r = a - q*b. The remainder r + will satisfy abs(r) <= abs(b)/2, with equality possible only if q is + even. +*/ +PyAPI_FUNC(PyObject *) _PyLong_DivmodNear(PyObject *, PyObject *); + +/* _PyLong_FromByteArray: View the n unsigned bytes as a binary integer in + base 256, and return a Python int with the same numeric value. + If n is 0, the integer is 0. Else: + If little_endian is 1/true, bytes[n-1] is the MSB and bytes[0] the LSB; + else (little_endian is 0/false) bytes[0] is the MSB and bytes[n-1] the + LSB. + If is_signed is 0/false, view the bytes as a non-negative integer. + If is_signed is 1/true, view the bytes as a 2's-complement integer, + non-negative if bit 0x80 of the MSB is clear, negative if set. + Error returns: + + Return NULL with the appropriate exception set if there's not + enough memory to create the Python int. +*/ +PyAPI_FUNC(PyObject *) _PyLong_FromByteArray( + const unsigned char* bytes, size_t n, + int little_endian, int is_signed); + +/* _PyLong_AsByteArray: Convert the least-significant 8*n bits of long + v to a base-256 integer, stored in array bytes. Normally return 0, + return -1 on error. + If little_endian is 1/true, store the MSB at bytes[n-1] and the LSB at + bytes[0]; else (little_endian is 0/false) store the MSB at bytes[0] and + the LSB at bytes[n-1]. + If is_signed is 0/false, it's an error if v < 0; else (v >= 0) n bytes + are filled and there's nothing special about bit 0x80 of the MSB. + If is_signed is 1/true, bytes is filled with the 2's-complement + representation of v's value. Bit 0x80 of the MSB is the sign bit. + Error returns (-1): + + is_signed is 0 and v < 0. TypeError is set in this case, and bytes + isn't altered. + + n isn't big enough to hold the full mathematical value of v. For + example, if is_signed is 0 and there are more digits in the v than + fit in n; or if is_signed is 1, v < 0, and n is just 1 bit shy of + being large enough to hold a sign bit. OverflowError is set in this + case, but bytes holds the least-signficant n bytes of the true value. +*/ +PyAPI_FUNC(int) _PyLong_AsByteArray(PyLongObject* v, + unsigned char* bytes, size_t n, + int little_endian, int is_signed); + +/* _PyLong_FromNbInt: Convert the given object to a PyLongObject + using the nb_int slot, if available. Raise TypeError if either the + nb_int slot is not available or the result of the call to nb_int + returns something not of type int. +*/ +PyAPI_FUNC(PyLongObject *)_PyLong_FromNbInt(PyObject *); + +/* _PyLong_Format: Convert the long to a string object with given base, + appending a base prefix of 0[box] if base is 2, 8 or 16. */ +PyAPI_FUNC(PyObject *) _PyLong_Format(PyObject *obj, int base); + +PyAPI_FUNC(int) _PyLong_FormatWriter( + _PyUnicodeWriter *writer, + PyObject *obj, + int base, + int alternate); + +/* Format the object based on the format_spec, as defined in PEP 3101 + (Advanced String Formatting). */ +PyAPI_FUNC(int) _PyLong_FormatAdvancedWriter( + _PyUnicodeWriter *writer, + PyObject *obj, + PyObject *format_spec, + Py_ssize_t start, + Py_ssize_t end); +#endif /* Py_LIMITED_API */ + +/* These aren't really part of the int object, but they're handy. The + functions are in Python/mystrtoul.c. + */ +PyAPI_FUNC(unsigned long) PyOS_strtoul(const char *, char **, int); +PyAPI_FUNC(long) PyOS_strtol(const char *, char **, int); + +/* For use by the gcd function in mathmodule.c */ +PyAPI_FUNC(PyObject *) _PyLong_GCD(PyObject *, PyObject *); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_LONGOBJECT_H */ diff --git a/android/python35/include/marshal.h b/android/python35/include/marshal.h new file mode 100644 index 000000000..09d9337e5 --- /dev/null +++ b/android/python35/include/marshal.h @@ -0,0 +1,28 @@ + +/* Interface for marshal.c */ + +#ifndef Py_MARSHAL_H +#define Py_MARSHAL_H +#ifdef __cplusplus +extern "C" { +#endif + +#define Py_MARSHAL_VERSION 4 + +PyAPI_FUNC(void) PyMarshal_WriteLongToFile(long, FILE *, int); +PyAPI_FUNC(void) PyMarshal_WriteObjectToFile(PyObject *, FILE *, int); +PyAPI_FUNC(PyObject *) PyMarshal_WriteObjectToString(PyObject *, int); + +#ifndef Py_LIMITED_API +PyAPI_FUNC(long) PyMarshal_ReadLongFromFile(FILE *); +PyAPI_FUNC(int) PyMarshal_ReadShortFromFile(FILE *); +PyAPI_FUNC(PyObject *) PyMarshal_ReadObjectFromFile(FILE *); +PyAPI_FUNC(PyObject *) PyMarshal_ReadLastObjectFromFile(FILE *); +#endif +PyAPI_FUNC(PyObject *) PyMarshal_ReadObjectFromString(const char *, + Py_ssize_t); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_MARSHAL_H */ diff --git a/android/python35/include/memoryobject.h b/android/python35/include/memoryobject.h new file mode 100644 index 000000000..ab5ee0956 --- /dev/null +++ b/android/python35/include/memoryobject.h @@ -0,0 +1,70 @@ +/* Memory view object. In Python this is available as "memoryview". */ + +#ifndef Py_MEMORYOBJECT_H +#define Py_MEMORYOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_LIMITED_API +PyAPI_DATA(PyTypeObject) _PyManagedBuffer_Type; +#endif +PyAPI_DATA(PyTypeObject) PyMemoryView_Type; + +#define PyMemoryView_Check(op) (Py_TYPE(op) == &PyMemoryView_Type) + +#ifndef Py_LIMITED_API +/* Get a pointer to the memoryview's private copy of the exporter's buffer. */ +#define PyMemoryView_GET_BUFFER(op) (&((PyMemoryViewObject *)(op))->view) +/* Get a pointer to the exporting object (this may be NULL!). */ +#define PyMemoryView_GET_BASE(op) (((PyMemoryViewObject *)(op))->view.obj) +#endif + +PyAPI_FUNC(PyObject *) PyMemoryView_FromObject(PyObject *base); +PyAPI_FUNC(PyObject *) PyMemoryView_FromMemory(char *mem, Py_ssize_t size, + int flags); +#ifndef Py_LIMITED_API +PyAPI_FUNC(PyObject *) PyMemoryView_FromBuffer(Py_buffer *info); +#endif +PyAPI_FUNC(PyObject *) PyMemoryView_GetContiguous(PyObject *base, + int buffertype, + char order); + + +/* The structs are declared here so that macros can work, but they shouldn't + be considered public. Don't access their fields directly, use the macros + and functions instead! */ +#ifndef Py_LIMITED_API +#define _Py_MANAGED_BUFFER_RELEASED 0x001 /* access to exporter blocked */ +#define _Py_MANAGED_BUFFER_FREE_FORMAT 0x002 /* free format */ +typedef struct { + PyObject_HEAD + int flags; /* state flags */ + Py_ssize_t exports; /* number of direct memoryview exports */ + Py_buffer master; /* snapshot buffer obtained from the original exporter */ +} _PyManagedBufferObject; + + +/* memoryview state flags */ +#define _Py_MEMORYVIEW_RELEASED 0x001 /* access to master buffer blocked */ +#define _Py_MEMORYVIEW_C 0x002 /* C-contiguous layout */ +#define _Py_MEMORYVIEW_FORTRAN 0x004 /* Fortran contiguous layout */ +#define _Py_MEMORYVIEW_SCALAR 0x008 /* scalar: ndim = 0 */ +#define _Py_MEMORYVIEW_PIL 0x010 /* PIL-style layout */ + +typedef struct { + PyObject_VAR_HEAD + _PyManagedBufferObject *mbuf; /* managed buffer */ + Py_hash_t hash; /* hash value for read-only views */ + int flags; /* state flags */ + Py_ssize_t exports; /* number of buffer re-exports */ + Py_buffer view; /* private copy of the exporter's view */ + PyObject *weakreflist; + Py_ssize_t ob_array[1]; /* shape, strides, suboffsets */ +} PyMemoryViewObject; +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_MEMORYOBJECT_H */ diff --git a/android/python35/include/metagrammar.h b/android/python35/include/metagrammar.h new file mode 100644 index 000000000..15c8ef8f3 --- /dev/null +++ b/android/python35/include/metagrammar.h @@ -0,0 +1,18 @@ +#ifndef Py_METAGRAMMAR_H +#define Py_METAGRAMMAR_H +#ifdef __cplusplus +extern "C" { +#endif + + +#define MSTART 256 +#define RULE 257 +#define RHS 258 +#define ALT 259 +#define ITEM 260 +#define ATOM 261 + +#ifdef __cplusplus +} +#endif +#endif /* !Py_METAGRAMMAR_H */ diff --git a/android/python35/include/methodobject.h b/android/python35/include/methodobject.h new file mode 100644 index 000000000..e2ad80440 --- /dev/null +++ b/android/python35/include/methodobject.h @@ -0,0 +1,94 @@ + +/* Method object interface */ + +#ifndef Py_METHODOBJECT_H +#define Py_METHODOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +/* This is about the type 'builtin_function_or_method', + not Python methods in user-defined classes. See classobject.h + for the latter. */ + +PyAPI_DATA(PyTypeObject) PyCFunction_Type; + +#define PyCFunction_Check(op) (Py_TYPE(op) == &PyCFunction_Type) + +typedef PyObject *(*PyCFunction)(PyObject *, PyObject *); +typedef PyObject *(*PyCFunctionWithKeywords)(PyObject *, PyObject *, + PyObject *); +typedef PyObject *(*PyNoArgsFunction)(PyObject *); + +PyAPI_FUNC(PyCFunction) PyCFunction_GetFunction(PyObject *); +PyAPI_FUNC(PyObject *) PyCFunction_GetSelf(PyObject *); +PyAPI_FUNC(int) PyCFunction_GetFlags(PyObject *); + +/* Macros for direct access to these values. Type checks are *not* + done, so use with care. */ +#ifndef Py_LIMITED_API +#define PyCFunction_GET_FUNCTION(func) \ + (((PyCFunctionObject *)func) -> m_ml -> ml_meth) +#define PyCFunction_GET_SELF(func) \ + (((PyCFunctionObject *)func) -> m_ml -> ml_flags & METH_STATIC ? \ + NULL : ((PyCFunctionObject *)func) -> m_self) +#define PyCFunction_GET_FLAGS(func) \ + (((PyCFunctionObject *)func) -> m_ml -> ml_flags) +#endif +PyAPI_FUNC(PyObject *) PyCFunction_Call(PyObject *, PyObject *, PyObject *); + +struct PyMethodDef { + const char *ml_name; /* The name of the built-in function/method */ + PyCFunction ml_meth; /* The C function that implements it */ + int ml_flags; /* Combination of METH_xxx flags, which mostly + describe the args expected by the C func */ + const char *ml_doc; /* The __doc__ attribute, or NULL */ +}; +typedef struct PyMethodDef PyMethodDef; + +#define PyCFunction_New(ML, SELF) PyCFunction_NewEx((ML), (SELF), NULL) +PyAPI_FUNC(PyObject *) PyCFunction_NewEx(PyMethodDef *, PyObject *, + PyObject *); + +/* Flag passed to newmethodobject */ +/* #define METH_OLDARGS 0x0000 -- unsupported now */ +#define METH_VARARGS 0x0001 +#define METH_KEYWORDS 0x0002 +/* METH_NOARGS and METH_O must not be combined with the flags above. */ +#define METH_NOARGS 0x0004 +#define METH_O 0x0008 + +/* METH_CLASS and METH_STATIC are a little different; these control + the construction of methods for a class. These cannot be used for + functions in modules. */ +#define METH_CLASS 0x0010 +#define METH_STATIC 0x0020 + +/* METH_COEXIST allows a method to be entered even though a slot has + already filled the entry. When defined, the flag allows a separate + method, "__contains__" for example, to coexist with a defined + slot like sq_contains. */ + +#define METH_COEXIST 0x0040 + +#ifndef Py_LIMITED_API +typedef struct { + PyObject_HEAD + PyMethodDef *m_ml; /* Description of the C function to call */ + PyObject *m_self; /* Passed as 'self' arg to the C func, can be NULL */ + PyObject *m_module; /* The __module__ attribute, can be anything */ + PyObject *m_weakreflist; /* List of weak references */ +} PyCFunctionObject; +#endif + +PyAPI_FUNC(int) PyCFunction_ClearFreeList(void); + +#ifndef Py_LIMITED_API +PyAPI_FUNC(void) _PyCFunction_DebugMallocStats(FILE *out); +PyAPI_FUNC(void) _PyMethod_DebugMallocStats(FILE *out); +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_METHODOBJECT_H */ diff --git a/android/python35/include/modsupport.h b/android/python35/include/modsupport.h new file mode 100644 index 000000000..829aaf859 --- /dev/null +++ b/android/python35/include/modsupport.h @@ -0,0 +1,155 @@ + +#ifndef Py_MODSUPPORT_H +#define Py_MODSUPPORT_H +#ifdef __cplusplus +extern "C" { +#endif + +/* Module support interface */ + +#include + +/* If PY_SSIZE_T_CLEAN is defined, each functions treats #-specifier + to mean Py_ssize_t */ +#ifdef PY_SSIZE_T_CLEAN +#define PyArg_Parse _PyArg_Parse_SizeT +#define PyArg_ParseTuple _PyArg_ParseTuple_SizeT +#define PyArg_ParseTupleAndKeywords _PyArg_ParseTupleAndKeywords_SizeT +#define PyArg_VaParse _PyArg_VaParse_SizeT +#define PyArg_VaParseTupleAndKeywords _PyArg_VaParseTupleAndKeywords_SizeT +#define Py_BuildValue _Py_BuildValue_SizeT +#define Py_VaBuildValue _Py_VaBuildValue_SizeT +#else +PyAPI_FUNC(PyObject *) _Py_VaBuildValue_SizeT(const char *, va_list); +#endif + +/* Due to a glitch in 3.2, the _SizeT versions weren't exported from the DLL. */ +#if !defined(PY_SSIZE_T_CLEAN) || !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000 +PyAPI_FUNC(int) PyArg_Parse(PyObject *, const char *, ...); +PyAPI_FUNC(int) PyArg_ParseTuple(PyObject *, const char *, ...); +PyAPI_FUNC(int) PyArg_ParseTupleAndKeywords(PyObject *, PyObject *, + const char *, char **, ...); +PyAPI_FUNC(int) PyArg_ValidateKeywordArguments(PyObject *); +PyAPI_FUNC(int) PyArg_UnpackTuple(PyObject *, const char *, Py_ssize_t, Py_ssize_t, ...); +PyAPI_FUNC(PyObject *) Py_BuildValue(const char *, ...); +PyAPI_FUNC(PyObject *) _Py_BuildValue_SizeT(const char *, ...); +#endif +#ifndef Py_LIMITED_API +PyAPI_FUNC(int) _PyArg_NoKeywords(const char *funcname, PyObject *kw); +PyAPI_FUNC(int) _PyArg_NoPositional(const char *funcname, PyObject *args); + +PyAPI_FUNC(int) PyArg_VaParse(PyObject *, const char *, va_list); +PyAPI_FUNC(int) PyArg_VaParseTupleAndKeywords(PyObject *, PyObject *, + const char *, char **, va_list); +#endif +PyAPI_FUNC(PyObject *) Py_VaBuildValue(const char *, va_list); + +PyAPI_FUNC(int) PyModule_AddObject(PyObject *, const char *, PyObject *); +PyAPI_FUNC(int) PyModule_AddIntConstant(PyObject *, const char *, long); +PyAPI_FUNC(int) PyModule_AddStringConstant(PyObject *, const char *, const char *); +#define PyModule_AddIntMacro(m, c) PyModule_AddIntConstant(m, #c, c) +#define PyModule_AddStringMacro(m, c) PyModule_AddStringConstant(m, #c, c) + +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000 +/* New in 3.5 */ +PyAPI_FUNC(int) PyModule_SetDocString(PyObject *, const char *); +PyAPI_FUNC(int) PyModule_AddFunctions(PyObject *, PyMethodDef *); +PyAPI_FUNC(int) PyModule_ExecDef(PyObject *module, PyModuleDef *def); +#endif + +#define Py_CLEANUP_SUPPORTED 0x20000 + +#define PYTHON_API_VERSION 1013 +#define PYTHON_API_STRING "1013" +/* The API version is maintained (independently from the Python version) + so we can detect mismatches between the interpreter and dynamically + loaded modules. These are diagnosed by an error message but + the module is still loaded (because the mismatch can only be tested + after loading the module). The error message is intended to + explain the core dump a few seconds later. + + The symbol PYTHON_API_STRING defines the same value as a string + literal. *** PLEASE MAKE SURE THE DEFINITIONS MATCH. *** + + Please add a line or two to the top of this log for each API + version change: + + 22-Feb-2006 MvL 1013 PEP 353 - long indices for sequence lengths + + 19-Aug-2002 GvR 1012 Changes to string object struct for + interning changes, saving 3 bytes. + + 17-Jul-2001 GvR 1011 Descr-branch, just to be on the safe side + + 25-Jan-2001 FLD 1010 Parameters added to PyCode_New() and + PyFrame_New(); Python 2.1a2 + + 14-Mar-2000 GvR 1009 Unicode API added + + 3-Jan-1999 GvR 1007 Decided to change back! (Don't reuse 1008!) + + 3-Dec-1998 GvR 1008 Python 1.5.2b1 + + 18-Jan-1997 GvR 1007 string interning and other speedups + + 11-Oct-1996 GvR renamed Py_Ellipses to Py_Ellipsis :-( + + 30-Jul-1996 GvR Slice and ellipses syntax added + + 23-Jul-1996 GvR For 1.4 -- better safe than sorry this time :-) + + 7-Nov-1995 GvR Keyword arguments (should've been done at 1.3 :-( ) + + 10-Jan-1995 GvR Renamed globals to new naming scheme + + 9-Jan-1995 GvR Initial version (incompatible with older API) +*/ + +/* The PYTHON_ABI_VERSION is introduced in PEP 384. For the lifetime of + Python 3, it will stay at the value of 3; changes to the limited API + must be performed in a strictly backwards-compatible manner. */ +#define PYTHON_ABI_VERSION 3 +#define PYTHON_ABI_STRING "3" + +#ifdef Py_TRACE_REFS + /* When we are tracing reference counts, rename module creation functions so + modules compiled with incompatible settings will generate a + link-time error. */ + #define PyModule_Create2 PyModule_Create2TraceRefs + #define PyModule_FromDefAndSpec2 PyModule_FromDefAndSpec2TraceRefs +#endif + +PyAPI_FUNC(PyObject *) PyModule_Create2(struct PyModuleDef*, + int apiver); + +#ifdef Py_LIMITED_API +#define PyModule_Create(module) \ + PyModule_Create2(module, PYTHON_ABI_VERSION) +#else +#define PyModule_Create(module) \ + PyModule_Create2(module, PYTHON_API_VERSION) +#endif + +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000 +/* New in 3.5 */ +PyAPI_FUNC(PyObject *) PyModule_FromDefAndSpec2(PyModuleDef *def, + PyObject *spec, + int module_api_version); + +#ifdef Py_LIMITED_API +#define PyModule_FromDefAndSpec(module, spec) \ + PyModule_FromDefAndSpec2(module, spec, PYTHON_ABI_VERSION) +#else +#define PyModule_FromDefAndSpec(module, spec) \ + PyModule_FromDefAndSpec2(module, spec, PYTHON_API_VERSION) +#endif /* Py_LIMITED_API */ +#endif /* New in 3.5 */ + +#ifndef Py_LIMITED_API +PyAPI_DATA(char *) _Py_PackageContext; +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_MODSUPPORT_H */ diff --git a/android/python35/include/moduleobject.h b/android/python35/include/moduleobject.h new file mode 100644 index 000000000..229d7fadc --- /dev/null +++ b/android/python35/include/moduleobject.h @@ -0,0 +1,85 @@ + +/* Module object interface */ + +#ifndef Py_MODULEOBJECT_H +#define Py_MODULEOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_DATA(PyTypeObject) PyModule_Type; + +#define PyModule_Check(op) PyObject_TypeCheck(op, &PyModule_Type) +#define PyModule_CheckExact(op) (Py_TYPE(op) == &PyModule_Type) + +PyAPI_FUNC(PyObject *) PyModule_NewObject( + PyObject *name + ); +PyAPI_FUNC(PyObject *) PyModule_New( + const char *name /* UTF-8 encoded string */ + ); +PyAPI_FUNC(PyObject *) PyModule_GetDict(PyObject *); +PyAPI_FUNC(PyObject *) PyModule_GetNameObject(PyObject *); +PyAPI_FUNC(const char *) PyModule_GetName(PyObject *); +PyAPI_FUNC(const char *) PyModule_GetFilename(PyObject *); +PyAPI_FUNC(PyObject *) PyModule_GetFilenameObject(PyObject *); +#ifndef Py_LIMITED_API +PyAPI_FUNC(void) _PyModule_Clear(PyObject *); +PyAPI_FUNC(void) _PyModule_ClearDict(PyObject *); +#endif +PyAPI_FUNC(struct PyModuleDef*) PyModule_GetDef(PyObject*); +PyAPI_FUNC(void*) PyModule_GetState(PyObject*); + +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000 +/* New in 3.5 */ +PyAPI_FUNC(PyObject *) PyModuleDef_Init(struct PyModuleDef*); +PyAPI_DATA(PyTypeObject) PyModuleDef_Type; +#endif + +typedef struct PyModuleDef_Base { + PyObject_HEAD + PyObject* (*m_init)(void); + Py_ssize_t m_index; + PyObject* m_copy; +} PyModuleDef_Base; + +#define PyModuleDef_HEAD_INIT { \ + PyObject_HEAD_INIT(NULL) \ + NULL, /* m_init */ \ + 0, /* m_index */ \ + NULL, /* m_copy */ \ + } + +struct PyModuleDef_Slot; +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000 +/* New in 3.5 */ +typedef struct PyModuleDef_Slot{ + int slot; + void *value; +} PyModuleDef_Slot; + +#define Py_mod_create 1 +#define Py_mod_exec 2 + +#ifndef Py_LIMITED_API +#define _Py_mod_LAST_SLOT 2 +#endif + +#endif /* New in 3.5 */ + +typedef struct PyModuleDef{ + PyModuleDef_Base m_base; + const char* m_name; + const char* m_doc; + Py_ssize_t m_size; + PyMethodDef *m_methods; + struct PyModuleDef_Slot* m_slots; + traverseproc m_traverse; + inquiry m_clear; + freefunc m_free; +}PyModuleDef; + +#ifdef __cplusplus +} +#endif +#endif /* !Py_MODULEOBJECT_H */ diff --git a/android/python35/include/namespaceobject.h b/android/python35/include/namespaceobject.h new file mode 100644 index 000000000..a412f0520 --- /dev/null +++ b/android/python35/include/namespaceobject.h @@ -0,0 +1,17 @@ + +/* simple namespace object interface */ + +#ifndef NAMESPACEOBJECT_H +#define NAMESPACEOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_DATA(PyTypeObject) _PyNamespace_Type; + +PyAPI_FUNC(PyObject *) _PyNamespace_New(PyObject *kwds); + +#ifdef __cplusplus +} +#endif +#endif /* !NAMESPACEOBJECT_H */ diff --git a/android/python35/include/node.h b/android/python35/include/node.h new file mode 100644 index 000000000..654ad8582 --- /dev/null +++ b/android/python35/include/node.h @@ -0,0 +1,44 @@ + +/* Parse tree node interface */ + +#ifndef Py_NODE_H +#define Py_NODE_H +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct _node { + short n_type; + char *n_str; + int n_lineno; + int n_col_offset; + int n_nchildren; + struct _node *n_child; +} node; + +PyAPI_FUNC(node *) PyNode_New(int type); +PyAPI_FUNC(int) PyNode_AddChild(node *n, int type, + char *str, int lineno, int col_offset); +PyAPI_FUNC(void) PyNode_Free(node *n); +#ifndef Py_LIMITED_API +PyAPI_FUNC(Py_ssize_t) _PyNode_SizeOf(node *n); +#endif + +/* Node access functions */ +#define NCH(n) ((n)->n_nchildren) + +#define CHILD(n, i) (&(n)->n_child[i]) +#define RCHILD(n, i) (CHILD(n, NCH(n) + i)) +#define TYPE(n) ((n)->n_type) +#define STR(n) ((n)->n_str) +#define LINENO(n) ((n)->n_lineno) + +/* Assert that the type of a node is what we expect */ +#define REQ(n, type) assert(TYPE(n) == (type)) + +PyAPI_FUNC(void) PyNode_ListTree(node *); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_NODE_H */ diff --git a/android/python35/include/object.h b/android/python35/include/object.h new file mode 100644 index 000000000..8afcbe96d --- /dev/null +++ b/android/python35/include/object.h @@ -0,0 +1,1028 @@ +#ifndef Py_OBJECT_H +#define Py_OBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + + +/* Object and type object interface */ + +/* +Objects are structures allocated on the heap. Special rules apply to +the use of objects to ensure they are properly garbage-collected. +Objects are never allocated statically or on the stack; they must be +accessed through special macros and functions only. (Type objects are +exceptions to the first rule; the standard types are represented by +statically initialized type objects, although work on type/class unification +for Python 2.2 made it possible to have heap-allocated type objects too). + +An object has a 'reference count' that is increased or decreased when a +pointer to the object is copied or deleted; when the reference count +reaches zero there are no references to the object left and it can be +removed from the heap. + +An object has a 'type' that determines what it represents and what kind +of data it contains. An object's type is fixed when it is created. +Types themselves are represented as objects; an object contains a +pointer to the corresponding type object. The type itself has a type +pointer pointing to the object representing the type 'type', which +contains a pointer to itself!). + +Objects do not float around in memory; once allocated an object keeps +the same size and address. Objects that must hold variable-size data +can contain pointers to variable-size parts of the object. Not all +objects of the same type have the same size; but the size cannot change +after allocation. (These restrictions are made so a reference to an +object can be simply a pointer -- moving an object would require +updating all the pointers, and changing an object's size would require +moving it if there was another object right next to it.) + +Objects are always accessed through pointers of the type 'PyObject *'. +The type 'PyObject' is a structure that only contains the reference count +and the type pointer. The actual memory allocated for an object +contains other data that can only be accessed after casting the pointer +to a pointer to a longer structure type. This longer type must start +with the reference count and type fields; the macro PyObject_HEAD should be +used for this (to accommodate for future changes). The implementation +of a particular object type can cast the object pointer to the proper +type and back. + +A standard interface exists for objects that contain an array of items +whose size is determined when the object is allocated. +*/ + +/* Py_DEBUG implies Py_TRACE_REFS. */ +#if defined(Py_DEBUG) && !defined(Py_TRACE_REFS) +#define Py_TRACE_REFS +#endif + +/* Py_TRACE_REFS implies Py_REF_DEBUG. */ +#if defined(Py_TRACE_REFS) && !defined(Py_REF_DEBUG) +#define Py_REF_DEBUG +#endif + +#if defined(Py_LIMITED_API) && defined(Py_REF_DEBUG) +#error Py_LIMITED_API is incompatible with Py_DEBUG, Py_TRACE_REFS, and Py_REF_DEBUG +#endif + + +#ifdef Py_TRACE_REFS +/* Define pointers to support a doubly-linked list of all live heap objects. */ +#define _PyObject_HEAD_EXTRA \ + struct _object *_ob_next; \ + struct _object *_ob_prev; + +#define _PyObject_EXTRA_INIT 0, 0, + +#else +#define _PyObject_HEAD_EXTRA +#define _PyObject_EXTRA_INIT +#endif + +/* PyObject_HEAD defines the initial segment of every PyObject. */ +#define PyObject_HEAD PyObject ob_base; + +#define PyObject_HEAD_INIT(type) \ + { _PyObject_EXTRA_INIT \ + 1, type }, + +#define PyVarObject_HEAD_INIT(type, size) \ + { PyObject_HEAD_INIT(type) size }, + +/* PyObject_VAR_HEAD defines the initial segment of all variable-size + * container objects. These end with a declaration of an array with 1 + * element, but enough space is malloc'ed so that the array actually + * has room for ob_size elements. Note that ob_size is an element count, + * not necessarily a byte count. + */ +#define PyObject_VAR_HEAD PyVarObject ob_base; +#define Py_INVALID_SIZE (Py_ssize_t)-1 + +/* Nothing is actually declared to be a PyObject, but every pointer to + * a Python object can be cast to a PyObject*. This is inheritance built + * by hand. Similarly every pointer to a variable-size Python object can, + * in addition, be cast to PyVarObject*. + */ +typedef struct _object { + _PyObject_HEAD_EXTRA + Py_ssize_t ob_refcnt; + struct _typeobject *ob_type; +} PyObject; + +typedef struct { + PyObject ob_base; + Py_ssize_t ob_size; /* Number of items in variable part */ +} PyVarObject; + +#define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt) +#define Py_TYPE(ob) (((PyObject*)(ob))->ob_type) +#define Py_SIZE(ob) (((PyVarObject*)(ob))->ob_size) + +/********************* String Literals ****************************************/ +/* This structure helps managing static strings. The basic usage goes like this: + Instead of doing + + r = PyObject_CallMethod(o, "foo", "args", ...); + + do + + _Py_IDENTIFIER(foo); + ... + r = _PyObject_CallMethodId(o, &PyId_foo, "args", ...); + + PyId_foo is a static variable, either on block level or file level. On first + usage, the string "foo" is interned, and the structures are linked. On interpreter + shutdown, all strings are released (through _PyUnicode_ClearStaticStrings). + + Alternatively, _Py_static_string allows to choose the variable name. + _PyUnicode_FromId returns a borrowed reference to the interned string. + _PyObject_{Get,Set,Has}AttrId are __getattr__ versions using _Py_Identifier*. +*/ +typedef struct _Py_Identifier { + struct _Py_Identifier *next; + const char* string; + PyObject *object; +} _Py_Identifier; + +#define _Py_static_string_init(value) { 0, value, 0 } +#define _Py_static_string(varname, value) static _Py_Identifier varname = _Py_static_string_init(value) +#define _Py_IDENTIFIER(varname) _Py_static_string(PyId_##varname, #varname) + +/* +Type objects contain a string containing the type name (to help somewhat +in debugging), the allocation parameters (see PyObject_New() and +PyObject_NewVar()), +and methods for accessing objects of the type. Methods are optional, a +nil pointer meaning that particular kind of access is not available for +this type. The Py_DECREF() macro uses the tp_dealloc method without +checking for a nil pointer; it should always be implemented except if +the implementation can guarantee that the reference count will never +reach zero (e.g., for statically allocated type objects). + +NB: the methods for certain type groups are now contained in separate +method blocks. +*/ + +typedef PyObject * (*unaryfunc)(PyObject *); +typedef PyObject * (*binaryfunc)(PyObject *, PyObject *); +typedef PyObject * (*ternaryfunc)(PyObject *, PyObject *, PyObject *); +typedef int (*inquiry)(PyObject *); +typedef Py_ssize_t (*lenfunc)(PyObject *); +typedef PyObject *(*ssizeargfunc)(PyObject *, Py_ssize_t); +typedef PyObject *(*ssizessizeargfunc)(PyObject *, Py_ssize_t, Py_ssize_t); +typedef int(*ssizeobjargproc)(PyObject *, Py_ssize_t, PyObject *); +typedef int(*ssizessizeobjargproc)(PyObject *, Py_ssize_t, Py_ssize_t, PyObject *); +typedef int(*objobjargproc)(PyObject *, PyObject *, PyObject *); + +#ifndef Py_LIMITED_API +/* buffer interface */ +typedef struct bufferinfo { + void *buf; + PyObject *obj; /* owned reference */ + Py_ssize_t len; + Py_ssize_t itemsize; /* This is Py_ssize_t so it can be + pointed to by strides in simple case.*/ + int readonly; + int ndim; + char *format; + Py_ssize_t *shape; + Py_ssize_t *strides; + Py_ssize_t *suboffsets; + void *internal; +} Py_buffer; + +typedef int (*getbufferproc)(PyObject *, Py_buffer *, int); +typedef void (*releasebufferproc)(PyObject *, Py_buffer *); + +/* Maximum number of dimensions */ +#define PyBUF_MAX_NDIM 64 + +/* Flags for getting buffers */ +#define PyBUF_SIMPLE 0 +#define PyBUF_WRITABLE 0x0001 +/* we used to include an E, backwards compatible alias */ +#define PyBUF_WRITEABLE PyBUF_WRITABLE +#define PyBUF_FORMAT 0x0004 +#define PyBUF_ND 0x0008 +#define PyBUF_STRIDES (0x0010 | PyBUF_ND) +#define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES) +#define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES) +#define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES) +#define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES) + +#define PyBUF_CONTIG (PyBUF_ND | PyBUF_WRITABLE) +#define PyBUF_CONTIG_RO (PyBUF_ND) + +#define PyBUF_STRIDED (PyBUF_STRIDES | PyBUF_WRITABLE) +#define PyBUF_STRIDED_RO (PyBUF_STRIDES) + +#define PyBUF_RECORDS (PyBUF_STRIDES | PyBUF_WRITABLE | PyBUF_FORMAT) +#define PyBUF_RECORDS_RO (PyBUF_STRIDES | PyBUF_FORMAT) + +#define PyBUF_FULL (PyBUF_INDIRECT | PyBUF_WRITABLE | PyBUF_FORMAT) +#define PyBUF_FULL_RO (PyBUF_INDIRECT | PyBUF_FORMAT) + + +#define PyBUF_READ 0x100 +#define PyBUF_WRITE 0x200 + +/* End buffer interface */ +#endif /* Py_LIMITED_API */ + +typedef int (*objobjproc)(PyObject *, PyObject *); +typedef int (*visitproc)(PyObject *, void *); +typedef int (*traverseproc)(PyObject *, visitproc, void *); + +#ifndef Py_LIMITED_API +typedef struct { + /* Number implementations must check *both* + arguments for proper type and implement the necessary conversions + in the slot functions themselves. */ + + binaryfunc nb_add; + binaryfunc nb_subtract; + binaryfunc nb_multiply; + binaryfunc nb_remainder; + binaryfunc nb_divmod; + ternaryfunc nb_power; + unaryfunc nb_negative; + unaryfunc nb_positive; + unaryfunc nb_absolute; + inquiry nb_bool; + unaryfunc nb_invert; + binaryfunc nb_lshift; + binaryfunc nb_rshift; + binaryfunc nb_and; + binaryfunc nb_xor; + binaryfunc nb_or; + unaryfunc nb_int; + void *nb_reserved; /* the slot formerly known as nb_long */ + unaryfunc nb_float; + + binaryfunc nb_inplace_add; + binaryfunc nb_inplace_subtract; + binaryfunc nb_inplace_multiply; + binaryfunc nb_inplace_remainder; + ternaryfunc nb_inplace_power; + binaryfunc nb_inplace_lshift; + binaryfunc nb_inplace_rshift; + binaryfunc nb_inplace_and; + binaryfunc nb_inplace_xor; + binaryfunc nb_inplace_or; + + binaryfunc nb_floor_divide; + binaryfunc nb_true_divide; + binaryfunc nb_inplace_floor_divide; + binaryfunc nb_inplace_true_divide; + + unaryfunc nb_index; + + binaryfunc nb_matrix_multiply; + binaryfunc nb_inplace_matrix_multiply; +} PyNumberMethods; + +typedef struct { + lenfunc sq_length; + binaryfunc sq_concat; + ssizeargfunc sq_repeat; + ssizeargfunc sq_item; + void *was_sq_slice; + ssizeobjargproc sq_ass_item; + void *was_sq_ass_slice; + objobjproc sq_contains; + + binaryfunc sq_inplace_concat; + ssizeargfunc sq_inplace_repeat; +} PySequenceMethods; + +typedef struct { + lenfunc mp_length; + binaryfunc mp_subscript; + objobjargproc mp_ass_subscript; +} PyMappingMethods; + +typedef struct { + unaryfunc am_await; + unaryfunc am_aiter; + unaryfunc am_anext; +} PyAsyncMethods; + +typedef struct { + getbufferproc bf_getbuffer; + releasebufferproc bf_releasebuffer; +} PyBufferProcs; +#endif /* Py_LIMITED_API */ + +typedef void (*freefunc)(void *); +typedef void (*destructor)(PyObject *); +#ifndef Py_LIMITED_API +/* We can't provide a full compile-time check that limited-API + users won't implement tp_print. However, not defining printfunc + and making tp_print of a different function pointer type + should at least cause a warning in most cases. */ +typedef int (*printfunc)(PyObject *, FILE *, int); +#endif +typedef PyObject *(*getattrfunc)(PyObject *, char *); +typedef PyObject *(*getattrofunc)(PyObject *, PyObject *); +typedef int (*setattrfunc)(PyObject *, char *, PyObject *); +typedef int (*setattrofunc)(PyObject *, PyObject *, PyObject *); +typedef PyObject *(*reprfunc)(PyObject *); +typedef Py_hash_t (*hashfunc)(PyObject *); +typedef PyObject *(*richcmpfunc) (PyObject *, PyObject *, int); +typedef PyObject *(*getiterfunc) (PyObject *); +typedef PyObject *(*iternextfunc) (PyObject *); +typedef PyObject *(*descrgetfunc) (PyObject *, PyObject *, PyObject *); +typedef int (*descrsetfunc) (PyObject *, PyObject *, PyObject *); +typedef int (*initproc)(PyObject *, PyObject *, PyObject *); +typedef PyObject *(*newfunc)(struct _typeobject *, PyObject *, PyObject *); +typedef PyObject *(*allocfunc)(struct _typeobject *, Py_ssize_t); + +#ifdef Py_LIMITED_API +typedef struct _typeobject PyTypeObject; /* opaque */ +#else +typedef struct _typeobject { + PyObject_VAR_HEAD + const char *tp_name; /* For printing, in format "." */ + Py_ssize_t tp_basicsize, tp_itemsize; /* For allocation */ + + /* Methods to implement standard operations */ + + destructor tp_dealloc; + printfunc tp_print; + getattrfunc tp_getattr; + setattrfunc tp_setattr; + PyAsyncMethods *tp_as_async; /* formerly known as tp_compare or tp_reserved */ + reprfunc tp_repr; + + /* Method suites for standard classes */ + + PyNumberMethods *tp_as_number; + PySequenceMethods *tp_as_sequence; + PyMappingMethods *tp_as_mapping; + + /* More standard operations (here for binary compatibility) */ + + hashfunc tp_hash; + ternaryfunc tp_call; + reprfunc tp_str; + getattrofunc tp_getattro; + setattrofunc tp_setattro; + + /* Functions to access object as input/output buffer */ + PyBufferProcs *tp_as_buffer; + + /* Flags to define presence of optional/expanded features */ + unsigned long tp_flags; + + const char *tp_doc; /* Documentation string */ + + /* Assigned meaning in release 2.0 */ + /* call function for all accessible objects */ + traverseproc tp_traverse; + + /* delete references to contained objects */ + inquiry tp_clear; + + /* Assigned meaning in release 2.1 */ + /* rich comparisons */ + richcmpfunc tp_richcompare; + + /* weak reference enabler */ + Py_ssize_t tp_weaklistoffset; + + /* Iterators */ + getiterfunc tp_iter; + iternextfunc tp_iternext; + + /* Attribute descriptor and subclassing stuff */ + struct PyMethodDef *tp_methods; + struct PyMemberDef *tp_members; + struct PyGetSetDef *tp_getset; + struct _typeobject *tp_base; + PyObject *tp_dict; + descrgetfunc tp_descr_get; + descrsetfunc tp_descr_set; + Py_ssize_t tp_dictoffset; + initproc tp_init; + allocfunc tp_alloc; + newfunc tp_new; + freefunc tp_free; /* Low-level free-memory routine */ + inquiry tp_is_gc; /* For PyObject_IS_GC */ + PyObject *tp_bases; + PyObject *tp_mro; /* method resolution order */ + PyObject *tp_cache; + PyObject *tp_subclasses; + PyObject *tp_weaklist; + destructor tp_del; + + /* Type attribute cache version tag. Added in version 2.6 */ + unsigned int tp_version_tag; + + destructor tp_finalize; + +#ifdef COUNT_ALLOCS + /* these must be last and never explicitly initialized */ + Py_ssize_t tp_allocs; + Py_ssize_t tp_frees; + Py_ssize_t tp_maxalloc; + struct _typeobject *tp_prev; + struct _typeobject *tp_next; +#endif +} PyTypeObject; +#endif + +typedef struct{ + int slot; /* slot id, see below */ + void *pfunc; /* function pointer */ +} PyType_Slot; + +typedef struct{ + const char* name; + int basicsize; + int itemsize; + unsigned int flags; + PyType_Slot *slots; /* terminated by slot==0. */ +} PyType_Spec; + +PyAPI_FUNC(PyObject*) PyType_FromSpec(PyType_Spec*); +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000 +PyAPI_FUNC(PyObject*) PyType_FromSpecWithBases(PyType_Spec*, PyObject*); +#endif +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03040000 +PyAPI_FUNC(void*) PyType_GetSlot(PyTypeObject*, int); +#endif + +#ifndef Py_LIMITED_API +/* The *real* layout of a type object when allocated on the heap */ +typedef struct _heaptypeobject { + /* Note: there's a dependency on the order of these members + in slotptr() in typeobject.c . */ + PyTypeObject ht_type; + PyAsyncMethods as_async; + PyNumberMethods as_number; + PyMappingMethods as_mapping; + PySequenceMethods as_sequence; /* as_sequence comes after as_mapping, + so that the mapping wins when both + the mapping and the sequence define + a given operator (e.g. __getitem__). + see add_operators() in typeobject.c . */ + PyBufferProcs as_buffer; + PyObject *ht_name, *ht_slots, *ht_qualname; + struct _dictkeysobject *ht_cached_keys; + /* here are optional user slots, followed by the members. */ +} PyHeapTypeObject; + +/* access macro to the members which are floating "behind" the object */ +#define PyHeapType_GET_MEMBERS(etype) \ + ((PyMemberDef *)(((char *)etype) + Py_TYPE(etype)->tp_basicsize)) +#endif + +/* Generic type check */ +PyAPI_FUNC(int) PyType_IsSubtype(PyTypeObject *, PyTypeObject *); +#define PyObject_TypeCheck(ob, tp) \ + (Py_TYPE(ob) == (tp) || PyType_IsSubtype(Py_TYPE(ob), (tp))) + +PyAPI_DATA(PyTypeObject) PyType_Type; /* built-in 'type' */ +PyAPI_DATA(PyTypeObject) PyBaseObject_Type; /* built-in 'object' */ +PyAPI_DATA(PyTypeObject) PySuper_Type; /* built-in 'super' */ + +PyAPI_FUNC(unsigned long) PyType_GetFlags(PyTypeObject*); + +#define PyType_Check(op) \ + PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_TYPE_SUBCLASS) +#define PyType_CheckExact(op) (Py_TYPE(op) == &PyType_Type) + +PyAPI_FUNC(int) PyType_Ready(PyTypeObject *); +PyAPI_FUNC(PyObject *) PyType_GenericAlloc(PyTypeObject *, Py_ssize_t); +PyAPI_FUNC(PyObject *) PyType_GenericNew(PyTypeObject *, + PyObject *, PyObject *); +#ifndef Py_LIMITED_API +PyAPI_FUNC(PyObject *) _PyType_Lookup(PyTypeObject *, PyObject *); +PyAPI_FUNC(PyObject *) _PyType_LookupId(PyTypeObject *, _Py_Identifier *); +PyAPI_FUNC(PyObject *) _PyObject_LookupSpecial(PyObject *, _Py_Identifier *); +PyAPI_FUNC(PyTypeObject *) _PyType_CalculateMetaclass(PyTypeObject *, PyObject *); +#endif +PyAPI_FUNC(unsigned int) PyType_ClearCache(void); +PyAPI_FUNC(void) PyType_Modified(PyTypeObject *); + +#ifndef Py_LIMITED_API +PyAPI_FUNC(PyObject *) _PyType_GetDocFromInternalDoc(const char *, const char *); +PyAPI_FUNC(PyObject *) _PyType_GetTextSignatureFromInternalDoc(const char *, const char *); +#endif + +/* Generic operations on objects */ +struct _Py_Identifier; +#ifndef Py_LIMITED_API +PyAPI_FUNC(int) PyObject_Print(PyObject *, FILE *, int); +PyAPI_FUNC(void) _Py_BreakPoint(void); +PyAPI_FUNC(void) _PyObject_Dump(PyObject *); +#endif +PyAPI_FUNC(PyObject *) PyObject_Repr(PyObject *); +PyAPI_FUNC(PyObject *) PyObject_Str(PyObject *); +PyAPI_FUNC(PyObject *) PyObject_ASCII(PyObject *); +PyAPI_FUNC(PyObject *) PyObject_Bytes(PyObject *); +PyAPI_FUNC(PyObject *) PyObject_RichCompare(PyObject *, PyObject *, int); +PyAPI_FUNC(int) PyObject_RichCompareBool(PyObject *, PyObject *, int); +PyAPI_FUNC(PyObject *) PyObject_GetAttrString(PyObject *, const char *); +PyAPI_FUNC(int) PyObject_SetAttrString(PyObject *, const char *, PyObject *); +PyAPI_FUNC(int) PyObject_HasAttrString(PyObject *, const char *); +PyAPI_FUNC(PyObject *) PyObject_GetAttr(PyObject *, PyObject *); +PyAPI_FUNC(int) PyObject_SetAttr(PyObject *, PyObject *, PyObject *); +PyAPI_FUNC(int) PyObject_HasAttr(PyObject *, PyObject *); +PyAPI_FUNC(int) _PyObject_IsAbstract(PyObject *); +PyAPI_FUNC(PyObject *) _PyObject_GetAttrId(PyObject *, struct _Py_Identifier *); +PyAPI_FUNC(int) _PyObject_SetAttrId(PyObject *, struct _Py_Identifier *, PyObject *); +PyAPI_FUNC(int) _PyObject_HasAttrId(PyObject *, struct _Py_Identifier *); +#ifndef Py_LIMITED_API +PyAPI_FUNC(PyObject **) _PyObject_GetDictPtr(PyObject *); +#endif +PyAPI_FUNC(PyObject *) PyObject_SelfIter(PyObject *); +#ifndef Py_LIMITED_API +PyAPI_FUNC(PyObject *) _PyObject_NextNotImplemented(PyObject *); +#endif +PyAPI_FUNC(PyObject *) PyObject_GenericGetAttr(PyObject *, PyObject *); +PyAPI_FUNC(int) PyObject_GenericSetAttr(PyObject *, + PyObject *, PyObject *); +PyAPI_FUNC(int) PyObject_GenericSetDict(PyObject *, PyObject *, void *); +PyAPI_FUNC(Py_hash_t) PyObject_Hash(PyObject *); +PyAPI_FUNC(Py_hash_t) PyObject_HashNotImplemented(PyObject *); +PyAPI_FUNC(int) PyObject_IsTrue(PyObject *); +PyAPI_FUNC(int) PyObject_Not(PyObject *); +PyAPI_FUNC(int) PyCallable_Check(PyObject *); + +PyAPI_FUNC(void) PyObject_ClearWeakRefs(PyObject *); +#ifndef Py_LIMITED_API +PyAPI_FUNC(void) PyObject_CallFinalizer(PyObject *); +PyAPI_FUNC(int) PyObject_CallFinalizerFromDealloc(PyObject *); +#endif + +/* Same as PyObject_Generic{Get,Set}Attr, but passing the attributes + dict as the last parameter. */ +PyAPI_FUNC(PyObject *) +_PyObject_GenericGetAttrWithDict(PyObject *, PyObject *, PyObject *); +PyAPI_FUNC(int) +_PyObject_GenericSetAttrWithDict(PyObject *, PyObject *, + PyObject *, PyObject *); + +/* Helper to look up a builtin object */ +#ifndef Py_LIMITED_API +PyAPI_FUNC(PyObject *) +_PyObject_GetBuiltin(const char *name); +#endif + +/* PyObject_Dir(obj) acts like Python builtins.dir(obj), returning a + list of strings. PyObject_Dir(NULL) is like builtins.dir(), + returning the names of the current locals. In this case, if there are + no current locals, NULL is returned, and PyErr_Occurred() is false. +*/ +PyAPI_FUNC(PyObject *) PyObject_Dir(PyObject *); + + +/* Helpers for printing recursive container types */ +PyAPI_FUNC(int) Py_ReprEnter(PyObject *); +PyAPI_FUNC(void) Py_ReprLeave(PyObject *); + +/* Flag bits for printing: */ +#define Py_PRINT_RAW 1 /* No string quotes etc. */ + +/* +`Type flags (tp_flags) + +These flags are used to extend the type structure in a backwards-compatible +fashion. Extensions can use the flags to indicate (and test) when a given +type structure contains a new feature. The Python core will use these when +introducing new functionality between major revisions (to avoid mid-version +changes in the PYTHON_API_VERSION). + +Arbitration of the flag bit positions will need to be coordinated among +all extension writers who publically release their extensions (this will +be fewer than you might expect!).. + +Most flags were removed as of Python 3.0 to make room for new flags. (Some +flags are not for backwards compatibility but to indicate the presence of an +optional feature; these flags remain of course.) + +Type definitions should use Py_TPFLAGS_DEFAULT for their tp_flags value. + +Code can use PyType_HasFeature(type_ob, flag_value) to test whether the +given type object has a specified feature. +*/ + +/* Set if the type object is dynamically allocated */ +#define Py_TPFLAGS_HEAPTYPE (1UL << 9) + +/* Set if the type allows subclassing */ +#define Py_TPFLAGS_BASETYPE (1UL << 10) + +/* Set if the type is 'ready' -- fully initialized */ +#define Py_TPFLAGS_READY (1UL << 12) + +/* Set while the type is being 'readied', to prevent recursive ready calls */ +#define Py_TPFLAGS_READYING (1UL << 13) + +/* Objects support garbage collection (see objimp.h) */ +#define Py_TPFLAGS_HAVE_GC (1UL << 14) + +/* These two bits are preserved for Stackless Python, next after this is 17 */ +#ifdef STACKLESS +#define Py_TPFLAGS_HAVE_STACKLESS_EXTENSION (3UL << 15) +#else +#define Py_TPFLAGS_HAVE_STACKLESS_EXTENSION 0 +#endif + +/* Objects support type attribute cache */ +#define Py_TPFLAGS_HAVE_VERSION_TAG (1UL << 18) +#define Py_TPFLAGS_VALID_VERSION_TAG (1UL << 19) + +/* Type is abstract and cannot be instantiated */ +#define Py_TPFLAGS_IS_ABSTRACT (1UL << 20) + +/* These flags are used to determine if a type is a subclass. */ +#define Py_TPFLAGS_LONG_SUBCLASS (1UL << 24) +#define Py_TPFLAGS_LIST_SUBCLASS (1UL << 25) +#define Py_TPFLAGS_TUPLE_SUBCLASS (1UL << 26) +#define Py_TPFLAGS_BYTES_SUBCLASS (1UL << 27) +#define Py_TPFLAGS_UNICODE_SUBCLASS (1UL << 28) +#define Py_TPFLAGS_DICT_SUBCLASS (1UL << 29) +#define Py_TPFLAGS_BASE_EXC_SUBCLASS (1UL << 30) +#define Py_TPFLAGS_TYPE_SUBCLASS (1UL << 31) + +#define Py_TPFLAGS_DEFAULT ( \ + Py_TPFLAGS_HAVE_STACKLESS_EXTENSION | \ + Py_TPFLAGS_HAVE_VERSION_TAG | \ + 0) + +/* NOTE: The following flags reuse lower bits (removed as part of the + * Python 3.0 transition). */ + +/* Type structure has tp_finalize member (3.4) */ +#define Py_TPFLAGS_HAVE_FINALIZE (1UL << 0) + +#ifdef Py_LIMITED_API +#define PyType_HasFeature(t,f) ((PyType_GetFlags(t) & (f)) != 0) +#else +#define PyType_HasFeature(t,f) (((t)->tp_flags & (f)) != 0) +#endif +#define PyType_FastSubclass(t,f) PyType_HasFeature(t,f) + + +/* +The macros Py_INCREF(op) and Py_DECREF(op) are used to increment or decrement +reference counts. Py_DECREF calls the object's deallocator function when +the refcount falls to 0; for +objects that don't contain references to other objects or heap memory +this can be the standard function free(). Both macros can be used +wherever a void expression is allowed. The argument must not be a +NULL pointer. If it may be NULL, use Py_XINCREF/Py_XDECREF instead. +The macro _Py_NewReference(op) initialize reference counts to 1, and +in special builds (Py_REF_DEBUG, Py_TRACE_REFS) performs additional +bookkeeping appropriate to the special build. + +We assume that the reference count field can never overflow; this can +be proven when the size of the field is the same as the pointer size, so +we ignore the possibility. Provided a C int is at least 32 bits (which +is implicitly assumed in many parts of this code), that's enough for +about 2**31 references to an object. + +XXX The following became out of date in Python 2.2, but I'm not sure +XXX what the full truth is now. Certainly, heap-allocated type objects +XXX can and should be deallocated. +Type objects should never be deallocated; the type pointer in an object +is not considered to be a reference to the type object, to save +complications in the deallocation function. (This is actually a +decision that's up to the implementer of each new type so if you want, +you can count such references to the type object.) +*/ + +/* First define a pile of simple helper macros, one set per special + * build symbol. These either expand to the obvious things, or to + * nothing at all when the special mode isn't in effect. The main + * macros can later be defined just once then, yet expand to different + * things depending on which special build options are and aren't in effect. + * Trust me : while painful, this is 20x easier to understand than, + * e.g, defining _Py_NewReference five different times in a maze of nested + * #ifdefs (we used to do that -- it was impenetrable). + */ +#ifdef Py_REF_DEBUG +PyAPI_DATA(Py_ssize_t) _Py_RefTotal; +PyAPI_FUNC(void) _Py_NegativeRefcount(const char *fname, + int lineno, PyObject *op); +PyAPI_FUNC(PyObject *) _PyDict_Dummy(void); +PyAPI_FUNC(Py_ssize_t) _Py_GetRefTotal(void); +#define _Py_INC_REFTOTAL _Py_RefTotal++ +#define _Py_DEC_REFTOTAL _Py_RefTotal-- +#define _Py_REF_DEBUG_COMMA , +#define _Py_CHECK_REFCNT(OP) \ +{ if (((PyObject*)OP)->ob_refcnt < 0) \ + _Py_NegativeRefcount(__FILE__, __LINE__, \ + (PyObject *)(OP)); \ +} +/* Py_REF_DEBUG also controls the display of refcounts and memory block + * allocations at the interactive prompt and at interpreter shutdown + */ +PyAPI_FUNC(void) _PyDebug_PrintTotalRefs(void); +#define _PY_DEBUG_PRINT_TOTAL_REFS() _PyDebug_PrintTotalRefs() +#else +#define _Py_INC_REFTOTAL +#define _Py_DEC_REFTOTAL +#define _Py_REF_DEBUG_COMMA +#define _Py_CHECK_REFCNT(OP) /* a semicolon */; +#define _PY_DEBUG_PRINT_TOTAL_REFS() +#endif /* Py_REF_DEBUG */ + +#ifdef COUNT_ALLOCS +PyAPI_FUNC(void) inc_count(PyTypeObject *); +PyAPI_FUNC(void) dec_count(PyTypeObject *); +#define _Py_INC_TPALLOCS(OP) inc_count(Py_TYPE(OP)) +#define _Py_INC_TPFREES(OP) dec_count(Py_TYPE(OP)) +#define _Py_DEC_TPFREES(OP) Py_TYPE(OP)->tp_frees-- +#define _Py_COUNT_ALLOCS_COMMA , +#else +#define _Py_INC_TPALLOCS(OP) +#define _Py_INC_TPFREES(OP) +#define _Py_DEC_TPFREES(OP) +#define _Py_COUNT_ALLOCS_COMMA +#endif /* COUNT_ALLOCS */ + +#ifdef Py_TRACE_REFS +/* Py_TRACE_REFS is such major surgery that we call external routines. */ +PyAPI_FUNC(void) _Py_NewReference(PyObject *); +PyAPI_FUNC(void) _Py_ForgetReference(PyObject *); +PyAPI_FUNC(void) _Py_Dealloc(PyObject *); +PyAPI_FUNC(void) _Py_PrintReferences(FILE *); +PyAPI_FUNC(void) _Py_PrintReferenceAddresses(FILE *); +PyAPI_FUNC(void) _Py_AddToAllObjects(PyObject *, int force); + +#else +/* Without Py_TRACE_REFS, there's little enough to do that we expand code + * inline. + */ +#define _Py_NewReference(op) ( \ + _Py_INC_TPALLOCS(op) _Py_COUNT_ALLOCS_COMMA \ + _Py_INC_REFTOTAL _Py_REF_DEBUG_COMMA \ + Py_REFCNT(op) = 1) + +#define _Py_ForgetReference(op) _Py_INC_TPFREES(op) + +#ifdef Py_LIMITED_API +PyAPI_FUNC(void) _Py_Dealloc(PyObject *); +#else +#define _Py_Dealloc(op) ( \ + _Py_INC_TPFREES(op) _Py_COUNT_ALLOCS_COMMA \ + (*Py_TYPE(op)->tp_dealloc)((PyObject *)(op))) +#endif +#endif /* !Py_TRACE_REFS */ + +#define Py_INCREF(op) ( \ + _Py_INC_REFTOTAL _Py_REF_DEBUG_COMMA \ + ((PyObject *)(op))->ob_refcnt++) + +#define Py_DECREF(op) \ + do { \ + PyObject *_py_decref_tmp = (PyObject *)(op); \ + if (_Py_DEC_REFTOTAL _Py_REF_DEBUG_COMMA \ + --(_py_decref_tmp)->ob_refcnt != 0) \ + _Py_CHECK_REFCNT(_py_decref_tmp) \ + else \ + _Py_Dealloc(_py_decref_tmp); \ + } while (0) + +/* Safely decref `op` and set `op` to NULL, especially useful in tp_clear + * and tp_dealloc implementations. + * + * Note that "the obvious" code can be deadly: + * + * Py_XDECREF(op); + * op = NULL; + * + * Typically, `op` is something like self->containee, and `self` is done + * using its `containee` member. In the code sequence above, suppose + * `containee` is non-NULL with a refcount of 1. Its refcount falls to + * 0 on the first line, which can trigger an arbitrary amount of code, + * possibly including finalizers (like __del__ methods or weakref callbacks) + * coded in Python, which in turn can release the GIL and allow other threads + * to run, etc. Such code may even invoke methods of `self` again, or cause + * cyclic gc to trigger, but-- oops! --self->containee still points to the + * object being torn down, and it may be in an insane state while being torn + * down. This has in fact been a rich historic source of miserable (rare & + * hard-to-diagnose) segfaulting (and other) bugs. + * + * The safe way is: + * + * Py_CLEAR(op); + * + * That arranges to set `op` to NULL _before_ decref'ing, so that any code + * triggered as a side-effect of `op` getting torn down no longer believes + * `op` points to a valid object. + * + * There are cases where it's safe to use the naive code, but they're brittle. + * For example, if `op` points to a Python integer, you know that destroying + * one of those can't cause problems -- but in part that relies on that + * Python integers aren't currently weakly referencable. Best practice is + * to use Py_CLEAR() even if you can't think of a reason for why you need to. + */ +#define Py_CLEAR(op) \ + do { \ + PyObject *_py_tmp = (PyObject *)(op); \ + if (_py_tmp != NULL) { \ + (op) = NULL; \ + Py_DECREF(_py_tmp); \ + } \ + } while (0) + +/* Macros to use in case the object pointer may be NULL: */ +#define Py_XINCREF(op) \ + do { \ + PyObject *_py_xincref_tmp = (PyObject *)(op); \ + if (_py_xincref_tmp != NULL) \ + Py_INCREF(_py_xincref_tmp); \ + } while (0) + +#define Py_XDECREF(op) \ + do { \ + PyObject *_py_xdecref_tmp = (PyObject *)(op); \ + if (_py_xdecref_tmp != NULL) \ + Py_DECREF(_py_xdecref_tmp); \ + } while (0) + +/* +These are provided as conveniences to Python runtime embedders, so that +they can have object code that is not dependent on Python compilation flags. +*/ +PyAPI_FUNC(void) Py_IncRef(PyObject *); +PyAPI_FUNC(void) Py_DecRef(PyObject *); + +PyAPI_DATA(PyTypeObject) _PyNone_Type; +PyAPI_DATA(PyTypeObject) _PyNotImplemented_Type; + +/* +_Py_NoneStruct is an object of undefined type which can be used in contexts +where NULL (nil) is not suitable (since NULL often means 'error'). + +Don't forget to apply Py_INCREF() when returning this value!!! +*/ +PyAPI_DATA(PyObject) _Py_NoneStruct; /* Don't use this directly */ +#define Py_None (&_Py_NoneStruct) + +/* Macro for returning Py_None from a function */ +#define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None + +/* +Py_NotImplemented is a singleton used to signal that an operation is +not implemented for a given type combination. +*/ +PyAPI_DATA(PyObject) _Py_NotImplementedStruct; /* Don't use this directly */ +#define Py_NotImplemented (&_Py_NotImplementedStruct) + +/* Macro for returning Py_NotImplemented from a function */ +#define Py_RETURN_NOTIMPLEMENTED \ + return Py_INCREF(Py_NotImplemented), Py_NotImplemented + +/* Rich comparison opcodes */ +#define Py_LT 0 +#define Py_LE 1 +#define Py_EQ 2 +#define Py_NE 3 +#define Py_GT 4 +#define Py_GE 5 + +/* Maps Py_LT to Py_GT, ..., Py_GE to Py_LE. + * Defined in object.c. + */ +PyAPI_DATA(int) _Py_SwappedOp[]; + + +/* +More conventions +================ + +Argument Checking +----------------- + +Functions that take objects as arguments normally don't check for nil +arguments, but they do check the type of the argument, and return an +error if the function doesn't apply to the type. + +Failure Modes +------------- + +Functions may fail for a variety of reasons, including running out of +memory. This is communicated to the caller in two ways: an error string +is set (see errors.h), and the function result differs: functions that +normally return a pointer return NULL for failure, functions returning +an integer return -1 (which could be a legal return value too!), and +other functions return 0 for success and -1 for failure. +Callers should always check for errors before using the result. If +an error was set, the caller must either explicitly clear it, or pass +the error on to its caller. + +Reference Counts +---------------- + +It takes a while to get used to the proper usage of reference counts. + +Functions that create an object set the reference count to 1; such new +objects must be stored somewhere or destroyed again with Py_DECREF(). +Some functions that 'store' objects, such as PyTuple_SetItem() and +PyList_SetItem(), +don't increment the reference count of the object, since the most +frequent use is to store a fresh object. Functions that 'retrieve' +objects, such as PyTuple_GetItem() and PyDict_GetItemString(), also +don't increment +the reference count, since most frequently the object is only looked at +quickly. Thus, to retrieve an object and store it again, the caller +must call Py_INCREF() explicitly. + +NOTE: functions that 'consume' a reference count, like +PyList_SetItem(), consume the reference even if the object wasn't +successfully stored, to simplify error handling. + +It seems attractive to make other functions that take an object as +argument consume a reference count; however, this may quickly get +confusing (even the current practice is already confusing). Consider +it carefully, it may save lots of calls to Py_INCREF() and Py_DECREF() at +times. +*/ + + +/* Trashcan mechanism, thanks to Christian Tismer. + +When deallocating a container object, it's possible to trigger an unbounded +chain of deallocations, as each Py_DECREF in turn drops the refcount on "the +next" object in the chain to 0. This can easily lead to stack faults, and +especially in threads (which typically have less stack space to work with). + +A container object that participates in cyclic gc can avoid this by +bracketing the body of its tp_dealloc function with a pair of macros: + +static void +mytype_dealloc(mytype *p) +{ + ... declarations go here ... + + PyObject_GC_UnTrack(p); // must untrack first + Py_TRASHCAN_SAFE_BEGIN(p) + ... The body of the deallocator goes here, including all calls ... + ... to Py_DECREF on contained objects. ... + Py_TRASHCAN_SAFE_END(p) +} + +CAUTION: Never return from the middle of the body! If the body needs to +"get out early", put a label immediately before the Py_TRASHCAN_SAFE_END +call, and goto it. Else the call-depth counter (see below) will stay +above 0 forever, and the trashcan will never get emptied. + +How it works: The BEGIN macro increments a call-depth counter. So long +as this counter is small, the body of the deallocator is run directly without +further ado. But if the counter gets large, it instead adds p to a list of +objects to be deallocated later, skips the body of the deallocator, and +resumes execution after the END macro. The tp_dealloc routine then returns +without deallocating anything (and so unbounded call-stack depth is avoided). + +When the call stack finishes unwinding again, code generated by the END macro +notices this, and calls another routine to deallocate all the objects that +may have been added to the list of deferred deallocations. In effect, a +chain of N deallocations is broken into N / PyTrash_UNWIND_LEVEL pieces, +with the call stack never exceeding a depth of PyTrash_UNWIND_LEVEL. +*/ + +/* This is the old private API, invoked by the macros before 3.2.4. + Kept for binary compatibility of extensions using the stable ABI. */ +PyAPI_FUNC(void) _PyTrash_deposit_object(PyObject*); +PyAPI_FUNC(void) _PyTrash_destroy_chain(void); +PyAPI_DATA(int) _PyTrash_delete_nesting; +PyAPI_DATA(PyObject *) _PyTrash_delete_later; + +/* The new thread-safe private API, invoked by the macros below. */ +PyAPI_FUNC(void) _PyTrash_thread_deposit_object(PyObject*); +PyAPI_FUNC(void) _PyTrash_thread_destroy_chain(void); + +#define PyTrash_UNWIND_LEVEL 50 + +#define Py_TRASHCAN_SAFE_BEGIN(op) \ + do { \ + PyThreadState *_tstate = PyThreadState_GET(); \ + if (_tstate->trash_delete_nesting < PyTrash_UNWIND_LEVEL) { \ + ++_tstate->trash_delete_nesting; + /* The body of the deallocator is here. */ +#define Py_TRASHCAN_SAFE_END(op) \ + --_tstate->trash_delete_nesting; \ + if (_tstate->trash_delete_later && _tstate->trash_delete_nesting <= 0) \ + _PyTrash_thread_destroy_chain(); \ + } \ + else \ + _PyTrash_thread_deposit_object((PyObject*)op); \ + } while (0); + +#ifndef Py_LIMITED_API +PyAPI_FUNC(void) +_PyDebugAllocatorStats(FILE *out, const char *block_name, int num_blocks, + size_t sizeof_block); +PyAPI_FUNC(void) +_PyObject_DebugTypeStats(FILE *out); +#endif /* ifndef Py_LIMITED_API */ + +#ifdef __cplusplus +} +#endif +#endif /* !Py_OBJECT_H */ diff --git a/android/python35/include/objimpl.h b/android/python35/include/objimpl.h new file mode 100644 index 000000000..65b6d91c3 --- /dev/null +++ b/android/python35/include/objimpl.h @@ -0,0 +1,363 @@ +/* The PyObject_ memory family: high-level object memory interfaces. + See pymem.h for the low-level PyMem_ family. +*/ + +#ifndef Py_OBJIMPL_H +#define Py_OBJIMPL_H + +#include "pymem.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* BEWARE: + + Each interface exports both functions and macros. Extension modules should + use the functions, to ensure binary compatibility across Python versions. + Because the Python implementation is free to change internal details, and + the macros may (or may not) expose details for speed, if you do use the + macros you must recompile your extensions with each Python release. + + Never mix calls to PyObject_ memory functions with calls to the platform + malloc/realloc/ calloc/free, or with calls to PyMem_. +*/ + +/* +Functions and macros for modules that implement new object types. + + - PyObject_New(type, typeobj) allocates memory for a new object of the given + type, and initializes part of it. 'type' must be the C structure type used + to represent the object, and 'typeobj' the address of the corresponding + type object. Reference count and type pointer are filled in; the rest of + the bytes of the object are *undefined*! The resulting expression type is + 'type *'. The size of the object is determined by the tp_basicsize field + of the type object. + + - PyObject_NewVar(type, typeobj, n) is similar but allocates a variable-size + object with room for n items. In addition to the refcount and type pointer + fields, this also fills in the ob_size field. + + - PyObject_Del(op) releases the memory allocated for an object. It does not + run a destructor -- it only frees the memory. PyObject_Free is identical. + + - PyObject_Init(op, typeobj) and PyObject_InitVar(op, typeobj, n) don't + allocate memory. Instead of a 'type' parameter, they take a pointer to a + new object (allocated by an arbitrary allocator), and initialize its object + header fields. + +Note that objects created with PyObject_{New, NewVar} are allocated using the +specialized Python allocator (implemented in obmalloc.c), if WITH_PYMALLOC is +enabled. In addition, a special debugging allocator is used if PYMALLOC_DEBUG +is also #defined. + +In case a specific form of memory management is needed (for example, if you +must use the platform malloc heap(s), or shared memory, or C++ local storage or +operator new), you must first allocate the object with your custom allocator, +then pass its pointer to PyObject_{Init, InitVar} for filling in its Python- +specific fields: reference count, type pointer, possibly others. You should +be aware that Python no control over these objects because they don't +cooperate with the Python memory manager. Such objects may not be eligible +for automatic garbage collection and you have to make sure that they are +released accordingly whenever their destructor gets called (cf. the specific +form of memory management you're using). + +Unless you have specific memory management requirements, use +PyObject_{New, NewVar, Del}. +*/ + +/* + * Raw object memory interface + * =========================== + */ + +/* Functions to call the same malloc/realloc/free as used by Python's + object allocator. If WITH_PYMALLOC is enabled, these may differ from + the platform malloc/realloc/free. The Python object allocator is + designed for fast, cache-conscious allocation of many "small" objects, + and with low hidden memory overhead. + + PyObject_Malloc(0) returns a unique non-NULL pointer if possible. + + PyObject_Realloc(NULL, n) acts like PyObject_Malloc(n). + PyObject_Realloc(p != NULL, 0) does not return NULL, or free the memory + at p. + + Returned pointers must be checked for NULL explicitly; no action is + performed on failure other than to return NULL (no warning it printed, no + exception is set, etc). + + For allocating objects, use PyObject_{New, NewVar} instead whenever + possible. The PyObject_{Malloc, Realloc, Free} family is exposed + so that you can exploit Python's small-block allocator for non-object + uses. If you must use these routines to allocate object memory, make sure + the object gets initialized via PyObject_{Init, InitVar} after obtaining + the raw memory. +*/ +PyAPI_FUNC(void *) PyObject_Malloc(size_t size); +PyAPI_FUNC(void *) PyObject_Calloc(size_t nelem, size_t elsize); +PyAPI_FUNC(void *) PyObject_Realloc(void *ptr, size_t new_size); +PyAPI_FUNC(void) PyObject_Free(void *ptr); + +/* This function returns the number of allocated memory blocks, regardless of size */ +PyAPI_FUNC(Py_ssize_t) _Py_GetAllocatedBlocks(void); + +/* Macros */ +#ifdef WITH_PYMALLOC +#ifndef Py_LIMITED_API +PyAPI_FUNC(void) _PyObject_DebugMallocStats(FILE *out); +#endif /* #ifndef Py_LIMITED_API */ +#endif + +/* Macros */ +#define PyObject_MALLOC PyObject_Malloc +#define PyObject_REALLOC PyObject_Realloc +#define PyObject_FREE PyObject_Free +#define PyObject_Del PyObject_Free +#define PyObject_DEL PyObject_Free + + +/* + * Generic object allocator interface + * ================================== + */ + +/* Functions */ +PyAPI_FUNC(PyObject *) PyObject_Init(PyObject *, PyTypeObject *); +PyAPI_FUNC(PyVarObject *) PyObject_InitVar(PyVarObject *, + PyTypeObject *, Py_ssize_t); +PyAPI_FUNC(PyObject *) _PyObject_New(PyTypeObject *); +PyAPI_FUNC(PyVarObject *) _PyObject_NewVar(PyTypeObject *, Py_ssize_t); + +#define PyObject_New(type, typeobj) \ + ( (type *) _PyObject_New(typeobj) ) +#define PyObject_NewVar(type, typeobj, n) \ + ( (type *) _PyObject_NewVar((typeobj), (n)) ) + +/* Macros trading binary compatibility for speed. See also pymem.h. + Note that these macros expect non-NULL object pointers.*/ +#define PyObject_INIT(op, typeobj) \ + ( Py_TYPE(op) = (typeobj), _Py_NewReference((PyObject *)(op)), (op) ) +#define PyObject_INIT_VAR(op, typeobj, size) \ + ( Py_SIZE(op) = (size), PyObject_INIT((op), (typeobj)) ) + +#define _PyObject_SIZE(typeobj) ( (typeobj)->tp_basicsize ) + +/* _PyObject_VAR_SIZE returns the number of bytes (as size_t) allocated for a + vrbl-size object with nitems items, exclusive of gc overhead (if any). The + value is rounded up to the closest multiple of sizeof(void *), in order to + ensure that pointer fields at the end of the object are correctly aligned + for the platform (this is of special importance for subclasses of, e.g., + str or int, so that pointers can be stored after the embedded data). + + Note that there's no memory wastage in doing this, as malloc has to + return (at worst) pointer-aligned memory anyway. +*/ +#if ((SIZEOF_VOID_P - 1) & SIZEOF_VOID_P) != 0 +# error "_PyObject_VAR_SIZE requires SIZEOF_VOID_P be a power of 2" +#endif + +#define _PyObject_VAR_SIZE(typeobj, nitems) \ + _Py_SIZE_ROUND_UP((typeobj)->tp_basicsize + \ + (nitems)*(typeobj)->tp_itemsize, \ + SIZEOF_VOID_P) + +#define PyObject_NEW(type, typeobj) \ +( (type *) PyObject_Init( \ + (PyObject *) PyObject_MALLOC( _PyObject_SIZE(typeobj) ), (typeobj)) ) + +#define PyObject_NEW_VAR(type, typeobj, n) \ +( (type *) PyObject_InitVar( \ + (PyVarObject *) PyObject_MALLOC(_PyObject_VAR_SIZE((typeobj),(n)) ),\ + (typeobj), (n)) ) + +/* This example code implements an object constructor with a custom + allocator, where PyObject_New is inlined, and shows the important + distinction between two steps (at least): + 1) the actual allocation of the object storage; + 2) the initialization of the Python specific fields + in this storage with PyObject_{Init, InitVar}. + + PyObject * + YourObject_New(...) + { + PyObject *op; + + op = (PyObject *) Your_Allocator(_PyObject_SIZE(YourTypeStruct)); + if (op == NULL) + return PyErr_NoMemory(); + + PyObject_Init(op, &YourTypeStruct); + + op->ob_field = value; + ... + return op; + } + + Note that in C++, the use of the new operator usually implies that + the 1st step is performed automatically for you, so in a C++ class + constructor you would start directly with PyObject_Init/InitVar +*/ + +#ifndef Py_LIMITED_API +typedef struct { + /* user context passed as the first argument to the 2 functions */ + void *ctx; + + /* allocate an arena of size bytes */ + void* (*alloc) (void *ctx, size_t size); + + /* free an arena */ + void (*free) (void *ctx, void *ptr, size_t size); +} PyObjectArenaAllocator; + +/* Get the arena allocator. */ +PyAPI_FUNC(void) PyObject_GetArenaAllocator(PyObjectArenaAllocator *allocator); + +/* Set the arena allocator. */ +PyAPI_FUNC(void) PyObject_SetArenaAllocator(PyObjectArenaAllocator *allocator); +#endif + + +/* + * Garbage Collection Support + * ========================== + */ + +/* C equivalent of gc.collect(). */ +PyAPI_FUNC(Py_ssize_t) PyGC_Collect(void); + +#ifndef Py_LIMITED_API +PyAPI_FUNC(Py_ssize_t) _PyGC_CollectNoFail(void); +#endif + +/* Test if a type has a GC head */ +#define PyType_IS_GC(t) PyType_HasFeature((t), Py_TPFLAGS_HAVE_GC) + +/* Test if an object has a GC head */ +#define PyObject_IS_GC(o) (PyType_IS_GC(Py_TYPE(o)) && \ + (Py_TYPE(o)->tp_is_gc == NULL || Py_TYPE(o)->tp_is_gc(o))) + +PyAPI_FUNC(PyVarObject *) _PyObject_GC_Resize(PyVarObject *, Py_ssize_t); +#define PyObject_GC_Resize(type, op, n) \ + ( (type *) _PyObject_GC_Resize((PyVarObject *)(op), (n)) ) + +/* GC information is stored BEFORE the object structure. */ +#ifndef Py_LIMITED_API +typedef union _gc_head { + struct { + union _gc_head *gc_next; + union _gc_head *gc_prev; + Py_ssize_t gc_refs; + } gc; + double dummy; /* force worst-case alignment */ +} PyGC_Head; + +extern PyGC_Head *_PyGC_generation0; + +#define _Py_AS_GC(o) ((PyGC_Head *)(o)-1) + +/* Bit 0 is set when tp_finalize is called */ +#define _PyGC_REFS_MASK_FINALIZED (1 << 0) +/* The (N-1) most significant bits contain the gc state / refcount */ +#define _PyGC_REFS_SHIFT (1) +#define _PyGC_REFS_MASK (((size_t) -1) << _PyGC_REFS_SHIFT) + +#define _PyGCHead_REFS(g) ((g)->gc.gc_refs >> _PyGC_REFS_SHIFT) +#define _PyGCHead_SET_REFS(g, v) do { \ + (g)->gc.gc_refs = ((g)->gc.gc_refs & ~_PyGC_REFS_MASK) \ + | (((size_t)(v)) << _PyGC_REFS_SHIFT); \ + } while (0) +#define _PyGCHead_DECREF(g) ((g)->gc.gc_refs -= 1 << _PyGC_REFS_SHIFT) + +#define _PyGCHead_FINALIZED(g) (((g)->gc.gc_refs & _PyGC_REFS_MASK_FINALIZED) != 0) +#define _PyGCHead_SET_FINALIZED(g, v) do { \ + (g)->gc.gc_refs = ((g)->gc.gc_refs & ~_PyGC_REFS_MASK_FINALIZED) \ + | (v != 0); \ + } while (0) + +#define _PyGC_FINALIZED(o) _PyGCHead_FINALIZED(_Py_AS_GC(o)) +#define _PyGC_SET_FINALIZED(o, v) _PyGCHead_SET_FINALIZED(_Py_AS_GC(o), v) + +#define _PyGC_REFS(o) _PyGCHead_REFS(_Py_AS_GC(o)) + +#define _PyGC_REFS_UNTRACKED (-2) +#define _PyGC_REFS_REACHABLE (-3) +#define _PyGC_REFS_TENTATIVELY_UNREACHABLE (-4) + +/* Tell the GC to track this object. NB: While the object is tracked the + * collector it must be safe to call the ob_traverse method. */ +#define _PyObject_GC_TRACK(o) do { \ + PyGC_Head *g = _Py_AS_GC(o); \ + if (_PyGCHead_REFS(g) != _PyGC_REFS_UNTRACKED) \ + Py_FatalError("GC object already tracked"); \ + _PyGCHead_SET_REFS(g, _PyGC_REFS_REACHABLE); \ + g->gc.gc_next = _PyGC_generation0; \ + g->gc.gc_prev = _PyGC_generation0->gc.gc_prev; \ + g->gc.gc_prev->gc.gc_next = g; \ + _PyGC_generation0->gc.gc_prev = g; \ + } while (0); + +/* Tell the GC to stop tracking this object. + * gc_next doesn't need to be set to NULL, but doing so is a good + * way to provoke memory errors if calling code is confused. + */ +#define _PyObject_GC_UNTRACK(o) do { \ + PyGC_Head *g = _Py_AS_GC(o); \ + assert(_PyGCHead_REFS(g) != _PyGC_REFS_UNTRACKED); \ + _PyGCHead_SET_REFS(g, _PyGC_REFS_UNTRACKED); \ + g->gc.gc_prev->gc.gc_next = g->gc.gc_next; \ + g->gc.gc_next->gc.gc_prev = g->gc.gc_prev; \ + g->gc.gc_next = NULL; \ + } while (0); + +/* True if the object is currently tracked by the GC. */ +#define _PyObject_GC_IS_TRACKED(o) \ + (_PyGC_REFS(o) != _PyGC_REFS_UNTRACKED) + +/* True if the object may be tracked by the GC in the future, or already is. + This can be useful to implement some optimizations. */ +#define _PyObject_GC_MAY_BE_TRACKED(obj) \ + (PyObject_IS_GC(obj) && \ + (!PyTuple_CheckExact(obj) || _PyObject_GC_IS_TRACKED(obj))) +#endif /* Py_LIMITED_API */ + +PyAPI_FUNC(PyObject *) _PyObject_GC_Malloc(size_t size); +PyAPI_FUNC(PyObject *) _PyObject_GC_Calloc(size_t size); +PyAPI_FUNC(PyObject *) _PyObject_GC_New(PyTypeObject *); +PyAPI_FUNC(PyVarObject *) _PyObject_GC_NewVar(PyTypeObject *, Py_ssize_t); +PyAPI_FUNC(void) PyObject_GC_Track(void *); +PyAPI_FUNC(void) PyObject_GC_UnTrack(void *); +PyAPI_FUNC(void) PyObject_GC_Del(void *); + +#define PyObject_GC_New(type, typeobj) \ + ( (type *) _PyObject_GC_New(typeobj) ) +#define PyObject_GC_NewVar(type, typeobj, n) \ + ( (type *) _PyObject_GC_NewVar((typeobj), (n)) ) + + +/* Utility macro to help write tp_traverse functions. + * To use this macro, the tp_traverse function must name its arguments + * "visit" and "arg". This is intended to keep tp_traverse functions + * looking as much alike as possible. + */ +#define Py_VISIT(op) \ + do { \ + if (op) { \ + int vret = visit((PyObject *)(op), arg); \ + if (vret) \ + return vret; \ + } \ + } while (0) + + +/* Test if a type supports weak references */ +#define PyType_SUPPORTS_WEAKREFS(t) ((t)->tp_weaklistoffset > 0) + +#define PyObject_GET_WEAKREFS_LISTPTR(o) \ + ((PyObject **) (((char *) (o)) + Py_TYPE(o)->tp_weaklistoffset)) + +#ifdef __cplusplus +} +#endif +#endif /* !Py_OBJIMPL_H */ diff --git a/android/python35/include/odictobject.h b/android/python35/include/odictobject.h new file mode 100644 index 000000000..c1d9592a1 --- /dev/null +++ b/android/python35/include/odictobject.h @@ -0,0 +1,43 @@ +#ifndef Py_ODICTOBJECT_H +#define Py_ODICTOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + + +/* OrderedDict */ + +#ifndef Py_LIMITED_API + +typedef struct _odictobject PyODictObject; + +PyAPI_DATA(PyTypeObject) PyODict_Type; +PyAPI_DATA(PyTypeObject) PyODictIter_Type; +PyAPI_DATA(PyTypeObject) PyODictKeys_Type; +PyAPI_DATA(PyTypeObject) PyODictItems_Type; +PyAPI_DATA(PyTypeObject) PyODictValues_Type; + +#endif /* Py_LIMITED_API */ + +#define PyODict_Check(op) PyObject_TypeCheck(op, &PyODict_Type) +#define PyODict_CheckExact(op) (Py_TYPE(op) == &PyODict_Type) +#define PyODict_SIZE(op) ((PyDictObject *)op)->ma_used +#define PyODict_HasKey(od, key) (PyMapping_HasKey(PyObject *)od, key) + +PyAPI_FUNC(PyObject *) PyODict_New(void); +PyAPI_FUNC(int) PyODict_SetItem(PyObject *od, PyObject *key, PyObject *item); +PyAPI_FUNC(int) PyODict_DelItem(PyObject *od, PyObject *key); + +/* wrappers around PyDict* functions */ +#define PyODict_GetItem(od, key) PyDict_GetItem((PyObject *)od, key) +#define PyODict_GetItemWithError(od, key) \ + PyDict_GetItemWithError((PyObject *)od, key) +#define PyODict_Contains(od, key) PyDict_Contains((PyObject *)od, key) +#define PyODict_Size(od) PyDict_Size((PyObject *)od) +#define PyODict_GetItemString(od, key) \ + PyDict_GetItemString((PyObject *)od, key) + +#ifdef __cplusplus +} +#endif +#endif /* !Py_ODICTOBJECT_H */ diff --git a/android/python35/include/opcode.h b/android/python35/include/opcode.h new file mode 100644 index 000000000..3f917fb6e --- /dev/null +++ b/android/python35/include/opcode.h @@ -0,0 +1,142 @@ +/* Auto-generated by Tools/scripts/generate_opcode_h.py */ +#ifndef Py_OPCODE_H +#define Py_OPCODE_H +#ifdef __cplusplus +extern "C" { +#endif + + + /* Instruction opcodes for compiled code */ +#define POP_TOP 1 +#define ROT_TWO 2 +#define ROT_THREE 3 +#define DUP_TOP 4 +#define DUP_TOP_TWO 5 +#define NOP 9 +#define UNARY_POSITIVE 10 +#define UNARY_NEGATIVE 11 +#define UNARY_NOT 12 +#define UNARY_INVERT 15 +#define BINARY_MATRIX_MULTIPLY 16 +#define INPLACE_MATRIX_MULTIPLY 17 +#define BINARY_POWER 19 +#define BINARY_MULTIPLY 20 +#define BINARY_MODULO 22 +#define BINARY_ADD 23 +#define BINARY_SUBTRACT 24 +#define BINARY_SUBSCR 25 +#define BINARY_FLOOR_DIVIDE 26 +#define BINARY_TRUE_DIVIDE 27 +#define INPLACE_FLOOR_DIVIDE 28 +#define INPLACE_TRUE_DIVIDE 29 +#define GET_AITER 50 +#define GET_ANEXT 51 +#define BEFORE_ASYNC_WITH 52 +#define INPLACE_ADD 55 +#define INPLACE_SUBTRACT 56 +#define INPLACE_MULTIPLY 57 +#define INPLACE_MODULO 59 +#define STORE_SUBSCR 60 +#define DELETE_SUBSCR 61 +#define BINARY_LSHIFT 62 +#define BINARY_RSHIFT 63 +#define BINARY_AND 64 +#define BINARY_XOR 65 +#define BINARY_OR 66 +#define INPLACE_POWER 67 +#define GET_ITER 68 +#define GET_YIELD_FROM_ITER 69 +#define PRINT_EXPR 70 +#define LOAD_BUILD_CLASS 71 +#define YIELD_FROM 72 +#define GET_AWAITABLE 73 +#define INPLACE_LSHIFT 75 +#define INPLACE_RSHIFT 76 +#define INPLACE_AND 77 +#define INPLACE_XOR 78 +#define INPLACE_OR 79 +#define BREAK_LOOP 80 +#define WITH_CLEANUP_START 81 +#define WITH_CLEANUP_FINISH 82 +#define RETURN_VALUE 83 +#define IMPORT_STAR 84 +#define YIELD_VALUE 86 +#define POP_BLOCK 87 +#define END_FINALLY 88 +#define POP_EXCEPT 89 +#define HAVE_ARGUMENT 90 +#define STORE_NAME 90 +#define DELETE_NAME 91 +#define UNPACK_SEQUENCE 92 +#define FOR_ITER 93 +#define UNPACK_EX 94 +#define STORE_ATTR 95 +#define DELETE_ATTR 96 +#define STORE_GLOBAL 97 +#define DELETE_GLOBAL 98 +#define LOAD_CONST 100 +#define LOAD_NAME 101 +#define BUILD_TUPLE 102 +#define BUILD_LIST 103 +#define BUILD_SET 104 +#define BUILD_MAP 105 +#define LOAD_ATTR 106 +#define COMPARE_OP 107 +#define IMPORT_NAME 108 +#define IMPORT_FROM 109 +#define JUMP_FORWARD 110 +#define JUMP_IF_FALSE_OR_POP 111 +#define JUMP_IF_TRUE_OR_POP 112 +#define JUMP_ABSOLUTE 113 +#define POP_JUMP_IF_FALSE 114 +#define POP_JUMP_IF_TRUE 115 +#define LOAD_GLOBAL 116 +#define CONTINUE_LOOP 119 +#define SETUP_LOOP 120 +#define SETUP_EXCEPT 121 +#define SETUP_FINALLY 122 +#define LOAD_FAST 124 +#define STORE_FAST 125 +#define DELETE_FAST 126 +#define RAISE_VARARGS 130 +#define CALL_FUNCTION 131 +#define MAKE_FUNCTION 132 +#define BUILD_SLICE 133 +#define MAKE_CLOSURE 134 +#define LOAD_CLOSURE 135 +#define LOAD_DEREF 136 +#define STORE_DEREF 137 +#define DELETE_DEREF 138 +#define CALL_FUNCTION_VAR 140 +#define CALL_FUNCTION_KW 141 +#define CALL_FUNCTION_VAR_KW 142 +#define SETUP_WITH 143 +#define EXTENDED_ARG 144 +#define LIST_APPEND 145 +#define SET_ADD 146 +#define MAP_ADD 147 +#define LOAD_CLASSDEREF 148 +#define BUILD_LIST_UNPACK 149 +#define BUILD_MAP_UNPACK 150 +#define BUILD_MAP_UNPACK_WITH_CALL 151 +#define BUILD_TUPLE_UNPACK 152 +#define BUILD_SET_UNPACK 153 +#define SETUP_ASYNC_WITH 154 + +/* EXCEPT_HANDLER is a special, implicit block type which is created when + entering an except handler. It is not an opcode but we define it here + as we want it to be available to both frameobject.c and ceval.c, while + remaining private.*/ +#define EXCEPT_HANDLER 257 + + +enum cmp_op {PyCmp_LT=Py_LT, PyCmp_LE=Py_LE, PyCmp_EQ=Py_EQ, PyCmp_NE=Py_NE, + PyCmp_GT=Py_GT, PyCmp_GE=Py_GE, PyCmp_IN, PyCmp_NOT_IN, + PyCmp_IS, PyCmp_IS_NOT, PyCmp_EXC_MATCH, PyCmp_BAD}; + +#define HAS_ARG(op) ((op) >= HAVE_ARGUMENT) + +#ifdef __cplusplus +} +#endif +#endif /* !Py_OPCODE_H */ diff --git a/android/python35/include/osdefs.h b/android/python35/include/osdefs.h new file mode 100644 index 000000000..bd84c1c12 --- /dev/null +++ b/android/python35/include/osdefs.h @@ -0,0 +1,47 @@ +#ifndef Py_OSDEFS_H +#define Py_OSDEFS_H +#ifdef __cplusplus +extern "C" { +#endif + + +/* Operating system dependencies */ + +#ifdef MS_WINDOWS +#define SEP L'\\' +#define ALTSEP L'/' +#define MAXPATHLEN 256 +#define DELIM L';' +#endif + +/* Filename separator */ +#ifndef SEP +#define SEP L'/' +#endif + +/* Max pathname length */ +#ifdef __hpux +#include +#include +#ifndef PATH_MAX +#define PATH_MAX MAXPATHLEN +#endif +#endif + +#ifndef MAXPATHLEN +#if defined(PATH_MAX) && PATH_MAX > 1024 +#define MAXPATHLEN PATH_MAX +#else +#define MAXPATHLEN 1024 +#endif +#endif + +/* Search path entry delimiter */ +#ifndef DELIM +#define DELIM L':' +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_OSDEFS_H */ diff --git a/android/python35/include/parsetok.h b/android/python35/include/parsetok.h new file mode 100644 index 000000000..2acb85467 --- /dev/null +++ b/android/python35/include/parsetok.h @@ -0,0 +1,108 @@ + +/* Parser-tokenizer link interface */ +#ifndef Py_LIMITED_API +#ifndef Py_PARSETOK_H +#define Py_PARSETOK_H +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + int error; +#ifndef PGEN + /* The filename is useless for pgen, see comment in tok_state structure */ + PyObject *filename; +#endif + int lineno; + int offset; + char *text; /* UTF-8-encoded string */ + int token; + int expected; +} perrdetail; + +#if 0 +#define PyPARSE_YIELD_IS_KEYWORD 0x0001 +#endif + +#define PyPARSE_DONT_IMPLY_DEDENT 0x0002 + +#if 0 +#define PyPARSE_WITH_IS_KEYWORD 0x0003 +#define PyPARSE_PRINT_IS_FUNCTION 0x0004 +#define PyPARSE_UNICODE_LITERALS 0x0008 +#endif + +#define PyPARSE_IGNORE_COOKIE 0x0010 +#define PyPARSE_BARRY_AS_BDFL 0x0020 + +PyAPI_FUNC(node *) PyParser_ParseString(const char *, grammar *, int, + perrdetail *); +PyAPI_FUNC(node *) PyParser_ParseFile (FILE *, const char *, grammar *, int, + const char *, const char *, + perrdetail *); + +PyAPI_FUNC(node *) PyParser_ParseStringFlags(const char *, grammar *, int, + perrdetail *, int); +PyAPI_FUNC(node *) PyParser_ParseFileFlags( + FILE *fp, + const char *filename, /* decoded from the filesystem encoding */ + const char *enc, + grammar *g, + int start, + const char *ps1, + const char *ps2, + perrdetail *err_ret, + int flags); +PyAPI_FUNC(node *) PyParser_ParseFileFlagsEx( + FILE *fp, + const char *filename, /* decoded from the filesystem encoding */ + const char *enc, + grammar *g, + int start, + const char *ps1, + const char *ps2, + perrdetail *err_ret, + int *flags); +PyAPI_FUNC(node *) PyParser_ParseFileObject( + FILE *fp, + PyObject *filename, + const char *enc, + grammar *g, + int start, + const char *ps1, + const char *ps2, + perrdetail *err_ret, + int *flags); + +PyAPI_FUNC(node *) PyParser_ParseStringFlagsFilename( + const char *s, + const char *filename, /* decoded from the filesystem encoding */ + grammar *g, + int start, + perrdetail *err_ret, + int flags); +PyAPI_FUNC(node *) PyParser_ParseStringFlagsFilenameEx( + const char *s, + const char *filename, /* decoded from the filesystem encoding */ + grammar *g, + int start, + perrdetail *err_ret, + int *flags); +PyAPI_FUNC(node *) PyParser_ParseStringObject( + const char *s, + PyObject *filename, + grammar *g, + int start, + perrdetail *err_ret, + int *flags); + +/* Note that the following functions are defined in pythonrun.c, + not in parsetok.c */ +PyAPI_FUNC(void) PyParser_SetError(perrdetail *); +PyAPI_FUNC(void) PyParser_ClearError(perrdetail *); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_PARSETOK_H */ +#endif /* !Py_LIMITED_API */ diff --git a/android/python35/include/patchlevel.h b/android/python35/include/patchlevel.h new file mode 100644 index 000000000..226f9cfdd --- /dev/null +++ b/android/python35/include/patchlevel.h @@ -0,0 +1,35 @@ + +/* Python version identification scheme. + + When the major or minor version changes, the VERSION variable in + configure.ac must also be changed. + + There is also (independent) API version information in modsupport.h. +*/ + +/* Values for PY_RELEASE_LEVEL */ +#define PY_RELEASE_LEVEL_ALPHA 0xA +#define PY_RELEASE_LEVEL_BETA 0xB +#define PY_RELEASE_LEVEL_GAMMA 0xC /* For release candidates */ +#define PY_RELEASE_LEVEL_FINAL 0xF /* Serial should be 0 here */ + /* Higher for patch releases */ + +/* Version parsed out into numeric values */ +/*--start constants--*/ +#define PY_MAJOR_VERSION 3 +#define PY_MINOR_VERSION 5 +#define PY_MICRO_VERSION 0 +#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_FINAL +#define PY_RELEASE_SERIAL 0 + +/* Version as a string */ +#define PY_VERSION "3.5.0" +/*--end constants--*/ + +/* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2. + Use this for numeric comparisons, e.g. #if PY_VERSION_HEX >= ... */ +#define PY_VERSION_HEX ((PY_MAJOR_VERSION << 24) | \ + (PY_MINOR_VERSION << 16) | \ + (PY_MICRO_VERSION << 8) | \ + (PY_RELEASE_LEVEL << 4) | \ + (PY_RELEASE_SERIAL << 0)) diff --git a/android/python35/include/pgen.h b/android/python35/include/pgen.h new file mode 100644 index 000000000..8a325ed07 --- /dev/null +++ b/android/python35/include/pgen.h @@ -0,0 +1,18 @@ +#ifndef Py_PGEN_H +#define Py_PGEN_H +#ifdef __cplusplus +extern "C" { +#endif + + +/* Parser generator interface */ + +extern grammar *meta_grammar(void); + +struct _node; +extern grammar *pgen(struct _node *); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_PGEN_H */ diff --git a/android/python35/include/pgenheaders.h b/android/python35/include/pgenheaders.h new file mode 100644 index 000000000..2049ae32b --- /dev/null +++ b/android/python35/include/pgenheaders.h @@ -0,0 +1,42 @@ +#ifndef Py_PGENHEADERS_H +#define Py_PGENHEADERS_H +#ifdef __cplusplus +extern "C" { +#endif + + +/* Include files and extern declarations used by most of the parser. */ + +#include "Python.h" + +PyAPI_FUNC(void) PySys_WriteStdout(const char *format, ...) + Py_GCC_ATTRIBUTE((format(printf, 1, 2))); +PyAPI_FUNC(void) PySys_WriteStderr(const char *format, ...) + Py_GCC_ATTRIBUTE((format(printf, 1, 2))); + +#define addarc _Py_addarc +#define addbit _Py_addbit +#define adddfa _Py_adddfa +#define addfirstsets _Py_addfirstsets +#define addlabel _Py_addlabel +#define addstate _Py_addstate +#define delbitset _Py_delbitset +#define dumptree _Py_dumptree +#define findlabel _Py_findlabel +#define mergebitset _Py_mergebitset +#define meta_grammar _Py_meta_grammar +#define newbitset _Py_newbitset +#define newgrammar _Py_newgrammar +#define pgen _Py_pgen +#define printgrammar _Py_printgrammar +#define printnonterminals _Py_printnonterminals +#define printtree _Py_printtree +#define samebitset _Py_samebitset +#define showtree _Py_showtree +#define tok_dump _Py_tok_dump +#define translatelabels _Py_translatelabels + +#ifdef __cplusplus +} +#endif +#endif /* !Py_PGENHEADERS_H */ diff --git a/android/python35/include/py_curses.h b/android/python35/include/py_curses.h new file mode 100644 index 000000000..f2c08f641 --- /dev/null +++ b/android/python35/include/py_curses.h @@ -0,0 +1,177 @@ + +#ifndef Py_CURSES_H +#define Py_CURSES_H + +#ifdef __APPLE__ +/* +** On Mac OS X 10.2 [n]curses.h and stdlib.h use different guards +** against multiple definition of wchar_t. +*/ +#ifdef _BSD_WCHAR_T_DEFINED_ +#define _WCHAR_T +#endif + +/* the following define is necessary for OS X 10.6; without it, the + Apple-supplied ncurses.h sets NCURSES_OPAQUE to 1, and then Python + can't get at the WINDOW flags field. */ +#define NCURSES_OPAQUE 0 +#endif /* __APPLE__ */ + +#ifdef __FreeBSD__ +/* +** On FreeBSD, [n]curses.h and stdlib.h/wchar.h use different guards +** against multiple definition of wchar_t and wint_t. +*/ +#ifdef _XOPEN_SOURCE_EXTENDED +#ifndef __FreeBSD_version +#include +#endif +#if __FreeBSD_version >= 500000 +#ifndef __wchar_t +#define __wchar_t +#endif +#ifndef __wint_t +#define __wint_t +#endif +#else +#ifndef _WCHAR_T +#define _WCHAR_T +#endif +#ifndef _WINT_T +#define _WINT_T +#endif +#endif +#endif +#endif + +#ifdef HAVE_NCURSES_H +#include +#else +#include +#ifdef HAVE_TERM_H +/* for tigetstr, which is not declared in SysV curses */ +#include +#endif +#endif + +#ifdef HAVE_NCURSES_H +/* configure was checking , but we will + use , which has all these features. */ +#ifndef WINDOW_HAS_FLAGS +#define WINDOW_HAS_FLAGS 1 +#endif +#ifndef MVWDELCH_IS_EXPRESSION +#define MVWDELCH_IS_EXPRESSION 1 +#endif +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#define PyCurses_API_pointers 4 + +/* Type declarations */ + +typedef struct { + PyObject_HEAD + WINDOW *win; + char *encoding; +} PyCursesWindowObject; + +#define PyCursesWindow_Check(v) (Py_TYPE(v) == &PyCursesWindow_Type) + +#define PyCurses_CAPSULE_NAME "_curses._C_API" + + +#ifdef CURSES_MODULE +/* This section is used when compiling _cursesmodule.c */ + +#else +/* This section is used in modules that use the _cursesmodule API */ + +static void **PyCurses_API; + +#define PyCursesWindow_Type (*(PyTypeObject *) PyCurses_API[0]) +#define PyCursesSetupTermCalled {if (! ((int (*)(void))PyCurses_API[1]) () ) return NULL;} +#define PyCursesInitialised {if (! ((int (*)(void))PyCurses_API[2]) () ) return NULL;} +#define PyCursesInitialisedColor {if (! ((int (*)(void))PyCurses_API[3]) () ) return NULL;} + +#define import_curses() \ + PyCurses_API = (void **)PyCapsule_Import(PyCurses_CAPSULE_NAME, 1); + +#endif + +/* general error messages */ +static char *catchall_ERR = "curses function returned ERR"; +static char *catchall_NULL = "curses function returned NULL"; + +/* Function Prototype Macros - They are ugly but very, very useful. ;-) + + X - function name + TYPE - parameter Type + ERGSTR - format string for construction of the return value + PARSESTR - format string for argument parsing + */ + +#define NoArgNoReturnFunction(X) \ +static PyObject *PyCurses_ ## X (PyObject *self) \ +{ \ + PyCursesInitialised \ + return PyCursesCheckERR(X(), # X); } + +#define NoArgOrFlagNoReturnFunction(X) \ +static PyObject *PyCurses_ ## X (PyObject *self, PyObject *args) \ +{ \ + int flag = 0; \ + PyCursesInitialised \ + switch(PyTuple_Size(args)) { \ + case 0: \ + return PyCursesCheckERR(X(), # X); \ + case 1: \ + if (!PyArg_ParseTuple(args, "i;True(1) or False(0)", &flag)) return NULL; \ + if (flag) return PyCursesCheckERR(X(), # X); \ + else return PyCursesCheckERR(no ## X (), # X); \ + default: \ + PyErr_SetString(PyExc_TypeError, # X " requires 0 or 1 arguments"); \ + return NULL; } } + +#define NoArgReturnIntFunction(X) \ +static PyObject *PyCurses_ ## X (PyObject *self) \ +{ \ + PyCursesInitialised \ + return PyLong_FromLong((long) X()); } + + +#define NoArgReturnStringFunction(X) \ +static PyObject *PyCurses_ ## X (PyObject *self) \ +{ \ + PyCursesInitialised \ + return PyBytes_FromString(X()); } + +#define NoArgTrueFalseFunction(X) \ +static PyObject *PyCurses_ ## X (PyObject *self) \ +{ \ + PyCursesInitialised \ + if (X () == FALSE) { \ + Py_INCREF(Py_False); \ + return Py_False; \ + } \ + Py_INCREF(Py_True); \ + return Py_True; } + +#define NoArgNoReturnVoidFunction(X) \ +static PyObject *PyCurses_ ## X (PyObject *self) \ +{ \ + PyCursesInitialised \ + X(); \ + Py_INCREF(Py_None); \ + return Py_None; } + +#ifdef __cplusplus +} +#endif + +#endif /* !defined(Py_CURSES_H) */ + + diff --git a/android/python35/include/pyarena.h b/android/python35/include/pyarena.h new file mode 100644 index 000000000..db3ad0188 --- /dev/null +++ b/android/python35/include/pyarena.h @@ -0,0 +1,64 @@ +/* An arena-like memory interface for the compiler. + */ + +#ifndef Py_LIMITED_API +#ifndef Py_PYARENA_H +#define Py_PYARENA_H + +#ifdef __cplusplus +extern "C" { +#endif + + typedef struct _arena PyArena; + + /* PyArena_New() and PyArena_Free() create a new arena and free it, + respectively. Once an arena has been created, it can be used + to allocate memory via PyArena_Malloc(). Pointers to PyObject can + also be registered with the arena via PyArena_AddPyObject(), and the + arena will ensure that the PyObjects stay alive at least until + PyArena_Free() is called. When an arena is freed, all the memory it + allocated is freed, the arena releases internal references to registered + PyObject*, and none of its pointers are valid. + XXX (tim) What does "none of its pointers are valid" mean? Does it + XXX mean that pointers previously obtained via PyArena_Malloc() are + XXX no longer valid? (That's clearly true, but not sure that's what + XXX the text is trying to say.) + + PyArena_New() returns an arena pointer. On error, it + returns a negative number and sets an exception. + XXX (tim): Not true. On error, PyArena_New() actually returns NULL, + XXX and looks like it may or may not set an exception (e.g., if the + XXX internal PyList_New(0) returns NULL, PyArena_New() passes that on + XXX and an exception is set; OTOH, if the internal + XXX block_new(DEFAULT_BLOCK_SIZE) returns NULL, that's passed on but + XXX an exception is not set in that case). + */ + PyAPI_FUNC(PyArena *) PyArena_New(void); + PyAPI_FUNC(void) PyArena_Free(PyArena *); + + /* Mostly like malloc(), return the address of a block of memory spanning + * `size` bytes, or return NULL (without setting an exception) if enough + * new memory can't be obtained. Unlike malloc(0), PyArena_Malloc() with + * size=0 does not guarantee to return a unique pointer (the pointer + * returned may equal one or more other pointers obtained from + * PyArena_Malloc()). + * Note that pointers obtained via PyArena_Malloc() must never be passed to + * the system free() or realloc(), or to any of Python's similar memory- + * management functions. PyArena_Malloc()-obtained pointers remain valid + * until PyArena_Free(ar) is called, at which point all pointers obtained + * from the arena `ar` become invalid simultaneously. + */ + PyAPI_FUNC(void *) PyArena_Malloc(PyArena *, size_t size); + + /* This routine isn't a proper arena allocation routine. It takes + * a PyObject* and records it so that it can be DECREFed when the + * arena is freed. + */ + PyAPI_FUNC(int) PyArena_AddPyObject(PyArena *, PyObject *); + +#ifdef __cplusplus +} +#endif + +#endif /* !Py_PYARENA_H */ +#endif /* Py_LIMITED_API */ diff --git a/android/python35/include/pyatomic.h b/android/python35/include/pyatomic.h new file mode 100644 index 000000000..99816a5b6 --- /dev/null +++ b/android/python35/include/pyatomic.h @@ -0,0 +1,252 @@ +/* Issue #23644: is incompatible with C++, see: + https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60932 */ +#if !defined(Py_LIMITED_API) && !defined(__cplusplus) +#ifndef Py_ATOMIC_H +#define Py_ATOMIC_H + +#include "dynamic_annotations.h" + +#include "pyconfig.h" + +#if defined(HAVE_STD_ATOMIC) +#include +#endif + +/* This is modeled after the atomics interface from C1x, according to + * the draft at + * http://www.open-std.org/JTC1/SC22/wg14/www/docs/n1425.pdf. + * Operations and types are named the same except with a _Py_ prefix + * and have the same semantics. + * + * Beware, the implementations here are deep magic. + */ + +#if defined(HAVE_STD_ATOMIC) + +typedef enum _Py_memory_order { + _Py_memory_order_relaxed = memory_order_relaxed, + _Py_memory_order_acquire = memory_order_acquire, + _Py_memory_order_release = memory_order_release, + _Py_memory_order_acq_rel = memory_order_acq_rel, + _Py_memory_order_seq_cst = memory_order_seq_cst +} _Py_memory_order; + +typedef struct _Py_atomic_address { + _Atomic void *_value; +} _Py_atomic_address; + +typedef struct _Py_atomic_int { + atomic_int _value; +} _Py_atomic_int; + +#define _Py_atomic_signal_fence(/*memory_order*/ ORDER) \ + atomic_signal_fence(ORDER) + +#define _Py_atomic_thread_fence(/*memory_order*/ ORDER) \ + atomic_thread_fence(ORDER) + +#define _Py_atomic_store_explicit(ATOMIC_VAL, NEW_VAL, ORDER) \ + atomic_store_explicit(&(ATOMIC_VAL)->_value, NEW_VAL, ORDER) + +#define _Py_atomic_load_explicit(ATOMIC_VAL, ORDER) \ + atomic_load_explicit(&(ATOMIC_VAL)->_value, ORDER) + +/* Use builtin atomic operations in GCC >= 4.7 */ +#elif defined(HAVE_BUILTIN_ATOMIC) + +typedef enum _Py_memory_order { + _Py_memory_order_relaxed = __ATOMIC_RELAXED, + _Py_memory_order_acquire = __ATOMIC_ACQUIRE, + _Py_memory_order_release = __ATOMIC_RELEASE, + _Py_memory_order_acq_rel = __ATOMIC_ACQ_REL, + _Py_memory_order_seq_cst = __ATOMIC_SEQ_CST +} _Py_memory_order; + +typedef struct _Py_atomic_address { + void *_value; +} _Py_atomic_address; + +typedef struct _Py_atomic_int { + int _value; +} _Py_atomic_int; + +#define _Py_atomic_signal_fence(/*memory_order*/ ORDER) \ + __atomic_signal_fence(ORDER) + +#define _Py_atomic_thread_fence(/*memory_order*/ ORDER) \ + __atomic_thread_fence(ORDER) + +#define _Py_atomic_store_explicit(ATOMIC_VAL, NEW_VAL, ORDER) \ + (assert((ORDER) == __ATOMIC_RELAXED \ + || (ORDER) == __ATOMIC_SEQ_CST \ + || (ORDER) == __ATOMIC_RELEASE), \ + __atomic_store_n(&(ATOMIC_VAL)->_value, NEW_VAL, ORDER)) + +#define _Py_atomic_load_explicit(ATOMIC_VAL, ORDER) \ + (assert((ORDER) == __ATOMIC_RELAXED \ + || (ORDER) == __ATOMIC_SEQ_CST \ + || (ORDER) == __ATOMIC_ACQUIRE \ + || (ORDER) == __ATOMIC_CONSUME), \ + __atomic_load_n(&(ATOMIC_VAL)->_value, ORDER)) + +#else + +typedef enum _Py_memory_order { + _Py_memory_order_relaxed, + _Py_memory_order_acquire, + _Py_memory_order_release, + _Py_memory_order_acq_rel, + _Py_memory_order_seq_cst +} _Py_memory_order; + +typedef struct _Py_atomic_address { + void *_value; +} _Py_atomic_address; + +typedef struct _Py_atomic_int { + int _value; +} _Py_atomic_int; + +/* Only support GCC (for expression statements) and x86 (for simple + * atomic semantics) for now */ +#if defined(__GNUC__) && (defined(__i386__) || defined(__amd64)) + +static __inline__ void +_Py_atomic_signal_fence(_Py_memory_order order) +{ + if (order != _Py_memory_order_relaxed) + __asm__ volatile("":::"memory"); +} + +static __inline__ void +_Py_atomic_thread_fence(_Py_memory_order order) +{ + if (order != _Py_memory_order_relaxed) + __asm__ volatile("mfence":::"memory"); +} + +/* Tell the race checker about this operation's effects. */ +static __inline__ void +_Py_ANNOTATE_MEMORY_ORDER(const volatile void *address, _Py_memory_order order) +{ + (void)address; /* shut up -Wunused-parameter */ + switch(order) { + case _Py_memory_order_release: + case _Py_memory_order_acq_rel: + case _Py_memory_order_seq_cst: + _Py_ANNOTATE_HAPPENS_BEFORE(address); + break; + case _Py_memory_order_relaxed: + case _Py_memory_order_acquire: + break; + } + switch(order) { + case _Py_memory_order_acquire: + case _Py_memory_order_acq_rel: + case _Py_memory_order_seq_cst: + _Py_ANNOTATE_HAPPENS_AFTER(address); + break; + case _Py_memory_order_relaxed: + case _Py_memory_order_release: + break; + } +} + +#define _Py_atomic_store_explicit(ATOMIC_VAL, NEW_VAL, ORDER) \ + __extension__ ({ \ + __typeof__(ATOMIC_VAL) atomic_val = ATOMIC_VAL; \ + __typeof__(atomic_val->_value) new_val = NEW_VAL;\ + volatile __typeof__(new_val) *volatile_data = &atomic_val->_value; \ + _Py_memory_order order = ORDER; \ + _Py_ANNOTATE_MEMORY_ORDER(atomic_val, order); \ + \ + /* Perform the operation. */ \ + _Py_ANNOTATE_IGNORE_WRITES_BEGIN(); \ + switch(order) { \ + case _Py_memory_order_release: \ + _Py_atomic_signal_fence(_Py_memory_order_release); \ + /* fallthrough */ \ + case _Py_memory_order_relaxed: \ + *volatile_data = new_val; \ + break; \ + \ + case _Py_memory_order_acquire: \ + case _Py_memory_order_acq_rel: \ + case _Py_memory_order_seq_cst: \ + __asm__ volatile("xchg %0, %1" \ + : "+r"(new_val) \ + : "m"(atomic_val->_value) \ + : "memory"); \ + break; \ + } \ + _Py_ANNOTATE_IGNORE_WRITES_END(); \ + }) + +#define _Py_atomic_load_explicit(ATOMIC_VAL, ORDER) \ + __extension__ ({ \ + __typeof__(ATOMIC_VAL) atomic_val = ATOMIC_VAL; \ + __typeof__(atomic_val->_value) result; \ + volatile __typeof__(result) *volatile_data = &atomic_val->_value; \ + _Py_memory_order order = ORDER; \ + _Py_ANNOTATE_MEMORY_ORDER(atomic_val, order); \ + \ + /* Perform the operation. */ \ + _Py_ANNOTATE_IGNORE_READS_BEGIN(); \ + switch(order) { \ + case _Py_memory_order_release: \ + case _Py_memory_order_acq_rel: \ + case _Py_memory_order_seq_cst: \ + /* Loads on x86 are not releases by default, so need a */ \ + /* thread fence. */ \ + _Py_atomic_thread_fence(_Py_memory_order_release); \ + break; \ + default: \ + /* No fence */ \ + break; \ + } \ + result = *volatile_data; \ + switch(order) { \ + case _Py_memory_order_acquire: \ + case _Py_memory_order_acq_rel: \ + case _Py_memory_order_seq_cst: \ + /* Loads on x86 are automatically acquire operations so */ \ + /* can get by with just a compiler fence. */ \ + _Py_atomic_signal_fence(_Py_memory_order_acquire); \ + break; \ + default: \ + /* No fence */ \ + break; \ + } \ + _Py_ANNOTATE_IGNORE_READS_END(); \ + result; \ + }) + +#else /* !gcc x86 */ +/* Fall back to other compilers and processors by assuming that simple + volatile accesses are atomic. This is false, so people should port + this. */ +#define _Py_atomic_signal_fence(/*memory_order*/ ORDER) ((void)0) +#define _Py_atomic_thread_fence(/*memory_order*/ ORDER) ((void)0) +#define _Py_atomic_store_explicit(ATOMIC_VAL, NEW_VAL, ORDER) \ + ((ATOMIC_VAL)->_value = NEW_VAL) +#define _Py_atomic_load_explicit(ATOMIC_VAL, ORDER) \ + ((ATOMIC_VAL)->_value) + +#endif /* !gcc x86 */ +#endif + +/* Standardized shortcuts. */ +#define _Py_atomic_store(ATOMIC_VAL, NEW_VAL) \ + _Py_atomic_store_explicit(ATOMIC_VAL, NEW_VAL, _Py_memory_order_seq_cst) +#define _Py_atomic_load(ATOMIC_VAL) \ + _Py_atomic_load_explicit(ATOMIC_VAL, _Py_memory_order_seq_cst) + +/* Python-local extensions */ + +#define _Py_atomic_store_relaxed(ATOMIC_VAL, NEW_VAL) \ + _Py_atomic_store_explicit(ATOMIC_VAL, NEW_VAL, _Py_memory_order_relaxed) +#define _Py_atomic_load_relaxed(ATOMIC_VAL) \ + _Py_atomic_load_explicit(ATOMIC_VAL, _Py_memory_order_relaxed) + +#endif /* Py_ATOMIC_H */ +#endif /* Py_LIMITED_API */ diff --git a/android/python35/include/pycapsule.h b/android/python35/include/pycapsule.h new file mode 100644 index 000000000..d9ecda7a4 --- /dev/null +++ b/android/python35/include/pycapsule.h @@ -0,0 +1,59 @@ + +/* Capsule objects let you wrap a C "void *" pointer in a Python + object. They're a way of passing data through the Python interpreter + without creating your own custom type. + + Capsules are used for communication between extension modules. + They provide a way for an extension module to export a C interface + to other extension modules, so that extension modules can use the + Python import mechanism to link to one another. + + For more information, please see "c-api/capsule.html" in the + documentation. +*/ + +#ifndef Py_CAPSULE_H +#define Py_CAPSULE_H +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_DATA(PyTypeObject) PyCapsule_Type; + +typedef void (*PyCapsule_Destructor)(PyObject *); + +#define PyCapsule_CheckExact(op) (Py_TYPE(op) == &PyCapsule_Type) + + +PyAPI_FUNC(PyObject *) PyCapsule_New( + void *pointer, + const char *name, + PyCapsule_Destructor destructor); + +PyAPI_FUNC(void *) PyCapsule_GetPointer(PyObject *capsule, const char *name); + +PyAPI_FUNC(PyCapsule_Destructor) PyCapsule_GetDestructor(PyObject *capsule); + +PyAPI_FUNC(const char *) PyCapsule_GetName(PyObject *capsule); + +PyAPI_FUNC(void *) PyCapsule_GetContext(PyObject *capsule); + +PyAPI_FUNC(int) PyCapsule_IsValid(PyObject *capsule, const char *name); + +PyAPI_FUNC(int) PyCapsule_SetPointer(PyObject *capsule, void *pointer); + +PyAPI_FUNC(int) PyCapsule_SetDestructor(PyObject *capsule, PyCapsule_Destructor destructor); + +PyAPI_FUNC(int) PyCapsule_SetName(PyObject *capsule, const char *name); + +PyAPI_FUNC(int) PyCapsule_SetContext(PyObject *capsule, void *context); + +PyAPI_FUNC(void *) PyCapsule_Import( + const char *name, /* UTF-8 encoded string */ + int no_block); + + +#ifdef __cplusplus +} +#endif +#endif /* !Py_CAPSULE_H */ diff --git a/android/python35/include/pyconfig.h b/android/python35/include/pyconfig.h new file mode 100644 index 000000000..1068f5eed --- /dev/null +++ b/android/python35/include/pyconfig.h @@ -0,0 +1,20 @@ +#if defined(__ARM_ARCH_5TE__) +#include "pyconfig_armeabi.h" +#elif defined(__ARM_ARCH_7A__) && !defined(__ARM_PCS_VFP) +#include "pyconfig_armeabi_v7a.h" +#elif defined(__ARM_ARCH_7A__) && defined(__ARM_PCS_VFP) +#include "pyconfig_armeabi_v7a_hard.h" +#elif defined(__aarch64__) +#include "pyconfig_arm64_v8a.h" +#elif defined(__i386__) +#include "pyconfig_x86.h" +#elif defined(__x86_64__) +#include "pyconfig_x86_64.h" +#elif defined(__mips__) && !defined(__mips64) +#include "pyconfig_mips.h" +#elif defined(__mips__) && defined(__mips64) +#include "pyconfig_mips64.h" +#else +#error "Unsupported ABI" +#endif + diff --git a/android/python35/include/pyconfig_arm64_v8a.h b/android/python35/include/pyconfig_arm64_v8a.h new file mode 100644 index 000000000..be4b1a9d2 --- /dev/null +++ b/android/python35/include/pyconfig_arm64_v8a.h @@ -0,0 +1,1530 @@ +/* pyconfig.h. Generated from pyconfig.h.in by configure. */ +/* pyconfig.h.in. Generated from configure.ac by autoheader. */ + + +#ifndef Py_PYCONFIG_H +#define Py_PYCONFIG_H + + +/* Define if building universal (internal helper macro) */ +/* #undef AC_APPLE_UNIVERSAL_BUILD */ + +/* Define for AIX if your compiler is a genuine IBM xlC/xlC_r and you want + support for AIX C++ shared extension modules. */ +/* #undef AIX_GENUINE_CPLUSPLUS */ + +/* Define if C doubles are 64-bit IEEE 754 binary format, stored in ARM + mixed-endian order (byte order 45670123) */ +/* #undef DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754 */ + +/* Define if C doubles are 64-bit IEEE 754 binary format, stored with the most + significant byte first */ +/* #undef DOUBLE_IS_BIG_ENDIAN_IEEE754 */ + +/* Define if C doubles are 64-bit IEEE 754 binary format, stored with the + least significant byte first */ +/* #undef DOUBLE_IS_LITTLE_ENDIAN_IEEE754 */ + +/* Define if --enable-ipv6 is specified */ +#define ENABLE_IPV6 1 + +/* Define if flock needs to be linked with bsd library. */ +/* #undef FLOCK_NEEDS_LIBBSD */ + +/* Define if getpgrp() must be called as getpgrp(0). */ +/* #undef GETPGRP_HAVE_ARG */ + +/* Define if gettimeofday() does not have second (timezone) argument This is + the case on Motorola V4 (R40V4.2) */ +/* #undef GETTIMEOFDAY_NO_TZ */ + +/* Define to 1 if you have the `accept4' function. */ +#define HAVE_ACCEPT4 1 + +/* Define to 1 if you have the `acosh' function. */ +#define HAVE_ACOSH 1 + +/* struct addrinfo (netdb.h) */ +#define HAVE_ADDRINFO 1 + +/* Define to 1 if you have the `alarm' function. */ +#define HAVE_ALARM 1 + +/* Define if aligned memory access is required */ +#define HAVE_ALIGNED_REQUIRED 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ALLOCA_H 1 + +/* Define this if your time.h defines altzone. */ +/* #undef HAVE_ALTZONE */ + +/* Define to 1 if you have the `asinh' function. */ +#define HAVE_ASINH 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ASM_TYPES_H 1 + +/* Define to 1 if you have the `atanh' function. */ +#define HAVE_ATANH 1 + +/* Define to 1 if you have the `bind_textdomain_codeset' function. */ +/* #undef HAVE_BIND_TEXTDOMAIN_CODESET */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_BLUETOOTH_BLUETOOTH_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_BLUETOOTH_H */ + +/* Define if mbstowcs(NULL, "text", 0) does not return the number of wide + chars that would be converted. */ +/* #undef HAVE_BROKEN_MBSTOWCS */ + +/* Define if nice() returns success/failure instead of the new priority. */ +/* #undef HAVE_BROKEN_NICE */ + +/* Define if the system reports an invalid PIPE_BUF value. */ +/* #undef HAVE_BROKEN_PIPE_BUF */ + +/* Define if poll() sets errno on invalid file descriptors. */ +/* #undef HAVE_BROKEN_POLL */ + +/* Define if the Posix semaphores do not work on your system */ +/* #undef HAVE_BROKEN_POSIX_SEMAPHORES */ + +/* Define if pthread_sigmask() does not work on your system. */ +/* #undef HAVE_BROKEN_PTHREAD_SIGMASK */ + +/* define to 1 if your sem_getvalue is broken. */ +#define HAVE_BROKEN_SEM_GETVALUE 1 + +/* Define if `unsetenv` does not return an int. */ +/* #undef HAVE_BROKEN_UNSETENV */ + +/* Has builtin atomics */ +#define HAVE_BUILTIN_ATOMIC 1 + +/* Define this if you have the type _Bool. */ +#define HAVE_C99_BOOL 1 + +/* Define to 1 if you have the 'chflags' function. */ +/* #undef HAVE_CHFLAGS */ + +/* Define to 1 if you have the `chown' function. */ +#define HAVE_CHOWN 1 + +/* Define if you have the 'chroot' function. */ +#define HAVE_CHROOT 1 + +/* Define to 1 if you have the `clock' function. */ +#define HAVE_CLOCK 1 + +/* Define to 1 if you have the `clock_getres' function. */ +#define HAVE_CLOCK_GETRES 1 + +/* Define to 1 if you have the `clock_gettime' function. */ +#define HAVE_CLOCK_GETTIME 1 + +/* Define if the C compiler supports computed gotos. */ +#define HAVE_COMPUTED_GOTOS 1 + +/* Define to 1 if you have the `confstr' function. */ +/* #undef HAVE_CONFSTR */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_CONIO_H */ + +/* Define to 1 if you have the `copysign' function. */ +#define HAVE_COPYSIGN 1 + +/* Define to 1 if you have the `ctermid' function. */ +/* #undef HAVE_CTERMID */ + +/* Define if you have the 'ctermid_r' function. */ +#define HAVE_CTERMID_R 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_CURSES_H */ + +/* Define if you have the 'is_term_resized' function. */ +/* #undef HAVE_CURSES_IS_TERM_RESIZED */ + +/* Define if you have the 'resizeterm' function. */ +/* #undef HAVE_CURSES_RESIZETERM */ + +/* Define if you have the 'resize_term' function. */ +/* #undef HAVE_CURSES_RESIZE_TERM */ + +/* Define to 1 if you have the declaration of `isfinite', and to 0 if you + don't. */ +#define HAVE_DECL_ISFINITE 1 + +/* Define to 1 if you have the declaration of `isinf', and to 0 if you don't. + */ +#define HAVE_DECL_ISINF 1 + +/* Define to 1 if you have the declaration of `isnan', and to 0 if you don't. + */ +#define HAVE_DECL_ISNAN 1 + +/* Define to 1 if you have the declaration of `tzname', and to 0 if you don't. + */ +/* #undef HAVE_DECL_TZNAME */ + +/* Define to 1 if you have the device macros. */ +#define HAVE_DEVICE_MACROS 1 + +/* Define to 1 if you have the /dev/ptc device file. */ +/* #undef HAVE_DEV_PTC */ + +/* Define to 1 if you have the /dev/ptmx device file. */ +/* #undef HAVE_DEV_PTMX */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_DIRECT_H */ + +/* Define to 1 if the dirent structure has a d_type field */ +#define HAVE_DIRENT_D_TYPE 1 + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#define HAVE_DIRENT_H 1 + +/* Define if you have the 'dirfd' function or macro. */ +#define HAVE_DIRFD 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_DLFCN_H 1 + +/* Define to 1 if you have the `dlopen' function. */ +#define HAVE_DLOPEN 1 + +/* Define to 1 if you have the `dup2' function. */ +#define HAVE_DUP2 1 + +/* Define to 1 if you have the `dup3' function. */ +#define HAVE_DUP3 1 + +/* Defined when any dynamic module loading is enabled. */ +#define HAVE_DYNAMIC_LOADING 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ENDIAN_H 1 + +/* Define if you have the 'epoll' functions. */ +#define HAVE_EPOLL 1 + +/* Define if you have the 'epoll_create1' function. */ +#define HAVE_EPOLL_CREATE1 1 + +/* Define to 1 if you have the `erf' function. */ +#define HAVE_ERF 1 + +/* Define to 1 if you have the `erfc' function. */ +#define HAVE_ERFC 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ERRNO_H 1 + +/* Define to 1 if you have the `execv' function. */ +#define HAVE_EXECV 1 + +/* Define to 1 if you have the `expm1' function. */ +#define HAVE_EXPM1 1 + +/* Define to 1 if you have the `faccessat' function. */ +/* #undef HAVE_FACCESSAT */ + +/* Define if you have the 'fchdir' function. */ +#define HAVE_FCHDIR 1 + +/* Define to 1 if you have the `fchmod' function. */ +#define HAVE_FCHMOD 1 + +/* Define to 1 if you have the `fchmodat' function. */ +#define HAVE_FCHMODAT 1 + +/* Define to 1 if you have the `fchown' function. */ +#define HAVE_FCHOWN 1 + +/* Define to 1 if you have the `fchownat' function. */ +#define HAVE_FCHOWNAT 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* Define if you have the 'fdatasync' function. */ +#define HAVE_FDATASYNC 1 + +/* Define to 1 if you have the `fdopendir' function. */ +#define HAVE_FDOPENDIR 1 + +/* Define to 1 if you have the `fexecve' function. */ +/* #undef HAVE_FEXECVE */ + +/* Define to 1 if you have the `finite' function. */ +#define HAVE_FINITE 1 + +/* Define to 1 if you have the `flock' function. */ +#define HAVE_FLOCK 1 + +/* Define to 1 if you have the `fork' function. */ +#define HAVE_FORK 1 + +/* Define to 1 if you have the `forkpty' function. */ +/* #undef HAVE_FORKPTY */ + +/* Define to 1 if you have the `fpathconf' function. */ +#define HAVE_FPATHCONF 1 + +/* Define to 1 if you have the `fseek64' function. */ +/* #undef HAVE_FSEEK64 */ + +/* Define to 1 if you have the `fseeko' function. */ +#define HAVE_FSEEKO 1 + +/* Define to 1 if you have the `fstatat' function. */ +#define HAVE_FSTATAT 1 + +/* Define to 1 if you have the `fstatvfs' function. */ +#define HAVE_FSTATVFS 1 + +/* Define if you have the 'fsync' function. */ +#define HAVE_FSYNC 1 + +/* Define to 1 if you have the `ftell64' function. */ +/* #undef HAVE_FTELL64 */ + +/* Define to 1 if you have the `ftello' function. */ +#define HAVE_FTELLO 1 + +/* Define to 1 if you have the `ftime' function. */ +/* #undef HAVE_FTIME */ + +/* Define to 1 if you have the `ftruncate' function. */ +#define HAVE_FTRUNCATE 1 + +/* Define to 1 if you have the `futimens' function. */ +#define HAVE_FUTIMENS 1 + +/* Define to 1 if you have the `futimes' function. */ +/* #undef HAVE_FUTIMES */ + +/* Define to 1 if you have the `futimesat' function. */ +/* #undef HAVE_FUTIMESAT */ + +/* Define to 1 if you have the `gai_strerror' function. */ +#define HAVE_GAI_STRERROR 1 + +/* Define to 1 if you have the `gamma' function. */ +/* #undef HAVE_GAMMA */ + +/* Define if we can use gcc inline assembler to get and set mc68881 fpcr */ +/* #undef HAVE_GCC_ASM_FOR_MC68881 */ + +/* Define if we can use x64 gcc inline assembler */ +/* #undef HAVE_GCC_ASM_FOR_X64 */ + +/* Define if we can use gcc inline assembler to get and set x87 control word + */ +/* #undef HAVE_GCC_ASM_FOR_X87 */ + +/* Define if your compiler provides __uint128_t */ +#define HAVE_GCC_UINT128_T 1 + +/* Define if you have the getaddrinfo function. */ +#define HAVE_GETADDRINFO 1 + +/* Define this if you have flockfile(), getc_unlocked(), and funlockfile() */ +#define HAVE_GETC_UNLOCKED 1 + +/* Define to 1 if you have the `getentropy' function. */ +/* #undef HAVE_GETENTROPY */ + +/* Define to 1 if you have the `getgrouplist' function. */ +#define HAVE_GETGROUPLIST 1 + +/* Define to 1 if you have the `getgroups' function. */ +#define HAVE_GETGROUPS 1 + +/* Define to 1 if you have the `gethostbyname' function. */ +#define HAVE_GETHOSTBYNAME 1 + +/* Define this if you have some version of gethostbyname_r() */ +/* #undef HAVE_GETHOSTBYNAME_R */ + +/* Define this if you have the 3-arg version of gethostbyname_r(). */ +/* #undef HAVE_GETHOSTBYNAME_R_3_ARG */ + +/* Define this if you have the 5-arg version of gethostbyname_r(). */ +/* #undef HAVE_GETHOSTBYNAME_R_5_ARG */ + +/* Define this if you have the 6-arg version of gethostbyname_r(). */ +/* #undef HAVE_GETHOSTBYNAME_R_6_ARG */ + +/* Define to 1 if you have the `getitimer' function. */ +#define HAVE_GETITIMER 1 + +/* Define to 1 if you have the `getloadavg' function. */ +#define HAVE_GETLOADAVG 1 + +/* Define to 1 if you have the `getlogin' function. */ +#define HAVE_GETLOGIN 1 + +/* Define to 1 if you have the `getnameinfo' function. */ +#define HAVE_GETNAMEINFO 1 + +/* Define if you have the 'getpagesize' function. */ +#define HAVE_GETPAGESIZE 1 + +/* Define to 1 if you have the `getpeername' function. */ +#define HAVE_GETPEERNAME 1 + +/* Define to 1 if you have the `getpgid' function. */ +#define HAVE_GETPGID 1 + +/* Define to 1 if you have the `getpgrp' function. */ +#define HAVE_GETPGRP 1 + +/* Define to 1 if you have the `getpid' function. */ +#define HAVE_GETPID 1 + +/* Define to 1 if you have the `getpriority' function. */ +#define HAVE_GETPRIORITY 1 + +/* Define to 1 if you have the `getpwent' function. */ +#define HAVE_GETPWENT 1 + +/* Define to 1 if the Linux getrandom() syscall is available */ +/* #undef HAVE_GETRANDOM_SYSCALL */ + +/* Define to 1 if you have the `getresgid' function. */ +#define HAVE_GETRESGID 1 + +/* Define to 1 if you have the `getresuid' function. */ +#define HAVE_GETRESUID 1 + +/* Define to 1 if you have the `getsid' function. */ +#define HAVE_GETSID 1 + +/* Define to 1 if you have the `getspent' function. */ +/* #undef HAVE_GETSPENT */ + +/* Define to 1 if you have the `getspnam' function. */ +/* #undef HAVE_GETSPNAM */ + +/* Define to 1 if you have the `gettimeofday' function. */ +#define HAVE_GETTIMEOFDAY 1 + +/* Define to 1 if you have the `getwd' function. */ +/* #undef HAVE_GETWD */ + +/* Define if glibc has incorrect _FORTIFY_SOURCE wrappers for memmove and + bcopy. */ +/* #undef HAVE_GLIBC_MEMMOVE_BUG */ + +/* Define to 1 if you have the header file. */ +#define HAVE_GRP_H 1 + +/* Define if you have the 'hstrerror' function. */ +#define HAVE_HSTRERROR 1 + +/* Define this if you have le64toh() */ +#define HAVE_HTOLE64 1 + +/* Define to 1 if you have the `hypot' function. */ +#define HAVE_HYPOT 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_IEEEFP_H */ + +/* Define to 1 if you have the `if_nameindex' function. */ +/* #undef HAVE_IF_NAMEINDEX */ + +/* Define if you have the 'inet_aton' function. */ +#define HAVE_INET_ATON 1 + +/* Define if you have the 'inet_pton' function. */ +#define HAVE_INET_PTON 1 + +/* Define to 1 if you have the `initgroups' function. */ +#define HAVE_INITGROUPS 1 + +/* Define if your compiler provides int32_t. */ +#define HAVE_INT32_T 1 + +/* Define if your compiler provides int64_t. */ +#define HAVE_INT64_T 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_IO_H */ + +/* Define if gcc has the ipa-pure-const bug. */ +/* #undef HAVE_IPA_PURE_CONST_BUG */ + +/* Define to 1 if you have the `kill' function. */ +#define HAVE_KILL 1 + +/* Define to 1 if you have the `killpg' function. */ +#define HAVE_KILLPG 1 + +/* Define if you have the 'kqueue' functions. */ +#define HAVE_KQUEUE 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_LANGINFO_H 1 + +/* Defined to enable large file support when an off_t is bigger than a long + and long long is available and at least as big as an off_t. You may need to + add some flags for configuration and compilation to enable this mode. (For + Solaris and Linux, the necessary defines are already defined.) */ +/* #undef HAVE_LARGEFILE_SUPPORT */ + +/* Define to 1 if you have the 'lchflags' function. */ +/* #undef HAVE_LCHFLAGS */ + +/* Define to 1 if you have the `lchmod' function. */ +/* #undef HAVE_LCHMOD */ + +/* Define to 1 if you have the `lchown' function. */ +#define HAVE_LCHOWN 1 + +/* Define to 1 if you have the `lgamma' function. */ +#define HAVE_LGAMMA 1 + +/* Define to 1 if you have the `dl' library (-ldl). */ +#define HAVE_LIBDL 1 + +/* Define to 1 if you have the `dld' library (-ldld). */ +/* #undef HAVE_LIBDLD */ + +/* Define to 1 if you have the `ieee' library (-lieee). */ +/* #undef HAVE_LIBIEEE */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LIBINTL_H */ + +/* Define if you have the readline library (-lreadline). */ +/* #undef HAVE_LIBREADLINE */ + +/* Define to 1 if you have the `resolv' library (-lresolv). */ +/* #undef HAVE_LIBRESOLV */ + +/* Define to 1 if you have the `sendfile' library (-lsendfile). */ +/* #undef HAVE_LIBSENDFILE */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LIBUTIL_H */ + +/* Define if you have the 'link' function. */ +#define HAVE_LINK 1 + +/* Define to 1 if you have the `linkat' function. */ +#define HAVE_LINKAT 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LINUX_CAN_BCM_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_LINUX_CAN_H 1 + +/* Define if compiling using Linux 3.6 or later. */ +#define HAVE_LINUX_CAN_RAW_FD_FRAMES 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_LINUX_CAN_RAW_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_LINUX_NETLINK_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_LINUX_TIPC_H 1 + +/* Define to 1 if you have the `lockf' function. */ +#define HAVE_LOCKF 1 + +/* Define to 1 if you have the `log1p' function. */ +#define HAVE_LOG1P 1 + +/* Define to 1 if you have the `log2' function. */ +#define HAVE_LOG2 1 + +/* Define this if you have the type long double. */ +#define HAVE_LONG_DOUBLE 1 + +/* Define this if you have the type long long. */ +#define HAVE_LONG_LONG 1 + +/* Define to 1 if you have the `lstat' function. */ +#define HAVE_LSTAT 1 + +/* Define to 1 if you have the `lutimes' function. */ +/* #undef HAVE_LUTIMES */ + +/* Define this if you have the makedev macro. */ +#define HAVE_MAKEDEV 1 + +/* Define to 1 if you have the `mbrtowc' function. */ +#define HAVE_MBRTOWC 1 + +/* Define to 1 if you have the `memmove' function. */ +#define HAVE_MEMMOVE 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `memrchr' function. */ +#define HAVE_MEMRCHR 1 + +/* Define to 1 if you have the `mkdirat' function. */ +#define HAVE_MKDIRAT 1 + +/* Define to 1 if you have the `mkfifo' function. */ +#define HAVE_MKFIFO 1 + +/* Define to 1 if you have the `mkfifoat' function. */ +/* #undef HAVE_MKFIFOAT */ + +/* Define to 1 if you have the `mknod' function. */ +#define HAVE_MKNOD 1 + +/* Define to 1 if you have the `mknodat' function. */ +#define HAVE_MKNODAT 1 + +/* Define to 1 if you have the `mktime' function. */ +#define HAVE_MKTIME 1 + +/* Define to 1 if you have the `mmap' function. */ +#define HAVE_MMAP 1 + +/* Define to 1 if you have the `mremap' function. */ +#define HAVE_MREMAP 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NCURSES_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. */ +/* #undef HAVE_NDIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_NETPACKET_PACKET_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_NET_IF_H 1 + +/* Define to 1 if you have the `nice' function. */ +#define HAVE_NICE 1 + +/* Define to 1 if you have the `openat' function. */ +#define HAVE_OPENAT 1 + +/* Define to 1 if you have the `openpty' function. */ +/* #undef HAVE_OPENPTY */ + +/* Define if compiling using MacOS X 10.5 SDK or later. */ +/* #undef HAVE_OSX105_SDK */ + +/* Define to 1 if you have the `pathconf' function. */ +#define HAVE_PATHCONF 1 + +/* Define to 1 if you have the `pause' function. */ +#define HAVE_PAUSE 1 + +/* Define to 1 if you have the `pipe2' function. */ +#define HAVE_PIPE2 1 + +/* Define to 1 if you have the `plock' function. */ +/* #undef HAVE_PLOCK */ + +/* Define to 1 if you have the `poll' function. */ +#define HAVE_POLL 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_POLL_H 1 + +/* Define to 1 if you have the `posix_fadvise' function. */ +#define HAVE_POSIX_FADVISE 1 + +/* Define to 1 if you have the `posix_fallocate' function. */ +#define HAVE_POSIX_FALLOCATE 1 + +/* Define to 1 if you have the `pread' function. */ +#define HAVE_PREAD 1 + +/* Define if you have the 'prlimit' functions. */ +#define HAVE_PRLIMIT 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PROCESS_H */ + +/* Define if your compiler supports function prototype */ +#define HAVE_PROTOTYPES 1 + +/* Define to 1 if you have the `pthread_atfork' function. */ +#define HAVE_PTHREAD_ATFORK 1 + +/* Defined for Solaris 2.6 bug in pthread header. */ +/* #undef HAVE_PTHREAD_DESTRUCTOR */ + +/* Define to 1 if you have the header file. */ +#define HAVE_PTHREAD_H 1 + +/* Define to 1 if you have the `pthread_init' function. */ +/* #undef HAVE_PTHREAD_INIT */ + +/* Define to 1 if you have the `pthread_kill' function. */ +#define HAVE_PTHREAD_KILL 1 + +/* Define to 1 if you have the `pthread_sigmask' function. */ +#define HAVE_PTHREAD_SIGMASK 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PTY_H */ + +/* Define to 1 if you have the `putenv' function. */ +#define HAVE_PUTENV 1 + +/* Define to 1 if you have the `pwrite' function. */ +#define HAVE_PWRITE 1 + +/* Define if the libcrypto has RAND_egd */ +/* #undef HAVE_RAND_EGD */ + +/* Define to 1 if you have the `readlink' function. */ +#define HAVE_READLINK 1 + +/* Define to 1 if you have the `readlinkat' function. */ +#define HAVE_READLINKAT 1 + +/* Define to 1 if you have the `readv' function. */ +#define HAVE_READV 1 + +/* Define to 1 if you have the `realpath' function. */ +#define HAVE_REALPATH 1 + +/* Define to 1 if you have the `renameat' function. */ +#define HAVE_RENAMEAT 1 + +/* Define if readline supports append_history */ +/* #undef HAVE_RL_APPEND_HISTORY */ + +/* Define if you have readline 2.1 */ +/* #undef HAVE_RL_CALLBACK */ + +/* Define if you can turn off readline's signal handling. */ +/* #undef HAVE_RL_CATCH_SIGNAL */ + +/* Define if you have readline 2.2 */ +/* #undef HAVE_RL_COMPLETION_APPEND_CHARACTER */ + +/* Define if you have readline 4.0 */ +/* #undef HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK */ + +/* Define if you have readline 4.2 */ +/* #undef HAVE_RL_COMPLETION_MATCHES */ + +/* Define if you have rl_completion_suppress_append */ +/* #undef HAVE_RL_COMPLETION_SUPPRESS_APPEND */ + +/* Define if you have readline 4.0 */ +/* #undef HAVE_RL_PRE_INPUT_HOOK */ + +/* Define to 1 if you have the `round' function. */ +#define HAVE_ROUND 1 + +/* Define to 1 if you have the `sched_get_priority_max' function. */ +#define HAVE_SCHED_GET_PRIORITY_MAX 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SCHED_H 1 + +/* Define to 1 if you have the `sched_rr_get_interval' function. */ +#define HAVE_SCHED_RR_GET_INTERVAL 1 + +/* Define to 1 if you have the `sched_setaffinity' function. */ +#define HAVE_SCHED_SETAFFINITY 1 + +/* Define to 1 if you have the `sched_setparam' function. */ +#define HAVE_SCHED_SETPARAM 1 + +/* Define to 1 if you have the `sched_setscheduler' function. */ +#define HAVE_SCHED_SETSCHEDULER 1 + +/* Define to 1 if you have the `select' function. */ +#define HAVE_SELECT 1 + +/* Define to 1 if you have the `sem_getvalue' function. */ +#define HAVE_SEM_GETVALUE 1 + +/* Define to 1 if you have the `sem_open' function. */ +#define HAVE_SEM_OPEN 1 + +/* Define to 1 if you have the `sem_timedwait' function. */ +#define HAVE_SEM_TIMEDWAIT 1 + +/* Define to 1 if you have the `sem_unlink' function. */ +#define HAVE_SEM_UNLINK 1 + +/* Define to 1 if you have the `sendfile' function. */ +#define HAVE_SENDFILE 1 + +/* Define to 1 if you have the `setegid' function. */ +#define HAVE_SETEGID 1 + +/* Define to 1 if you have the `seteuid' function. */ +#define HAVE_SETEUID 1 + +/* Define to 1 if you have the `setgid' function. */ +#define HAVE_SETGID 1 + +/* Define if you have the 'setgroups' function. */ +#define HAVE_SETGROUPS 1 + +/* Define to 1 if you have the `sethostname' function. */ +/* #undef HAVE_SETHOSTNAME */ + +/* Define to 1 if you have the `setitimer' function. */ +#define HAVE_SETITIMER 1 + +/* Define to 1 if you have the `setlocale' function. */ +#define HAVE_SETLOCALE 1 + +/* Define to 1 if you have the `setpgid' function. */ +#define HAVE_SETPGID 1 + +/* Define to 1 if you have the `setpgrp' function. */ +#define HAVE_SETPGRP 1 + +/* Define to 1 if you have the `setpriority' function. */ +#define HAVE_SETPRIORITY 1 + +/* Define to 1 if you have the `setregid' function. */ +#define HAVE_SETREGID 1 + +/* Define to 1 if you have the `setresgid' function. */ +#define HAVE_SETRESGID 1 + +/* Define to 1 if you have the `setresuid' function. */ +#define HAVE_SETRESUID 1 + +/* Define to 1 if you have the `setreuid' function. */ +#define HAVE_SETREUID 1 + +/* Define to 1 if you have the `setsid' function. */ +#define HAVE_SETSID 1 + +/* Define to 1 if you have the `setuid' function. */ +#define HAVE_SETUID 1 + +/* Define to 1 if you have the `setvbuf' function. */ +#define HAVE_SETVBUF 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SHADOW_H */ + +/* Define to 1 if you have the `sigaction' function. */ +#define HAVE_SIGACTION 1 + +/* Define to 1 if you have the `sigaltstack' function. */ +#define HAVE_SIGALTSTACK 1 + +/* Define to 1 if you have the `siginterrupt' function. */ +#define HAVE_SIGINTERRUPT 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SIGNAL_H 1 + +/* Define to 1 if you have the `sigpending' function. */ +#define HAVE_SIGPENDING 1 + +/* Define to 1 if you have the `sigrelse' function. */ +/* #undef HAVE_SIGRELSE */ + +/* Define to 1 if you have the `sigtimedwait' function. */ +/* #undef HAVE_SIGTIMEDWAIT */ + +/* Define to 1 if you have the `sigwait' function. */ +#define HAVE_SIGWAIT 1 + +/* Define to 1 if you have the `sigwaitinfo' function. */ +/* #undef HAVE_SIGWAITINFO */ + +/* Define to 1 if you have the `snprintf' function. */ +#define HAVE_SNPRINTF 1 + +/* Define if sockaddr has sa_len member */ +/* #undef HAVE_SOCKADDR_SA_LEN */ + +/* struct sockaddr_storage (sys/socket.h) */ +#define HAVE_SOCKADDR_STORAGE 1 + +/* Define if you have the 'socketpair' function. */ +#define HAVE_SOCKETPAIR 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SPAWN_H */ + +/* Define if your compiler provides ssize_t */ +#define HAVE_SSIZE_T 1 + +/* Define to 1 if you have the `statvfs' function. */ +#define HAVE_STATVFS 1 + +/* Define if you have struct stat.st_mtim.tv_nsec */ +/* #undef HAVE_STAT_TV_NSEC */ + +/* Define if you have struct stat.st_mtimensec */ +/* #undef HAVE_STAT_TV_NSEC2 */ + +/* Define if your compiler supports variable length function prototypes (e.g. + void fprintf(FILE *, char *, ...);) *and* */ +#define HAVE_STDARG_PROTOTYPES 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Has stdatomic.h, atomic_int and _Atomic void* types work */ +#define HAVE_STD_ATOMIC 1 + +/* Define to 1 if you have the `strdup' function. */ +#define HAVE_STRDUP 1 + +/* Define to 1 if you have the `strftime' function. */ +#define HAVE_STRFTIME 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the `strlcpy' function. */ +#define HAVE_STRLCPY 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_STROPTS_H */ + +/* Define to 1 if `st_birthtime' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_BIRTHTIME */ + +/* Define to 1 if `st_blksize' is a member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_BLKSIZE 1 + +/* Define to 1 if `st_blocks' is a member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_BLOCKS 1 + +/* Define to 1 if `st_flags' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_FLAGS */ + +/* Define to 1 if `st_gen' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_GEN */ + +/* Define to 1 if `st_rdev' is a member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_RDEV 1 + +/* Define to 1 if `tm_zone' is a member of `struct tm'. */ +#define HAVE_STRUCT_TM_TM_ZONE 1 + +/* Define to 1 if your `struct stat' has `st_blocks'. Deprecated, use + `HAVE_STRUCT_STAT_ST_BLOCKS' instead. */ +#define HAVE_ST_BLOCKS 1 + +/* Define if you have the 'symlink' function. */ +#define HAVE_SYMLINK 1 + +/* Define to 1 if you have the `symlinkat' function. */ +#define HAVE_SYMLINKAT 1 + +/* Define to 1 if you have the `sync' function. */ +#define HAVE_SYNC 1 + +/* Define to 1 if you have the `sysconf' function. */ +#define HAVE_SYSCONF 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYSEXITS_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_AUDIOIO_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_BSDTTY_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_DEVPOLL_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +/* #undef HAVE_SYS_DIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_ENDIAN_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_EPOLL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_EVENT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_FILE_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_IOCTL_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_KERN_CONTROL_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_LOADAVG_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_LOCK_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_MKDEV_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_MODEM_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +/* #undef HAVE_SYS_NDIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_PARAM_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_POLL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_RESOURCE_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SELECT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SENDFILE_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SOCKET_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STATVFS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SYSCALL_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_SYS_DOMAIN_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_TERMIO_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIMES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UIO_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UN_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UTSNAME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_WAIT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_XATTR_H 1 + +/* Define to 1 if you have the `tcgetpgrp' function. */ +#define HAVE_TCGETPGRP 1 + +/* Define to 1 if you have the `tcsetpgrp' function. */ +#define HAVE_TCSETPGRP 1 + +/* Define to 1 if you have the `tempnam' function. */ +#define HAVE_TEMPNAM 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_TERMIOS_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_TERM_H */ + +/* Define to 1 if you have the `tgamma' function. */ +#define HAVE_TGAMMA 1 + +/* Define to 1 if you have the `timegm' function. */ +#define HAVE_TIMEGM 1 + +/* Define to 1 if you have the `times' function. */ +#define HAVE_TIMES 1 + +/* Define to 1 if you have the `tmpfile' function. */ +#define HAVE_TMPFILE 1 + +/* Define to 1 if you have the `tmpnam' function. */ +#define HAVE_TMPNAM 1 + +/* Define to 1 if you have the `tmpnam_r' function. */ +/* #undef HAVE_TMPNAM_R */ + +/* Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use + `HAVE_STRUCT_TM_TM_ZONE' instead. */ +#define HAVE_TM_ZONE 1 + +/* Define to 1 if you have the `truncate' function. */ +#define HAVE_TRUNCATE 1 + +/* Define to 1 if you don't have `tm_zone' but do have the external array + `tzname'. */ +/* #undef HAVE_TZNAME */ + +/* Define this if you have tcl and TCL_UTF_MAX==6 */ +/* #undef HAVE_UCS4_TCL */ + +/* Define if your compiler provides uint32_t. */ +#define HAVE_UINT32_T 1 + +/* Define if your compiler provides uint64_t. */ +#define HAVE_UINT64_T 1 + +/* Define to 1 if the system has the type `uintptr_t'. */ +#define HAVE_UINTPTR_T 1 + +/* Define to 1 if you have the `uname' function. */ +#define HAVE_UNAME 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you have the `unlinkat' function. */ +#define HAVE_UNLINKAT 1 + +/* Define to 1 if you have the `unsetenv' function. */ +#define HAVE_UNSETENV 1 + +/* Define if you have a useable wchar_t type defined in wchar.h; useable means + wchar_t must be an unsigned type with at least 16 bits. (see + Include/unicodeobject.h). */ +/* #undef HAVE_USABLE_WCHAR_T */ + +/* Define to 1 if you have the header file. */ +#define HAVE_UTIL_H 1 + +/* Define to 1 if you have the `utimensat' function. */ +#define HAVE_UTIMENSAT 1 + +/* Define to 1 if you have the `utimes' function. */ +#define HAVE_UTIMES 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UTIME_H 1 + +/* Define to 1 if you have the `wait3' function. */ +/* #undef HAVE_WAIT3 */ + +/* Define to 1 if you have the `wait4' function. */ +#define HAVE_WAIT4 1 + +/* Define to 1 if you have the `waitid' function. */ +#define HAVE_WAITID 1 + +/* Define to 1 if you have the `waitpid' function. */ +#define HAVE_WAITPID 1 + +/* Define if the compiler provides a wchar.h header file. */ +#define HAVE_WCHAR_H 1 + +/* Define to 1 if you have the `wcscoll' function. */ +#define HAVE_WCSCOLL 1 + +/* Define to 1 if you have the `wcsftime' function. */ +#define HAVE_WCSFTIME 1 + +/* Define to 1 if you have the `wcsxfrm' function. */ +#define HAVE_WCSXFRM 1 + +/* Define to 1 if you have the `wmemcmp' function. */ +#define HAVE_WMEMCMP 1 + +/* Define if tzset() actually switches the local timezone in a meaningful way. + */ +/* #undef HAVE_WORKING_TZSET */ + +/* Define to 1 if you have the `writev' function. */ +#define HAVE_WRITEV 1 + +/* Define if the zlib library has inflateCopy */ +#define HAVE_ZLIB_COPY 1 + +/* Define to 1 if you have the `_getpty' function. */ +/* #undef HAVE__GETPTY */ + +/* Define if log1p(-0.) is 0. rather than -0. */ +/* #undef LOG1P_DROPS_ZERO_SIGN */ + +/* Define to 1 if `major', `minor', and `makedev' are declared in . + */ +/* #undef MAJOR_IN_MKDEV */ + +/* Define to 1 if `major', `minor', and `makedev' are declared in + . */ +#define MAJOR_IN_SYSMACROS 1 + +/* Define if mvwdelch in curses.h is an expression. */ +/* #undef MVWDELCH_IS_EXPRESSION */ + +/* Define to the address where bug reports for this package should be sent. */ +/* #undef PACKAGE_BUGREPORT */ + +/* Define to the full name of this package. */ +/* #undef PACKAGE_NAME */ + +/* Define to the full name and version of this package. */ +/* #undef PACKAGE_STRING */ + +/* Define to the one symbol short name of this package. */ +/* #undef PACKAGE_TARNAME */ + +/* Define to the home page for this package. */ +/* #undef PACKAGE_URL */ + +/* Define to the version of this package. */ +/* #undef PACKAGE_VERSION */ + +/* Define if POSIX semaphores aren't enabled on your system */ +/* #undef POSIX_SEMAPHORES_NOT_ENABLED */ + +/* Defined if PTHREAD_SCOPE_SYSTEM supported. */ +/* #undef PTHREAD_SYSTEM_SCHED_SUPPORTED */ + +/* Define as the preferred size in bits of long digits */ +/* #undef PYLONG_BITS_IN_DIGIT */ + +/* Define to printf format modifier for long long type */ +#define PY_FORMAT_LONG_LONG "ll" + +/* Define to printf format modifier for Py_ssize_t */ +#define PY_FORMAT_SIZE_T "z" + +/* Define if you want to build an interpreter with many run-time checks. */ +/* #undef Py_DEBUG */ + +/* Defined if Python is built as a shared library. */ +#define Py_ENABLE_SHARED 1 + +/* Define hash algorithm for str, bytes and memoryview. SipHash24: 1, FNV: 2, + externally defined: 0 */ +/* #undef Py_HASH_ALGORITHM */ + +/* assume C89 semantics that RETSIGTYPE is always void */ +#define RETSIGTYPE void + +/* Define if setpgrp() must be called as setpgrp(0, 0). */ +/* #undef SETPGRP_HAVE_ARG */ + +/* Define if i>>j for signed int i does not extend the sign bit when i < 0 */ +/* #undef SIGNED_RIGHT_SHIFT_ZERO_FILLS */ + +/* The size of `double', as computed by sizeof. */ +#define SIZEOF_DOUBLE 8 + +/* The size of `float', as computed by sizeof. */ +#define SIZEOF_FLOAT 4 + +/* The size of `fpos_t', as computed by sizeof. */ +#define SIZEOF_FPOS_T 8 + +/* The size of `int', as computed by sizeof. */ +#define SIZEOF_INT 4 + +/* The size of `long', as computed by sizeof. */ +#define SIZEOF_LONG 8 + +/* The size of `long double', as computed by sizeof. */ +#define SIZEOF_LONG_DOUBLE 16 + +/* The size of `long long', as computed by sizeof. */ +#define SIZEOF_LONG_LONG 8 + +/* The size of `off_t', as computed by sizeof. */ +#define SIZEOF_OFF_T 8 + +/* The size of `pid_t', as computed by sizeof. */ +#define SIZEOF_PID_T 4 + +/* The size of `pthread_t', as computed by sizeof. */ +#define SIZEOF_PTHREAD_T 8 + +/* The size of `short', as computed by sizeof. */ +#define SIZEOF_SHORT 2 + +/* The size of `size_t', as computed by sizeof. */ +#define SIZEOF_SIZE_T 8 + +/* The size of `time_t', as computed by sizeof. */ +#define SIZEOF_TIME_T 8 + +/* The size of `uintptr_t', as computed by sizeof. */ +#define SIZEOF_UINTPTR_T 8 + +/* The size of `void *', as computed by sizeof. */ +#define SIZEOF_VOID_P 8 + +/* The size of `wchar_t', as computed by sizeof. */ +#define SIZEOF_WCHAR_T 4 + +/* The size of `_Bool', as computed by sizeof. */ +#define SIZEOF__BOOL 1 + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define if you can safely include both and + (which you can't on SCO ODT 3.0). */ +#define SYS_SELECT_WITH_SYS_TIME 1 + +/* Define if tanh(-0.) is -0., or if platform doesn't have signed zeros */ +/* #undef TANH_PRESERVES_ZERO_SIGN */ + +/* Library needed by timemodule.c: librt may be needed for clock_gettime() */ +/* #undef TIMEMODULE_LIB */ + +/* Define to 1 if you can safely include both and . */ +#define TIME_WITH_SYS_TIME 1 + +/* Define to 1 if your declares `struct tm'. */ +/* #undef TM_IN_SYS_TIME */ + +/* Define if you want to use computed gotos in ceval.c. */ +#define USE_COMPUTED_GOTOS 1 + +/* Define to use the C99 inline keyword. */ +#define USE_INLINE 1 + +/* Enable extensions on AIX 3, Interix. */ +#ifndef _ALL_SOURCE +# define _ALL_SOURCE 1 +#endif +/* Enable GNU extensions on systems that have them. */ +#ifndef _GNU_SOURCE +# define _GNU_SOURCE 1 +#endif +/* Enable threading extensions on Solaris. */ +#ifndef _POSIX_PTHREAD_SEMANTICS +# define _POSIX_PTHREAD_SEMANTICS 1 +#endif +/* Enable extensions on HP NonStop. */ +#ifndef _TANDEM_SOURCE +# define _TANDEM_SOURCE 1 +#endif +/* Enable general extensions on Solaris. */ +#ifndef __EXTENSIONS__ +# define __EXTENSIONS__ 1 +#endif + + +/* Define if a va_list is an array of some kind */ +/* #undef VA_LIST_IS_ARRAY */ + +/* Define if you want SIGFPE handled (see Include/pyfpe.h). */ +/* #undef WANT_SIGFPE_HANDLER */ + +/* Define if WINDOW in curses.h offers a field _flags. */ +/* #undef WINDOW_HAS_FLAGS */ + +/* Define if you want documentation strings in extension modules */ +#define WITH_DOC_STRINGS 1 + +/* Define if you want to use the new-style (Openstep, Rhapsody, MacOS) dynamic + linker (dyld) instead of the old-style (NextStep) dynamic linker (rld). + Dyld is necessary to support frameworks. */ +/* #undef WITH_DYLD */ + +/* Define to 1 if libintl is needed for locale functions. */ +/* #undef WITH_LIBINTL */ + +/* Define if you want to produce an OpenStep/Rhapsody framework (shared + library plus accessory files). */ +/* #undef WITH_NEXT_FRAMEWORK */ + +/* Define if you want to compile in Python-specific mallocs */ +#define WITH_PYMALLOC 1 + +/* Define if you want to compile in rudimentary thread support */ +#define WITH_THREAD 1 + +/* Define to profile with the Pentium timestamp counter */ +/* #undef WITH_TSC */ + +/* Define if you want pymalloc to be disabled when running under valgrind */ +/* #undef WITH_VALGRIND */ + +/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most + significant byte first (like Motorola and SPARC, unlike Intel). */ +#if defined AC_APPLE_UNIVERSAL_BUILD +# if defined __BIG_ENDIAN__ +# define WORDS_BIGENDIAN 1 +# endif +#else +# ifndef WORDS_BIGENDIAN +/* # undef WORDS_BIGENDIAN */ +# endif +#endif + +/* Define if arithmetic is subject to x87-style double rounding issue */ +/* #undef X87_DOUBLE_ROUNDING */ + +/* Define on OpenBSD to activate all library features */ +/* #undef _BSD_SOURCE */ + +/* Define on Irix to enable u_int */ +#define _BSD_TYPES 1 + +/* Define on Darwin to activate all library features */ +#define _DARWIN_C_SOURCE 1 + +/* This must be set to 64 on some systems to enable large file support. */ +#define _FILE_OFFSET_BITS 64 + +/* Define on Linux to activate all library features */ +#define _GNU_SOURCE 1 + +/* Define to include mbstate_t for mbrtowc */ +/* #undef _INCLUDE__STDC_A1_SOURCE */ + +/* This must be defined on some systems to enable large file support. */ +#define _LARGEFILE_SOURCE 1 + +/* This must be defined on AIX systems to enable large file support. */ +/* #undef _LARGE_FILES */ + +/* Define to 1 if on MINIX. */ +/* #undef _MINIX */ + +/* Define on NetBSD to activate all library features */ +#define _NETBSD_SOURCE 1 + +/* Define to 2 if the system does not provide POSIX.1 features except with + this defined. */ +/* #undef _POSIX_1_SOURCE */ + +/* Define to activate features from IEEE Stds 1003.1-2008 */ +#define _POSIX_C_SOURCE 200809L + +/* Define to 1 if you need to in order for `stat' and other things to work. */ +/* #undef _POSIX_SOURCE */ + +/* Define if you have POSIX threads, and your system does not define that. */ +/* #undef _POSIX_THREADS */ + +/* Define to force use of thread-safe errno, h_errno, and other functions */ +#define _REENTRANT 1 + +/* Define for Solaris 2.5.1 so the uint32_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +/* #undef _UINT32_T */ + +/* Define for Solaris 2.5.1 so the uint64_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +/* #undef _UINT64_T */ + +/* Define to the level of X/Open that your system supports */ +#define _XOPEN_SOURCE 700 + +/* Define to activate Unix95-and-earlier features */ +#define _XOPEN_SOURCE_EXTENDED 1 + +/* Define on FreeBSD to activate all library features */ +#define __BSD_VISIBLE 1 + +/* Define to 1 if type `char' is unsigned and you are not using gcc. */ +#ifndef __CHAR_UNSIGNED__ +/* # undef __CHAR_UNSIGNED__ */ +#endif + +/* Define to 'long' if doesn't define. */ +/* #undef clock_t */ + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ + +/* Define to `int' if doesn't define. */ +/* #undef gid_t */ + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +/* #undef inline */ +#endif + +/* Define to the type of a signed integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +/* #undef int32_t */ + +/* Define to the type of a signed integer type of width exactly 64 bits if + such a type exists and the standard includes do not define it. */ +/* #undef int64_t */ + +/* Define to `int' if does not define. */ +/* #undef mode_t */ + +/* Define to `long int' if does not define. */ +/* #undef off_t */ + +/* Define to `int' if does not define. */ +/* #undef pid_t */ + +/* Define to empty if the keyword does not work. */ +/* #undef signed */ + +/* Define to `unsigned int' if does not define. */ +/* #undef size_t */ + +/* Define to `int' if does not define. */ +/* #undef socklen_t */ + +/* Define to `int' if doesn't define. */ +/* #undef uid_t */ + +/* Define to the type of an unsigned integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint32_t */ + +/* Define to the type of an unsigned integer type of width exactly 64 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint64_t */ + +/* Define to empty if the keyword does not work. */ +/* #undef volatile */ + + +/* Define the macros needed if on a UnixWare 7.x system. */ +#if defined(__USLC__) && defined(__SCO_VERSION__) +#define STRICT_SYSV_CURSES /* Don't use ncurses extensions */ +#endif + +#endif /*Py_PYCONFIG_H*/ + diff --git a/android/python35/include/pyconfig_armeabi.h b/android/python35/include/pyconfig_armeabi.h new file mode 100644 index 000000000..ac47e6204 --- /dev/null +++ b/android/python35/include/pyconfig_armeabi.h @@ -0,0 +1,1530 @@ +/* pyconfig.h. Generated from pyconfig.h.in by configure. */ +/* pyconfig.h.in. Generated from configure.ac by autoheader. */ + + +#ifndef Py_PYCONFIG_H +#define Py_PYCONFIG_H + + +/* Define if building universal (internal helper macro) */ +/* #undef AC_APPLE_UNIVERSAL_BUILD */ + +/* Define for AIX if your compiler is a genuine IBM xlC/xlC_r and you want + support for AIX C++ shared extension modules. */ +/* #undef AIX_GENUINE_CPLUSPLUS */ + +/* Define if C doubles are 64-bit IEEE 754 binary format, stored in ARM + mixed-endian order (byte order 45670123) */ +/* #undef DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754 */ + +/* Define if C doubles are 64-bit IEEE 754 binary format, stored with the most + significant byte first */ +/* #undef DOUBLE_IS_BIG_ENDIAN_IEEE754 */ + +/* Define if C doubles are 64-bit IEEE 754 binary format, stored with the + least significant byte first */ +/* #undef DOUBLE_IS_LITTLE_ENDIAN_IEEE754 */ + +/* Define if --enable-ipv6 is specified */ +#define ENABLE_IPV6 1 + +/* Define if flock needs to be linked with bsd library. */ +/* #undef FLOCK_NEEDS_LIBBSD */ + +/* Define if getpgrp() must be called as getpgrp(0). */ +/* #undef GETPGRP_HAVE_ARG */ + +/* Define if gettimeofday() does not have second (timezone) argument This is + the case on Motorola V4 (R40V4.2) */ +/* #undef GETTIMEOFDAY_NO_TZ */ + +/* Define to 1 if you have the `accept4' function. */ +/* #undef HAVE_ACCEPT4 */ + +/* Define to 1 if you have the `acosh' function. */ +#define HAVE_ACOSH 1 + +/* struct addrinfo (netdb.h) */ +#define HAVE_ADDRINFO 1 + +/* Define to 1 if you have the `alarm' function. */ +#define HAVE_ALARM 1 + +/* Define if aligned memory access is required */ +#define HAVE_ALIGNED_REQUIRED 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ALLOCA_H 1 + +/* Define this if your time.h defines altzone. */ +/* #undef HAVE_ALTZONE */ + +/* Define to 1 if you have the `asinh' function. */ +#define HAVE_ASINH 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ASM_TYPES_H 1 + +/* Define to 1 if you have the `atanh' function. */ +#define HAVE_ATANH 1 + +/* Define to 1 if you have the `bind_textdomain_codeset' function. */ +/* #undef HAVE_BIND_TEXTDOMAIN_CODESET */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_BLUETOOTH_BLUETOOTH_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_BLUETOOTH_H */ + +/* Define if mbstowcs(NULL, "text", 0) does not return the number of wide + chars that would be converted. */ +/* #undef HAVE_BROKEN_MBSTOWCS */ + +/* Define if nice() returns success/failure instead of the new priority. */ +/* #undef HAVE_BROKEN_NICE */ + +/* Define if the system reports an invalid PIPE_BUF value. */ +/* #undef HAVE_BROKEN_PIPE_BUF */ + +/* Define if poll() sets errno on invalid file descriptors. */ +/* #undef HAVE_BROKEN_POLL */ + +/* Define if the Posix semaphores do not work on your system */ +/* #undef HAVE_BROKEN_POSIX_SEMAPHORES */ + +/* Define if pthread_sigmask() does not work on your system. */ +/* #undef HAVE_BROKEN_PTHREAD_SIGMASK */ + +/* define to 1 if your sem_getvalue is broken. */ +#define HAVE_BROKEN_SEM_GETVALUE 1 + +/* Define if `unsetenv` does not return an int. */ +/* #undef HAVE_BROKEN_UNSETENV */ + +/* Has builtin atomics */ +#define HAVE_BUILTIN_ATOMIC 1 + +/* Define this if you have the type _Bool. */ +#define HAVE_C99_BOOL 1 + +/* Define to 1 if you have the 'chflags' function. */ +/* #undef HAVE_CHFLAGS */ + +/* Define to 1 if you have the `chown' function. */ +#define HAVE_CHOWN 1 + +/* Define if you have the 'chroot' function. */ +#define HAVE_CHROOT 1 + +/* Define to 1 if you have the `clock' function. */ +#define HAVE_CLOCK 1 + +/* Define to 1 if you have the `clock_getres' function. */ +#define HAVE_CLOCK_GETRES 1 + +/* Define to 1 if you have the `clock_gettime' function. */ +#define HAVE_CLOCK_GETTIME 1 + +/* Define if the C compiler supports computed gotos. */ +#define HAVE_COMPUTED_GOTOS 1 + +/* Define to 1 if you have the `confstr' function. */ +/* #undef HAVE_CONFSTR */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_CONIO_H */ + +/* Define to 1 if you have the `copysign' function. */ +#define HAVE_COPYSIGN 1 + +/* Define to 1 if you have the `ctermid' function. */ +/* #undef HAVE_CTERMID */ + +/* Define if you have the 'ctermid_r' function. */ +#define HAVE_CTERMID_R 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_CURSES_H */ + +/* Define if you have the 'is_term_resized' function. */ +/* #undef HAVE_CURSES_IS_TERM_RESIZED */ + +/* Define if you have the 'resizeterm' function. */ +/* #undef HAVE_CURSES_RESIZETERM */ + +/* Define if you have the 'resize_term' function. */ +/* #undef HAVE_CURSES_RESIZE_TERM */ + +/* Define to 1 if you have the declaration of `isfinite', and to 0 if you + don't. */ +#define HAVE_DECL_ISFINITE 1 + +/* Define to 1 if you have the declaration of `isinf', and to 0 if you don't. + */ +#define HAVE_DECL_ISINF 1 + +/* Define to 1 if you have the declaration of `isnan', and to 0 if you don't. + */ +#define HAVE_DECL_ISNAN 1 + +/* Define to 1 if you have the declaration of `tzname', and to 0 if you don't. + */ +/* #undef HAVE_DECL_TZNAME */ + +/* Define to 1 if you have the device macros. */ +#define HAVE_DEVICE_MACROS 1 + +/* Define to 1 if you have the /dev/ptc device file. */ +/* #undef HAVE_DEV_PTC */ + +/* Define to 1 if you have the /dev/ptmx device file. */ +/* #undef HAVE_DEV_PTMX */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_DIRECT_H */ + +/* Define to 1 if the dirent structure has a d_type field */ +#define HAVE_DIRENT_D_TYPE 1 + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#define HAVE_DIRENT_H 1 + +/* Define if you have the 'dirfd' function or macro. */ +#define HAVE_DIRFD 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_DLFCN_H 1 + +/* Define to 1 if you have the `dlopen' function. */ +#define HAVE_DLOPEN 1 + +/* Define to 1 if you have the `dup2' function. */ +#define HAVE_DUP2 1 + +/* Define to 1 if you have the `dup3' function. */ +/* #undef HAVE_DUP3 */ + +/* Defined when any dynamic module loading is enabled. */ +#define HAVE_DYNAMIC_LOADING 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ENDIAN_H 1 + +/* Define if you have the 'epoll' functions. */ +#define HAVE_EPOLL 1 + +/* Define if you have the 'epoll_create1' function. */ +/* #undef HAVE_EPOLL_CREATE1 */ + +/* Define to 1 if you have the `erf' function. */ +#define HAVE_ERF 1 + +/* Define to 1 if you have the `erfc' function. */ +#define HAVE_ERFC 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ERRNO_H 1 + +/* Define to 1 if you have the `execv' function. */ +#define HAVE_EXECV 1 + +/* Define to 1 if you have the `expm1' function. */ +#define HAVE_EXPM1 1 + +/* Define to 1 if you have the `faccessat' function. */ +/* #undef HAVE_FACCESSAT */ + +/* Define if you have the 'fchdir' function. */ +#define HAVE_FCHDIR 1 + +/* Define to 1 if you have the `fchmod' function. */ +#define HAVE_FCHMOD 1 + +/* Define to 1 if you have the `fchmodat' function. */ +#define HAVE_FCHMODAT 1 + +/* Define to 1 if you have the `fchown' function. */ +#define HAVE_FCHOWN 1 + +/* Define to 1 if you have the `fchownat' function. */ +#define HAVE_FCHOWNAT 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* Define if you have the 'fdatasync' function. */ +#define HAVE_FDATASYNC 1 + +/* Define to 1 if you have the `fdopendir' function. */ +#define HAVE_FDOPENDIR 1 + +/* Define to 1 if you have the `fexecve' function. */ +/* #undef HAVE_FEXECVE */ + +/* Define to 1 if you have the `finite' function. */ +#define HAVE_FINITE 1 + +/* Define to 1 if you have the `flock' function. */ +#define HAVE_FLOCK 1 + +/* Define to 1 if you have the `fork' function. */ +#define HAVE_FORK 1 + +/* Define to 1 if you have the `forkpty' function. */ +/* #undef HAVE_FORKPTY */ + +/* Define to 1 if you have the `fpathconf' function. */ +#define HAVE_FPATHCONF 1 + +/* Define to 1 if you have the `fseek64' function. */ +/* #undef HAVE_FSEEK64 */ + +/* Define to 1 if you have the `fseeko' function. */ +#define HAVE_FSEEKO 1 + +/* Define to 1 if you have the `fstatat' function. */ +#define HAVE_FSTATAT 1 + +/* Define to 1 if you have the `fstatvfs' function. */ +/* #undef HAVE_FSTATVFS */ + +/* Define if you have the 'fsync' function. */ +#define HAVE_FSYNC 1 + +/* Define to 1 if you have the `ftell64' function. */ +/* #undef HAVE_FTELL64 */ + +/* Define to 1 if you have the `ftello' function. */ +#define HAVE_FTELLO 1 + +/* Define to 1 if you have the `ftime' function. */ +#define HAVE_FTIME 1 + +/* Define to 1 if you have the `ftruncate' function. */ +#define HAVE_FTRUNCATE 1 + +/* Define to 1 if you have the `futimens' function. */ +/* #undef HAVE_FUTIMENS */ + +/* Define to 1 if you have the `futimes' function. */ +/* #undef HAVE_FUTIMES */ + +/* Define to 1 if you have the `futimesat' function. */ +/* #undef HAVE_FUTIMESAT */ + +/* Define to 1 if you have the `gai_strerror' function. */ +#define HAVE_GAI_STRERROR 1 + +/* Define to 1 if you have the `gamma' function. */ +/* #undef HAVE_GAMMA */ + +/* Define if we can use gcc inline assembler to get and set mc68881 fpcr */ +/* #undef HAVE_GCC_ASM_FOR_MC68881 */ + +/* Define if we can use x64 gcc inline assembler */ +/* #undef HAVE_GCC_ASM_FOR_X64 */ + +/* Define if we can use gcc inline assembler to get and set x87 control word + */ +/* #undef HAVE_GCC_ASM_FOR_X87 */ + +/* Define if your compiler provides __uint128_t */ +/* #undef HAVE_GCC_UINT128_T */ + +/* Define if you have the getaddrinfo function. */ +#define HAVE_GETADDRINFO 1 + +/* Define this if you have flockfile(), getc_unlocked(), and funlockfile() */ +#define HAVE_GETC_UNLOCKED 1 + +/* Define to 1 if you have the `getentropy' function. */ +/* #undef HAVE_GETENTROPY */ + +/* Define to 1 if you have the `getgrouplist' function. */ +#define HAVE_GETGROUPLIST 1 + +/* Define to 1 if you have the `getgroups' function. */ +#define HAVE_GETGROUPS 1 + +/* Define to 1 if you have the `gethostbyname' function. */ +#define HAVE_GETHOSTBYNAME 1 + +/* Define this if you have some version of gethostbyname_r() */ +/* #undef HAVE_GETHOSTBYNAME_R */ + +/* Define this if you have the 3-arg version of gethostbyname_r(). */ +/* #undef HAVE_GETHOSTBYNAME_R_3_ARG */ + +/* Define this if you have the 5-arg version of gethostbyname_r(). */ +/* #undef HAVE_GETHOSTBYNAME_R_5_ARG */ + +/* Define this if you have the 6-arg version of gethostbyname_r(). */ +/* #undef HAVE_GETHOSTBYNAME_R_6_ARG */ + +/* Define to 1 if you have the `getitimer' function. */ +#define HAVE_GETITIMER 1 + +/* Define to 1 if you have the `getloadavg' function. */ +#define HAVE_GETLOADAVG 1 + +/* Define to 1 if you have the `getlogin' function. */ +#define HAVE_GETLOGIN 1 + +/* Define to 1 if you have the `getnameinfo' function. */ +#define HAVE_GETNAMEINFO 1 + +/* Define if you have the 'getpagesize' function. */ +#define HAVE_GETPAGESIZE 1 + +/* Define to 1 if you have the `getpeername' function. */ +#define HAVE_GETPEERNAME 1 + +/* Define to 1 if you have the `getpgid' function. */ +#define HAVE_GETPGID 1 + +/* Define to 1 if you have the `getpgrp' function. */ +#define HAVE_GETPGRP 1 + +/* Define to 1 if you have the `getpid' function. */ +#define HAVE_GETPID 1 + +/* Define to 1 if you have the `getpriority' function. */ +#define HAVE_GETPRIORITY 1 + +/* Define to 1 if you have the `getpwent' function. */ +#define HAVE_GETPWENT 1 + +/* Define to 1 if the Linux getrandom() syscall is available */ +/* #undef HAVE_GETRANDOM_SYSCALL */ + +/* Define to 1 if you have the `getresgid' function. */ +#define HAVE_GETRESGID 1 + +/* Define to 1 if you have the `getresuid' function. */ +#define HAVE_GETRESUID 1 + +/* Define to 1 if you have the `getsid' function. */ +/* #undef HAVE_GETSID */ + +/* Define to 1 if you have the `getspent' function. */ +/* #undef HAVE_GETSPENT */ + +/* Define to 1 if you have the `getspnam' function. */ +/* #undef HAVE_GETSPNAM */ + +/* Define to 1 if you have the `gettimeofday' function. */ +#define HAVE_GETTIMEOFDAY 1 + +/* Define to 1 if you have the `getwd' function. */ +/* #undef HAVE_GETWD */ + +/* Define if glibc has incorrect _FORTIFY_SOURCE wrappers for memmove and + bcopy. */ +/* #undef HAVE_GLIBC_MEMMOVE_BUG */ + +/* Define to 1 if you have the header file. */ +#define HAVE_GRP_H 1 + +/* Define if you have the 'hstrerror' function. */ +#define HAVE_HSTRERROR 1 + +/* Define this if you have le64toh() */ +#define HAVE_HTOLE64 1 + +/* Define to 1 if you have the `hypot' function. */ +#define HAVE_HYPOT 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_IEEEFP_H */ + +/* Define to 1 if you have the `if_nameindex' function. */ +/* #undef HAVE_IF_NAMEINDEX */ + +/* Define if you have the 'inet_aton' function. */ +#define HAVE_INET_ATON 1 + +/* Define if you have the 'inet_pton' function. */ +#define HAVE_INET_PTON 1 + +/* Define to 1 if you have the `initgroups' function. */ +#define HAVE_INITGROUPS 1 + +/* Define if your compiler provides int32_t. */ +#define HAVE_INT32_T 1 + +/* Define if your compiler provides int64_t. */ +#define HAVE_INT64_T 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_IO_H */ + +/* Define if gcc has the ipa-pure-const bug. */ +/* #undef HAVE_IPA_PURE_CONST_BUG */ + +/* Define to 1 if you have the `kill' function. */ +#define HAVE_KILL 1 + +/* Define to 1 if you have the `killpg' function. */ +#define HAVE_KILLPG 1 + +/* Define if you have the 'kqueue' functions. */ +#define HAVE_KQUEUE 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_LANGINFO_H 1 + +/* Defined to enable large file support when an off_t is bigger than a long + and long long is available and at least as big as an off_t. You may need to + add some flags for configuration and compilation to enable this mode. (For + Solaris and Linux, the necessary defines are already defined.) */ +/* #undef HAVE_LARGEFILE_SUPPORT */ + +/* Define to 1 if you have the 'lchflags' function. */ +/* #undef HAVE_LCHFLAGS */ + +/* Define to 1 if you have the `lchmod' function. */ +/* #undef HAVE_LCHMOD */ + +/* Define to 1 if you have the `lchown' function. */ +#define HAVE_LCHOWN 1 + +/* Define to 1 if you have the `lgamma' function. */ +#define HAVE_LGAMMA 1 + +/* Define to 1 if you have the `dl' library (-ldl). */ +#define HAVE_LIBDL 1 + +/* Define to 1 if you have the `dld' library (-ldld). */ +/* #undef HAVE_LIBDLD */ + +/* Define to 1 if you have the `ieee' library (-lieee). */ +/* #undef HAVE_LIBIEEE */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LIBINTL_H */ + +/* Define if you have the readline library (-lreadline). */ +/* #undef HAVE_LIBREADLINE */ + +/* Define to 1 if you have the `resolv' library (-lresolv). */ +/* #undef HAVE_LIBRESOLV */ + +/* Define to 1 if you have the `sendfile' library (-lsendfile). */ +/* #undef HAVE_LIBSENDFILE */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LIBUTIL_H */ + +/* Define if you have the 'link' function. */ +#define HAVE_LINK 1 + +/* Define to 1 if you have the `linkat' function. */ +/* #undef HAVE_LINKAT */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LINUX_CAN_BCM_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LINUX_CAN_H */ + +/* Define if compiling using Linux 3.6 or later. */ +/* #undef HAVE_LINUX_CAN_RAW_FD_FRAMES */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LINUX_CAN_RAW_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_LINUX_NETLINK_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LINUX_TIPC_H */ + +/* Define to 1 if you have the `lockf' function. */ +#define HAVE_LOCKF 1 + +/* Define to 1 if you have the `log1p' function. */ +#define HAVE_LOG1P 1 + +/* Define to 1 if you have the `log2' function. */ +#define HAVE_LOG2 1 + +/* Define this if you have the type long double. */ +#define HAVE_LONG_DOUBLE 1 + +/* Define this if you have the type long long. */ +#define HAVE_LONG_LONG 1 + +/* Define to 1 if you have the `lstat' function. */ +#define HAVE_LSTAT 1 + +/* Define to 1 if you have the `lutimes' function. */ +/* #undef HAVE_LUTIMES */ + +/* Define this if you have the makedev macro. */ +#define HAVE_MAKEDEV 1 + +/* Define to 1 if you have the `mbrtowc' function. */ +#define HAVE_MBRTOWC 1 + +/* Define to 1 if you have the `memmove' function. */ +#define HAVE_MEMMOVE 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `memrchr' function. */ +#define HAVE_MEMRCHR 1 + +/* Define to 1 if you have the `mkdirat' function. */ +#define HAVE_MKDIRAT 1 + +/* Define to 1 if you have the `mkfifo' function. */ +/* #undef HAVE_MKFIFO */ + +/* Define to 1 if you have the `mkfifoat' function. */ +/* #undef HAVE_MKFIFOAT */ + +/* Define to 1 if you have the `mknod' function. */ +#define HAVE_MKNOD 1 + +/* Define to 1 if you have the `mknodat' function. */ +/* #undef HAVE_MKNODAT */ + +/* Define to 1 if you have the `mktime' function. */ +#define HAVE_MKTIME 1 + +/* Define to 1 if you have the `mmap' function. */ +#define HAVE_MMAP 1 + +/* Define to 1 if you have the `mremap' function. */ +#define HAVE_MREMAP 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NCURSES_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. */ +/* #undef HAVE_NDIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_NETPACKET_PACKET_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_NET_IF_H 1 + +/* Define to 1 if you have the `nice' function. */ +#define HAVE_NICE 1 + +/* Define to 1 if you have the `openat' function. */ +#define HAVE_OPENAT 1 + +/* Define to 1 if you have the `openpty' function. */ +/* #undef HAVE_OPENPTY */ + +/* Define if compiling using MacOS X 10.5 SDK or later. */ +/* #undef HAVE_OSX105_SDK */ + +/* Define to 1 if you have the `pathconf' function. */ +#define HAVE_PATHCONF 1 + +/* Define to 1 if you have the `pause' function. */ +#define HAVE_PAUSE 1 + +/* Define to 1 if you have the `pipe2' function. */ +#define HAVE_PIPE2 1 + +/* Define to 1 if you have the `plock' function. */ +/* #undef HAVE_PLOCK */ + +/* Define to 1 if you have the `poll' function. */ +#define HAVE_POLL 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_POLL_H 1 + +/* Define to 1 if you have the `posix_fadvise' function. */ +#define HAVE_POSIX_FADVISE 1 + +/* Define to 1 if you have the `posix_fallocate' function. */ +#define HAVE_POSIX_FALLOCATE 1 + +/* Define to 1 if you have the `pread' function. */ +#define HAVE_PREAD 1 + +/* Define if you have the 'prlimit' functions. */ +/* #undef HAVE_PRLIMIT */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PROCESS_H */ + +/* Define if your compiler supports function prototype */ +#define HAVE_PROTOTYPES 1 + +/* Define to 1 if you have the `pthread_atfork' function. */ +/* #undef HAVE_PTHREAD_ATFORK */ + +/* Defined for Solaris 2.6 bug in pthread header. */ +/* #undef HAVE_PTHREAD_DESTRUCTOR */ + +/* Define to 1 if you have the header file. */ +#define HAVE_PTHREAD_H 1 + +/* Define to 1 if you have the `pthread_init' function. */ +/* #undef HAVE_PTHREAD_INIT */ + +/* Define to 1 if you have the `pthread_kill' function. */ +#define HAVE_PTHREAD_KILL 1 + +/* Define to 1 if you have the `pthread_sigmask' function. */ +#define HAVE_PTHREAD_SIGMASK 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PTY_H */ + +/* Define to 1 if you have the `putenv' function. */ +#define HAVE_PUTENV 1 + +/* Define to 1 if you have the `pwrite' function. */ +#define HAVE_PWRITE 1 + +/* Define if the libcrypto has RAND_egd */ +/* #undef HAVE_RAND_EGD */ + +/* Define to 1 if you have the `readlink' function. */ +#define HAVE_READLINK 1 + +/* Define to 1 if you have the `readlinkat' function. */ +/* #undef HAVE_READLINKAT */ + +/* Define to 1 if you have the `readv' function. */ +#define HAVE_READV 1 + +/* Define to 1 if you have the `realpath' function. */ +#define HAVE_REALPATH 1 + +/* Define to 1 if you have the `renameat' function. */ +#define HAVE_RENAMEAT 1 + +/* Define if readline supports append_history */ +/* #undef HAVE_RL_APPEND_HISTORY */ + +/* Define if you have readline 2.1 */ +/* #undef HAVE_RL_CALLBACK */ + +/* Define if you can turn off readline's signal handling. */ +/* #undef HAVE_RL_CATCH_SIGNAL */ + +/* Define if you have readline 2.2 */ +/* #undef HAVE_RL_COMPLETION_APPEND_CHARACTER */ + +/* Define if you have readline 4.0 */ +/* #undef HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK */ + +/* Define if you have readline 4.2 */ +/* #undef HAVE_RL_COMPLETION_MATCHES */ + +/* Define if you have rl_completion_suppress_append */ +/* #undef HAVE_RL_COMPLETION_SUPPRESS_APPEND */ + +/* Define if you have readline 4.0 */ +/* #undef HAVE_RL_PRE_INPUT_HOOK */ + +/* Define to 1 if you have the `round' function. */ +#define HAVE_ROUND 1 + +/* Define to 1 if you have the `sched_get_priority_max' function. */ +#define HAVE_SCHED_GET_PRIORITY_MAX 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SCHED_H 1 + +/* Define to 1 if you have the `sched_rr_get_interval' function. */ +#define HAVE_SCHED_RR_GET_INTERVAL 1 + +/* Define to 1 if you have the `sched_setaffinity' function. */ +#define HAVE_SCHED_SETAFFINITY 1 + +/* Define to 1 if you have the `sched_setparam' function. */ +#define HAVE_SCHED_SETPARAM 1 + +/* Define to 1 if you have the `sched_setscheduler' function. */ +#define HAVE_SCHED_SETSCHEDULER 1 + +/* Define to 1 if you have the `select' function. */ +#define HAVE_SELECT 1 + +/* Define to 1 if you have the `sem_getvalue' function. */ +#define HAVE_SEM_GETVALUE 1 + +/* Define to 1 if you have the `sem_open' function. */ +#define HAVE_SEM_OPEN 1 + +/* Define to 1 if you have the `sem_timedwait' function. */ +#define HAVE_SEM_TIMEDWAIT 1 + +/* Define to 1 if you have the `sem_unlink' function. */ +#define HAVE_SEM_UNLINK 1 + +/* Define to 1 if you have the `sendfile' function. */ +#define HAVE_SENDFILE 1 + +/* Define to 1 if you have the `setegid' function. */ +#define HAVE_SETEGID 1 + +/* Define to 1 if you have the `seteuid' function. */ +#define HAVE_SETEUID 1 + +/* Define to 1 if you have the `setgid' function. */ +#define HAVE_SETGID 1 + +/* Define if you have the 'setgroups' function. */ +#define HAVE_SETGROUPS 1 + +/* Define to 1 if you have the `sethostname' function. */ +/* #undef HAVE_SETHOSTNAME */ + +/* Define to 1 if you have the `setitimer' function. */ +#define HAVE_SETITIMER 1 + +/* Define to 1 if you have the `setlocale' function. */ +#define HAVE_SETLOCALE 1 + +/* Define to 1 if you have the `setpgid' function. */ +#define HAVE_SETPGID 1 + +/* Define to 1 if you have the `setpgrp' function. */ +#define HAVE_SETPGRP 1 + +/* Define to 1 if you have the `setpriority' function. */ +#define HAVE_SETPRIORITY 1 + +/* Define to 1 if you have the `setregid' function. */ +#define HAVE_SETREGID 1 + +/* Define to 1 if you have the `setresgid' function. */ +#define HAVE_SETRESGID 1 + +/* Define to 1 if you have the `setresuid' function. */ +#define HAVE_SETRESUID 1 + +/* Define to 1 if you have the `setreuid' function. */ +#define HAVE_SETREUID 1 + +/* Define to 1 if you have the `setsid' function. */ +#define HAVE_SETSID 1 + +/* Define to 1 if you have the `setuid' function. */ +#define HAVE_SETUID 1 + +/* Define to 1 if you have the `setvbuf' function. */ +#define HAVE_SETVBUF 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SHADOW_H */ + +/* Define to 1 if you have the `sigaction' function. */ +#define HAVE_SIGACTION 1 + +/* Define to 1 if you have the `sigaltstack' function. */ +#define HAVE_SIGALTSTACK 1 + +/* Define to 1 if you have the `siginterrupt' function. */ +#define HAVE_SIGINTERRUPT 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SIGNAL_H 1 + +/* Define to 1 if you have the `sigpending' function. */ +#define HAVE_SIGPENDING 1 + +/* Define to 1 if you have the `sigrelse' function. */ +/* #undef HAVE_SIGRELSE */ + +/* Define to 1 if you have the `sigtimedwait' function. */ +/* #undef HAVE_SIGTIMEDWAIT */ + +/* Define to 1 if you have the `sigwait' function. */ +#define HAVE_SIGWAIT 1 + +/* Define to 1 if you have the `sigwaitinfo' function. */ +/* #undef HAVE_SIGWAITINFO */ + +/* Define to 1 if you have the `snprintf' function. */ +#define HAVE_SNPRINTF 1 + +/* Define if sockaddr has sa_len member */ +/* #undef HAVE_SOCKADDR_SA_LEN */ + +/* struct sockaddr_storage (sys/socket.h) */ +#define HAVE_SOCKADDR_STORAGE 1 + +/* Define if you have the 'socketpair' function. */ +#define HAVE_SOCKETPAIR 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SPAWN_H */ + +/* Define if your compiler provides ssize_t */ +#define HAVE_SSIZE_T 1 + +/* Define to 1 if you have the `statvfs' function. */ +/* #undef HAVE_STATVFS */ + +/* Define if you have struct stat.st_mtim.tv_nsec */ +/* #undef HAVE_STAT_TV_NSEC */ + +/* Define if you have struct stat.st_mtimensec */ +/* #undef HAVE_STAT_TV_NSEC2 */ + +/* Define if your compiler supports variable length function prototypes (e.g. + void fprintf(FILE *, char *, ...);) *and* */ +#define HAVE_STDARG_PROTOTYPES 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Has stdatomic.h, atomic_int and _Atomic void* types work */ +#define HAVE_STD_ATOMIC 1 + +/* Define to 1 if you have the `strdup' function. */ +#define HAVE_STRDUP 1 + +/* Define to 1 if you have the `strftime' function. */ +#define HAVE_STRFTIME 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the `strlcpy' function. */ +#define HAVE_STRLCPY 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_STROPTS_H */ + +/* Define to 1 if `st_birthtime' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_BIRTHTIME */ + +/* Define to 1 if `st_blksize' is a member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_BLKSIZE 1 + +/* Define to 1 if `st_blocks' is a member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_BLOCKS 1 + +/* Define to 1 if `st_flags' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_FLAGS */ + +/* Define to 1 if `st_gen' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_GEN */ + +/* Define to 1 if `st_rdev' is a member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_RDEV 1 + +/* Define to 1 if `tm_zone' is a member of `struct tm'. */ +#define HAVE_STRUCT_TM_TM_ZONE 1 + +/* Define to 1 if your `struct stat' has `st_blocks'. Deprecated, use + `HAVE_STRUCT_STAT_ST_BLOCKS' instead. */ +#define HAVE_ST_BLOCKS 1 + +/* Define if you have the 'symlink' function. */ +#define HAVE_SYMLINK 1 + +/* Define to 1 if you have the `symlinkat' function. */ +/* #undef HAVE_SYMLINKAT */ + +/* Define to 1 if you have the `sync' function. */ +#define HAVE_SYNC 1 + +/* Define to 1 if you have the `sysconf' function. */ +#define HAVE_SYSCONF 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYSEXITS_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_AUDIOIO_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_BSDTTY_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_DEVPOLL_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +/* #undef HAVE_SYS_DIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_ENDIAN_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_EPOLL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_EVENT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_FILE_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_IOCTL_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_KERN_CONTROL_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_LOADAVG_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_LOCK_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_MKDEV_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_MODEM_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +/* #undef HAVE_SYS_NDIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_PARAM_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_POLL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_RESOURCE_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SELECT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SENDFILE_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SOCKET_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_STATVFS_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SYSCALL_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_SYS_DOMAIN_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_TERMIO_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIMES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UIO_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UN_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UTSNAME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_WAIT_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_XATTR_H */ + +/* Define to 1 if you have the `tcgetpgrp' function. */ +#define HAVE_TCGETPGRP 1 + +/* Define to 1 if you have the `tcsetpgrp' function. */ +#define HAVE_TCSETPGRP 1 + +/* Define to 1 if you have the `tempnam' function. */ +#define HAVE_TEMPNAM 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_TERMIOS_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_TERM_H */ + +/* Define to 1 if you have the `tgamma' function. */ +#define HAVE_TGAMMA 1 + +/* Define to 1 if you have the `timegm' function. */ +/* #undef HAVE_TIMEGM */ + +/* Define to 1 if you have the `times' function. */ +#define HAVE_TIMES 1 + +/* Define to 1 if you have the `tmpfile' function. */ +#define HAVE_TMPFILE 1 + +/* Define to 1 if you have the `tmpnam' function. */ +#define HAVE_TMPNAM 1 + +/* Define to 1 if you have the `tmpnam_r' function. */ +/* #undef HAVE_TMPNAM_R */ + +/* Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use + `HAVE_STRUCT_TM_TM_ZONE' instead. */ +#define HAVE_TM_ZONE 1 + +/* Define to 1 if you have the `truncate' function. */ +#define HAVE_TRUNCATE 1 + +/* Define to 1 if you don't have `tm_zone' but do have the external array + `tzname'. */ +/* #undef HAVE_TZNAME */ + +/* Define this if you have tcl and TCL_UTF_MAX==6 */ +/* #undef HAVE_UCS4_TCL */ + +/* Define if your compiler provides uint32_t. */ +#define HAVE_UINT32_T 1 + +/* Define if your compiler provides uint64_t. */ +#define HAVE_UINT64_T 1 + +/* Define to 1 if the system has the type `uintptr_t'. */ +#define HAVE_UINTPTR_T 1 + +/* Define to 1 if you have the `uname' function. */ +#define HAVE_UNAME 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you have the `unlinkat' function. */ +#define HAVE_UNLINKAT 1 + +/* Define to 1 if you have the `unsetenv' function. */ +#define HAVE_UNSETENV 1 + +/* Define if you have a useable wchar_t type defined in wchar.h; useable means + wchar_t must be an unsigned type with at least 16 bits. (see + Include/unicodeobject.h). */ +/* #undef HAVE_USABLE_WCHAR_T */ + +/* Define to 1 if you have the header file. */ +#define HAVE_UTIL_H 1 + +/* Define to 1 if you have the `utimensat' function. */ +/* #undef HAVE_UTIMENSAT */ + +/* Define to 1 if you have the `utimes' function. */ +#define HAVE_UTIMES 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UTIME_H 1 + +/* Define to 1 if you have the `wait3' function. */ +#define HAVE_WAIT3 1 + +/* Define to 1 if you have the `wait4' function. */ +/* #undef HAVE_WAIT4 */ + +/* Define to 1 if you have the `waitid' function. */ +#define HAVE_WAITID 1 + +/* Define to 1 if you have the `waitpid' function. */ +#define HAVE_WAITPID 1 + +/* Define if the compiler provides a wchar.h header file. */ +#define HAVE_WCHAR_H 1 + +/* Define to 1 if you have the `wcscoll' function. */ +#define HAVE_WCSCOLL 1 + +/* Define to 1 if you have the `wcsftime' function. */ +#define HAVE_WCSFTIME 1 + +/* Define to 1 if you have the `wcsxfrm' function. */ +#define HAVE_WCSXFRM 1 + +/* Define to 1 if you have the `wmemcmp' function. */ +#define HAVE_WMEMCMP 1 + +/* Define if tzset() actually switches the local timezone in a meaningful way. + */ +/* #undef HAVE_WORKING_TZSET */ + +/* Define to 1 if you have the `writev' function. */ +#define HAVE_WRITEV 1 + +/* Define if the zlib library has inflateCopy */ +#define HAVE_ZLIB_COPY 1 + +/* Define to 1 if you have the `_getpty' function. */ +/* #undef HAVE__GETPTY */ + +/* Define if log1p(-0.) is 0. rather than -0. */ +/* #undef LOG1P_DROPS_ZERO_SIGN */ + +/* Define to 1 if `major', `minor', and `makedev' are declared in . + */ +/* #undef MAJOR_IN_MKDEV */ + +/* Define to 1 if `major', `minor', and `makedev' are declared in + . */ +#define MAJOR_IN_SYSMACROS 1 + +/* Define if mvwdelch in curses.h is an expression. */ +/* #undef MVWDELCH_IS_EXPRESSION */ + +/* Define to the address where bug reports for this package should be sent. */ +/* #undef PACKAGE_BUGREPORT */ + +/* Define to the full name of this package. */ +/* #undef PACKAGE_NAME */ + +/* Define to the full name and version of this package. */ +/* #undef PACKAGE_STRING */ + +/* Define to the one symbol short name of this package. */ +/* #undef PACKAGE_TARNAME */ + +/* Define to the home page for this package. */ +/* #undef PACKAGE_URL */ + +/* Define to the version of this package. */ +/* #undef PACKAGE_VERSION */ + +/* Define if POSIX semaphores aren't enabled on your system */ +/* #undef POSIX_SEMAPHORES_NOT_ENABLED */ + +/* Defined if PTHREAD_SCOPE_SYSTEM supported. */ +/* #undef PTHREAD_SYSTEM_SCHED_SUPPORTED */ + +/* Define as the preferred size in bits of long digits */ +/* #undef PYLONG_BITS_IN_DIGIT */ + +/* Define to printf format modifier for long long type */ +#define PY_FORMAT_LONG_LONG "ll" + +/* Define to printf format modifier for Py_ssize_t */ +#define PY_FORMAT_SIZE_T "z" + +/* Define if you want to build an interpreter with many run-time checks. */ +/* #undef Py_DEBUG */ + +/* Defined if Python is built as a shared library. */ +#define Py_ENABLE_SHARED 1 + +/* Define hash algorithm for str, bytes and memoryview. SipHash24: 1, FNV: 2, + externally defined: 0 */ +/* #undef Py_HASH_ALGORITHM */ + +/* assume C89 semantics that RETSIGTYPE is always void */ +#define RETSIGTYPE void + +/* Define if setpgrp() must be called as setpgrp(0, 0). */ +/* #undef SETPGRP_HAVE_ARG */ + +/* Define if i>>j for signed int i does not extend the sign bit when i < 0 */ +/* #undef SIGNED_RIGHT_SHIFT_ZERO_FILLS */ + +/* The size of `double', as computed by sizeof. */ +#define SIZEOF_DOUBLE 8 + +/* The size of `float', as computed by sizeof. */ +#define SIZEOF_FLOAT 4 + +/* The size of `fpos_t', as computed by sizeof. */ +#define SIZEOF_FPOS_T 4 + +/* The size of `int', as computed by sizeof. */ +#define SIZEOF_INT 4 + +/* The size of `long', as computed by sizeof. */ +#define SIZEOF_LONG 4 + +/* The size of `long double', as computed by sizeof. */ +#define SIZEOF_LONG_DOUBLE 8 + +/* The size of `long long', as computed by sizeof. */ +#define SIZEOF_LONG_LONG 8 + +/* The size of `off_t', as computed by sizeof. */ +#define SIZEOF_OFF_T 4 + +/* The size of `pid_t', as computed by sizeof. */ +#define SIZEOF_PID_T 4 + +/* The size of `pthread_t', as computed by sizeof. */ +#define SIZEOF_PTHREAD_T 4 + +/* The size of `short', as computed by sizeof. */ +#define SIZEOF_SHORT 2 + +/* The size of `size_t', as computed by sizeof. */ +#define SIZEOF_SIZE_T 4 + +/* The size of `time_t', as computed by sizeof. */ +#define SIZEOF_TIME_T 4 + +/* The size of `uintptr_t', as computed by sizeof. */ +#define SIZEOF_UINTPTR_T 4 + +/* The size of `void *', as computed by sizeof. */ +#define SIZEOF_VOID_P 4 + +/* The size of `wchar_t', as computed by sizeof. */ +#define SIZEOF_WCHAR_T 4 + +/* The size of `_Bool', as computed by sizeof. */ +#define SIZEOF__BOOL 1 + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define if you can safely include both and + (which you can't on SCO ODT 3.0). */ +#define SYS_SELECT_WITH_SYS_TIME 1 + +/* Define if tanh(-0.) is -0., or if platform doesn't have signed zeros */ +/* #undef TANH_PRESERVES_ZERO_SIGN */ + +/* Library needed by timemodule.c: librt may be needed for clock_gettime() */ +/* #undef TIMEMODULE_LIB */ + +/* Define to 1 if you can safely include both and . */ +#define TIME_WITH_SYS_TIME 1 + +/* Define to 1 if your declares `struct tm'. */ +/* #undef TM_IN_SYS_TIME */ + +/* Define if you want to use computed gotos in ceval.c. */ +#define USE_COMPUTED_GOTOS 1 + +/* Define to use the C99 inline keyword. */ +#define USE_INLINE 1 + +/* Enable extensions on AIX 3, Interix. */ +#ifndef _ALL_SOURCE +# define _ALL_SOURCE 1 +#endif +/* Enable GNU extensions on systems that have them. */ +#ifndef _GNU_SOURCE +# define _GNU_SOURCE 1 +#endif +/* Enable threading extensions on Solaris. */ +#ifndef _POSIX_PTHREAD_SEMANTICS +# define _POSIX_PTHREAD_SEMANTICS 1 +#endif +/* Enable extensions on HP NonStop. */ +#ifndef _TANDEM_SOURCE +# define _TANDEM_SOURCE 1 +#endif +/* Enable general extensions on Solaris. */ +#ifndef __EXTENSIONS__ +# define __EXTENSIONS__ 1 +#endif + + +/* Define if a va_list is an array of some kind */ +/* #undef VA_LIST_IS_ARRAY */ + +/* Define if you want SIGFPE handled (see Include/pyfpe.h). */ +/* #undef WANT_SIGFPE_HANDLER */ + +/* Define if WINDOW in curses.h offers a field _flags. */ +/* #undef WINDOW_HAS_FLAGS */ + +/* Define if you want documentation strings in extension modules */ +#define WITH_DOC_STRINGS 1 + +/* Define if you want to use the new-style (Openstep, Rhapsody, MacOS) dynamic + linker (dyld) instead of the old-style (NextStep) dynamic linker (rld). + Dyld is necessary to support frameworks. */ +/* #undef WITH_DYLD */ + +/* Define to 1 if libintl is needed for locale functions. */ +/* #undef WITH_LIBINTL */ + +/* Define if you want to produce an OpenStep/Rhapsody framework (shared + library plus accessory files). */ +/* #undef WITH_NEXT_FRAMEWORK */ + +/* Define if you want to compile in Python-specific mallocs */ +#define WITH_PYMALLOC 1 + +/* Define if you want to compile in rudimentary thread support */ +#define WITH_THREAD 1 + +/* Define to profile with the Pentium timestamp counter */ +/* #undef WITH_TSC */ + +/* Define if you want pymalloc to be disabled when running under valgrind */ +/* #undef WITH_VALGRIND */ + +/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most + significant byte first (like Motorola and SPARC, unlike Intel). */ +#if defined AC_APPLE_UNIVERSAL_BUILD +# if defined __BIG_ENDIAN__ +# define WORDS_BIGENDIAN 1 +# endif +#else +# ifndef WORDS_BIGENDIAN +/* # undef WORDS_BIGENDIAN */ +# endif +#endif + +/* Define if arithmetic is subject to x87-style double rounding issue */ +/* #undef X87_DOUBLE_ROUNDING */ + +/* Define on OpenBSD to activate all library features */ +/* #undef _BSD_SOURCE */ + +/* Define on Irix to enable u_int */ +#define _BSD_TYPES 1 + +/* Define on Darwin to activate all library features */ +#define _DARWIN_C_SOURCE 1 + +/* This must be set to 64 on some systems to enable large file support. */ +#define _FILE_OFFSET_BITS 64 + +/* Define on Linux to activate all library features */ +#define _GNU_SOURCE 1 + +/* Define to include mbstate_t for mbrtowc */ +/* #undef _INCLUDE__STDC_A1_SOURCE */ + +/* This must be defined on some systems to enable large file support. */ +#define _LARGEFILE_SOURCE 1 + +/* This must be defined on AIX systems to enable large file support. */ +/* #undef _LARGE_FILES */ + +/* Define to 1 if on MINIX. */ +/* #undef _MINIX */ + +/* Define on NetBSD to activate all library features */ +#define _NETBSD_SOURCE 1 + +/* Define to 2 if the system does not provide POSIX.1 features except with + this defined. */ +/* #undef _POSIX_1_SOURCE */ + +/* Define to activate features from IEEE Stds 1003.1-2008 */ +#define _POSIX_C_SOURCE 200809L + +/* Define to 1 if you need to in order for `stat' and other things to work. */ +/* #undef _POSIX_SOURCE */ + +/* Define if you have POSIX threads, and your system does not define that. */ +/* #undef _POSIX_THREADS */ + +/* Define to force use of thread-safe errno, h_errno, and other functions */ +#define _REENTRANT 1 + +/* Define for Solaris 2.5.1 so the uint32_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +/* #undef _UINT32_T */ + +/* Define for Solaris 2.5.1 so the uint64_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +/* #undef _UINT64_T */ + +/* Define to the level of X/Open that your system supports */ +#define _XOPEN_SOURCE 700 + +/* Define to activate Unix95-and-earlier features */ +#define _XOPEN_SOURCE_EXTENDED 1 + +/* Define on FreeBSD to activate all library features */ +#define __BSD_VISIBLE 1 + +/* Define to 1 if type `char' is unsigned and you are not using gcc. */ +#ifndef __CHAR_UNSIGNED__ +/* # undef __CHAR_UNSIGNED__ */ +#endif + +/* Define to 'long' if doesn't define. */ +/* #undef clock_t */ + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ + +/* Define to `int' if doesn't define. */ +/* #undef gid_t */ + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +/* #undef inline */ +#endif + +/* Define to the type of a signed integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +/* #undef int32_t */ + +/* Define to the type of a signed integer type of width exactly 64 bits if + such a type exists and the standard includes do not define it. */ +/* #undef int64_t */ + +/* Define to `int' if does not define. */ +/* #undef mode_t */ + +/* Define to `long int' if does not define. */ +/* #undef off_t */ + +/* Define to `int' if does not define. */ +/* #undef pid_t */ + +/* Define to empty if the keyword does not work. */ +/* #undef signed */ + +/* Define to `unsigned int' if does not define. */ +/* #undef size_t */ + +/* Define to `int' if does not define. */ +/* #undef socklen_t */ + +/* Define to `int' if doesn't define. */ +/* #undef uid_t */ + +/* Define to the type of an unsigned integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint32_t */ + +/* Define to the type of an unsigned integer type of width exactly 64 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint64_t */ + +/* Define to empty if the keyword does not work. */ +/* #undef volatile */ + + +/* Define the macros needed if on a UnixWare 7.x system. */ +#if defined(__USLC__) && defined(__SCO_VERSION__) +#define STRICT_SYSV_CURSES /* Don't use ncurses extensions */ +#endif + +#endif /*Py_PYCONFIG_H*/ + diff --git a/android/python35/include/pyconfig_armeabi_v7a.h b/android/python35/include/pyconfig_armeabi_v7a.h new file mode 100644 index 000000000..ac47e6204 --- /dev/null +++ b/android/python35/include/pyconfig_armeabi_v7a.h @@ -0,0 +1,1530 @@ +/* pyconfig.h. Generated from pyconfig.h.in by configure. */ +/* pyconfig.h.in. Generated from configure.ac by autoheader. */ + + +#ifndef Py_PYCONFIG_H +#define Py_PYCONFIG_H + + +/* Define if building universal (internal helper macro) */ +/* #undef AC_APPLE_UNIVERSAL_BUILD */ + +/* Define for AIX if your compiler is a genuine IBM xlC/xlC_r and you want + support for AIX C++ shared extension modules. */ +/* #undef AIX_GENUINE_CPLUSPLUS */ + +/* Define if C doubles are 64-bit IEEE 754 binary format, stored in ARM + mixed-endian order (byte order 45670123) */ +/* #undef DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754 */ + +/* Define if C doubles are 64-bit IEEE 754 binary format, stored with the most + significant byte first */ +/* #undef DOUBLE_IS_BIG_ENDIAN_IEEE754 */ + +/* Define if C doubles are 64-bit IEEE 754 binary format, stored with the + least significant byte first */ +/* #undef DOUBLE_IS_LITTLE_ENDIAN_IEEE754 */ + +/* Define if --enable-ipv6 is specified */ +#define ENABLE_IPV6 1 + +/* Define if flock needs to be linked with bsd library. */ +/* #undef FLOCK_NEEDS_LIBBSD */ + +/* Define if getpgrp() must be called as getpgrp(0). */ +/* #undef GETPGRP_HAVE_ARG */ + +/* Define if gettimeofday() does not have second (timezone) argument This is + the case on Motorola V4 (R40V4.2) */ +/* #undef GETTIMEOFDAY_NO_TZ */ + +/* Define to 1 if you have the `accept4' function. */ +/* #undef HAVE_ACCEPT4 */ + +/* Define to 1 if you have the `acosh' function. */ +#define HAVE_ACOSH 1 + +/* struct addrinfo (netdb.h) */ +#define HAVE_ADDRINFO 1 + +/* Define to 1 if you have the `alarm' function. */ +#define HAVE_ALARM 1 + +/* Define if aligned memory access is required */ +#define HAVE_ALIGNED_REQUIRED 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ALLOCA_H 1 + +/* Define this if your time.h defines altzone. */ +/* #undef HAVE_ALTZONE */ + +/* Define to 1 if you have the `asinh' function. */ +#define HAVE_ASINH 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ASM_TYPES_H 1 + +/* Define to 1 if you have the `atanh' function. */ +#define HAVE_ATANH 1 + +/* Define to 1 if you have the `bind_textdomain_codeset' function. */ +/* #undef HAVE_BIND_TEXTDOMAIN_CODESET */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_BLUETOOTH_BLUETOOTH_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_BLUETOOTH_H */ + +/* Define if mbstowcs(NULL, "text", 0) does not return the number of wide + chars that would be converted. */ +/* #undef HAVE_BROKEN_MBSTOWCS */ + +/* Define if nice() returns success/failure instead of the new priority. */ +/* #undef HAVE_BROKEN_NICE */ + +/* Define if the system reports an invalid PIPE_BUF value. */ +/* #undef HAVE_BROKEN_PIPE_BUF */ + +/* Define if poll() sets errno on invalid file descriptors. */ +/* #undef HAVE_BROKEN_POLL */ + +/* Define if the Posix semaphores do not work on your system */ +/* #undef HAVE_BROKEN_POSIX_SEMAPHORES */ + +/* Define if pthread_sigmask() does not work on your system. */ +/* #undef HAVE_BROKEN_PTHREAD_SIGMASK */ + +/* define to 1 if your sem_getvalue is broken. */ +#define HAVE_BROKEN_SEM_GETVALUE 1 + +/* Define if `unsetenv` does not return an int. */ +/* #undef HAVE_BROKEN_UNSETENV */ + +/* Has builtin atomics */ +#define HAVE_BUILTIN_ATOMIC 1 + +/* Define this if you have the type _Bool. */ +#define HAVE_C99_BOOL 1 + +/* Define to 1 if you have the 'chflags' function. */ +/* #undef HAVE_CHFLAGS */ + +/* Define to 1 if you have the `chown' function. */ +#define HAVE_CHOWN 1 + +/* Define if you have the 'chroot' function. */ +#define HAVE_CHROOT 1 + +/* Define to 1 if you have the `clock' function. */ +#define HAVE_CLOCK 1 + +/* Define to 1 if you have the `clock_getres' function. */ +#define HAVE_CLOCK_GETRES 1 + +/* Define to 1 if you have the `clock_gettime' function. */ +#define HAVE_CLOCK_GETTIME 1 + +/* Define if the C compiler supports computed gotos. */ +#define HAVE_COMPUTED_GOTOS 1 + +/* Define to 1 if you have the `confstr' function. */ +/* #undef HAVE_CONFSTR */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_CONIO_H */ + +/* Define to 1 if you have the `copysign' function. */ +#define HAVE_COPYSIGN 1 + +/* Define to 1 if you have the `ctermid' function. */ +/* #undef HAVE_CTERMID */ + +/* Define if you have the 'ctermid_r' function. */ +#define HAVE_CTERMID_R 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_CURSES_H */ + +/* Define if you have the 'is_term_resized' function. */ +/* #undef HAVE_CURSES_IS_TERM_RESIZED */ + +/* Define if you have the 'resizeterm' function. */ +/* #undef HAVE_CURSES_RESIZETERM */ + +/* Define if you have the 'resize_term' function. */ +/* #undef HAVE_CURSES_RESIZE_TERM */ + +/* Define to 1 if you have the declaration of `isfinite', and to 0 if you + don't. */ +#define HAVE_DECL_ISFINITE 1 + +/* Define to 1 if you have the declaration of `isinf', and to 0 if you don't. + */ +#define HAVE_DECL_ISINF 1 + +/* Define to 1 if you have the declaration of `isnan', and to 0 if you don't. + */ +#define HAVE_DECL_ISNAN 1 + +/* Define to 1 if you have the declaration of `tzname', and to 0 if you don't. + */ +/* #undef HAVE_DECL_TZNAME */ + +/* Define to 1 if you have the device macros. */ +#define HAVE_DEVICE_MACROS 1 + +/* Define to 1 if you have the /dev/ptc device file. */ +/* #undef HAVE_DEV_PTC */ + +/* Define to 1 if you have the /dev/ptmx device file. */ +/* #undef HAVE_DEV_PTMX */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_DIRECT_H */ + +/* Define to 1 if the dirent structure has a d_type field */ +#define HAVE_DIRENT_D_TYPE 1 + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#define HAVE_DIRENT_H 1 + +/* Define if you have the 'dirfd' function or macro. */ +#define HAVE_DIRFD 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_DLFCN_H 1 + +/* Define to 1 if you have the `dlopen' function. */ +#define HAVE_DLOPEN 1 + +/* Define to 1 if you have the `dup2' function. */ +#define HAVE_DUP2 1 + +/* Define to 1 if you have the `dup3' function. */ +/* #undef HAVE_DUP3 */ + +/* Defined when any dynamic module loading is enabled. */ +#define HAVE_DYNAMIC_LOADING 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ENDIAN_H 1 + +/* Define if you have the 'epoll' functions. */ +#define HAVE_EPOLL 1 + +/* Define if you have the 'epoll_create1' function. */ +/* #undef HAVE_EPOLL_CREATE1 */ + +/* Define to 1 if you have the `erf' function. */ +#define HAVE_ERF 1 + +/* Define to 1 if you have the `erfc' function. */ +#define HAVE_ERFC 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ERRNO_H 1 + +/* Define to 1 if you have the `execv' function. */ +#define HAVE_EXECV 1 + +/* Define to 1 if you have the `expm1' function. */ +#define HAVE_EXPM1 1 + +/* Define to 1 if you have the `faccessat' function. */ +/* #undef HAVE_FACCESSAT */ + +/* Define if you have the 'fchdir' function. */ +#define HAVE_FCHDIR 1 + +/* Define to 1 if you have the `fchmod' function. */ +#define HAVE_FCHMOD 1 + +/* Define to 1 if you have the `fchmodat' function. */ +#define HAVE_FCHMODAT 1 + +/* Define to 1 if you have the `fchown' function. */ +#define HAVE_FCHOWN 1 + +/* Define to 1 if you have the `fchownat' function. */ +#define HAVE_FCHOWNAT 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* Define if you have the 'fdatasync' function. */ +#define HAVE_FDATASYNC 1 + +/* Define to 1 if you have the `fdopendir' function. */ +#define HAVE_FDOPENDIR 1 + +/* Define to 1 if you have the `fexecve' function. */ +/* #undef HAVE_FEXECVE */ + +/* Define to 1 if you have the `finite' function. */ +#define HAVE_FINITE 1 + +/* Define to 1 if you have the `flock' function. */ +#define HAVE_FLOCK 1 + +/* Define to 1 if you have the `fork' function. */ +#define HAVE_FORK 1 + +/* Define to 1 if you have the `forkpty' function. */ +/* #undef HAVE_FORKPTY */ + +/* Define to 1 if you have the `fpathconf' function. */ +#define HAVE_FPATHCONF 1 + +/* Define to 1 if you have the `fseek64' function. */ +/* #undef HAVE_FSEEK64 */ + +/* Define to 1 if you have the `fseeko' function. */ +#define HAVE_FSEEKO 1 + +/* Define to 1 if you have the `fstatat' function. */ +#define HAVE_FSTATAT 1 + +/* Define to 1 if you have the `fstatvfs' function. */ +/* #undef HAVE_FSTATVFS */ + +/* Define if you have the 'fsync' function. */ +#define HAVE_FSYNC 1 + +/* Define to 1 if you have the `ftell64' function. */ +/* #undef HAVE_FTELL64 */ + +/* Define to 1 if you have the `ftello' function. */ +#define HAVE_FTELLO 1 + +/* Define to 1 if you have the `ftime' function. */ +#define HAVE_FTIME 1 + +/* Define to 1 if you have the `ftruncate' function. */ +#define HAVE_FTRUNCATE 1 + +/* Define to 1 if you have the `futimens' function. */ +/* #undef HAVE_FUTIMENS */ + +/* Define to 1 if you have the `futimes' function. */ +/* #undef HAVE_FUTIMES */ + +/* Define to 1 if you have the `futimesat' function. */ +/* #undef HAVE_FUTIMESAT */ + +/* Define to 1 if you have the `gai_strerror' function. */ +#define HAVE_GAI_STRERROR 1 + +/* Define to 1 if you have the `gamma' function. */ +/* #undef HAVE_GAMMA */ + +/* Define if we can use gcc inline assembler to get and set mc68881 fpcr */ +/* #undef HAVE_GCC_ASM_FOR_MC68881 */ + +/* Define if we can use x64 gcc inline assembler */ +/* #undef HAVE_GCC_ASM_FOR_X64 */ + +/* Define if we can use gcc inline assembler to get and set x87 control word + */ +/* #undef HAVE_GCC_ASM_FOR_X87 */ + +/* Define if your compiler provides __uint128_t */ +/* #undef HAVE_GCC_UINT128_T */ + +/* Define if you have the getaddrinfo function. */ +#define HAVE_GETADDRINFO 1 + +/* Define this if you have flockfile(), getc_unlocked(), and funlockfile() */ +#define HAVE_GETC_UNLOCKED 1 + +/* Define to 1 if you have the `getentropy' function. */ +/* #undef HAVE_GETENTROPY */ + +/* Define to 1 if you have the `getgrouplist' function. */ +#define HAVE_GETGROUPLIST 1 + +/* Define to 1 if you have the `getgroups' function. */ +#define HAVE_GETGROUPS 1 + +/* Define to 1 if you have the `gethostbyname' function. */ +#define HAVE_GETHOSTBYNAME 1 + +/* Define this if you have some version of gethostbyname_r() */ +/* #undef HAVE_GETHOSTBYNAME_R */ + +/* Define this if you have the 3-arg version of gethostbyname_r(). */ +/* #undef HAVE_GETHOSTBYNAME_R_3_ARG */ + +/* Define this if you have the 5-arg version of gethostbyname_r(). */ +/* #undef HAVE_GETHOSTBYNAME_R_5_ARG */ + +/* Define this if you have the 6-arg version of gethostbyname_r(). */ +/* #undef HAVE_GETHOSTBYNAME_R_6_ARG */ + +/* Define to 1 if you have the `getitimer' function. */ +#define HAVE_GETITIMER 1 + +/* Define to 1 if you have the `getloadavg' function. */ +#define HAVE_GETLOADAVG 1 + +/* Define to 1 if you have the `getlogin' function. */ +#define HAVE_GETLOGIN 1 + +/* Define to 1 if you have the `getnameinfo' function. */ +#define HAVE_GETNAMEINFO 1 + +/* Define if you have the 'getpagesize' function. */ +#define HAVE_GETPAGESIZE 1 + +/* Define to 1 if you have the `getpeername' function. */ +#define HAVE_GETPEERNAME 1 + +/* Define to 1 if you have the `getpgid' function. */ +#define HAVE_GETPGID 1 + +/* Define to 1 if you have the `getpgrp' function. */ +#define HAVE_GETPGRP 1 + +/* Define to 1 if you have the `getpid' function. */ +#define HAVE_GETPID 1 + +/* Define to 1 if you have the `getpriority' function. */ +#define HAVE_GETPRIORITY 1 + +/* Define to 1 if you have the `getpwent' function. */ +#define HAVE_GETPWENT 1 + +/* Define to 1 if the Linux getrandom() syscall is available */ +/* #undef HAVE_GETRANDOM_SYSCALL */ + +/* Define to 1 if you have the `getresgid' function. */ +#define HAVE_GETRESGID 1 + +/* Define to 1 if you have the `getresuid' function. */ +#define HAVE_GETRESUID 1 + +/* Define to 1 if you have the `getsid' function. */ +/* #undef HAVE_GETSID */ + +/* Define to 1 if you have the `getspent' function. */ +/* #undef HAVE_GETSPENT */ + +/* Define to 1 if you have the `getspnam' function. */ +/* #undef HAVE_GETSPNAM */ + +/* Define to 1 if you have the `gettimeofday' function. */ +#define HAVE_GETTIMEOFDAY 1 + +/* Define to 1 if you have the `getwd' function. */ +/* #undef HAVE_GETWD */ + +/* Define if glibc has incorrect _FORTIFY_SOURCE wrappers for memmove and + bcopy. */ +/* #undef HAVE_GLIBC_MEMMOVE_BUG */ + +/* Define to 1 if you have the header file. */ +#define HAVE_GRP_H 1 + +/* Define if you have the 'hstrerror' function. */ +#define HAVE_HSTRERROR 1 + +/* Define this if you have le64toh() */ +#define HAVE_HTOLE64 1 + +/* Define to 1 if you have the `hypot' function. */ +#define HAVE_HYPOT 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_IEEEFP_H */ + +/* Define to 1 if you have the `if_nameindex' function. */ +/* #undef HAVE_IF_NAMEINDEX */ + +/* Define if you have the 'inet_aton' function. */ +#define HAVE_INET_ATON 1 + +/* Define if you have the 'inet_pton' function. */ +#define HAVE_INET_PTON 1 + +/* Define to 1 if you have the `initgroups' function. */ +#define HAVE_INITGROUPS 1 + +/* Define if your compiler provides int32_t. */ +#define HAVE_INT32_T 1 + +/* Define if your compiler provides int64_t. */ +#define HAVE_INT64_T 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_IO_H */ + +/* Define if gcc has the ipa-pure-const bug. */ +/* #undef HAVE_IPA_PURE_CONST_BUG */ + +/* Define to 1 if you have the `kill' function. */ +#define HAVE_KILL 1 + +/* Define to 1 if you have the `killpg' function. */ +#define HAVE_KILLPG 1 + +/* Define if you have the 'kqueue' functions. */ +#define HAVE_KQUEUE 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_LANGINFO_H 1 + +/* Defined to enable large file support when an off_t is bigger than a long + and long long is available and at least as big as an off_t. You may need to + add some flags for configuration and compilation to enable this mode. (For + Solaris and Linux, the necessary defines are already defined.) */ +/* #undef HAVE_LARGEFILE_SUPPORT */ + +/* Define to 1 if you have the 'lchflags' function. */ +/* #undef HAVE_LCHFLAGS */ + +/* Define to 1 if you have the `lchmod' function. */ +/* #undef HAVE_LCHMOD */ + +/* Define to 1 if you have the `lchown' function. */ +#define HAVE_LCHOWN 1 + +/* Define to 1 if you have the `lgamma' function. */ +#define HAVE_LGAMMA 1 + +/* Define to 1 if you have the `dl' library (-ldl). */ +#define HAVE_LIBDL 1 + +/* Define to 1 if you have the `dld' library (-ldld). */ +/* #undef HAVE_LIBDLD */ + +/* Define to 1 if you have the `ieee' library (-lieee). */ +/* #undef HAVE_LIBIEEE */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LIBINTL_H */ + +/* Define if you have the readline library (-lreadline). */ +/* #undef HAVE_LIBREADLINE */ + +/* Define to 1 if you have the `resolv' library (-lresolv). */ +/* #undef HAVE_LIBRESOLV */ + +/* Define to 1 if you have the `sendfile' library (-lsendfile). */ +/* #undef HAVE_LIBSENDFILE */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LIBUTIL_H */ + +/* Define if you have the 'link' function. */ +#define HAVE_LINK 1 + +/* Define to 1 if you have the `linkat' function. */ +/* #undef HAVE_LINKAT */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LINUX_CAN_BCM_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LINUX_CAN_H */ + +/* Define if compiling using Linux 3.6 or later. */ +/* #undef HAVE_LINUX_CAN_RAW_FD_FRAMES */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LINUX_CAN_RAW_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_LINUX_NETLINK_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LINUX_TIPC_H */ + +/* Define to 1 if you have the `lockf' function. */ +#define HAVE_LOCKF 1 + +/* Define to 1 if you have the `log1p' function. */ +#define HAVE_LOG1P 1 + +/* Define to 1 if you have the `log2' function. */ +#define HAVE_LOG2 1 + +/* Define this if you have the type long double. */ +#define HAVE_LONG_DOUBLE 1 + +/* Define this if you have the type long long. */ +#define HAVE_LONG_LONG 1 + +/* Define to 1 if you have the `lstat' function. */ +#define HAVE_LSTAT 1 + +/* Define to 1 if you have the `lutimes' function. */ +/* #undef HAVE_LUTIMES */ + +/* Define this if you have the makedev macro. */ +#define HAVE_MAKEDEV 1 + +/* Define to 1 if you have the `mbrtowc' function. */ +#define HAVE_MBRTOWC 1 + +/* Define to 1 if you have the `memmove' function. */ +#define HAVE_MEMMOVE 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `memrchr' function. */ +#define HAVE_MEMRCHR 1 + +/* Define to 1 if you have the `mkdirat' function. */ +#define HAVE_MKDIRAT 1 + +/* Define to 1 if you have the `mkfifo' function. */ +/* #undef HAVE_MKFIFO */ + +/* Define to 1 if you have the `mkfifoat' function. */ +/* #undef HAVE_MKFIFOAT */ + +/* Define to 1 if you have the `mknod' function. */ +#define HAVE_MKNOD 1 + +/* Define to 1 if you have the `mknodat' function. */ +/* #undef HAVE_MKNODAT */ + +/* Define to 1 if you have the `mktime' function. */ +#define HAVE_MKTIME 1 + +/* Define to 1 if you have the `mmap' function. */ +#define HAVE_MMAP 1 + +/* Define to 1 if you have the `mremap' function. */ +#define HAVE_MREMAP 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NCURSES_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. */ +/* #undef HAVE_NDIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_NETPACKET_PACKET_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_NET_IF_H 1 + +/* Define to 1 if you have the `nice' function. */ +#define HAVE_NICE 1 + +/* Define to 1 if you have the `openat' function. */ +#define HAVE_OPENAT 1 + +/* Define to 1 if you have the `openpty' function. */ +/* #undef HAVE_OPENPTY */ + +/* Define if compiling using MacOS X 10.5 SDK or later. */ +/* #undef HAVE_OSX105_SDK */ + +/* Define to 1 if you have the `pathconf' function. */ +#define HAVE_PATHCONF 1 + +/* Define to 1 if you have the `pause' function. */ +#define HAVE_PAUSE 1 + +/* Define to 1 if you have the `pipe2' function. */ +#define HAVE_PIPE2 1 + +/* Define to 1 if you have the `plock' function. */ +/* #undef HAVE_PLOCK */ + +/* Define to 1 if you have the `poll' function. */ +#define HAVE_POLL 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_POLL_H 1 + +/* Define to 1 if you have the `posix_fadvise' function. */ +#define HAVE_POSIX_FADVISE 1 + +/* Define to 1 if you have the `posix_fallocate' function. */ +#define HAVE_POSIX_FALLOCATE 1 + +/* Define to 1 if you have the `pread' function. */ +#define HAVE_PREAD 1 + +/* Define if you have the 'prlimit' functions. */ +/* #undef HAVE_PRLIMIT */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PROCESS_H */ + +/* Define if your compiler supports function prototype */ +#define HAVE_PROTOTYPES 1 + +/* Define to 1 if you have the `pthread_atfork' function. */ +/* #undef HAVE_PTHREAD_ATFORK */ + +/* Defined for Solaris 2.6 bug in pthread header. */ +/* #undef HAVE_PTHREAD_DESTRUCTOR */ + +/* Define to 1 if you have the header file. */ +#define HAVE_PTHREAD_H 1 + +/* Define to 1 if you have the `pthread_init' function. */ +/* #undef HAVE_PTHREAD_INIT */ + +/* Define to 1 if you have the `pthread_kill' function. */ +#define HAVE_PTHREAD_KILL 1 + +/* Define to 1 if you have the `pthread_sigmask' function. */ +#define HAVE_PTHREAD_SIGMASK 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PTY_H */ + +/* Define to 1 if you have the `putenv' function. */ +#define HAVE_PUTENV 1 + +/* Define to 1 if you have the `pwrite' function. */ +#define HAVE_PWRITE 1 + +/* Define if the libcrypto has RAND_egd */ +/* #undef HAVE_RAND_EGD */ + +/* Define to 1 if you have the `readlink' function. */ +#define HAVE_READLINK 1 + +/* Define to 1 if you have the `readlinkat' function. */ +/* #undef HAVE_READLINKAT */ + +/* Define to 1 if you have the `readv' function. */ +#define HAVE_READV 1 + +/* Define to 1 if you have the `realpath' function. */ +#define HAVE_REALPATH 1 + +/* Define to 1 if you have the `renameat' function. */ +#define HAVE_RENAMEAT 1 + +/* Define if readline supports append_history */ +/* #undef HAVE_RL_APPEND_HISTORY */ + +/* Define if you have readline 2.1 */ +/* #undef HAVE_RL_CALLBACK */ + +/* Define if you can turn off readline's signal handling. */ +/* #undef HAVE_RL_CATCH_SIGNAL */ + +/* Define if you have readline 2.2 */ +/* #undef HAVE_RL_COMPLETION_APPEND_CHARACTER */ + +/* Define if you have readline 4.0 */ +/* #undef HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK */ + +/* Define if you have readline 4.2 */ +/* #undef HAVE_RL_COMPLETION_MATCHES */ + +/* Define if you have rl_completion_suppress_append */ +/* #undef HAVE_RL_COMPLETION_SUPPRESS_APPEND */ + +/* Define if you have readline 4.0 */ +/* #undef HAVE_RL_PRE_INPUT_HOOK */ + +/* Define to 1 if you have the `round' function. */ +#define HAVE_ROUND 1 + +/* Define to 1 if you have the `sched_get_priority_max' function. */ +#define HAVE_SCHED_GET_PRIORITY_MAX 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SCHED_H 1 + +/* Define to 1 if you have the `sched_rr_get_interval' function. */ +#define HAVE_SCHED_RR_GET_INTERVAL 1 + +/* Define to 1 if you have the `sched_setaffinity' function. */ +#define HAVE_SCHED_SETAFFINITY 1 + +/* Define to 1 if you have the `sched_setparam' function. */ +#define HAVE_SCHED_SETPARAM 1 + +/* Define to 1 if you have the `sched_setscheduler' function. */ +#define HAVE_SCHED_SETSCHEDULER 1 + +/* Define to 1 if you have the `select' function. */ +#define HAVE_SELECT 1 + +/* Define to 1 if you have the `sem_getvalue' function. */ +#define HAVE_SEM_GETVALUE 1 + +/* Define to 1 if you have the `sem_open' function. */ +#define HAVE_SEM_OPEN 1 + +/* Define to 1 if you have the `sem_timedwait' function. */ +#define HAVE_SEM_TIMEDWAIT 1 + +/* Define to 1 if you have the `sem_unlink' function. */ +#define HAVE_SEM_UNLINK 1 + +/* Define to 1 if you have the `sendfile' function. */ +#define HAVE_SENDFILE 1 + +/* Define to 1 if you have the `setegid' function. */ +#define HAVE_SETEGID 1 + +/* Define to 1 if you have the `seteuid' function. */ +#define HAVE_SETEUID 1 + +/* Define to 1 if you have the `setgid' function. */ +#define HAVE_SETGID 1 + +/* Define if you have the 'setgroups' function. */ +#define HAVE_SETGROUPS 1 + +/* Define to 1 if you have the `sethostname' function. */ +/* #undef HAVE_SETHOSTNAME */ + +/* Define to 1 if you have the `setitimer' function. */ +#define HAVE_SETITIMER 1 + +/* Define to 1 if you have the `setlocale' function. */ +#define HAVE_SETLOCALE 1 + +/* Define to 1 if you have the `setpgid' function. */ +#define HAVE_SETPGID 1 + +/* Define to 1 if you have the `setpgrp' function. */ +#define HAVE_SETPGRP 1 + +/* Define to 1 if you have the `setpriority' function. */ +#define HAVE_SETPRIORITY 1 + +/* Define to 1 if you have the `setregid' function. */ +#define HAVE_SETREGID 1 + +/* Define to 1 if you have the `setresgid' function. */ +#define HAVE_SETRESGID 1 + +/* Define to 1 if you have the `setresuid' function. */ +#define HAVE_SETRESUID 1 + +/* Define to 1 if you have the `setreuid' function. */ +#define HAVE_SETREUID 1 + +/* Define to 1 if you have the `setsid' function. */ +#define HAVE_SETSID 1 + +/* Define to 1 if you have the `setuid' function. */ +#define HAVE_SETUID 1 + +/* Define to 1 if you have the `setvbuf' function. */ +#define HAVE_SETVBUF 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SHADOW_H */ + +/* Define to 1 if you have the `sigaction' function. */ +#define HAVE_SIGACTION 1 + +/* Define to 1 if you have the `sigaltstack' function. */ +#define HAVE_SIGALTSTACK 1 + +/* Define to 1 if you have the `siginterrupt' function. */ +#define HAVE_SIGINTERRUPT 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SIGNAL_H 1 + +/* Define to 1 if you have the `sigpending' function. */ +#define HAVE_SIGPENDING 1 + +/* Define to 1 if you have the `sigrelse' function. */ +/* #undef HAVE_SIGRELSE */ + +/* Define to 1 if you have the `sigtimedwait' function. */ +/* #undef HAVE_SIGTIMEDWAIT */ + +/* Define to 1 if you have the `sigwait' function. */ +#define HAVE_SIGWAIT 1 + +/* Define to 1 if you have the `sigwaitinfo' function. */ +/* #undef HAVE_SIGWAITINFO */ + +/* Define to 1 if you have the `snprintf' function. */ +#define HAVE_SNPRINTF 1 + +/* Define if sockaddr has sa_len member */ +/* #undef HAVE_SOCKADDR_SA_LEN */ + +/* struct sockaddr_storage (sys/socket.h) */ +#define HAVE_SOCKADDR_STORAGE 1 + +/* Define if you have the 'socketpair' function. */ +#define HAVE_SOCKETPAIR 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SPAWN_H */ + +/* Define if your compiler provides ssize_t */ +#define HAVE_SSIZE_T 1 + +/* Define to 1 if you have the `statvfs' function. */ +/* #undef HAVE_STATVFS */ + +/* Define if you have struct stat.st_mtim.tv_nsec */ +/* #undef HAVE_STAT_TV_NSEC */ + +/* Define if you have struct stat.st_mtimensec */ +/* #undef HAVE_STAT_TV_NSEC2 */ + +/* Define if your compiler supports variable length function prototypes (e.g. + void fprintf(FILE *, char *, ...);) *and* */ +#define HAVE_STDARG_PROTOTYPES 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Has stdatomic.h, atomic_int and _Atomic void* types work */ +#define HAVE_STD_ATOMIC 1 + +/* Define to 1 if you have the `strdup' function. */ +#define HAVE_STRDUP 1 + +/* Define to 1 if you have the `strftime' function. */ +#define HAVE_STRFTIME 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the `strlcpy' function. */ +#define HAVE_STRLCPY 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_STROPTS_H */ + +/* Define to 1 if `st_birthtime' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_BIRTHTIME */ + +/* Define to 1 if `st_blksize' is a member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_BLKSIZE 1 + +/* Define to 1 if `st_blocks' is a member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_BLOCKS 1 + +/* Define to 1 if `st_flags' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_FLAGS */ + +/* Define to 1 if `st_gen' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_GEN */ + +/* Define to 1 if `st_rdev' is a member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_RDEV 1 + +/* Define to 1 if `tm_zone' is a member of `struct tm'. */ +#define HAVE_STRUCT_TM_TM_ZONE 1 + +/* Define to 1 if your `struct stat' has `st_blocks'. Deprecated, use + `HAVE_STRUCT_STAT_ST_BLOCKS' instead. */ +#define HAVE_ST_BLOCKS 1 + +/* Define if you have the 'symlink' function. */ +#define HAVE_SYMLINK 1 + +/* Define to 1 if you have the `symlinkat' function. */ +/* #undef HAVE_SYMLINKAT */ + +/* Define to 1 if you have the `sync' function. */ +#define HAVE_SYNC 1 + +/* Define to 1 if you have the `sysconf' function. */ +#define HAVE_SYSCONF 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYSEXITS_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_AUDIOIO_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_BSDTTY_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_DEVPOLL_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +/* #undef HAVE_SYS_DIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_ENDIAN_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_EPOLL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_EVENT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_FILE_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_IOCTL_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_KERN_CONTROL_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_LOADAVG_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_LOCK_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_MKDEV_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_MODEM_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +/* #undef HAVE_SYS_NDIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_PARAM_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_POLL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_RESOURCE_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SELECT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SENDFILE_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SOCKET_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_STATVFS_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SYSCALL_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_SYS_DOMAIN_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_TERMIO_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIMES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UIO_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UN_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UTSNAME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_WAIT_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_XATTR_H */ + +/* Define to 1 if you have the `tcgetpgrp' function. */ +#define HAVE_TCGETPGRP 1 + +/* Define to 1 if you have the `tcsetpgrp' function. */ +#define HAVE_TCSETPGRP 1 + +/* Define to 1 if you have the `tempnam' function. */ +#define HAVE_TEMPNAM 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_TERMIOS_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_TERM_H */ + +/* Define to 1 if you have the `tgamma' function. */ +#define HAVE_TGAMMA 1 + +/* Define to 1 if you have the `timegm' function. */ +/* #undef HAVE_TIMEGM */ + +/* Define to 1 if you have the `times' function. */ +#define HAVE_TIMES 1 + +/* Define to 1 if you have the `tmpfile' function. */ +#define HAVE_TMPFILE 1 + +/* Define to 1 if you have the `tmpnam' function. */ +#define HAVE_TMPNAM 1 + +/* Define to 1 if you have the `tmpnam_r' function. */ +/* #undef HAVE_TMPNAM_R */ + +/* Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use + `HAVE_STRUCT_TM_TM_ZONE' instead. */ +#define HAVE_TM_ZONE 1 + +/* Define to 1 if you have the `truncate' function. */ +#define HAVE_TRUNCATE 1 + +/* Define to 1 if you don't have `tm_zone' but do have the external array + `tzname'. */ +/* #undef HAVE_TZNAME */ + +/* Define this if you have tcl and TCL_UTF_MAX==6 */ +/* #undef HAVE_UCS4_TCL */ + +/* Define if your compiler provides uint32_t. */ +#define HAVE_UINT32_T 1 + +/* Define if your compiler provides uint64_t. */ +#define HAVE_UINT64_T 1 + +/* Define to 1 if the system has the type `uintptr_t'. */ +#define HAVE_UINTPTR_T 1 + +/* Define to 1 if you have the `uname' function. */ +#define HAVE_UNAME 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you have the `unlinkat' function. */ +#define HAVE_UNLINKAT 1 + +/* Define to 1 if you have the `unsetenv' function. */ +#define HAVE_UNSETENV 1 + +/* Define if you have a useable wchar_t type defined in wchar.h; useable means + wchar_t must be an unsigned type with at least 16 bits. (see + Include/unicodeobject.h). */ +/* #undef HAVE_USABLE_WCHAR_T */ + +/* Define to 1 if you have the header file. */ +#define HAVE_UTIL_H 1 + +/* Define to 1 if you have the `utimensat' function. */ +/* #undef HAVE_UTIMENSAT */ + +/* Define to 1 if you have the `utimes' function. */ +#define HAVE_UTIMES 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UTIME_H 1 + +/* Define to 1 if you have the `wait3' function. */ +#define HAVE_WAIT3 1 + +/* Define to 1 if you have the `wait4' function. */ +/* #undef HAVE_WAIT4 */ + +/* Define to 1 if you have the `waitid' function. */ +#define HAVE_WAITID 1 + +/* Define to 1 if you have the `waitpid' function. */ +#define HAVE_WAITPID 1 + +/* Define if the compiler provides a wchar.h header file. */ +#define HAVE_WCHAR_H 1 + +/* Define to 1 if you have the `wcscoll' function. */ +#define HAVE_WCSCOLL 1 + +/* Define to 1 if you have the `wcsftime' function. */ +#define HAVE_WCSFTIME 1 + +/* Define to 1 if you have the `wcsxfrm' function. */ +#define HAVE_WCSXFRM 1 + +/* Define to 1 if you have the `wmemcmp' function. */ +#define HAVE_WMEMCMP 1 + +/* Define if tzset() actually switches the local timezone in a meaningful way. + */ +/* #undef HAVE_WORKING_TZSET */ + +/* Define to 1 if you have the `writev' function. */ +#define HAVE_WRITEV 1 + +/* Define if the zlib library has inflateCopy */ +#define HAVE_ZLIB_COPY 1 + +/* Define to 1 if you have the `_getpty' function. */ +/* #undef HAVE__GETPTY */ + +/* Define if log1p(-0.) is 0. rather than -0. */ +/* #undef LOG1P_DROPS_ZERO_SIGN */ + +/* Define to 1 if `major', `minor', and `makedev' are declared in . + */ +/* #undef MAJOR_IN_MKDEV */ + +/* Define to 1 if `major', `minor', and `makedev' are declared in + . */ +#define MAJOR_IN_SYSMACROS 1 + +/* Define if mvwdelch in curses.h is an expression. */ +/* #undef MVWDELCH_IS_EXPRESSION */ + +/* Define to the address where bug reports for this package should be sent. */ +/* #undef PACKAGE_BUGREPORT */ + +/* Define to the full name of this package. */ +/* #undef PACKAGE_NAME */ + +/* Define to the full name and version of this package. */ +/* #undef PACKAGE_STRING */ + +/* Define to the one symbol short name of this package. */ +/* #undef PACKAGE_TARNAME */ + +/* Define to the home page for this package. */ +/* #undef PACKAGE_URL */ + +/* Define to the version of this package. */ +/* #undef PACKAGE_VERSION */ + +/* Define if POSIX semaphores aren't enabled on your system */ +/* #undef POSIX_SEMAPHORES_NOT_ENABLED */ + +/* Defined if PTHREAD_SCOPE_SYSTEM supported. */ +/* #undef PTHREAD_SYSTEM_SCHED_SUPPORTED */ + +/* Define as the preferred size in bits of long digits */ +/* #undef PYLONG_BITS_IN_DIGIT */ + +/* Define to printf format modifier for long long type */ +#define PY_FORMAT_LONG_LONG "ll" + +/* Define to printf format modifier for Py_ssize_t */ +#define PY_FORMAT_SIZE_T "z" + +/* Define if you want to build an interpreter with many run-time checks. */ +/* #undef Py_DEBUG */ + +/* Defined if Python is built as a shared library. */ +#define Py_ENABLE_SHARED 1 + +/* Define hash algorithm for str, bytes and memoryview. SipHash24: 1, FNV: 2, + externally defined: 0 */ +/* #undef Py_HASH_ALGORITHM */ + +/* assume C89 semantics that RETSIGTYPE is always void */ +#define RETSIGTYPE void + +/* Define if setpgrp() must be called as setpgrp(0, 0). */ +/* #undef SETPGRP_HAVE_ARG */ + +/* Define if i>>j for signed int i does not extend the sign bit when i < 0 */ +/* #undef SIGNED_RIGHT_SHIFT_ZERO_FILLS */ + +/* The size of `double', as computed by sizeof. */ +#define SIZEOF_DOUBLE 8 + +/* The size of `float', as computed by sizeof. */ +#define SIZEOF_FLOAT 4 + +/* The size of `fpos_t', as computed by sizeof. */ +#define SIZEOF_FPOS_T 4 + +/* The size of `int', as computed by sizeof. */ +#define SIZEOF_INT 4 + +/* The size of `long', as computed by sizeof. */ +#define SIZEOF_LONG 4 + +/* The size of `long double', as computed by sizeof. */ +#define SIZEOF_LONG_DOUBLE 8 + +/* The size of `long long', as computed by sizeof. */ +#define SIZEOF_LONG_LONG 8 + +/* The size of `off_t', as computed by sizeof. */ +#define SIZEOF_OFF_T 4 + +/* The size of `pid_t', as computed by sizeof. */ +#define SIZEOF_PID_T 4 + +/* The size of `pthread_t', as computed by sizeof. */ +#define SIZEOF_PTHREAD_T 4 + +/* The size of `short', as computed by sizeof. */ +#define SIZEOF_SHORT 2 + +/* The size of `size_t', as computed by sizeof. */ +#define SIZEOF_SIZE_T 4 + +/* The size of `time_t', as computed by sizeof. */ +#define SIZEOF_TIME_T 4 + +/* The size of `uintptr_t', as computed by sizeof. */ +#define SIZEOF_UINTPTR_T 4 + +/* The size of `void *', as computed by sizeof. */ +#define SIZEOF_VOID_P 4 + +/* The size of `wchar_t', as computed by sizeof. */ +#define SIZEOF_WCHAR_T 4 + +/* The size of `_Bool', as computed by sizeof. */ +#define SIZEOF__BOOL 1 + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define if you can safely include both and + (which you can't on SCO ODT 3.0). */ +#define SYS_SELECT_WITH_SYS_TIME 1 + +/* Define if tanh(-0.) is -0., or if platform doesn't have signed zeros */ +/* #undef TANH_PRESERVES_ZERO_SIGN */ + +/* Library needed by timemodule.c: librt may be needed for clock_gettime() */ +/* #undef TIMEMODULE_LIB */ + +/* Define to 1 if you can safely include both and . */ +#define TIME_WITH_SYS_TIME 1 + +/* Define to 1 if your declares `struct tm'. */ +/* #undef TM_IN_SYS_TIME */ + +/* Define if you want to use computed gotos in ceval.c. */ +#define USE_COMPUTED_GOTOS 1 + +/* Define to use the C99 inline keyword. */ +#define USE_INLINE 1 + +/* Enable extensions on AIX 3, Interix. */ +#ifndef _ALL_SOURCE +# define _ALL_SOURCE 1 +#endif +/* Enable GNU extensions on systems that have them. */ +#ifndef _GNU_SOURCE +# define _GNU_SOURCE 1 +#endif +/* Enable threading extensions on Solaris. */ +#ifndef _POSIX_PTHREAD_SEMANTICS +# define _POSIX_PTHREAD_SEMANTICS 1 +#endif +/* Enable extensions on HP NonStop. */ +#ifndef _TANDEM_SOURCE +# define _TANDEM_SOURCE 1 +#endif +/* Enable general extensions on Solaris. */ +#ifndef __EXTENSIONS__ +# define __EXTENSIONS__ 1 +#endif + + +/* Define if a va_list is an array of some kind */ +/* #undef VA_LIST_IS_ARRAY */ + +/* Define if you want SIGFPE handled (see Include/pyfpe.h). */ +/* #undef WANT_SIGFPE_HANDLER */ + +/* Define if WINDOW in curses.h offers a field _flags. */ +/* #undef WINDOW_HAS_FLAGS */ + +/* Define if you want documentation strings in extension modules */ +#define WITH_DOC_STRINGS 1 + +/* Define if you want to use the new-style (Openstep, Rhapsody, MacOS) dynamic + linker (dyld) instead of the old-style (NextStep) dynamic linker (rld). + Dyld is necessary to support frameworks. */ +/* #undef WITH_DYLD */ + +/* Define to 1 if libintl is needed for locale functions. */ +/* #undef WITH_LIBINTL */ + +/* Define if you want to produce an OpenStep/Rhapsody framework (shared + library plus accessory files). */ +/* #undef WITH_NEXT_FRAMEWORK */ + +/* Define if you want to compile in Python-specific mallocs */ +#define WITH_PYMALLOC 1 + +/* Define if you want to compile in rudimentary thread support */ +#define WITH_THREAD 1 + +/* Define to profile with the Pentium timestamp counter */ +/* #undef WITH_TSC */ + +/* Define if you want pymalloc to be disabled when running under valgrind */ +/* #undef WITH_VALGRIND */ + +/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most + significant byte first (like Motorola and SPARC, unlike Intel). */ +#if defined AC_APPLE_UNIVERSAL_BUILD +# if defined __BIG_ENDIAN__ +# define WORDS_BIGENDIAN 1 +# endif +#else +# ifndef WORDS_BIGENDIAN +/* # undef WORDS_BIGENDIAN */ +# endif +#endif + +/* Define if arithmetic is subject to x87-style double rounding issue */ +/* #undef X87_DOUBLE_ROUNDING */ + +/* Define on OpenBSD to activate all library features */ +/* #undef _BSD_SOURCE */ + +/* Define on Irix to enable u_int */ +#define _BSD_TYPES 1 + +/* Define on Darwin to activate all library features */ +#define _DARWIN_C_SOURCE 1 + +/* This must be set to 64 on some systems to enable large file support. */ +#define _FILE_OFFSET_BITS 64 + +/* Define on Linux to activate all library features */ +#define _GNU_SOURCE 1 + +/* Define to include mbstate_t for mbrtowc */ +/* #undef _INCLUDE__STDC_A1_SOURCE */ + +/* This must be defined on some systems to enable large file support. */ +#define _LARGEFILE_SOURCE 1 + +/* This must be defined on AIX systems to enable large file support. */ +/* #undef _LARGE_FILES */ + +/* Define to 1 if on MINIX. */ +/* #undef _MINIX */ + +/* Define on NetBSD to activate all library features */ +#define _NETBSD_SOURCE 1 + +/* Define to 2 if the system does not provide POSIX.1 features except with + this defined. */ +/* #undef _POSIX_1_SOURCE */ + +/* Define to activate features from IEEE Stds 1003.1-2008 */ +#define _POSIX_C_SOURCE 200809L + +/* Define to 1 if you need to in order for `stat' and other things to work. */ +/* #undef _POSIX_SOURCE */ + +/* Define if you have POSIX threads, and your system does not define that. */ +/* #undef _POSIX_THREADS */ + +/* Define to force use of thread-safe errno, h_errno, and other functions */ +#define _REENTRANT 1 + +/* Define for Solaris 2.5.1 so the uint32_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +/* #undef _UINT32_T */ + +/* Define for Solaris 2.5.1 so the uint64_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +/* #undef _UINT64_T */ + +/* Define to the level of X/Open that your system supports */ +#define _XOPEN_SOURCE 700 + +/* Define to activate Unix95-and-earlier features */ +#define _XOPEN_SOURCE_EXTENDED 1 + +/* Define on FreeBSD to activate all library features */ +#define __BSD_VISIBLE 1 + +/* Define to 1 if type `char' is unsigned and you are not using gcc. */ +#ifndef __CHAR_UNSIGNED__ +/* # undef __CHAR_UNSIGNED__ */ +#endif + +/* Define to 'long' if doesn't define. */ +/* #undef clock_t */ + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ + +/* Define to `int' if doesn't define. */ +/* #undef gid_t */ + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +/* #undef inline */ +#endif + +/* Define to the type of a signed integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +/* #undef int32_t */ + +/* Define to the type of a signed integer type of width exactly 64 bits if + such a type exists and the standard includes do not define it. */ +/* #undef int64_t */ + +/* Define to `int' if does not define. */ +/* #undef mode_t */ + +/* Define to `long int' if does not define. */ +/* #undef off_t */ + +/* Define to `int' if does not define. */ +/* #undef pid_t */ + +/* Define to empty if the keyword does not work. */ +/* #undef signed */ + +/* Define to `unsigned int' if does not define. */ +/* #undef size_t */ + +/* Define to `int' if does not define. */ +/* #undef socklen_t */ + +/* Define to `int' if doesn't define. */ +/* #undef uid_t */ + +/* Define to the type of an unsigned integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint32_t */ + +/* Define to the type of an unsigned integer type of width exactly 64 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint64_t */ + +/* Define to empty if the keyword does not work. */ +/* #undef volatile */ + + +/* Define the macros needed if on a UnixWare 7.x system. */ +#if defined(__USLC__) && defined(__SCO_VERSION__) +#define STRICT_SYSV_CURSES /* Don't use ncurses extensions */ +#endif + +#endif /*Py_PYCONFIG_H*/ + diff --git a/android/python35/include/pyconfig_armeabi_v7a_hard.h b/android/python35/include/pyconfig_armeabi_v7a_hard.h new file mode 100644 index 000000000..ac47e6204 --- /dev/null +++ b/android/python35/include/pyconfig_armeabi_v7a_hard.h @@ -0,0 +1,1530 @@ +/* pyconfig.h. Generated from pyconfig.h.in by configure. */ +/* pyconfig.h.in. Generated from configure.ac by autoheader. */ + + +#ifndef Py_PYCONFIG_H +#define Py_PYCONFIG_H + + +/* Define if building universal (internal helper macro) */ +/* #undef AC_APPLE_UNIVERSAL_BUILD */ + +/* Define for AIX if your compiler is a genuine IBM xlC/xlC_r and you want + support for AIX C++ shared extension modules. */ +/* #undef AIX_GENUINE_CPLUSPLUS */ + +/* Define if C doubles are 64-bit IEEE 754 binary format, stored in ARM + mixed-endian order (byte order 45670123) */ +/* #undef DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754 */ + +/* Define if C doubles are 64-bit IEEE 754 binary format, stored with the most + significant byte first */ +/* #undef DOUBLE_IS_BIG_ENDIAN_IEEE754 */ + +/* Define if C doubles are 64-bit IEEE 754 binary format, stored with the + least significant byte first */ +/* #undef DOUBLE_IS_LITTLE_ENDIAN_IEEE754 */ + +/* Define if --enable-ipv6 is specified */ +#define ENABLE_IPV6 1 + +/* Define if flock needs to be linked with bsd library. */ +/* #undef FLOCK_NEEDS_LIBBSD */ + +/* Define if getpgrp() must be called as getpgrp(0). */ +/* #undef GETPGRP_HAVE_ARG */ + +/* Define if gettimeofday() does not have second (timezone) argument This is + the case on Motorola V4 (R40V4.2) */ +/* #undef GETTIMEOFDAY_NO_TZ */ + +/* Define to 1 if you have the `accept4' function. */ +/* #undef HAVE_ACCEPT4 */ + +/* Define to 1 if you have the `acosh' function. */ +#define HAVE_ACOSH 1 + +/* struct addrinfo (netdb.h) */ +#define HAVE_ADDRINFO 1 + +/* Define to 1 if you have the `alarm' function. */ +#define HAVE_ALARM 1 + +/* Define if aligned memory access is required */ +#define HAVE_ALIGNED_REQUIRED 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ALLOCA_H 1 + +/* Define this if your time.h defines altzone. */ +/* #undef HAVE_ALTZONE */ + +/* Define to 1 if you have the `asinh' function. */ +#define HAVE_ASINH 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ASM_TYPES_H 1 + +/* Define to 1 if you have the `atanh' function. */ +#define HAVE_ATANH 1 + +/* Define to 1 if you have the `bind_textdomain_codeset' function. */ +/* #undef HAVE_BIND_TEXTDOMAIN_CODESET */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_BLUETOOTH_BLUETOOTH_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_BLUETOOTH_H */ + +/* Define if mbstowcs(NULL, "text", 0) does not return the number of wide + chars that would be converted. */ +/* #undef HAVE_BROKEN_MBSTOWCS */ + +/* Define if nice() returns success/failure instead of the new priority. */ +/* #undef HAVE_BROKEN_NICE */ + +/* Define if the system reports an invalid PIPE_BUF value. */ +/* #undef HAVE_BROKEN_PIPE_BUF */ + +/* Define if poll() sets errno on invalid file descriptors. */ +/* #undef HAVE_BROKEN_POLL */ + +/* Define if the Posix semaphores do not work on your system */ +/* #undef HAVE_BROKEN_POSIX_SEMAPHORES */ + +/* Define if pthread_sigmask() does not work on your system. */ +/* #undef HAVE_BROKEN_PTHREAD_SIGMASK */ + +/* define to 1 if your sem_getvalue is broken. */ +#define HAVE_BROKEN_SEM_GETVALUE 1 + +/* Define if `unsetenv` does not return an int. */ +/* #undef HAVE_BROKEN_UNSETENV */ + +/* Has builtin atomics */ +#define HAVE_BUILTIN_ATOMIC 1 + +/* Define this if you have the type _Bool. */ +#define HAVE_C99_BOOL 1 + +/* Define to 1 if you have the 'chflags' function. */ +/* #undef HAVE_CHFLAGS */ + +/* Define to 1 if you have the `chown' function. */ +#define HAVE_CHOWN 1 + +/* Define if you have the 'chroot' function. */ +#define HAVE_CHROOT 1 + +/* Define to 1 if you have the `clock' function. */ +#define HAVE_CLOCK 1 + +/* Define to 1 if you have the `clock_getres' function. */ +#define HAVE_CLOCK_GETRES 1 + +/* Define to 1 if you have the `clock_gettime' function. */ +#define HAVE_CLOCK_GETTIME 1 + +/* Define if the C compiler supports computed gotos. */ +#define HAVE_COMPUTED_GOTOS 1 + +/* Define to 1 if you have the `confstr' function. */ +/* #undef HAVE_CONFSTR */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_CONIO_H */ + +/* Define to 1 if you have the `copysign' function. */ +#define HAVE_COPYSIGN 1 + +/* Define to 1 if you have the `ctermid' function. */ +/* #undef HAVE_CTERMID */ + +/* Define if you have the 'ctermid_r' function. */ +#define HAVE_CTERMID_R 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_CURSES_H */ + +/* Define if you have the 'is_term_resized' function. */ +/* #undef HAVE_CURSES_IS_TERM_RESIZED */ + +/* Define if you have the 'resizeterm' function. */ +/* #undef HAVE_CURSES_RESIZETERM */ + +/* Define if you have the 'resize_term' function. */ +/* #undef HAVE_CURSES_RESIZE_TERM */ + +/* Define to 1 if you have the declaration of `isfinite', and to 0 if you + don't. */ +#define HAVE_DECL_ISFINITE 1 + +/* Define to 1 if you have the declaration of `isinf', and to 0 if you don't. + */ +#define HAVE_DECL_ISINF 1 + +/* Define to 1 if you have the declaration of `isnan', and to 0 if you don't. + */ +#define HAVE_DECL_ISNAN 1 + +/* Define to 1 if you have the declaration of `tzname', and to 0 if you don't. + */ +/* #undef HAVE_DECL_TZNAME */ + +/* Define to 1 if you have the device macros. */ +#define HAVE_DEVICE_MACROS 1 + +/* Define to 1 if you have the /dev/ptc device file. */ +/* #undef HAVE_DEV_PTC */ + +/* Define to 1 if you have the /dev/ptmx device file. */ +/* #undef HAVE_DEV_PTMX */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_DIRECT_H */ + +/* Define to 1 if the dirent structure has a d_type field */ +#define HAVE_DIRENT_D_TYPE 1 + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#define HAVE_DIRENT_H 1 + +/* Define if you have the 'dirfd' function or macro. */ +#define HAVE_DIRFD 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_DLFCN_H 1 + +/* Define to 1 if you have the `dlopen' function. */ +#define HAVE_DLOPEN 1 + +/* Define to 1 if you have the `dup2' function. */ +#define HAVE_DUP2 1 + +/* Define to 1 if you have the `dup3' function. */ +/* #undef HAVE_DUP3 */ + +/* Defined when any dynamic module loading is enabled. */ +#define HAVE_DYNAMIC_LOADING 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ENDIAN_H 1 + +/* Define if you have the 'epoll' functions. */ +#define HAVE_EPOLL 1 + +/* Define if you have the 'epoll_create1' function. */ +/* #undef HAVE_EPOLL_CREATE1 */ + +/* Define to 1 if you have the `erf' function. */ +#define HAVE_ERF 1 + +/* Define to 1 if you have the `erfc' function. */ +#define HAVE_ERFC 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ERRNO_H 1 + +/* Define to 1 if you have the `execv' function. */ +#define HAVE_EXECV 1 + +/* Define to 1 if you have the `expm1' function. */ +#define HAVE_EXPM1 1 + +/* Define to 1 if you have the `faccessat' function. */ +/* #undef HAVE_FACCESSAT */ + +/* Define if you have the 'fchdir' function. */ +#define HAVE_FCHDIR 1 + +/* Define to 1 if you have the `fchmod' function. */ +#define HAVE_FCHMOD 1 + +/* Define to 1 if you have the `fchmodat' function. */ +#define HAVE_FCHMODAT 1 + +/* Define to 1 if you have the `fchown' function. */ +#define HAVE_FCHOWN 1 + +/* Define to 1 if you have the `fchownat' function. */ +#define HAVE_FCHOWNAT 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* Define if you have the 'fdatasync' function. */ +#define HAVE_FDATASYNC 1 + +/* Define to 1 if you have the `fdopendir' function. */ +#define HAVE_FDOPENDIR 1 + +/* Define to 1 if you have the `fexecve' function. */ +/* #undef HAVE_FEXECVE */ + +/* Define to 1 if you have the `finite' function. */ +#define HAVE_FINITE 1 + +/* Define to 1 if you have the `flock' function. */ +#define HAVE_FLOCK 1 + +/* Define to 1 if you have the `fork' function. */ +#define HAVE_FORK 1 + +/* Define to 1 if you have the `forkpty' function. */ +/* #undef HAVE_FORKPTY */ + +/* Define to 1 if you have the `fpathconf' function. */ +#define HAVE_FPATHCONF 1 + +/* Define to 1 if you have the `fseek64' function. */ +/* #undef HAVE_FSEEK64 */ + +/* Define to 1 if you have the `fseeko' function. */ +#define HAVE_FSEEKO 1 + +/* Define to 1 if you have the `fstatat' function. */ +#define HAVE_FSTATAT 1 + +/* Define to 1 if you have the `fstatvfs' function. */ +/* #undef HAVE_FSTATVFS */ + +/* Define if you have the 'fsync' function. */ +#define HAVE_FSYNC 1 + +/* Define to 1 if you have the `ftell64' function. */ +/* #undef HAVE_FTELL64 */ + +/* Define to 1 if you have the `ftello' function. */ +#define HAVE_FTELLO 1 + +/* Define to 1 if you have the `ftime' function. */ +#define HAVE_FTIME 1 + +/* Define to 1 if you have the `ftruncate' function. */ +#define HAVE_FTRUNCATE 1 + +/* Define to 1 if you have the `futimens' function. */ +/* #undef HAVE_FUTIMENS */ + +/* Define to 1 if you have the `futimes' function. */ +/* #undef HAVE_FUTIMES */ + +/* Define to 1 if you have the `futimesat' function. */ +/* #undef HAVE_FUTIMESAT */ + +/* Define to 1 if you have the `gai_strerror' function. */ +#define HAVE_GAI_STRERROR 1 + +/* Define to 1 if you have the `gamma' function. */ +/* #undef HAVE_GAMMA */ + +/* Define if we can use gcc inline assembler to get and set mc68881 fpcr */ +/* #undef HAVE_GCC_ASM_FOR_MC68881 */ + +/* Define if we can use x64 gcc inline assembler */ +/* #undef HAVE_GCC_ASM_FOR_X64 */ + +/* Define if we can use gcc inline assembler to get and set x87 control word + */ +/* #undef HAVE_GCC_ASM_FOR_X87 */ + +/* Define if your compiler provides __uint128_t */ +/* #undef HAVE_GCC_UINT128_T */ + +/* Define if you have the getaddrinfo function. */ +#define HAVE_GETADDRINFO 1 + +/* Define this if you have flockfile(), getc_unlocked(), and funlockfile() */ +#define HAVE_GETC_UNLOCKED 1 + +/* Define to 1 if you have the `getentropy' function. */ +/* #undef HAVE_GETENTROPY */ + +/* Define to 1 if you have the `getgrouplist' function. */ +#define HAVE_GETGROUPLIST 1 + +/* Define to 1 if you have the `getgroups' function. */ +#define HAVE_GETGROUPS 1 + +/* Define to 1 if you have the `gethostbyname' function. */ +#define HAVE_GETHOSTBYNAME 1 + +/* Define this if you have some version of gethostbyname_r() */ +/* #undef HAVE_GETHOSTBYNAME_R */ + +/* Define this if you have the 3-arg version of gethostbyname_r(). */ +/* #undef HAVE_GETHOSTBYNAME_R_3_ARG */ + +/* Define this if you have the 5-arg version of gethostbyname_r(). */ +/* #undef HAVE_GETHOSTBYNAME_R_5_ARG */ + +/* Define this if you have the 6-arg version of gethostbyname_r(). */ +/* #undef HAVE_GETHOSTBYNAME_R_6_ARG */ + +/* Define to 1 if you have the `getitimer' function. */ +#define HAVE_GETITIMER 1 + +/* Define to 1 if you have the `getloadavg' function. */ +#define HAVE_GETLOADAVG 1 + +/* Define to 1 if you have the `getlogin' function. */ +#define HAVE_GETLOGIN 1 + +/* Define to 1 if you have the `getnameinfo' function. */ +#define HAVE_GETNAMEINFO 1 + +/* Define if you have the 'getpagesize' function. */ +#define HAVE_GETPAGESIZE 1 + +/* Define to 1 if you have the `getpeername' function. */ +#define HAVE_GETPEERNAME 1 + +/* Define to 1 if you have the `getpgid' function. */ +#define HAVE_GETPGID 1 + +/* Define to 1 if you have the `getpgrp' function. */ +#define HAVE_GETPGRP 1 + +/* Define to 1 if you have the `getpid' function. */ +#define HAVE_GETPID 1 + +/* Define to 1 if you have the `getpriority' function. */ +#define HAVE_GETPRIORITY 1 + +/* Define to 1 if you have the `getpwent' function. */ +#define HAVE_GETPWENT 1 + +/* Define to 1 if the Linux getrandom() syscall is available */ +/* #undef HAVE_GETRANDOM_SYSCALL */ + +/* Define to 1 if you have the `getresgid' function. */ +#define HAVE_GETRESGID 1 + +/* Define to 1 if you have the `getresuid' function. */ +#define HAVE_GETRESUID 1 + +/* Define to 1 if you have the `getsid' function. */ +/* #undef HAVE_GETSID */ + +/* Define to 1 if you have the `getspent' function. */ +/* #undef HAVE_GETSPENT */ + +/* Define to 1 if you have the `getspnam' function. */ +/* #undef HAVE_GETSPNAM */ + +/* Define to 1 if you have the `gettimeofday' function. */ +#define HAVE_GETTIMEOFDAY 1 + +/* Define to 1 if you have the `getwd' function. */ +/* #undef HAVE_GETWD */ + +/* Define if glibc has incorrect _FORTIFY_SOURCE wrappers for memmove and + bcopy. */ +/* #undef HAVE_GLIBC_MEMMOVE_BUG */ + +/* Define to 1 if you have the header file. */ +#define HAVE_GRP_H 1 + +/* Define if you have the 'hstrerror' function. */ +#define HAVE_HSTRERROR 1 + +/* Define this if you have le64toh() */ +#define HAVE_HTOLE64 1 + +/* Define to 1 if you have the `hypot' function. */ +#define HAVE_HYPOT 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_IEEEFP_H */ + +/* Define to 1 if you have the `if_nameindex' function. */ +/* #undef HAVE_IF_NAMEINDEX */ + +/* Define if you have the 'inet_aton' function. */ +#define HAVE_INET_ATON 1 + +/* Define if you have the 'inet_pton' function. */ +#define HAVE_INET_PTON 1 + +/* Define to 1 if you have the `initgroups' function. */ +#define HAVE_INITGROUPS 1 + +/* Define if your compiler provides int32_t. */ +#define HAVE_INT32_T 1 + +/* Define if your compiler provides int64_t. */ +#define HAVE_INT64_T 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_IO_H */ + +/* Define if gcc has the ipa-pure-const bug. */ +/* #undef HAVE_IPA_PURE_CONST_BUG */ + +/* Define to 1 if you have the `kill' function. */ +#define HAVE_KILL 1 + +/* Define to 1 if you have the `killpg' function. */ +#define HAVE_KILLPG 1 + +/* Define if you have the 'kqueue' functions. */ +#define HAVE_KQUEUE 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_LANGINFO_H 1 + +/* Defined to enable large file support when an off_t is bigger than a long + and long long is available and at least as big as an off_t. You may need to + add some flags for configuration and compilation to enable this mode. (For + Solaris and Linux, the necessary defines are already defined.) */ +/* #undef HAVE_LARGEFILE_SUPPORT */ + +/* Define to 1 if you have the 'lchflags' function. */ +/* #undef HAVE_LCHFLAGS */ + +/* Define to 1 if you have the `lchmod' function. */ +/* #undef HAVE_LCHMOD */ + +/* Define to 1 if you have the `lchown' function. */ +#define HAVE_LCHOWN 1 + +/* Define to 1 if you have the `lgamma' function. */ +#define HAVE_LGAMMA 1 + +/* Define to 1 if you have the `dl' library (-ldl). */ +#define HAVE_LIBDL 1 + +/* Define to 1 if you have the `dld' library (-ldld). */ +/* #undef HAVE_LIBDLD */ + +/* Define to 1 if you have the `ieee' library (-lieee). */ +/* #undef HAVE_LIBIEEE */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LIBINTL_H */ + +/* Define if you have the readline library (-lreadline). */ +/* #undef HAVE_LIBREADLINE */ + +/* Define to 1 if you have the `resolv' library (-lresolv). */ +/* #undef HAVE_LIBRESOLV */ + +/* Define to 1 if you have the `sendfile' library (-lsendfile). */ +/* #undef HAVE_LIBSENDFILE */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LIBUTIL_H */ + +/* Define if you have the 'link' function. */ +#define HAVE_LINK 1 + +/* Define to 1 if you have the `linkat' function. */ +/* #undef HAVE_LINKAT */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LINUX_CAN_BCM_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LINUX_CAN_H */ + +/* Define if compiling using Linux 3.6 or later. */ +/* #undef HAVE_LINUX_CAN_RAW_FD_FRAMES */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LINUX_CAN_RAW_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_LINUX_NETLINK_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LINUX_TIPC_H */ + +/* Define to 1 if you have the `lockf' function. */ +#define HAVE_LOCKF 1 + +/* Define to 1 if you have the `log1p' function. */ +#define HAVE_LOG1P 1 + +/* Define to 1 if you have the `log2' function. */ +#define HAVE_LOG2 1 + +/* Define this if you have the type long double. */ +#define HAVE_LONG_DOUBLE 1 + +/* Define this if you have the type long long. */ +#define HAVE_LONG_LONG 1 + +/* Define to 1 if you have the `lstat' function. */ +#define HAVE_LSTAT 1 + +/* Define to 1 if you have the `lutimes' function. */ +/* #undef HAVE_LUTIMES */ + +/* Define this if you have the makedev macro. */ +#define HAVE_MAKEDEV 1 + +/* Define to 1 if you have the `mbrtowc' function. */ +#define HAVE_MBRTOWC 1 + +/* Define to 1 if you have the `memmove' function. */ +#define HAVE_MEMMOVE 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `memrchr' function. */ +#define HAVE_MEMRCHR 1 + +/* Define to 1 if you have the `mkdirat' function. */ +#define HAVE_MKDIRAT 1 + +/* Define to 1 if you have the `mkfifo' function. */ +/* #undef HAVE_MKFIFO */ + +/* Define to 1 if you have the `mkfifoat' function. */ +/* #undef HAVE_MKFIFOAT */ + +/* Define to 1 if you have the `mknod' function. */ +#define HAVE_MKNOD 1 + +/* Define to 1 if you have the `mknodat' function. */ +/* #undef HAVE_MKNODAT */ + +/* Define to 1 if you have the `mktime' function. */ +#define HAVE_MKTIME 1 + +/* Define to 1 if you have the `mmap' function. */ +#define HAVE_MMAP 1 + +/* Define to 1 if you have the `mremap' function. */ +#define HAVE_MREMAP 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NCURSES_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. */ +/* #undef HAVE_NDIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_NETPACKET_PACKET_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_NET_IF_H 1 + +/* Define to 1 if you have the `nice' function. */ +#define HAVE_NICE 1 + +/* Define to 1 if you have the `openat' function. */ +#define HAVE_OPENAT 1 + +/* Define to 1 if you have the `openpty' function. */ +/* #undef HAVE_OPENPTY */ + +/* Define if compiling using MacOS X 10.5 SDK or later. */ +/* #undef HAVE_OSX105_SDK */ + +/* Define to 1 if you have the `pathconf' function. */ +#define HAVE_PATHCONF 1 + +/* Define to 1 if you have the `pause' function. */ +#define HAVE_PAUSE 1 + +/* Define to 1 if you have the `pipe2' function. */ +#define HAVE_PIPE2 1 + +/* Define to 1 if you have the `plock' function. */ +/* #undef HAVE_PLOCK */ + +/* Define to 1 if you have the `poll' function. */ +#define HAVE_POLL 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_POLL_H 1 + +/* Define to 1 if you have the `posix_fadvise' function. */ +#define HAVE_POSIX_FADVISE 1 + +/* Define to 1 if you have the `posix_fallocate' function. */ +#define HAVE_POSIX_FALLOCATE 1 + +/* Define to 1 if you have the `pread' function. */ +#define HAVE_PREAD 1 + +/* Define if you have the 'prlimit' functions. */ +/* #undef HAVE_PRLIMIT */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PROCESS_H */ + +/* Define if your compiler supports function prototype */ +#define HAVE_PROTOTYPES 1 + +/* Define to 1 if you have the `pthread_atfork' function. */ +/* #undef HAVE_PTHREAD_ATFORK */ + +/* Defined for Solaris 2.6 bug in pthread header. */ +/* #undef HAVE_PTHREAD_DESTRUCTOR */ + +/* Define to 1 if you have the header file. */ +#define HAVE_PTHREAD_H 1 + +/* Define to 1 if you have the `pthread_init' function. */ +/* #undef HAVE_PTHREAD_INIT */ + +/* Define to 1 if you have the `pthread_kill' function. */ +#define HAVE_PTHREAD_KILL 1 + +/* Define to 1 if you have the `pthread_sigmask' function. */ +#define HAVE_PTHREAD_SIGMASK 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PTY_H */ + +/* Define to 1 if you have the `putenv' function. */ +#define HAVE_PUTENV 1 + +/* Define to 1 if you have the `pwrite' function. */ +#define HAVE_PWRITE 1 + +/* Define if the libcrypto has RAND_egd */ +/* #undef HAVE_RAND_EGD */ + +/* Define to 1 if you have the `readlink' function. */ +#define HAVE_READLINK 1 + +/* Define to 1 if you have the `readlinkat' function. */ +/* #undef HAVE_READLINKAT */ + +/* Define to 1 if you have the `readv' function. */ +#define HAVE_READV 1 + +/* Define to 1 if you have the `realpath' function. */ +#define HAVE_REALPATH 1 + +/* Define to 1 if you have the `renameat' function. */ +#define HAVE_RENAMEAT 1 + +/* Define if readline supports append_history */ +/* #undef HAVE_RL_APPEND_HISTORY */ + +/* Define if you have readline 2.1 */ +/* #undef HAVE_RL_CALLBACK */ + +/* Define if you can turn off readline's signal handling. */ +/* #undef HAVE_RL_CATCH_SIGNAL */ + +/* Define if you have readline 2.2 */ +/* #undef HAVE_RL_COMPLETION_APPEND_CHARACTER */ + +/* Define if you have readline 4.0 */ +/* #undef HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK */ + +/* Define if you have readline 4.2 */ +/* #undef HAVE_RL_COMPLETION_MATCHES */ + +/* Define if you have rl_completion_suppress_append */ +/* #undef HAVE_RL_COMPLETION_SUPPRESS_APPEND */ + +/* Define if you have readline 4.0 */ +/* #undef HAVE_RL_PRE_INPUT_HOOK */ + +/* Define to 1 if you have the `round' function. */ +#define HAVE_ROUND 1 + +/* Define to 1 if you have the `sched_get_priority_max' function. */ +#define HAVE_SCHED_GET_PRIORITY_MAX 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SCHED_H 1 + +/* Define to 1 if you have the `sched_rr_get_interval' function. */ +#define HAVE_SCHED_RR_GET_INTERVAL 1 + +/* Define to 1 if you have the `sched_setaffinity' function. */ +#define HAVE_SCHED_SETAFFINITY 1 + +/* Define to 1 if you have the `sched_setparam' function. */ +#define HAVE_SCHED_SETPARAM 1 + +/* Define to 1 if you have the `sched_setscheduler' function. */ +#define HAVE_SCHED_SETSCHEDULER 1 + +/* Define to 1 if you have the `select' function. */ +#define HAVE_SELECT 1 + +/* Define to 1 if you have the `sem_getvalue' function. */ +#define HAVE_SEM_GETVALUE 1 + +/* Define to 1 if you have the `sem_open' function. */ +#define HAVE_SEM_OPEN 1 + +/* Define to 1 if you have the `sem_timedwait' function. */ +#define HAVE_SEM_TIMEDWAIT 1 + +/* Define to 1 if you have the `sem_unlink' function. */ +#define HAVE_SEM_UNLINK 1 + +/* Define to 1 if you have the `sendfile' function. */ +#define HAVE_SENDFILE 1 + +/* Define to 1 if you have the `setegid' function. */ +#define HAVE_SETEGID 1 + +/* Define to 1 if you have the `seteuid' function. */ +#define HAVE_SETEUID 1 + +/* Define to 1 if you have the `setgid' function. */ +#define HAVE_SETGID 1 + +/* Define if you have the 'setgroups' function. */ +#define HAVE_SETGROUPS 1 + +/* Define to 1 if you have the `sethostname' function. */ +/* #undef HAVE_SETHOSTNAME */ + +/* Define to 1 if you have the `setitimer' function. */ +#define HAVE_SETITIMER 1 + +/* Define to 1 if you have the `setlocale' function. */ +#define HAVE_SETLOCALE 1 + +/* Define to 1 if you have the `setpgid' function. */ +#define HAVE_SETPGID 1 + +/* Define to 1 if you have the `setpgrp' function. */ +#define HAVE_SETPGRP 1 + +/* Define to 1 if you have the `setpriority' function. */ +#define HAVE_SETPRIORITY 1 + +/* Define to 1 if you have the `setregid' function. */ +#define HAVE_SETREGID 1 + +/* Define to 1 if you have the `setresgid' function. */ +#define HAVE_SETRESGID 1 + +/* Define to 1 if you have the `setresuid' function. */ +#define HAVE_SETRESUID 1 + +/* Define to 1 if you have the `setreuid' function. */ +#define HAVE_SETREUID 1 + +/* Define to 1 if you have the `setsid' function. */ +#define HAVE_SETSID 1 + +/* Define to 1 if you have the `setuid' function. */ +#define HAVE_SETUID 1 + +/* Define to 1 if you have the `setvbuf' function. */ +#define HAVE_SETVBUF 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SHADOW_H */ + +/* Define to 1 if you have the `sigaction' function. */ +#define HAVE_SIGACTION 1 + +/* Define to 1 if you have the `sigaltstack' function. */ +#define HAVE_SIGALTSTACK 1 + +/* Define to 1 if you have the `siginterrupt' function. */ +#define HAVE_SIGINTERRUPT 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SIGNAL_H 1 + +/* Define to 1 if you have the `sigpending' function. */ +#define HAVE_SIGPENDING 1 + +/* Define to 1 if you have the `sigrelse' function. */ +/* #undef HAVE_SIGRELSE */ + +/* Define to 1 if you have the `sigtimedwait' function. */ +/* #undef HAVE_SIGTIMEDWAIT */ + +/* Define to 1 if you have the `sigwait' function. */ +#define HAVE_SIGWAIT 1 + +/* Define to 1 if you have the `sigwaitinfo' function. */ +/* #undef HAVE_SIGWAITINFO */ + +/* Define to 1 if you have the `snprintf' function. */ +#define HAVE_SNPRINTF 1 + +/* Define if sockaddr has sa_len member */ +/* #undef HAVE_SOCKADDR_SA_LEN */ + +/* struct sockaddr_storage (sys/socket.h) */ +#define HAVE_SOCKADDR_STORAGE 1 + +/* Define if you have the 'socketpair' function. */ +#define HAVE_SOCKETPAIR 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SPAWN_H */ + +/* Define if your compiler provides ssize_t */ +#define HAVE_SSIZE_T 1 + +/* Define to 1 if you have the `statvfs' function. */ +/* #undef HAVE_STATVFS */ + +/* Define if you have struct stat.st_mtim.tv_nsec */ +/* #undef HAVE_STAT_TV_NSEC */ + +/* Define if you have struct stat.st_mtimensec */ +/* #undef HAVE_STAT_TV_NSEC2 */ + +/* Define if your compiler supports variable length function prototypes (e.g. + void fprintf(FILE *, char *, ...);) *and* */ +#define HAVE_STDARG_PROTOTYPES 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Has stdatomic.h, atomic_int and _Atomic void* types work */ +#define HAVE_STD_ATOMIC 1 + +/* Define to 1 if you have the `strdup' function. */ +#define HAVE_STRDUP 1 + +/* Define to 1 if you have the `strftime' function. */ +#define HAVE_STRFTIME 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the `strlcpy' function. */ +#define HAVE_STRLCPY 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_STROPTS_H */ + +/* Define to 1 if `st_birthtime' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_BIRTHTIME */ + +/* Define to 1 if `st_blksize' is a member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_BLKSIZE 1 + +/* Define to 1 if `st_blocks' is a member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_BLOCKS 1 + +/* Define to 1 if `st_flags' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_FLAGS */ + +/* Define to 1 if `st_gen' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_GEN */ + +/* Define to 1 if `st_rdev' is a member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_RDEV 1 + +/* Define to 1 if `tm_zone' is a member of `struct tm'. */ +#define HAVE_STRUCT_TM_TM_ZONE 1 + +/* Define to 1 if your `struct stat' has `st_blocks'. Deprecated, use + `HAVE_STRUCT_STAT_ST_BLOCKS' instead. */ +#define HAVE_ST_BLOCKS 1 + +/* Define if you have the 'symlink' function. */ +#define HAVE_SYMLINK 1 + +/* Define to 1 if you have the `symlinkat' function. */ +/* #undef HAVE_SYMLINKAT */ + +/* Define to 1 if you have the `sync' function. */ +#define HAVE_SYNC 1 + +/* Define to 1 if you have the `sysconf' function. */ +#define HAVE_SYSCONF 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYSEXITS_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_AUDIOIO_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_BSDTTY_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_DEVPOLL_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +/* #undef HAVE_SYS_DIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_ENDIAN_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_EPOLL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_EVENT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_FILE_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_IOCTL_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_KERN_CONTROL_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_LOADAVG_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_LOCK_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_MKDEV_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_MODEM_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +/* #undef HAVE_SYS_NDIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_PARAM_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_POLL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_RESOURCE_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SELECT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SENDFILE_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SOCKET_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_STATVFS_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SYSCALL_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_SYS_DOMAIN_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_TERMIO_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIMES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UIO_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UN_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UTSNAME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_WAIT_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_XATTR_H */ + +/* Define to 1 if you have the `tcgetpgrp' function. */ +#define HAVE_TCGETPGRP 1 + +/* Define to 1 if you have the `tcsetpgrp' function. */ +#define HAVE_TCSETPGRP 1 + +/* Define to 1 if you have the `tempnam' function. */ +#define HAVE_TEMPNAM 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_TERMIOS_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_TERM_H */ + +/* Define to 1 if you have the `tgamma' function. */ +#define HAVE_TGAMMA 1 + +/* Define to 1 if you have the `timegm' function. */ +/* #undef HAVE_TIMEGM */ + +/* Define to 1 if you have the `times' function. */ +#define HAVE_TIMES 1 + +/* Define to 1 if you have the `tmpfile' function. */ +#define HAVE_TMPFILE 1 + +/* Define to 1 if you have the `tmpnam' function. */ +#define HAVE_TMPNAM 1 + +/* Define to 1 if you have the `tmpnam_r' function. */ +/* #undef HAVE_TMPNAM_R */ + +/* Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use + `HAVE_STRUCT_TM_TM_ZONE' instead. */ +#define HAVE_TM_ZONE 1 + +/* Define to 1 if you have the `truncate' function. */ +#define HAVE_TRUNCATE 1 + +/* Define to 1 if you don't have `tm_zone' but do have the external array + `tzname'. */ +/* #undef HAVE_TZNAME */ + +/* Define this if you have tcl and TCL_UTF_MAX==6 */ +/* #undef HAVE_UCS4_TCL */ + +/* Define if your compiler provides uint32_t. */ +#define HAVE_UINT32_T 1 + +/* Define if your compiler provides uint64_t. */ +#define HAVE_UINT64_T 1 + +/* Define to 1 if the system has the type `uintptr_t'. */ +#define HAVE_UINTPTR_T 1 + +/* Define to 1 if you have the `uname' function. */ +#define HAVE_UNAME 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you have the `unlinkat' function. */ +#define HAVE_UNLINKAT 1 + +/* Define to 1 if you have the `unsetenv' function. */ +#define HAVE_UNSETENV 1 + +/* Define if you have a useable wchar_t type defined in wchar.h; useable means + wchar_t must be an unsigned type with at least 16 bits. (see + Include/unicodeobject.h). */ +/* #undef HAVE_USABLE_WCHAR_T */ + +/* Define to 1 if you have the header file. */ +#define HAVE_UTIL_H 1 + +/* Define to 1 if you have the `utimensat' function. */ +/* #undef HAVE_UTIMENSAT */ + +/* Define to 1 if you have the `utimes' function. */ +#define HAVE_UTIMES 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UTIME_H 1 + +/* Define to 1 if you have the `wait3' function. */ +#define HAVE_WAIT3 1 + +/* Define to 1 if you have the `wait4' function. */ +/* #undef HAVE_WAIT4 */ + +/* Define to 1 if you have the `waitid' function. */ +#define HAVE_WAITID 1 + +/* Define to 1 if you have the `waitpid' function. */ +#define HAVE_WAITPID 1 + +/* Define if the compiler provides a wchar.h header file. */ +#define HAVE_WCHAR_H 1 + +/* Define to 1 if you have the `wcscoll' function. */ +#define HAVE_WCSCOLL 1 + +/* Define to 1 if you have the `wcsftime' function. */ +#define HAVE_WCSFTIME 1 + +/* Define to 1 if you have the `wcsxfrm' function. */ +#define HAVE_WCSXFRM 1 + +/* Define to 1 if you have the `wmemcmp' function. */ +#define HAVE_WMEMCMP 1 + +/* Define if tzset() actually switches the local timezone in a meaningful way. + */ +/* #undef HAVE_WORKING_TZSET */ + +/* Define to 1 if you have the `writev' function. */ +#define HAVE_WRITEV 1 + +/* Define if the zlib library has inflateCopy */ +#define HAVE_ZLIB_COPY 1 + +/* Define to 1 if you have the `_getpty' function. */ +/* #undef HAVE__GETPTY */ + +/* Define if log1p(-0.) is 0. rather than -0. */ +/* #undef LOG1P_DROPS_ZERO_SIGN */ + +/* Define to 1 if `major', `minor', and `makedev' are declared in . + */ +/* #undef MAJOR_IN_MKDEV */ + +/* Define to 1 if `major', `minor', and `makedev' are declared in + . */ +#define MAJOR_IN_SYSMACROS 1 + +/* Define if mvwdelch in curses.h is an expression. */ +/* #undef MVWDELCH_IS_EXPRESSION */ + +/* Define to the address where bug reports for this package should be sent. */ +/* #undef PACKAGE_BUGREPORT */ + +/* Define to the full name of this package. */ +/* #undef PACKAGE_NAME */ + +/* Define to the full name and version of this package. */ +/* #undef PACKAGE_STRING */ + +/* Define to the one symbol short name of this package. */ +/* #undef PACKAGE_TARNAME */ + +/* Define to the home page for this package. */ +/* #undef PACKAGE_URL */ + +/* Define to the version of this package. */ +/* #undef PACKAGE_VERSION */ + +/* Define if POSIX semaphores aren't enabled on your system */ +/* #undef POSIX_SEMAPHORES_NOT_ENABLED */ + +/* Defined if PTHREAD_SCOPE_SYSTEM supported. */ +/* #undef PTHREAD_SYSTEM_SCHED_SUPPORTED */ + +/* Define as the preferred size in bits of long digits */ +/* #undef PYLONG_BITS_IN_DIGIT */ + +/* Define to printf format modifier for long long type */ +#define PY_FORMAT_LONG_LONG "ll" + +/* Define to printf format modifier for Py_ssize_t */ +#define PY_FORMAT_SIZE_T "z" + +/* Define if you want to build an interpreter with many run-time checks. */ +/* #undef Py_DEBUG */ + +/* Defined if Python is built as a shared library. */ +#define Py_ENABLE_SHARED 1 + +/* Define hash algorithm for str, bytes and memoryview. SipHash24: 1, FNV: 2, + externally defined: 0 */ +/* #undef Py_HASH_ALGORITHM */ + +/* assume C89 semantics that RETSIGTYPE is always void */ +#define RETSIGTYPE void + +/* Define if setpgrp() must be called as setpgrp(0, 0). */ +/* #undef SETPGRP_HAVE_ARG */ + +/* Define if i>>j for signed int i does not extend the sign bit when i < 0 */ +/* #undef SIGNED_RIGHT_SHIFT_ZERO_FILLS */ + +/* The size of `double', as computed by sizeof. */ +#define SIZEOF_DOUBLE 8 + +/* The size of `float', as computed by sizeof. */ +#define SIZEOF_FLOAT 4 + +/* The size of `fpos_t', as computed by sizeof. */ +#define SIZEOF_FPOS_T 4 + +/* The size of `int', as computed by sizeof. */ +#define SIZEOF_INT 4 + +/* The size of `long', as computed by sizeof. */ +#define SIZEOF_LONG 4 + +/* The size of `long double', as computed by sizeof. */ +#define SIZEOF_LONG_DOUBLE 8 + +/* The size of `long long', as computed by sizeof. */ +#define SIZEOF_LONG_LONG 8 + +/* The size of `off_t', as computed by sizeof. */ +#define SIZEOF_OFF_T 4 + +/* The size of `pid_t', as computed by sizeof. */ +#define SIZEOF_PID_T 4 + +/* The size of `pthread_t', as computed by sizeof. */ +#define SIZEOF_PTHREAD_T 4 + +/* The size of `short', as computed by sizeof. */ +#define SIZEOF_SHORT 2 + +/* The size of `size_t', as computed by sizeof. */ +#define SIZEOF_SIZE_T 4 + +/* The size of `time_t', as computed by sizeof. */ +#define SIZEOF_TIME_T 4 + +/* The size of `uintptr_t', as computed by sizeof. */ +#define SIZEOF_UINTPTR_T 4 + +/* The size of `void *', as computed by sizeof. */ +#define SIZEOF_VOID_P 4 + +/* The size of `wchar_t', as computed by sizeof. */ +#define SIZEOF_WCHAR_T 4 + +/* The size of `_Bool', as computed by sizeof. */ +#define SIZEOF__BOOL 1 + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define if you can safely include both and + (which you can't on SCO ODT 3.0). */ +#define SYS_SELECT_WITH_SYS_TIME 1 + +/* Define if tanh(-0.) is -0., or if platform doesn't have signed zeros */ +/* #undef TANH_PRESERVES_ZERO_SIGN */ + +/* Library needed by timemodule.c: librt may be needed for clock_gettime() */ +/* #undef TIMEMODULE_LIB */ + +/* Define to 1 if you can safely include both and . */ +#define TIME_WITH_SYS_TIME 1 + +/* Define to 1 if your declares `struct tm'. */ +/* #undef TM_IN_SYS_TIME */ + +/* Define if you want to use computed gotos in ceval.c. */ +#define USE_COMPUTED_GOTOS 1 + +/* Define to use the C99 inline keyword. */ +#define USE_INLINE 1 + +/* Enable extensions on AIX 3, Interix. */ +#ifndef _ALL_SOURCE +# define _ALL_SOURCE 1 +#endif +/* Enable GNU extensions on systems that have them. */ +#ifndef _GNU_SOURCE +# define _GNU_SOURCE 1 +#endif +/* Enable threading extensions on Solaris. */ +#ifndef _POSIX_PTHREAD_SEMANTICS +# define _POSIX_PTHREAD_SEMANTICS 1 +#endif +/* Enable extensions on HP NonStop. */ +#ifndef _TANDEM_SOURCE +# define _TANDEM_SOURCE 1 +#endif +/* Enable general extensions on Solaris. */ +#ifndef __EXTENSIONS__ +# define __EXTENSIONS__ 1 +#endif + + +/* Define if a va_list is an array of some kind */ +/* #undef VA_LIST_IS_ARRAY */ + +/* Define if you want SIGFPE handled (see Include/pyfpe.h). */ +/* #undef WANT_SIGFPE_HANDLER */ + +/* Define if WINDOW in curses.h offers a field _flags. */ +/* #undef WINDOW_HAS_FLAGS */ + +/* Define if you want documentation strings in extension modules */ +#define WITH_DOC_STRINGS 1 + +/* Define if you want to use the new-style (Openstep, Rhapsody, MacOS) dynamic + linker (dyld) instead of the old-style (NextStep) dynamic linker (rld). + Dyld is necessary to support frameworks. */ +/* #undef WITH_DYLD */ + +/* Define to 1 if libintl is needed for locale functions. */ +/* #undef WITH_LIBINTL */ + +/* Define if you want to produce an OpenStep/Rhapsody framework (shared + library plus accessory files). */ +/* #undef WITH_NEXT_FRAMEWORK */ + +/* Define if you want to compile in Python-specific mallocs */ +#define WITH_PYMALLOC 1 + +/* Define if you want to compile in rudimentary thread support */ +#define WITH_THREAD 1 + +/* Define to profile with the Pentium timestamp counter */ +/* #undef WITH_TSC */ + +/* Define if you want pymalloc to be disabled when running under valgrind */ +/* #undef WITH_VALGRIND */ + +/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most + significant byte first (like Motorola and SPARC, unlike Intel). */ +#if defined AC_APPLE_UNIVERSAL_BUILD +# if defined __BIG_ENDIAN__ +# define WORDS_BIGENDIAN 1 +# endif +#else +# ifndef WORDS_BIGENDIAN +/* # undef WORDS_BIGENDIAN */ +# endif +#endif + +/* Define if arithmetic is subject to x87-style double rounding issue */ +/* #undef X87_DOUBLE_ROUNDING */ + +/* Define on OpenBSD to activate all library features */ +/* #undef _BSD_SOURCE */ + +/* Define on Irix to enable u_int */ +#define _BSD_TYPES 1 + +/* Define on Darwin to activate all library features */ +#define _DARWIN_C_SOURCE 1 + +/* This must be set to 64 on some systems to enable large file support. */ +#define _FILE_OFFSET_BITS 64 + +/* Define on Linux to activate all library features */ +#define _GNU_SOURCE 1 + +/* Define to include mbstate_t for mbrtowc */ +/* #undef _INCLUDE__STDC_A1_SOURCE */ + +/* This must be defined on some systems to enable large file support. */ +#define _LARGEFILE_SOURCE 1 + +/* This must be defined on AIX systems to enable large file support. */ +/* #undef _LARGE_FILES */ + +/* Define to 1 if on MINIX. */ +/* #undef _MINIX */ + +/* Define on NetBSD to activate all library features */ +#define _NETBSD_SOURCE 1 + +/* Define to 2 if the system does not provide POSIX.1 features except with + this defined. */ +/* #undef _POSIX_1_SOURCE */ + +/* Define to activate features from IEEE Stds 1003.1-2008 */ +#define _POSIX_C_SOURCE 200809L + +/* Define to 1 if you need to in order for `stat' and other things to work. */ +/* #undef _POSIX_SOURCE */ + +/* Define if you have POSIX threads, and your system does not define that. */ +/* #undef _POSIX_THREADS */ + +/* Define to force use of thread-safe errno, h_errno, and other functions */ +#define _REENTRANT 1 + +/* Define for Solaris 2.5.1 so the uint32_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +/* #undef _UINT32_T */ + +/* Define for Solaris 2.5.1 so the uint64_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +/* #undef _UINT64_T */ + +/* Define to the level of X/Open that your system supports */ +#define _XOPEN_SOURCE 700 + +/* Define to activate Unix95-and-earlier features */ +#define _XOPEN_SOURCE_EXTENDED 1 + +/* Define on FreeBSD to activate all library features */ +#define __BSD_VISIBLE 1 + +/* Define to 1 if type `char' is unsigned and you are not using gcc. */ +#ifndef __CHAR_UNSIGNED__ +/* # undef __CHAR_UNSIGNED__ */ +#endif + +/* Define to 'long' if doesn't define. */ +/* #undef clock_t */ + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ + +/* Define to `int' if doesn't define. */ +/* #undef gid_t */ + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +/* #undef inline */ +#endif + +/* Define to the type of a signed integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +/* #undef int32_t */ + +/* Define to the type of a signed integer type of width exactly 64 bits if + such a type exists and the standard includes do not define it. */ +/* #undef int64_t */ + +/* Define to `int' if does not define. */ +/* #undef mode_t */ + +/* Define to `long int' if does not define. */ +/* #undef off_t */ + +/* Define to `int' if does not define. */ +/* #undef pid_t */ + +/* Define to empty if the keyword does not work. */ +/* #undef signed */ + +/* Define to `unsigned int' if does not define. */ +/* #undef size_t */ + +/* Define to `int' if does not define. */ +/* #undef socklen_t */ + +/* Define to `int' if doesn't define. */ +/* #undef uid_t */ + +/* Define to the type of an unsigned integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint32_t */ + +/* Define to the type of an unsigned integer type of width exactly 64 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint64_t */ + +/* Define to empty if the keyword does not work. */ +/* #undef volatile */ + + +/* Define the macros needed if on a UnixWare 7.x system. */ +#if defined(__USLC__) && defined(__SCO_VERSION__) +#define STRICT_SYSV_CURSES /* Don't use ncurses extensions */ +#endif + +#endif /*Py_PYCONFIG_H*/ + diff --git a/android/python35/include/pyconfig_mips.h b/android/python35/include/pyconfig_mips.h new file mode 100644 index 000000000..ac47e6204 --- /dev/null +++ b/android/python35/include/pyconfig_mips.h @@ -0,0 +1,1530 @@ +/* pyconfig.h. Generated from pyconfig.h.in by configure. */ +/* pyconfig.h.in. Generated from configure.ac by autoheader. */ + + +#ifndef Py_PYCONFIG_H +#define Py_PYCONFIG_H + + +/* Define if building universal (internal helper macro) */ +/* #undef AC_APPLE_UNIVERSAL_BUILD */ + +/* Define for AIX if your compiler is a genuine IBM xlC/xlC_r and you want + support for AIX C++ shared extension modules. */ +/* #undef AIX_GENUINE_CPLUSPLUS */ + +/* Define if C doubles are 64-bit IEEE 754 binary format, stored in ARM + mixed-endian order (byte order 45670123) */ +/* #undef DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754 */ + +/* Define if C doubles are 64-bit IEEE 754 binary format, stored with the most + significant byte first */ +/* #undef DOUBLE_IS_BIG_ENDIAN_IEEE754 */ + +/* Define if C doubles are 64-bit IEEE 754 binary format, stored with the + least significant byte first */ +/* #undef DOUBLE_IS_LITTLE_ENDIAN_IEEE754 */ + +/* Define if --enable-ipv6 is specified */ +#define ENABLE_IPV6 1 + +/* Define if flock needs to be linked with bsd library. */ +/* #undef FLOCK_NEEDS_LIBBSD */ + +/* Define if getpgrp() must be called as getpgrp(0). */ +/* #undef GETPGRP_HAVE_ARG */ + +/* Define if gettimeofday() does not have second (timezone) argument This is + the case on Motorola V4 (R40V4.2) */ +/* #undef GETTIMEOFDAY_NO_TZ */ + +/* Define to 1 if you have the `accept4' function. */ +/* #undef HAVE_ACCEPT4 */ + +/* Define to 1 if you have the `acosh' function. */ +#define HAVE_ACOSH 1 + +/* struct addrinfo (netdb.h) */ +#define HAVE_ADDRINFO 1 + +/* Define to 1 if you have the `alarm' function. */ +#define HAVE_ALARM 1 + +/* Define if aligned memory access is required */ +#define HAVE_ALIGNED_REQUIRED 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ALLOCA_H 1 + +/* Define this if your time.h defines altzone. */ +/* #undef HAVE_ALTZONE */ + +/* Define to 1 if you have the `asinh' function. */ +#define HAVE_ASINH 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ASM_TYPES_H 1 + +/* Define to 1 if you have the `atanh' function. */ +#define HAVE_ATANH 1 + +/* Define to 1 if you have the `bind_textdomain_codeset' function. */ +/* #undef HAVE_BIND_TEXTDOMAIN_CODESET */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_BLUETOOTH_BLUETOOTH_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_BLUETOOTH_H */ + +/* Define if mbstowcs(NULL, "text", 0) does not return the number of wide + chars that would be converted. */ +/* #undef HAVE_BROKEN_MBSTOWCS */ + +/* Define if nice() returns success/failure instead of the new priority. */ +/* #undef HAVE_BROKEN_NICE */ + +/* Define if the system reports an invalid PIPE_BUF value. */ +/* #undef HAVE_BROKEN_PIPE_BUF */ + +/* Define if poll() sets errno on invalid file descriptors. */ +/* #undef HAVE_BROKEN_POLL */ + +/* Define if the Posix semaphores do not work on your system */ +/* #undef HAVE_BROKEN_POSIX_SEMAPHORES */ + +/* Define if pthread_sigmask() does not work on your system. */ +/* #undef HAVE_BROKEN_PTHREAD_SIGMASK */ + +/* define to 1 if your sem_getvalue is broken. */ +#define HAVE_BROKEN_SEM_GETVALUE 1 + +/* Define if `unsetenv` does not return an int. */ +/* #undef HAVE_BROKEN_UNSETENV */ + +/* Has builtin atomics */ +#define HAVE_BUILTIN_ATOMIC 1 + +/* Define this if you have the type _Bool. */ +#define HAVE_C99_BOOL 1 + +/* Define to 1 if you have the 'chflags' function. */ +/* #undef HAVE_CHFLAGS */ + +/* Define to 1 if you have the `chown' function. */ +#define HAVE_CHOWN 1 + +/* Define if you have the 'chroot' function. */ +#define HAVE_CHROOT 1 + +/* Define to 1 if you have the `clock' function. */ +#define HAVE_CLOCK 1 + +/* Define to 1 if you have the `clock_getres' function. */ +#define HAVE_CLOCK_GETRES 1 + +/* Define to 1 if you have the `clock_gettime' function. */ +#define HAVE_CLOCK_GETTIME 1 + +/* Define if the C compiler supports computed gotos. */ +#define HAVE_COMPUTED_GOTOS 1 + +/* Define to 1 if you have the `confstr' function. */ +/* #undef HAVE_CONFSTR */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_CONIO_H */ + +/* Define to 1 if you have the `copysign' function. */ +#define HAVE_COPYSIGN 1 + +/* Define to 1 if you have the `ctermid' function. */ +/* #undef HAVE_CTERMID */ + +/* Define if you have the 'ctermid_r' function. */ +#define HAVE_CTERMID_R 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_CURSES_H */ + +/* Define if you have the 'is_term_resized' function. */ +/* #undef HAVE_CURSES_IS_TERM_RESIZED */ + +/* Define if you have the 'resizeterm' function. */ +/* #undef HAVE_CURSES_RESIZETERM */ + +/* Define if you have the 'resize_term' function. */ +/* #undef HAVE_CURSES_RESIZE_TERM */ + +/* Define to 1 if you have the declaration of `isfinite', and to 0 if you + don't. */ +#define HAVE_DECL_ISFINITE 1 + +/* Define to 1 if you have the declaration of `isinf', and to 0 if you don't. + */ +#define HAVE_DECL_ISINF 1 + +/* Define to 1 if you have the declaration of `isnan', and to 0 if you don't. + */ +#define HAVE_DECL_ISNAN 1 + +/* Define to 1 if you have the declaration of `tzname', and to 0 if you don't. + */ +/* #undef HAVE_DECL_TZNAME */ + +/* Define to 1 if you have the device macros. */ +#define HAVE_DEVICE_MACROS 1 + +/* Define to 1 if you have the /dev/ptc device file. */ +/* #undef HAVE_DEV_PTC */ + +/* Define to 1 if you have the /dev/ptmx device file. */ +/* #undef HAVE_DEV_PTMX */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_DIRECT_H */ + +/* Define to 1 if the dirent structure has a d_type field */ +#define HAVE_DIRENT_D_TYPE 1 + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#define HAVE_DIRENT_H 1 + +/* Define if you have the 'dirfd' function or macro. */ +#define HAVE_DIRFD 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_DLFCN_H 1 + +/* Define to 1 if you have the `dlopen' function. */ +#define HAVE_DLOPEN 1 + +/* Define to 1 if you have the `dup2' function. */ +#define HAVE_DUP2 1 + +/* Define to 1 if you have the `dup3' function. */ +/* #undef HAVE_DUP3 */ + +/* Defined when any dynamic module loading is enabled. */ +#define HAVE_DYNAMIC_LOADING 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ENDIAN_H 1 + +/* Define if you have the 'epoll' functions. */ +#define HAVE_EPOLL 1 + +/* Define if you have the 'epoll_create1' function. */ +/* #undef HAVE_EPOLL_CREATE1 */ + +/* Define to 1 if you have the `erf' function. */ +#define HAVE_ERF 1 + +/* Define to 1 if you have the `erfc' function. */ +#define HAVE_ERFC 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ERRNO_H 1 + +/* Define to 1 if you have the `execv' function. */ +#define HAVE_EXECV 1 + +/* Define to 1 if you have the `expm1' function. */ +#define HAVE_EXPM1 1 + +/* Define to 1 if you have the `faccessat' function. */ +/* #undef HAVE_FACCESSAT */ + +/* Define if you have the 'fchdir' function. */ +#define HAVE_FCHDIR 1 + +/* Define to 1 if you have the `fchmod' function. */ +#define HAVE_FCHMOD 1 + +/* Define to 1 if you have the `fchmodat' function. */ +#define HAVE_FCHMODAT 1 + +/* Define to 1 if you have the `fchown' function. */ +#define HAVE_FCHOWN 1 + +/* Define to 1 if you have the `fchownat' function. */ +#define HAVE_FCHOWNAT 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* Define if you have the 'fdatasync' function. */ +#define HAVE_FDATASYNC 1 + +/* Define to 1 if you have the `fdopendir' function. */ +#define HAVE_FDOPENDIR 1 + +/* Define to 1 if you have the `fexecve' function. */ +/* #undef HAVE_FEXECVE */ + +/* Define to 1 if you have the `finite' function. */ +#define HAVE_FINITE 1 + +/* Define to 1 if you have the `flock' function. */ +#define HAVE_FLOCK 1 + +/* Define to 1 if you have the `fork' function. */ +#define HAVE_FORK 1 + +/* Define to 1 if you have the `forkpty' function. */ +/* #undef HAVE_FORKPTY */ + +/* Define to 1 if you have the `fpathconf' function. */ +#define HAVE_FPATHCONF 1 + +/* Define to 1 if you have the `fseek64' function. */ +/* #undef HAVE_FSEEK64 */ + +/* Define to 1 if you have the `fseeko' function. */ +#define HAVE_FSEEKO 1 + +/* Define to 1 if you have the `fstatat' function. */ +#define HAVE_FSTATAT 1 + +/* Define to 1 if you have the `fstatvfs' function. */ +/* #undef HAVE_FSTATVFS */ + +/* Define if you have the 'fsync' function. */ +#define HAVE_FSYNC 1 + +/* Define to 1 if you have the `ftell64' function. */ +/* #undef HAVE_FTELL64 */ + +/* Define to 1 if you have the `ftello' function. */ +#define HAVE_FTELLO 1 + +/* Define to 1 if you have the `ftime' function. */ +#define HAVE_FTIME 1 + +/* Define to 1 if you have the `ftruncate' function. */ +#define HAVE_FTRUNCATE 1 + +/* Define to 1 if you have the `futimens' function. */ +/* #undef HAVE_FUTIMENS */ + +/* Define to 1 if you have the `futimes' function. */ +/* #undef HAVE_FUTIMES */ + +/* Define to 1 if you have the `futimesat' function. */ +/* #undef HAVE_FUTIMESAT */ + +/* Define to 1 if you have the `gai_strerror' function. */ +#define HAVE_GAI_STRERROR 1 + +/* Define to 1 if you have the `gamma' function. */ +/* #undef HAVE_GAMMA */ + +/* Define if we can use gcc inline assembler to get and set mc68881 fpcr */ +/* #undef HAVE_GCC_ASM_FOR_MC68881 */ + +/* Define if we can use x64 gcc inline assembler */ +/* #undef HAVE_GCC_ASM_FOR_X64 */ + +/* Define if we can use gcc inline assembler to get and set x87 control word + */ +/* #undef HAVE_GCC_ASM_FOR_X87 */ + +/* Define if your compiler provides __uint128_t */ +/* #undef HAVE_GCC_UINT128_T */ + +/* Define if you have the getaddrinfo function. */ +#define HAVE_GETADDRINFO 1 + +/* Define this if you have flockfile(), getc_unlocked(), and funlockfile() */ +#define HAVE_GETC_UNLOCKED 1 + +/* Define to 1 if you have the `getentropy' function. */ +/* #undef HAVE_GETENTROPY */ + +/* Define to 1 if you have the `getgrouplist' function. */ +#define HAVE_GETGROUPLIST 1 + +/* Define to 1 if you have the `getgroups' function. */ +#define HAVE_GETGROUPS 1 + +/* Define to 1 if you have the `gethostbyname' function. */ +#define HAVE_GETHOSTBYNAME 1 + +/* Define this if you have some version of gethostbyname_r() */ +/* #undef HAVE_GETHOSTBYNAME_R */ + +/* Define this if you have the 3-arg version of gethostbyname_r(). */ +/* #undef HAVE_GETHOSTBYNAME_R_3_ARG */ + +/* Define this if you have the 5-arg version of gethostbyname_r(). */ +/* #undef HAVE_GETHOSTBYNAME_R_5_ARG */ + +/* Define this if you have the 6-arg version of gethostbyname_r(). */ +/* #undef HAVE_GETHOSTBYNAME_R_6_ARG */ + +/* Define to 1 if you have the `getitimer' function. */ +#define HAVE_GETITIMER 1 + +/* Define to 1 if you have the `getloadavg' function. */ +#define HAVE_GETLOADAVG 1 + +/* Define to 1 if you have the `getlogin' function. */ +#define HAVE_GETLOGIN 1 + +/* Define to 1 if you have the `getnameinfo' function. */ +#define HAVE_GETNAMEINFO 1 + +/* Define if you have the 'getpagesize' function. */ +#define HAVE_GETPAGESIZE 1 + +/* Define to 1 if you have the `getpeername' function. */ +#define HAVE_GETPEERNAME 1 + +/* Define to 1 if you have the `getpgid' function. */ +#define HAVE_GETPGID 1 + +/* Define to 1 if you have the `getpgrp' function. */ +#define HAVE_GETPGRP 1 + +/* Define to 1 if you have the `getpid' function. */ +#define HAVE_GETPID 1 + +/* Define to 1 if you have the `getpriority' function. */ +#define HAVE_GETPRIORITY 1 + +/* Define to 1 if you have the `getpwent' function. */ +#define HAVE_GETPWENT 1 + +/* Define to 1 if the Linux getrandom() syscall is available */ +/* #undef HAVE_GETRANDOM_SYSCALL */ + +/* Define to 1 if you have the `getresgid' function. */ +#define HAVE_GETRESGID 1 + +/* Define to 1 if you have the `getresuid' function. */ +#define HAVE_GETRESUID 1 + +/* Define to 1 if you have the `getsid' function. */ +/* #undef HAVE_GETSID */ + +/* Define to 1 if you have the `getspent' function. */ +/* #undef HAVE_GETSPENT */ + +/* Define to 1 if you have the `getspnam' function. */ +/* #undef HAVE_GETSPNAM */ + +/* Define to 1 if you have the `gettimeofday' function. */ +#define HAVE_GETTIMEOFDAY 1 + +/* Define to 1 if you have the `getwd' function. */ +/* #undef HAVE_GETWD */ + +/* Define if glibc has incorrect _FORTIFY_SOURCE wrappers for memmove and + bcopy. */ +/* #undef HAVE_GLIBC_MEMMOVE_BUG */ + +/* Define to 1 if you have the header file. */ +#define HAVE_GRP_H 1 + +/* Define if you have the 'hstrerror' function. */ +#define HAVE_HSTRERROR 1 + +/* Define this if you have le64toh() */ +#define HAVE_HTOLE64 1 + +/* Define to 1 if you have the `hypot' function. */ +#define HAVE_HYPOT 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_IEEEFP_H */ + +/* Define to 1 if you have the `if_nameindex' function. */ +/* #undef HAVE_IF_NAMEINDEX */ + +/* Define if you have the 'inet_aton' function. */ +#define HAVE_INET_ATON 1 + +/* Define if you have the 'inet_pton' function. */ +#define HAVE_INET_PTON 1 + +/* Define to 1 if you have the `initgroups' function. */ +#define HAVE_INITGROUPS 1 + +/* Define if your compiler provides int32_t. */ +#define HAVE_INT32_T 1 + +/* Define if your compiler provides int64_t. */ +#define HAVE_INT64_T 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_IO_H */ + +/* Define if gcc has the ipa-pure-const bug. */ +/* #undef HAVE_IPA_PURE_CONST_BUG */ + +/* Define to 1 if you have the `kill' function. */ +#define HAVE_KILL 1 + +/* Define to 1 if you have the `killpg' function. */ +#define HAVE_KILLPG 1 + +/* Define if you have the 'kqueue' functions. */ +#define HAVE_KQUEUE 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_LANGINFO_H 1 + +/* Defined to enable large file support when an off_t is bigger than a long + and long long is available and at least as big as an off_t. You may need to + add some flags for configuration and compilation to enable this mode. (For + Solaris and Linux, the necessary defines are already defined.) */ +/* #undef HAVE_LARGEFILE_SUPPORT */ + +/* Define to 1 if you have the 'lchflags' function. */ +/* #undef HAVE_LCHFLAGS */ + +/* Define to 1 if you have the `lchmod' function. */ +/* #undef HAVE_LCHMOD */ + +/* Define to 1 if you have the `lchown' function. */ +#define HAVE_LCHOWN 1 + +/* Define to 1 if you have the `lgamma' function. */ +#define HAVE_LGAMMA 1 + +/* Define to 1 if you have the `dl' library (-ldl). */ +#define HAVE_LIBDL 1 + +/* Define to 1 if you have the `dld' library (-ldld). */ +/* #undef HAVE_LIBDLD */ + +/* Define to 1 if you have the `ieee' library (-lieee). */ +/* #undef HAVE_LIBIEEE */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LIBINTL_H */ + +/* Define if you have the readline library (-lreadline). */ +/* #undef HAVE_LIBREADLINE */ + +/* Define to 1 if you have the `resolv' library (-lresolv). */ +/* #undef HAVE_LIBRESOLV */ + +/* Define to 1 if you have the `sendfile' library (-lsendfile). */ +/* #undef HAVE_LIBSENDFILE */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LIBUTIL_H */ + +/* Define if you have the 'link' function. */ +#define HAVE_LINK 1 + +/* Define to 1 if you have the `linkat' function. */ +/* #undef HAVE_LINKAT */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LINUX_CAN_BCM_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LINUX_CAN_H */ + +/* Define if compiling using Linux 3.6 or later. */ +/* #undef HAVE_LINUX_CAN_RAW_FD_FRAMES */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LINUX_CAN_RAW_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_LINUX_NETLINK_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LINUX_TIPC_H */ + +/* Define to 1 if you have the `lockf' function. */ +#define HAVE_LOCKF 1 + +/* Define to 1 if you have the `log1p' function. */ +#define HAVE_LOG1P 1 + +/* Define to 1 if you have the `log2' function. */ +#define HAVE_LOG2 1 + +/* Define this if you have the type long double. */ +#define HAVE_LONG_DOUBLE 1 + +/* Define this if you have the type long long. */ +#define HAVE_LONG_LONG 1 + +/* Define to 1 if you have the `lstat' function. */ +#define HAVE_LSTAT 1 + +/* Define to 1 if you have the `lutimes' function. */ +/* #undef HAVE_LUTIMES */ + +/* Define this if you have the makedev macro. */ +#define HAVE_MAKEDEV 1 + +/* Define to 1 if you have the `mbrtowc' function. */ +#define HAVE_MBRTOWC 1 + +/* Define to 1 if you have the `memmove' function. */ +#define HAVE_MEMMOVE 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `memrchr' function. */ +#define HAVE_MEMRCHR 1 + +/* Define to 1 if you have the `mkdirat' function. */ +#define HAVE_MKDIRAT 1 + +/* Define to 1 if you have the `mkfifo' function. */ +/* #undef HAVE_MKFIFO */ + +/* Define to 1 if you have the `mkfifoat' function. */ +/* #undef HAVE_MKFIFOAT */ + +/* Define to 1 if you have the `mknod' function. */ +#define HAVE_MKNOD 1 + +/* Define to 1 if you have the `mknodat' function. */ +/* #undef HAVE_MKNODAT */ + +/* Define to 1 if you have the `mktime' function. */ +#define HAVE_MKTIME 1 + +/* Define to 1 if you have the `mmap' function. */ +#define HAVE_MMAP 1 + +/* Define to 1 if you have the `mremap' function. */ +#define HAVE_MREMAP 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NCURSES_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. */ +/* #undef HAVE_NDIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_NETPACKET_PACKET_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_NET_IF_H 1 + +/* Define to 1 if you have the `nice' function. */ +#define HAVE_NICE 1 + +/* Define to 1 if you have the `openat' function. */ +#define HAVE_OPENAT 1 + +/* Define to 1 if you have the `openpty' function. */ +/* #undef HAVE_OPENPTY */ + +/* Define if compiling using MacOS X 10.5 SDK or later. */ +/* #undef HAVE_OSX105_SDK */ + +/* Define to 1 if you have the `pathconf' function. */ +#define HAVE_PATHCONF 1 + +/* Define to 1 if you have the `pause' function. */ +#define HAVE_PAUSE 1 + +/* Define to 1 if you have the `pipe2' function. */ +#define HAVE_PIPE2 1 + +/* Define to 1 if you have the `plock' function. */ +/* #undef HAVE_PLOCK */ + +/* Define to 1 if you have the `poll' function. */ +#define HAVE_POLL 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_POLL_H 1 + +/* Define to 1 if you have the `posix_fadvise' function. */ +#define HAVE_POSIX_FADVISE 1 + +/* Define to 1 if you have the `posix_fallocate' function. */ +#define HAVE_POSIX_FALLOCATE 1 + +/* Define to 1 if you have the `pread' function. */ +#define HAVE_PREAD 1 + +/* Define if you have the 'prlimit' functions. */ +/* #undef HAVE_PRLIMIT */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PROCESS_H */ + +/* Define if your compiler supports function prototype */ +#define HAVE_PROTOTYPES 1 + +/* Define to 1 if you have the `pthread_atfork' function. */ +/* #undef HAVE_PTHREAD_ATFORK */ + +/* Defined for Solaris 2.6 bug in pthread header. */ +/* #undef HAVE_PTHREAD_DESTRUCTOR */ + +/* Define to 1 if you have the header file. */ +#define HAVE_PTHREAD_H 1 + +/* Define to 1 if you have the `pthread_init' function. */ +/* #undef HAVE_PTHREAD_INIT */ + +/* Define to 1 if you have the `pthread_kill' function. */ +#define HAVE_PTHREAD_KILL 1 + +/* Define to 1 if you have the `pthread_sigmask' function. */ +#define HAVE_PTHREAD_SIGMASK 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PTY_H */ + +/* Define to 1 if you have the `putenv' function. */ +#define HAVE_PUTENV 1 + +/* Define to 1 if you have the `pwrite' function. */ +#define HAVE_PWRITE 1 + +/* Define if the libcrypto has RAND_egd */ +/* #undef HAVE_RAND_EGD */ + +/* Define to 1 if you have the `readlink' function. */ +#define HAVE_READLINK 1 + +/* Define to 1 if you have the `readlinkat' function. */ +/* #undef HAVE_READLINKAT */ + +/* Define to 1 if you have the `readv' function. */ +#define HAVE_READV 1 + +/* Define to 1 if you have the `realpath' function. */ +#define HAVE_REALPATH 1 + +/* Define to 1 if you have the `renameat' function. */ +#define HAVE_RENAMEAT 1 + +/* Define if readline supports append_history */ +/* #undef HAVE_RL_APPEND_HISTORY */ + +/* Define if you have readline 2.1 */ +/* #undef HAVE_RL_CALLBACK */ + +/* Define if you can turn off readline's signal handling. */ +/* #undef HAVE_RL_CATCH_SIGNAL */ + +/* Define if you have readline 2.2 */ +/* #undef HAVE_RL_COMPLETION_APPEND_CHARACTER */ + +/* Define if you have readline 4.0 */ +/* #undef HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK */ + +/* Define if you have readline 4.2 */ +/* #undef HAVE_RL_COMPLETION_MATCHES */ + +/* Define if you have rl_completion_suppress_append */ +/* #undef HAVE_RL_COMPLETION_SUPPRESS_APPEND */ + +/* Define if you have readline 4.0 */ +/* #undef HAVE_RL_PRE_INPUT_HOOK */ + +/* Define to 1 if you have the `round' function. */ +#define HAVE_ROUND 1 + +/* Define to 1 if you have the `sched_get_priority_max' function. */ +#define HAVE_SCHED_GET_PRIORITY_MAX 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SCHED_H 1 + +/* Define to 1 if you have the `sched_rr_get_interval' function. */ +#define HAVE_SCHED_RR_GET_INTERVAL 1 + +/* Define to 1 if you have the `sched_setaffinity' function. */ +#define HAVE_SCHED_SETAFFINITY 1 + +/* Define to 1 if you have the `sched_setparam' function. */ +#define HAVE_SCHED_SETPARAM 1 + +/* Define to 1 if you have the `sched_setscheduler' function. */ +#define HAVE_SCHED_SETSCHEDULER 1 + +/* Define to 1 if you have the `select' function. */ +#define HAVE_SELECT 1 + +/* Define to 1 if you have the `sem_getvalue' function. */ +#define HAVE_SEM_GETVALUE 1 + +/* Define to 1 if you have the `sem_open' function. */ +#define HAVE_SEM_OPEN 1 + +/* Define to 1 if you have the `sem_timedwait' function. */ +#define HAVE_SEM_TIMEDWAIT 1 + +/* Define to 1 if you have the `sem_unlink' function. */ +#define HAVE_SEM_UNLINK 1 + +/* Define to 1 if you have the `sendfile' function. */ +#define HAVE_SENDFILE 1 + +/* Define to 1 if you have the `setegid' function. */ +#define HAVE_SETEGID 1 + +/* Define to 1 if you have the `seteuid' function. */ +#define HAVE_SETEUID 1 + +/* Define to 1 if you have the `setgid' function. */ +#define HAVE_SETGID 1 + +/* Define if you have the 'setgroups' function. */ +#define HAVE_SETGROUPS 1 + +/* Define to 1 if you have the `sethostname' function. */ +/* #undef HAVE_SETHOSTNAME */ + +/* Define to 1 if you have the `setitimer' function. */ +#define HAVE_SETITIMER 1 + +/* Define to 1 if you have the `setlocale' function. */ +#define HAVE_SETLOCALE 1 + +/* Define to 1 if you have the `setpgid' function. */ +#define HAVE_SETPGID 1 + +/* Define to 1 if you have the `setpgrp' function. */ +#define HAVE_SETPGRP 1 + +/* Define to 1 if you have the `setpriority' function. */ +#define HAVE_SETPRIORITY 1 + +/* Define to 1 if you have the `setregid' function. */ +#define HAVE_SETREGID 1 + +/* Define to 1 if you have the `setresgid' function. */ +#define HAVE_SETRESGID 1 + +/* Define to 1 if you have the `setresuid' function. */ +#define HAVE_SETRESUID 1 + +/* Define to 1 if you have the `setreuid' function. */ +#define HAVE_SETREUID 1 + +/* Define to 1 if you have the `setsid' function. */ +#define HAVE_SETSID 1 + +/* Define to 1 if you have the `setuid' function. */ +#define HAVE_SETUID 1 + +/* Define to 1 if you have the `setvbuf' function. */ +#define HAVE_SETVBUF 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SHADOW_H */ + +/* Define to 1 if you have the `sigaction' function. */ +#define HAVE_SIGACTION 1 + +/* Define to 1 if you have the `sigaltstack' function. */ +#define HAVE_SIGALTSTACK 1 + +/* Define to 1 if you have the `siginterrupt' function. */ +#define HAVE_SIGINTERRUPT 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SIGNAL_H 1 + +/* Define to 1 if you have the `sigpending' function. */ +#define HAVE_SIGPENDING 1 + +/* Define to 1 if you have the `sigrelse' function. */ +/* #undef HAVE_SIGRELSE */ + +/* Define to 1 if you have the `sigtimedwait' function. */ +/* #undef HAVE_SIGTIMEDWAIT */ + +/* Define to 1 if you have the `sigwait' function. */ +#define HAVE_SIGWAIT 1 + +/* Define to 1 if you have the `sigwaitinfo' function. */ +/* #undef HAVE_SIGWAITINFO */ + +/* Define to 1 if you have the `snprintf' function. */ +#define HAVE_SNPRINTF 1 + +/* Define if sockaddr has sa_len member */ +/* #undef HAVE_SOCKADDR_SA_LEN */ + +/* struct sockaddr_storage (sys/socket.h) */ +#define HAVE_SOCKADDR_STORAGE 1 + +/* Define if you have the 'socketpair' function. */ +#define HAVE_SOCKETPAIR 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SPAWN_H */ + +/* Define if your compiler provides ssize_t */ +#define HAVE_SSIZE_T 1 + +/* Define to 1 if you have the `statvfs' function. */ +/* #undef HAVE_STATVFS */ + +/* Define if you have struct stat.st_mtim.tv_nsec */ +/* #undef HAVE_STAT_TV_NSEC */ + +/* Define if you have struct stat.st_mtimensec */ +/* #undef HAVE_STAT_TV_NSEC2 */ + +/* Define if your compiler supports variable length function prototypes (e.g. + void fprintf(FILE *, char *, ...);) *and* */ +#define HAVE_STDARG_PROTOTYPES 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Has stdatomic.h, atomic_int and _Atomic void* types work */ +#define HAVE_STD_ATOMIC 1 + +/* Define to 1 if you have the `strdup' function. */ +#define HAVE_STRDUP 1 + +/* Define to 1 if you have the `strftime' function. */ +#define HAVE_STRFTIME 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the `strlcpy' function. */ +#define HAVE_STRLCPY 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_STROPTS_H */ + +/* Define to 1 if `st_birthtime' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_BIRTHTIME */ + +/* Define to 1 if `st_blksize' is a member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_BLKSIZE 1 + +/* Define to 1 if `st_blocks' is a member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_BLOCKS 1 + +/* Define to 1 if `st_flags' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_FLAGS */ + +/* Define to 1 if `st_gen' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_GEN */ + +/* Define to 1 if `st_rdev' is a member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_RDEV 1 + +/* Define to 1 if `tm_zone' is a member of `struct tm'. */ +#define HAVE_STRUCT_TM_TM_ZONE 1 + +/* Define to 1 if your `struct stat' has `st_blocks'. Deprecated, use + `HAVE_STRUCT_STAT_ST_BLOCKS' instead. */ +#define HAVE_ST_BLOCKS 1 + +/* Define if you have the 'symlink' function. */ +#define HAVE_SYMLINK 1 + +/* Define to 1 if you have the `symlinkat' function. */ +/* #undef HAVE_SYMLINKAT */ + +/* Define to 1 if you have the `sync' function. */ +#define HAVE_SYNC 1 + +/* Define to 1 if you have the `sysconf' function. */ +#define HAVE_SYSCONF 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYSEXITS_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_AUDIOIO_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_BSDTTY_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_DEVPOLL_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +/* #undef HAVE_SYS_DIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_ENDIAN_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_EPOLL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_EVENT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_FILE_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_IOCTL_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_KERN_CONTROL_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_LOADAVG_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_LOCK_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_MKDEV_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_MODEM_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +/* #undef HAVE_SYS_NDIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_PARAM_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_POLL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_RESOURCE_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SELECT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SENDFILE_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SOCKET_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_STATVFS_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SYSCALL_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_SYS_DOMAIN_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_TERMIO_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIMES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UIO_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UN_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UTSNAME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_WAIT_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_XATTR_H */ + +/* Define to 1 if you have the `tcgetpgrp' function. */ +#define HAVE_TCGETPGRP 1 + +/* Define to 1 if you have the `tcsetpgrp' function. */ +#define HAVE_TCSETPGRP 1 + +/* Define to 1 if you have the `tempnam' function. */ +#define HAVE_TEMPNAM 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_TERMIOS_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_TERM_H */ + +/* Define to 1 if you have the `tgamma' function. */ +#define HAVE_TGAMMA 1 + +/* Define to 1 if you have the `timegm' function. */ +/* #undef HAVE_TIMEGM */ + +/* Define to 1 if you have the `times' function. */ +#define HAVE_TIMES 1 + +/* Define to 1 if you have the `tmpfile' function. */ +#define HAVE_TMPFILE 1 + +/* Define to 1 if you have the `tmpnam' function. */ +#define HAVE_TMPNAM 1 + +/* Define to 1 if you have the `tmpnam_r' function. */ +/* #undef HAVE_TMPNAM_R */ + +/* Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use + `HAVE_STRUCT_TM_TM_ZONE' instead. */ +#define HAVE_TM_ZONE 1 + +/* Define to 1 if you have the `truncate' function. */ +#define HAVE_TRUNCATE 1 + +/* Define to 1 if you don't have `tm_zone' but do have the external array + `tzname'. */ +/* #undef HAVE_TZNAME */ + +/* Define this if you have tcl and TCL_UTF_MAX==6 */ +/* #undef HAVE_UCS4_TCL */ + +/* Define if your compiler provides uint32_t. */ +#define HAVE_UINT32_T 1 + +/* Define if your compiler provides uint64_t. */ +#define HAVE_UINT64_T 1 + +/* Define to 1 if the system has the type `uintptr_t'. */ +#define HAVE_UINTPTR_T 1 + +/* Define to 1 if you have the `uname' function. */ +#define HAVE_UNAME 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you have the `unlinkat' function. */ +#define HAVE_UNLINKAT 1 + +/* Define to 1 if you have the `unsetenv' function. */ +#define HAVE_UNSETENV 1 + +/* Define if you have a useable wchar_t type defined in wchar.h; useable means + wchar_t must be an unsigned type with at least 16 bits. (see + Include/unicodeobject.h). */ +/* #undef HAVE_USABLE_WCHAR_T */ + +/* Define to 1 if you have the header file. */ +#define HAVE_UTIL_H 1 + +/* Define to 1 if you have the `utimensat' function. */ +/* #undef HAVE_UTIMENSAT */ + +/* Define to 1 if you have the `utimes' function. */ +#define HAVE_UTIMES 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UTIME_H 1 + +/* Define to 1 if you have the `wait3' function. */ +#define HAVE_WAIT3 1 + +/* Define to 1 if you have the `wait4' function. */ +/* #undef HAVE_WAIT4 */ + +/* Define to 1 if you have the `waitid' function. */ +#define HAVE_WAITID 1 + +/* Define to 1 if you have the `waitpid' function. */ +#define HAVE_WAITPID 1 + +/* Define if the compiler provides a wchar.h header file. */ +#define HAVE_WCHAR_H 1 + +/* Define to 1 if you have the `wcscoll' function. */ +#define HAVE_WCSCOLL 1 + +/* Define to 1 if you have the `wcsftime' function. */ +#define HAVE_WCSFTIME 1 + +/* Define to 1 if you have the `wcsxfrm' function. */ +#define HAVE_WCSXFRM 1 + +/* Define to 1 if you have the `wmemcmp' function. */ +#define HAVE_WMEMCMP 1 + +/* Define if tzset() actually switches the local timezone in a meaningful way. + */ +/* #undef HAVE_WORKING_TZSET */ + +/* Define to 1 if you have the `writev' function. */ +#define HAVE_WRITEV 1 + +/* Define if the zlib library has inflateCopy */ +#define HAVE_ZLIB_COPY 1 + +/* Define to 1 if you have the `_getpty' function. */ +/* #undef HAVE__GETPTY */ + +/* Define if log1p(-0.) is 0. rather than -0. */ +/* #undef LOG1P_DROPS_ZERO_SIGN */ + +/* Define to 1 if `major', `minor', and `makedev' are declared in . + */ +/* #undef MAJOR_IN_MKDEV */ + +/* Define to 1 if `major', `minor', and `makedev' are declared in + . */ +#define MAJOR_IN_SYSMACROS 1 + +/* Define if mvwdelch in curses.h is an expression. */ +/* #undef MVWDELCH_IS_EXPRESSION */ + +/* Define to the address where bug reports for this package should be sent. */ +/* #undef PACKAGE_BUGREPORT */ + +/* Define to the full name of this package. */ +/* #undef PACKAGE_NAME */ + +/* Define to the full name and version of this package. */ +/* #undef PACKAGE_STRING */ + +/* Define to the one symbol short name of this package. */ +/* #undef PACKAGE_TARNAME */ + +/* Define to the home page for this package. */ +/* #undef PACKAGE_URL */ + +/* Define to the version of this package. */ +/* #undef PACKAGE_VERSION */ + +/* Define if POSIX semaphores aren't enabled on your system */ +/* #undef POSIX_SEMAPHORES_NOT_ENABLED */ + +/* Defined if PTHREAD_SCOPE_SYSTEM supported. */ +/* #undef PTHREAD_SYSTEM_SCHED_SUPPORTED */ + +/* Define as the preferred size in bits of long digits */ +/* #undef PYLONG_BITS_IN_DIGIT */ + +/* Define to printf format modifier for long long type */ +#define PY_FORMAT_LONG_LONG "ll" + +/* Define to printf format modifier for Py_ssize_t */ +#define PY_FORMAT_SIZE_T "z" + +/* Define if you want to build an interpreter with many run-time checks. */ +/* #undef Py_DEBUG */ + +/* Defined if Python is built as a shared library. */ +#define Py_ENABLE_SHARED 1 + +/* Define hash algorithm for str, bytes and memoryview. SipHash24: 1, FNV: 2, + externally defined: 0 */ +/* #undef Py_HASH_ALGORITHM */ + +/* assume C89 semantics that RETSIGTYPE is always void */ +#define RETSIGTYPE void + +/* Define if setpgrp() must be called as setpgrp(0, 0). */ +/* #undef SETPGRP_HAVE_ARG */ + +/* Define if i>>j for signed int i does not extend the sign bit when i < 0 */ +/* #undef SIGNED_RIGHT_SHIFT_ZERO_FILLS */ + +/* The size of `double', as computed by sizeof. */ +#define SIZEOF_DOUBLE 8 + +/* The size of `float', as computed by sizeof. */ +#define SIZEOF_FLOAT 4 + +/* The size of `fpos_t', as computed by sizeof. */ +#define SIZEOF_FPOS_T 4 + +/* The size of `int', as computed by sizeof. */ +#define SIZEOF_INT 4 + +/* The size of `long', as computed by sizeof. */ +#define SIZEOF_LONG 4 + +/* The size of `long double', as computed by sizeof. */ +#define SIZEOF_LONG_DOUBLE 8 + +/* The size of `long long', as computed by sizeof. */ +#define SIZEOF_LONG_LONG 8 + +/* The size of `off_t', as computed by sizeof. */ +#define SIZEOF_OFF_T 4 + +/* The size of `pid_t', as computed by sizeof. */ +#define SIZEOF_PID_T 4 + +/* The size of `pthread_t', as computed by sizeof. */ +#define SIZEOF_PTHREAD_T 4 + +/* The size of `short', as computed by sizeof. */ +#define SIZEOF_SHORT 2 + +/* The size of `size_t', as computed by sizeof. */ +#define SIZEOF_SIZE_T 4 + +/* The size of `time_t', as computed by sizeof. */ +#define SIZEOF_TIME_T 4 + +/* The size of `uintptr_t', as computed by sizeof. */ +#define SIZEOF_UINTPTR_T 4 + +/* The size of `void *', as computed by sizeof. */ +#define SIZEOF_VOID_P 4 + +/* The size of `wchar_t', as computed by sizeof. */ +#define SIZEOF_WCHAR_T 4 + +/* The size of `_Bool', as computed by sizeof. */ +#define SIZEOF__BOOL 1 + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define if you can safely include both and + (which you can't on SCO ODT 3.0). */ +#define SYS_SELECT_WITH_SYS_TIME 1 + +/* Define if tanh(-0.) is -0., or if platform doesn't have signed zeros */ +/* #undef TANH_PRESERVES_ZERO_SIGN */ + +/* Library needed by timemodule.c: librt may be needed for clock_gettime() */ +/* #undef TIMEMODULE_LIB */ + +/* Define to 1 if you can safely include both and . */ +#define TIME_WITH_SYS_TIME 1 + +/* Define to 1 if your declares `struct tm'. */ +/* #undef TM_IN_SYS_TIME */ + +/* Define if you want to use computed gotos in ceval.c. */ +#define USE_COMPUTED_GOTOS 1 + +/* Define to use the C99 inline keyword. */ +#define USE_INLINE 1 + +/* Enable extensions on AIX 3, Interix. */ +#ifndef _ALL_SOURCE +# define _ALL_SOURCE 1 +#endif +/* Enable GNU extensions on systems that have them. */ +#ifndef _GNU_SOURCE +# define _GNU_SOURCE 1 +#endif +/* Enable threading extensions on Solaris. */ +#ifndef _POSIX_PTHREAD_SEMANTICS +# define _POSIX_PTHREAD_SEMANTICS 1 +#endif +/* Enable extensions on HP NonStop. */ +#ifndef _TANDEM_SOURCE +# define _TANDEM_SOURCE 1 +#endif +/* Enable general extensions on Solaris. */ +#ifndef __EXTENSIONS__ +# define __EXTENSIONS__ 1 +#endif + + +/* Define if a va_list is an array of some kind */ +/* #undef VA_LIST_IS_ARRAY */ + +/* Define if you want SIGFPE handled (see Include/pyfpe.h). */ +/* #undef WANT_SIGFPE_HANDLER */ + +/* Define if WINDOW in curses.h offers a field _flags. */ +/* #undef WINDOW_HAS_FLAGS */ + +/* Define if you want documentation strings in extension modules */ +#define WITH_DOC_STRINGS 1 + +/* Define if you want to use the new-style (Openstep, Rhapsody, MacOS) dynamic + linker (dyld) instead of the old-style (NextStep) dynamic linker (rld). + Dyld is necessary to support frameworks. */ +/* #undef WITH_DYLD */ + +/* Define to 1 if libintl is needed for locale functions. */ +/* #undef WITH_LIBINTL */ + +/* Define if you want to produce an OpenStep/Rhapsody framework (shared + library plus accessory files). */ +/* #undef WITH_NEXT_FRAMEWORK */ + +/* Define if you want to compile in Python-specific mallocs */ +#define WITH_PYMALLOC 1 + +/* Define if you want to compile in rudimentary thread support */ +#define WITH_THREAD 1 + +/* Define to profile with the Pentium timestamp counter */ +/* #undef WITH_TSC */ + +/* Define if you want pymalloc to be disabled when running under valgrind */ +/* #undef WITH_VALGRIND */ + +/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most + significant byte first (like Motorola and SPARC, unlike Intel). */ +#if defined AC_APPLE_UNIVERSAL_BUILD +# if defined __BIG_ENDIAN__ +# define WORDS_BIGENDIAN 1 +# endif +#else +# ifndef WORDS_BIGENDIAN +/* # undef WORDS_BIGENDIAN */ +# endif +#endif + +/* Define if arithmetic is subject to x87-style double rounding issue */ +/* #undef X87_DOUBLE_ROUNDING */ + +/* Define on OpenBSD to activate all library features */ +/* #undef _BSD_SOURCE */ + +/* Define on Irix to enable u_int */ +#define _BSD_TYPES 1 + +/* Define on Darwin to activate all library features */ +#define _DARWIN_C_SOURCE 1 + +/* This must be set to 64 on some systems to enable large file support. */ +#define _FILE_OFFSET_BITS 64 + +/* Define on Linux to activate all library features */ +#define _GNU_SOURCE 1 + +/* Define to include mbstate_t for mbrtowc */ +/* #undef _INCLUDE__STDC_A1_SOURCE */ + +/* This must be defined on some systems to enable large file support. */ +#define _LARGEFILE_SOURCE 1 + +/* This must be defined on AIX systems to enable large file support. */ +/* #undef _LARGE_FILES */ + +/* Define to 1 if on MINIX. */ +/* #undef _MINIX */ + +/* Define on NetBSD to activate all library features */ +#define _NETBSD_SOURCE 1 + +/* Define to 2 if the system does not provide POSIX.1 features except with + this defined. */ +/* #undef _POSIX_1_SOURCE */ + +/* Define to activate features from IEEE Stds 1003.1-2008 */ +#define _POSIX_C_SOURCE 200809L + +/* Define to 1 if you need to in order for `stat' and other things to work. */ +/* #undef _POSIX_SOURCE */ + +/* Define if you have POSIX threads, and your system does not define that. */ +/* #undef _POSIX_THREADS */ + +/* Define to force use of thread-safe errno, h_errno, and other functions */ +#define _REENTRANT 1 + +/* Define for Solaris 2.5.1 so the uint32_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +/* #undef _UINT32_T */ + +/* Define for Solaris 2.5.1 so the uint64_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +/* #undef _UINT64_T */ + +/* Define to the level of X/Open that your system supports */ +#define _XOPEN_SOURCE 700 + +/* Define to activate Unix95-and-earlier features */ +#define _XOPEN_SOURCE_EXTENDED 1 + +/* Define on FreeBSD to activate all library features */ +#define __BSD_VISIBLE 1 + +/* Define to 1 if type `char' is unsigned and you are not using gcc. */ +#ifndef __CHAR_UNSIGNED__ +/* # undef __CHAR_UNSIGNED__ */ +#endif + +/* Define to 'long' if doesn't define. */ +/* #undef clock_t */ + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ + +/* Define to `int' if doesn't define. */ +/* #undef gid_t */ + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +/* #undef inline */ +#endif + +/* Define to the type of a signed integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +/* #undef int32_t */ + +/* Define to the type of a signed integer type of width exactly 64 bits if + such a type exists and the standard includes do not define it. */ +/* #undef int64_t */ + +/* Define to `int' if does not define. */ +/* #undef mode_t */ + +/* Define to `long int' if does not define. */ +/* #undef off_t */ + +/* Define to `int' if does not define. */ +/* #undef pid_t */ + +/* Define to empty if the keyword does not work. */ +/* #undef signed */ + +/* Define to `unsigned int' if does not define. */ +/* #undef size_t */ + +/* Define to `int' if does not define. */ +/* #undef socklen_t */ + +/* Define to `int' if doesn't define. */ +/* #undef uid_t */ + +/* Define to the type of an unsigned integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint32_t */ + +/* Define to the type of an unsigned integer type of width exactly 64 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint64_t */ + +/* Define to empty if the keyword does not work. */ +/* #undef volatile */ + + +/* Define the macros needed if on a UnixWare 7.x system. */ +#if defined(__USLC__) && defined(__SCO_VERSION__) +#define STRICT_SYSV_CURSES /* Don't use ncurses extensions */ +#endif + +#endif /*Py_PYCONFIG_H*/ + diff --git a/android/python35/include/pyconfig_mips64.h b/android/python35/include/pyconfig_mips64.h new file mode 100644 index 000000000..be4b1a9d2 --- /dev/null +++ b/android/python35/include/pyconfig_mips64.h @@ -0,0 +1,1530 @@ +/* pyconfig.h. Generated from pyconfig.h.in by configure. */ +/* pyconfig.h.in. Generated from configure.ac by autoheader. */ + + +#ifndef Py_PYCONFIG_H +#define Py_PYCONFIG_H + + +/* Define if building universal (internal helper macro) */ +/* #undef AC_APPLE_UNIVERSAL_BUILD */ + +/* Define for AIX if your compiler is a genuine IBM xlC/xlC_r and you want + support for AIX C++ shared extension modules. */ +/* #undef AIX_GENUINE_CPLUSPLUS */ + +/* Define if C doubles are 64-bit IEEE 754 binary format, stored in ARM + mixed-endian order (byte order 45670123) */ +/* #undef DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754 */ + +/* Define if C doubles are 64-bit IEEE 754 binary format, stored with the most + significant byte first */ +/* #undef DOUBLE_IS_BIG_ENDIAN_IEEE754 */ + +/* Define if C doubles are 64-bit IEEE 754 binary format, stored with the + least significant byte first */ +/* #undef DOUBLE_IS_LITTLE_ENDIAN_IEEE754 */ + +/* Define if --enable-ipv6 is specified */ +#define ENABLE_IPV6 1 + +/* Define if flock needs to be linked with bsd library. */ +/* #undef FLOCK_NEEDS_LIBBSD */ + +/* Define if getpgrp() must be called as getpgrp(0). */ +/* #undef GETPGRP_HAVE_ARG */ + +/* Define if gettimeofday() does not have second (timezone) argument This is + the case on Motorola V4 (R40V4.2) */ +/* #undef GETTIMEOFDAY_NO_TZ */ + +/* Define to 1 if you have the `accept4' function. */ +#define HAVE_ACCEPT4 1 + +/* Define to 1 if you have the `acosh' function. */ +#define HAVE_ACOSH 1 + +/* struct addrinfo (netdb.h) */ +#define HAVE_ADDRINFO 1 + +/* Define to 1 if you have the `alarm' function. */ +#define HAVE_ALARM 1 + +/* Define if aligned memory access is required */ +#define HAVE_ALIGNED_REQUIRED 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ALLOCA_H 1 + +/* Define this if your time.h defines altzone. */ +/* #undef HAVE_ALTZONE */ + +/* Define to 1 if you have the `asinh' function. */ +#define HAVE_ASINH 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ASM_TYPES_H 1 + +/* Define to 1 if you have the `atanh' function. */ +#define HAVE_ATANH 1 + +/* Define to 1 if you have the `bind_textdomain_codeset' function. */ +/* #undef HAVE_BIND_TEXTDOMAIN_CODESET */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_BLUETOOTH_BLUETOOTH_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_BLUETOOTH_H */ + +/* Define if mbstowcs(NULL, "text", 0) does not return the number of wide + chars that would be converted. */ +/* #undef HAVE_BROKEN_MBSTOWCS */ + +/* Define if nice() returns success/failure instead of the new priority. */ +/* #undef HAVE_BROKEN_NICE */ + +/* Define if the system reports an invalid PIPE_BUF value. */ +/* #undef HAVE_BROKEN_PIPE_BUF */ + +/* Define if poll() sets errno on invalid file descriptors. */ +/* #undef HAVE_BROKEN_POLL */ + +/* Define if the Posix semaphores do not work on your system */ +/* #undef HAVE_BROKEN_POSIX_SEMAPHORES */ + +/* Define if pthread_sigmask() does not work on your system. */ +/* #undef HAVE_BROKEN_PTHREAD_SIGMASK */ + +/* define to 1 if your sem_getvalue is broken. */ +#define HAVE_BROKEN_SEM_GETVALUE 1 + +/* Define if `unsetenv` does not return an int. */ +/* #undef HAVE_BROKEN_UNSETENV */ + +/* Has builtin atomics */ +#define HAVE_BUILTIN_ATOMIC 1 + +/* Define this if you have the type _Bool. */ +#define HAVE_C99_BOOL 1 + +/* Define to 1 if you have the 'chflags' function. */ +/* #undef HAVE_CHFLAGS */ + +/* Define to 1 if you have the `chown' function. */ +#define HAVE_CHOWN 1 + +/* Define if you have the 'chroot' function. */ +#define HAVE_CHROOT 1 + +/* Define to 1 if you have the `clock' function. */ +#define HAVE_CLOCK 1 + +/* Define to 1 if you have the `clock_getres' function. */ +#define HAVE_CLOCK_GETRES 1 + +/* Define to 1 if you have the `clock_gettime' function. */ +#define HAVE_CLOCK_GETTIME 1 + +/* Define if the C compiler supports computed gotos. */ +#define HAVE_COMPUTED_GOTOS 1 + +/* Define to 1 if you have the `confstr' function. */ +/* #undef HAVE_CONFSTR */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_CONIO_H */ + +/* Define to 1 if you have the `copysign' function. */ +#define HAVE_COPYSIGN 1 + +/* Define to 1 if you have the `ctermid' function. */ +/* #undef HAVE_CTERMID */ + +/* Define if you have the 'ctermid_r' function. */ +#define HAVE_CTERMID_R 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_CURSES_H */ + +/* Define if you have the 'is_term_resized' function. */ +/* #undef HAVE_CURSES_IS_TERM_RESIZED */ + +/* Define if you have the 'resizeterm' function. */ +/* #undef HAVE_CURSES_RESIZETERM */ + +/* Define if you have the 'resize_term' function. */ +/* #undef HAVE_CURSES_RESIZE_TERM */ + +/* Define to 1 if you have the declaration of `isfinite', and to 0 if you + don't. */ +#define HAVE_DECL_ISFINITE 1 + +/* Define to 1 if you have the declaration of `isinf', and to 0 if you don't. + */ +#define HAVE_DECL_ISINF 1 + +/* Define to 1 if you have the declaration of `isnan', and to 0 if you don't. + */ +#define HAVE_DECL_ISNAN 1 + +/* Define to 1 if you have the declaration of `tzname', and to 0 if you don't. + */ +/* #undef HAVE_DECL_TZNAME */ + +/* Define to 1 if you have the device macros. */ +#define HAVE_DEVICE_MACROS 1 + +/* Define to 1 if you have the /dev/ptc device file. */ +/* #undef HAVE_DEV_PTC */ + +/* Define to 1 if you have the /dev/ptmx device file. */ +/* #undef HAVE_DEV_PTMX */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_DIRECT_H */ + +/* Define to 1 if the dirent structure has a d_type field */ +#define HAVE_DIRENT_D_TYPE 1 + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#define HAVE_DIRENT_H 1 + +/* Define if you have the 'dirfd' function or macro. */ +#define HAVE_DIRFD 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_DLFCN_H 1 + +/* Define to 1 if you have the `dlopen' function. */ +#define HAVE_DLOPEN 1 + +/* Define to 1 if you have the `dup2' function. */ +#define HAVE_DUP2 1 + +/* Define to 1 if you have the `dup3' function. */ +#define HAVE_DUP3 1 + +/* Defined when any dynamic module loading is enabled. */ +#define HAVE_DYNAMIC_LOADING 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ENDIAN_H 1 + +/* Define if you have the 'epoll' functions. */ +#define HAVE_EPOLL 1 + +/* Define if you have the 'epoll_create1' function. */ +#define HAVE_EPOLL_CREATE1 1 + +/* Define to 1 if you have the `erf' function. */ +#define HAVE_ERF 1 + +/* Define to 1 if you have the `erfc' function. */ +#define HAVE_ERFC 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ERRNO_H 1 + +/* Define to 1 if you have the `execv' function. */ +#define HAVE_EXECV 1 + +/* Define to 1 if you have the `expm1' function. */ +#define HAVE_EXPM1 1 + +/* Define to 1 if you have the `faccessat' function. */ +/* #undef HAVE_FACCESSAT */ + +/* Define if you have the 'fchdir' function. */ +#define HAVE_FCHDIR 1 + +/* Define to 1 if you have the `fchmod' function. */ +#define HAVE_FCHMOD 1 + +/* Define to 1 if you have the `fchmodat' function. */ +#define HAVE_FCHMODAT 1 + +/* Define to 1 if you have the `fchown' function. */ +#define HAVE_FCHOWN 1 + +/* Define to 1 if you have the `fchownat' function. */ +#define HAVE_FCHOWNAT 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* Define if you have the 'fdatasync' function. */ +#define HAVE_FDATASYNC 1 + +/* Define to 1 if you have the `fdopendir' function. */ +#define HAVE_FDOPENDIR 1 + +/* Define to 1 if you have the `fexecve' function. */ +/* #undef HAVE_FEXECVE */ + +/* Define to 1 if you have the `finite' function. */ +#define HAVE_FINITE 1 + +/* Define to 1 if you have the `flock' function. */ +#define HAVE_FLOCK 1 + +/* Define to 1 if you have the `fork' function. */ +#define HAVE_FORK 1 + +/* Define to 1 if you have the `forkpty' function. */ +/* #undef HAVE_FORKPTY */ + +/* Define to 1 if you have the `fpathconf' function. */ +#define HAVE_FPATHCONF 1 + +/* Define to 1 if you have the `fseek64' function. */ +/* #undef HAVE_FSEEK64 */ + +/* Define to 1 if you have the `fseeko' function. */ +#define HAVE_FSEEKO 1 + +/* Define to 1 if you have the `fstatat' function. */ +#define HAVE_FSTATAT 1 + +/* Define to 1 if you have the `fstatvfs' function. */ +#define HAVE_FSTATVFS 1 + +/* Define if you have the 'fsync' function. */ +#define HAVE_FSYNC 1 + +/* Define to 1 if you have the `ftell64' function. */ +/* #undef HAVE_FTELL64 */ + +/* Define to 1 if you have the `ftello' function. */ +#define HAVE_FTELLO 1 + +/* Define to 1 if you have the `ftime' function. */ +/* #undef HAVE_FTIME */ + +/* Define to 1 if you have the `ftruncate' function. */ +#define HAVE_FTRUNCATE 1 + +/* Define to 1 if you have the `futimens' function. */ +#define HAVE_FUTIMENS 1 + +/* Define to 1 if you have the `futimes' function. */ +/* #undef HAVE_FUTIMES */ + +/* Define to 1 if you have the `futimesat' function. */ +/* #undef HAVE_FUTIMESAT */ + +/* Define to 1 if you have the `gai_strerror' function. */ +#define HAVE_GAI_STRERROR 1 + +/* Define to 1 if you have the `gamma' function. */ +/* #undef HAVE_GAMMA */ + +/* Define if we can use gcc inline assembler to get and set mc68881 fpcr */ +/* #undef HAVE_GCC_ASM_FOR_MC68881 */ + +/* Define if we can use x64 gcc inline assembler */ +/* #undef HAVE_GCC_ASM_FOR_X64 */ + +/* Define if we can use gcc inline assembler to get and set x87 control word + */ +/* #undef HAVE_GCC_ASM_FOR_X87 */ + +/* Define if your compiler provides __uint128_t */ +#define HAVE_GCC_UINT128_T 1 + +/* Define if you have the getaddrinfo function. */ +#define HAVE_GETADDRINFO 1 + +/* Define this if you have flockfile(), getc_unlocked(), and funlockfile() */ +#define HAVE_GETC_UNLOCKED 1 + +/* Define to 1 if you have the `getentropy' function. */ +/* #undef HAVE_GETENTROPY */ + +/* Define to 1 if you have the `getgrouplist' function. */ +#define HAVE_GETGROUPLIST 1 + +/* Define to 1 if you have the `getgroups' function. */ +#define HAVE_GETGROUPS 1 + +/* Define to 1 if you have the `gethostbyname' function. */ +#define HAVE_GETHOSTBYNAME 1 + +/* Define this if you have some version of gethostbyname_r() */ +/* #undef HAVE_GETHOSTBYNAME_R */ + +/* Define this if you have the 3-arg version of gethostbyname_r(). */ +/* #undef HAVE_GETHOSTBYNAME_R_3_ARG */ + +/* Define this if you have the 5-arg version of gethostbyname_r(). */ +/* #undef HAVE_GETHOSTBYNAME_R_5_ARG */ + +/* Define this if you have the 6-arg version of gethostbyname_r(). */ +/* #undef HAVE_GETHOSTBYNAME_R_6_ARG */ + +/* Define to 1 if you have the `getitimer' function. */ +#define HAVE_GETITIMER 1 + +/* Define to 1 if you have the `getloadavg' function. */ +#define HAVE_GETLOADAVG 1 + +/* Define to 1 if you have the `getlogin' function. */ +#define HAVE_GETLOGIN 1 + +/* Define to 1 if you have the `getnameinfo' function. */ +#define HAVE_GETNAMEINFO 1 + +/* Define if you have the 'getpagesize' function. */ +#define HAVE_GETPAGESIZE 1 + +/* Define to 1 if you have the `getpeername' function. */ +#define HAVE_GETPEERNAME 1 + +/* Define to 1 if you have the `getpgid' function. */ +#define HAVE_GETPGID 1 + +/* Define to 1 if you have the `getpgrp' function. */ +#define HAVE_GETPGRP 1 + +/* Define to 1 if you have the `getpid' function. */ +#define HAVE_GETPID 1 + +/* Define to 1 if you have the `getpriority' function. */ +#define HAVE_GETPRIORITY 1 + +/* Define to 1 if you have the `getpwent' function. */ +#define HAVE_GETPWENT 1 + +/* Define to 1 if the Linux getrandom() syscall is available */ +/* #undef HAVE_GETRANDOM_SYSCALL */ + +/* Define to 1 if you have the `getresgid' function. */ +#define HAVE_GETRESGID 1 + +/* Define to 1 if you have the `getresuid' function. */ +#define HAVE_GETRESUID 1 + +/* Define to 1 if you have the `getsid' function. */ +#define HAVE_GETSID 1 + +/* Define to 1 if you have the `getspent' function. */ +/* #undef HAVE_GETSPENT */ + +/* Define to 1 if you have the `getspnam' function. */ +/* #undef HAVE_GETSPNAM */ + +/* Define to 1 if you have the `gettimeofday' function. */ +#define HAVE_GETTIMEOFDAY 1 + +/* Define to 1 if you have the `getwd' function. */ +/* #undef HAVE_GETWD */ + +/* Define if glibc has incorrect _FORTIFY_SOURCE wrappers for memmove and + bcopy. */ +/* #undef HAVE_GLIBC_MEMMOVE_BUG */ + +/* Define to 1 if you have the header file. */ +#define HAVE_GRP_H 1 + +/* Define if you have the 'hstrerror' function. */ +#define HAVE_HSTRERROR 1 + +/* Define this if you have le64toh() */ +#define HAVE_HTOLE64 1 + +/* Define to 1 if you have the `hypot' function. */ +#define HAVE_HYPOT 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_IEEEFP_H */ + +/* Define to 1 if you have the `if_nameindex' function. */ +/* #undef HAVE_IF_NAMEINDEX */ + +/* Define if you have the 'inet_aton' function. */ +#define HAVE_INET_ATON 1 + +/* Define if you have the 'inet_pton' function. */ +#define HAVE_INET_PTON 1 + +/* Define to 1 if you have the `initgroups' function. */ +#define HAVE_INITGROUPS 1 + +/* Define if your compiler provides int32_t. */ +#define HAVE_INT32_T 1 + +/* Define if your compiler provides int64_t. */ +#define HAVE_INT64_T 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_IO_H */ + +/* Define if gcc has the ipa-pure-const bug. */ +/* #undef HAVE_IPA_PURE_CONST_BUG */ + +/* Define to 1 if you have the `kill' function. */ +#define HAVE_KILL 1 + +/* Define to 1 if you have the `killpg' function. */ +#define HAVE_KILLPG 1 + +/* Define if you have the 'kqueue' functions. */ +#define HAVE_KQUEUE 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_LANGINFO_H 1 + +/* Defined to enable large file support when an off_t is bigger than a long + and long long is available and at least as big as an off_t. You may need to + add some flags for configuration and compilation to enable this mode. (For + Solaris and Linux, the necessary defines are already defined.) */ +/* #undef HAVE_LARGEFILE_SUPPORT */ + +/* Define to 1 if you have the 'lchflags' function. */ +/* #undef HAVE_LCHFLAGS */ + +/* Define to 1 if you have the `lchmod' function. */ +/* #undef HAVE_LCHMOD */ + +/* Define to 1 if you have the `lchown' function. */ +#define HAVE_LCHOWN 1 + +/* Define to 1 if you have the `lgamma' function. */ +#define HAVE_LGAMMA 1 + +/* Define to 1 if you have the `dl' library (-ldl). */ +#define HAVE_LIBDL 1 + +/* Define to 1 if you have the `dld' library (-ldld). */ +/* #undef HAVE_LIBDLD */ + +/* Define to 1 if you have the `ieee' library (-lieee). */ +/* #undef HAVE_LIBIEEE */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LIBINTL_H */ + +/* Define if you have the readline library (-lreadline). */ +/* #undef HAVE_LIBREADLINE */ + +/* Define to 1 if you have the `resolv' library (-lresolv). */ +/* #undef HAVE_LIBRESOLV */ + +/* Define to 1 if you have the `sendfile' library (-lsendfile). */ +/* #undef HAVE_LIBSENDFILE */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LIBUTIL_H */ + +/* Define if you have the 'link' function. */ +#define HAVE_LINK 1 + +/* Define to 1 if you have the `linkat' function. */ +#define HAVE_LINKAT 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LINUX_CAN_BCM_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_LINUX_CAN_H 1 + +/* Define if compiling using Linux 3.6 or later. */ +#define HAVE_LINUX_CAN_RAW_FD_FRAMES 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_LINUX_CAN_RAW_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_LINUX_NETLINK_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_LINUX_TIPC_H 1 + +/* Define to 1 if you have the `lockf' function. */ +#define HAVE_LOCKF 1 + +/* Define to 1 if you have the `log1p' function. */ +#define HAVE_LOG1P 1 + +/* Define to 1 if you have the `log2' function. */ +#define HAVE_LOG2 1 + +/* Define this if you have the type long double. */ +#define HAVE_LONG_DOUBLE 1 + +/* Define this if you have the type long long. */ +#define HAVE_LONG_LONG 1 + +/* Define to 1 if you have the `lstat' function. */ +#define HAVE_LSTAT 1 + +/* Define to 1 if you have the `lutimes' function. */ +/* #undef HAVE_LUTIMES */ + +/* Define this if you have the makedev macro. */ +#define HAVE_MAKEDEV 1 + +/* Define to 1 if you have the `mbrtowc' function. */ +#define HAVE_MBRTOWC 1 + +/* Define to 1 if you have the `memmove' function. */ +#define HAVE_MEMMOVE 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `memrchr' function. */ +#define HAVE_MEMRCHR 1 + +/* Define to 1 if you have the `mkdirat' function. */ +#define HAVE_MKDIRAT 1 + +/* Define to 1 if you have the `mkfifo' function. */ +#define HAVE_MKFIFO 1 + +/* Define to 1 if you have the `mkfifoat' function. */ +/* #undef HAVE_MKFIFOAT */ + +/* Define to 1 if you have the `mknod' function. */ +#define HAVE_MKNOD 1 + +/* Define to 1 if you have the `mknodat' function. */ +#define HAVE_MKNODAT 1 + +/* Define to 1 if you have the `mktime' function. */ +#define HAVE_MKTIME 1 + +/* Define to 1 if you have the `mmap' function. */ +#define HAVE_MMAP 1 + +/* Define to 1 if you have the `mremap' function. */ +#define HAVE_MREMAP 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NCURSES_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. */ +/* #undef HAVE_NDIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_NETPACKET_PACKET_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_NET_IF_H 1 + +/* Define to 1 if you have the `nice' function. */ +#define HAVE_NICE 1 + +/* Define to 1 if you have the `openat' function. */ +#define HAVE_OPENAT 1 + +/* Define to 1 if you have the `openpty' function. */ +/* #undef HAVE_OPENPTY */ + +/* Define if compiling using MacOS X 10.5 SDK or later. */ +/* #undef HAVE_OSX105_SDK */ + +/* Define to 1 if you have the `pathconf' function. */ +#define HAVE_PATHCONF 1 + +/* Define to 1 if you have the `pause' function. */ +#define HAVE_PAUSE 1 + +/* Define to 1 if you have the `pipe2' function. */ +#define HAVE_PIPE2 1 + +/* Define to 1 if you have the `plock' function. */ +/* #undef HAVE_PLOCK */ + +/* Define to 1 if you have the `poll' function. */ +#define HAVE_POLL 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_POLL_H 1 + +/* Define to 1 if you have the `posix_fadvise' function. */ +#define HAVE_POSIX_FADVISE 1 + +/* Define to 1 if you have the `posix_fallocate' function. */ +#define HAVE_POSIX_FALLOCATE 1 + +/* Define to 1 if you have the `pread' function. */ +#define HAVE_PREAD 1 + +/* Define if you have the 'prlimit' functions. */ +#define HAVE_PRLIMIT 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PROCESS_H */ + +/* Define if your compiler supports function prototype */ +#define HAVE_PROTOTYPES 1 + +/* Define to 1 if you have the `pthread_atfork' function. */ +#define HAVE_PTHREAD_ATFORK 1 + +/* Defined for Solaris 2.6 bug in pthread header. */ +/* #undef HAVE_PTHREAD_DESTRUCTOR */ + +/* Define to 1 if you have the header file. */ +#define HAVE_PTHREAD_H 1 + +/* Define to 1 if you have the `pthread_init' function. */ +/* #undef HAVE_PTHREAD_INIT */ + +/* Define to 1 if you have the `pthread_kill' function. */ +#define HAVE_PTHREAD_KILL 1 + +/* Define to 1 if you have the `pthread_sigmask' function. */ +#define HAVE_PTHREAD_SIGMASK 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PTY_H */ + +/* Define to 1 if you have the `putenv' function. */ +#define HAVE_PUTENV 1 + +/* Define to 1 if you have the `pwrite' function. */ +#define HAVE_PWRITE 1 + +/* Define if the libcrypto has RAND_egd */ +/* #undef HAVE_RAND_EGD */ + +/* Define to 1 if you have the `readlink' function. */ +#define HAVE_READLINK 1 + +/* Define to 1 if you have the `readlinkat' function. */ +#define HAVE_READLINKAT 1 + +/* Define to 1 if you have the `readv' function. */ +#define HAVE_READV 1 + +/* Define to 1 if you have the `realpath' function. */ +#define HAVE_REALPATH 1 + +/* Define to 1 if you have the `renameat' function. */ +#define HAVE_RENAMEAT 1 + +/* Define if readline supports append_history */ +/* #undef HAVE_RL_APPEND_HISTORY */ + +/* Define if you have readline 2.1 */ +/* #undef HAVE_RL_CALLBACK */ + +/* Define if you can turn off readline's signal handling. */ +/* #undef HAVE_RL_CATCH_SIGNAL */ + +/* Define if you have readline 2.2 */ +/* #undef HAVE_RL_COMPLETION_APPEND_CHARACTER */ + +/* Define if you have readline 4.0 */ +/* #undef HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK */ + +/* Define if you have readline 4.2 */ +/* #undef HAVE_RL_COMPLETION_MATCHES */ + +/* Define if you have rl_completion_suppress_append */ +/* #undef HAVE_RL_COMPLETION_SUPPRESS_APPEND */ + +/* Define if you have readline 4.0 */ +/* #undef HAVE_RL_PRE_INPUT_HOOK */ + +/* Define to 1 if you have the `round' function. */ +#define HAVE_ROUND 1 + +/* Define to 1 if you have the `sched_get_priority_max' function. */ +#define HAVE_SCHED_GET_PRIORITY_MAX 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SCHED_H 1 + +/* Define to 1 if you have the `sched_rr_get_interval' function. */ +#define HAVE_SCHED_RR_GET_INTERVAL 1 + +/* Define to 1 if you have the `sched_setaffinity' function. */ +#define HAVE_SCHED_SETAFFINITY 1 + +/* Define to 1 if you have the `sched_setparam' function. */ +#define HAVE_SCHED_SETPARAM 1 + +/* Define to 1 if you have the `sched_setscheduler' function. */ +#define HAVE_SCHED_SETSCHEDULER 1 + +/* Define to 1 if you have the `select' function. */ +#define HAVE_SELECT 1 + +/* Define to 1 if you have the `sem_getvalue' function. */ +#define HAVE_SEM_GETVALUE 1 + +/* Define to 1 if you have the `sem_open' function. */ +#define HAVE_SEM_OPEN 1 + +/* Define to 1 if you have the `sem_timedwait' function. */ +#define HAVE_SEM_TIMEDWAIT 1 + +/* Define to 1 if you have the `sem_unlink' function. */ +#define HAVE_SEM_UNLINK 1 + +/* Define to 1 if you have the `sendfile' function. */ +#define HAVE_SENDFILE 1 + +/* Define to 1 if you have the `setegid' function. */ +#define HAVE_SETEGID 1 + +/* Define to 1 if you have the `seteuid' function. */ +#define HAVE_SETEUID 1 + +/* Define to 1 if you have the `setgid' function. */ +#define HAVE_SETGID 1 + +/* Define if you have the 'setgroups' function. */ +#define HAVE_SETGROUPS 1 + +/* Define to 1 if you have the `sethostname' function. */ +/* #undef HAVE_SETHOSTNAME */ + +/* Define to 1 if you have the `setitimer' function. */ +#define HAVE_SETITIMER 1 + +/* Define to 1 if you have the `setlocale' function. */ +#define HAVE_SETLOCALE 1 + +/* Define to 1 if you have the `setpgid' function. */ +#define HAVE_SETPGID 1 + +/* Define to 1 if you have the `setpgrp' function. */ +#define HAVE_SETPGRP 1 + +/* Define to 1 if you have the `setpriority' function. */ +#define HAVE_SETPRIORITY 1 + +/* Define to 1 if you have the `setregid' function. */ +#define HAVE_SETREGID 1 + +/* Define to 1 if you have the `setresgid' function. */ +#define HAVE_SETRESGID 1 + +/* Define to 1 if you have the `setresuid' function. */ +#define HAVE_SETRESUID 1 + +/* Define to 1 if you have the `setreuid' function. */ +#define HAVE_SETREUID 1 + +/* Define to 1 if you have the `setsid' function. */ +#define HAVE_SETSID 1 + +/* Define to 1 if you have the `setuid' function. */ +#define HAVE_SETUID 1 + +/* Define to 1 if you have the `setvbuf' function. */ +#define HAVE_SETVBUF 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SHADOW_H */ + +/* Define to 1 if you have the `sigaction' function. */ +#define HAVE_SIGACTION 1 + +/* Define to 1 if you have the `sigaltstack' function. */ +#define HAVE_SIGALTSTACK 1 + +/* Define to 1 if you have the `siginterrupt' function. */ +#define HAVE_SIGINTERRUPT 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SIGNAL_H 1 + +/* Define to 1 if you have the `sigpending' function. */ +#define HAVE_SIGPENDING 1 + +/* Define to 1 if you have the `sigrelse' function. */ +/* #undef HAVE_SIGRELSE */ + +/* Define to 1 if you have the `sigtimedwait' function. */ +/* #undef HAVE_SIGTIMEDWAIT */ + +/* Define to 1 if you have the `sigwait' function. */ +#define HAVE_SIGWAIT 1 + +/* Define to 1 if you have the `sigwaitinfo' function. */ +/* #undef HAVE_SIGWAITINFO */ + +/* Define to 1 if you have the `snprintf' function. */ +#define HAVE_SNPRINTF 1 + +/* Define if sockaddr has sa_len member */ +/* #undef HAVE_SOCKADDR_SA_LEN */ + +/* struct sockaddr_storage (sys/socket.h) */ +#define HAVE_SOCKADDR_STORAGE 1 + +/* Define if you have the 'socketpair' function. */ +#define HAVE_SOCKETPAIR 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SPAWN_H */ + +/* Define if your compiler provides ssize_t */ +#define HAVE_SSIZE_T 1 + +/* Define to 1 if you have the `statvfs' function. */ +#define HAVE_STATVFS 1 + +/* Define if you have struct stat.st_mtim.tv_nsec */ +/* #undef HAVE_STAT_TV_NSEC */ + +/* Define if you have struct stat.st_mtimensec */ +/* #undef HAVE_STAT_TV_NSEC2 */ + +/* Define if your compiler supports variable length function prototypes (e.g. + void fprintf(FILE *, char *, ...);) *and* */ +#define HAVE_STDARG_PROTOTYPES 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Has stdatomic.h, atomic_int and _Atomic void* types work */ +#define HAVE_STD_ATOMIC 1 + +/* Define to 1 if you have the `strdup' function. */ +#define HAVE_STRDUP 1 + +/* Define to 1 if you have the `strftime' function. */ +#define HAVE_STRFTIME 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the `strlcpy' function. */ +#define HAVE_STRLCPY 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_STROPTS_H */ + +/* Define to 1 if `st_birthtime' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_BIRTHTIME */ + +/* Define to 1 if `st_blksize' is a member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_BLKSIZE 1 + +/* Define to 1 if `st_blocks' is a member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_BLOCKS 1 + +/* Define to 1 if `st_flags' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_FLAGS */ + +/* Define to 1 if `st_gen' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_GEN */ + +/* Define to 1 if `st_rdev' is a member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_RDEV 1 + +/* Define to 1 if `tm_zone' is a member of `struct tm'. */ +#define HAVE_STRUCT_TM_TM_ZONE 1 + +/* Define to 1 if your `struct stat' has `st_blocks'. Deprecated, use + `HAVE_STRUCT_STAT_ST_BLOCKS' instead. */ +#define HAVE_ST_BLOCKS 1 + +/* Define if you have the 'symlink' function. */ +#define HAVE_SYMLINK 1 + +/* Define to 1 if you have the `symlinkat' function. */ +#define HAVE_SYMLINKAT 1 + +/* Define to 1 if you have the `sync' function. */ +#define HAVE_SYNC 1 + +/* Define to 1 if you have the `sysconf' function. */ +#define HAVE_SYSCONF 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYSEXITS_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_AUDIOIO_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_BSDTTY_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_DEVPOLL_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +/* #undef HAVE_SYS_DIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_ENDIAN_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_EPOLL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_EVENT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_FILE_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_IOCTL_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_KERN_CONTROL_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_LOADAVG_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_LOCK_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_MKDEV_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_MODEM_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +/* #undef HAVE_SYS_NDIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_PARAM_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_POLL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_RESOURCE_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SELECT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SENDFILE_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SOCKET_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STATVFS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SYSCALL_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_SYS_DOMAIN_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_TERMIO_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIMES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UIO_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UN_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UTSNAME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_WAIT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_XATTR_H 1 + +/* Define to 1 if you have the `tcgetpgrp' function. */ +#define HAVE_TCGETPGRP 1 + +/* Define to 1 if you have the `tcsetpgrp' function. */ +#define HAVE_TCSETPGRP 1 + +/* Define to 1 if you have the `tempnam' function. */ +#define HAVE_TEMPNAM 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_TERMIOS_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_TERM_H */ + +/* Define to 1 if you have the `tgamma' function. */ +#define HAVE_TGAMMA 1 + +/* Define to 1 if you have the `timegm' function. */ +#define HAVE_TIMEGM 1 + +/* Define to 1 if you have the `times' function. */ +#define HAVE_TIMES 1 + +/* Define to 1 if you have the `tmpfile' function. */ +#define HAVE_TMPFILE 1 + +/* Define to 1 if you have the `tmpnam' function. */ +#define HAVE_TMPNAM 1 + +/* Define to 1 if you have the `tmpnam_r' function. */ +/* #undef HAVE_TMPNAM_R */ + +/* Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use + `HAVE_STRUCT_TM_TM_ZONE' instead. */ +#define HAVE_TM_ZONE 1 + +/* Define to 1 if you have the `truncate' function. */ +#define HAVE_TRUNCATE 1 + +/* Define to 1 if you don't have `tm_zone' but do have the external array + `tzname'. */ +/* #undef HAVE_TZNAME */ + +/* Define this if you have tcl and TCL_UTF_MAX==6 */ +/* #undef HAVE_UCS4_TCL */ + +/* Define if your compiler provides uint32_t. */ +#define HAVE_UINT32_T 1 + +/* Define if your compiler provides uint64_t. */ +#define HAVE_UINT64_T 1 + +/* Define to 1 if the system has the type `uintptr_t'. */ +#define HAVE_UINTPTR_T 1 + +/* Define to 1 if you have the `uname' function. */ +#define HAVE_UNAME 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you have the `unlinkat' function. */ +#define HAVE_UNLINKAT 1 + +/* Define to 1 if you have the `unsetenv' function. */ +#define HAVE_UNSETENV 1 + +/* Define if you have a useable wchar_t type defined in wchar.h; useable means + wchar_t must be an unsigned type with at least 16 bits. (see + Include/unicodeobject.h). */ +/* #undef HAVE_USABLE_WCHAR_T */ + +/* Define to 1 if you have the header file. */ +#define HAVE_UTIL_H 1 + +/* Define to 1 if you have the `utimensat' function. */ +#define HAVE_UTIMENSAT 1 + +/* Define to 1 if you have the `utimes' function. */ +#define HAVE_UTIMES 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UTIME_H 1 + +/* Define to 1 if you have the `wait3' function. */ +/* #undef HAVE_WAIT3 */ + +/* Define to 1 if you have the `wait4' function. */ +#define HAVE_WAIT4 1 + +/* Define to 1 if you have the `waitid' function. */ +#define HAVE_WAITID 1 + +/* Define to 1 if you have the `waitpid' function. */ +#define HAVE_WAITPID 1 + +/* Define if the compiler provides a wchar.h header file. */ +#define HAVE_WCHAR_H 1 + +/* Define to 1 if you have the `wcscoll' function. */ +#define HAVE_WCSCOLL 1 + +/* Define to 1 if you have the `wcsftime' function. */ +#define HAVE_WCSFTIME 1 + +/* Define to 1 if you have the `wcsxfrm' function. */ +#define HAVE_WCSXFRM 1 + +/* Define to 1 if you have the `wmemcmp' function. */ +#define HAVE_WMEMCMP 1 + +/* Define if tzset() actually switches the local timezone in a meaningful way. + */ +/* #undef HAVE_WORKING_TZSET */ + +/* Define to 1 if you have the `writev' function. */ +#define HAVE_WRITEV 1 + +/* Define if the zlib library has inflateCopy */ +#define HAVE_ZLIB_COPY 1 + +/* Define to 1 if you have the `_getpty' function. */ +/* #undef HAVE__GETPTY */ + +/* Define if log1p(-0.) is 0. rather than -0. */ +/* #undef LOG1P_DROPS_ZERO_SIGN */ + +/* Define to 1 if `major', `minor', and `makedev' are declared in . + */ +/* #undef MAJOR_IN_MKDEV */ + +/* Define to 1 if `major', `minor', and `makedev' are declared in + . */ +#define MAJOR_IN_SYSMACROS 1 + +/* Define if mvwdelch in curses.h is an expression. */ +/* #undef MVWDELCH_IS_EXPRESSION */ + +/* Define to the address where bug reports for this package should be sent. */ +/* #undef PACKAGE_BUGREPORT */ + +/* Define to the full name of this package. */ +/* #undef PACKAGE_NAME */ + +/* Define to the full name and version of this package. */ +/* #undef PACKAGE_STRING */ + +/* Define to the one symbol short name of this package. */ +/* #undef PACKAGE_TARNAME */ + +/* Define to the home page for this package. */ +/* #undef PACKAGE_URL */ + +/* Define to the version of this package. */ +/* #undef PACKAGE_VERSION */ + +/* Define if POSIX semaphores aren't enabled on your system */ +/* #undef POSIX_SEMAPHORES_NOT_ENABLED */ + +/* Defined if PTHREAD_SCOPE_SYSTEM supported. */ +/* #undef PTHREAD_SYSTEM_SCHED_SUPPORTED */ + +/* Define as the preferred size in bits of long digits */ +/* #undef PYLONG_BITS_IN_DIGIT */ + +/* Define to printf format modifier for long long type */ +#define PY_FORMAT_LONG_LONG "ll" + +/* Define to printf format modifier for Py_ssize_t */ +#define PY_FORMAT_SIZE_T "z" + +/* Define if you want to build an interpreter with many run-time checks. */ +/* #undef Py_DEBUG */ + +/* Defined if Python is built as a shared library. */ +#define Py_ENABLE_SHARED 1 + +/* Define hash algorithm for str, bytes and memoryview. SipHash24: 1, FNV: 2, + externally defined: 0 */ +/* #undef Py_HASH_ALGORITHM */ + +/* assume C89 semantics that RETSIGTYPE is always void */ +#define RETSIGTYPE void + +/* Define if setpgrp() must be called as setpgrp(0, 0). */ +/* #undef SETPGRP_HAVE_ARG */ + +/* Define if i>>j for signed int i does not extend the sign bit when i < 0 */ +/* #undef SIGNED_RIGHT_SHIFT_ZERO_FILLS */ + +/* The size of `double', as computed by sizeof. */ +#define SIZEOF_DOUBLE 8 + +/* The size of `float', as computed by sizeof. */ +#define SIZEOF_FLOAT 4 + +/* The size of `fpos_t', as computed by sizeof. */ +#define SIZEOF_FPOS_T 8 + +/* The size of `int', as computed by sizeof. */ +#define SIZEOF_INT 4 + +/* The size of `long', as computed by sizeof. */ +#define SIZEOF_LONG 8 + +/* The size of `long double', as computed by sizeof. */ +#define SIZEOF_LONG_DOUBLE 16 + +/* The size of `long long', as computed by sizeof. */ +#define SIZEOF_LONG_LONG 8 + +/* The size of `off_t', as computed by sizeof. */ +#define SIZEOF_OFF_T 8 + +/* The size of `pid_t', as computed by sizeof. */ +#define SIZEOF_PID_T 4 + +/* The size of `pthread_t', as computed by sizeof. */ +#define SIZEOF_PTHREAD_T 8 + +/* The size of `short', as computed by sizeof. */ +#define SIZEOF_SHORT 2 + +/* The size of `size_t', as computed by sizeof. */ +#define SIZEOF_SIZE_T 8 + +/* The size of `time_t', as computed by sizeof. */ +#define SIZEOF_TIME_T 8 + +/* The size of `uintptr_t', as computed by sizeof. */ +#define SIZEOF_UINTPTR_T 8 + +/* The size of `void *', as computed by sizeof. */ +#define SIZEOF_VOID_P 8 + +/* The size of `wchar_t', as computed by sizeof. */ +#define SIZEOF_WCHAR_T 4 + +/* The size of `_Bool', as computed by sizeof. */ +#define SIZEOF__BOOL 1 + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define if you can safely include both and + (which you can't on SCO ODT 3.0). */ +#define SYS_SELECT_WITH_SYS_TIME 1 + +/* Define if tanh(-0.) is -0., or if platform doesn't have signed zeros */ +/* #undef TANH_PRESERVES_ZERO_SIGN */ + +/* Library needed by timemodule.c: librt may be needed for clock_gettime() */ +/* #undef TIMEMODULE_LIB */ + +/* Define to 1 if you can safely include both and . */ +#define TIME_WITH_SYS_TIME 1 + +/* Define to 1 if your declares `struct tm'. */ +/* #undef TM_IN_SYS_TIME */ + +/* Define if you want to use computed gotos in ceval.c. */ +#define USE_COMPUTED_GOTOS 1 + +/* Define to use the C99 inline keyword. */ +#define USE_INLINE 1 + +/* Enable extensions on AIX 3, Interix. */ +#ifndef _ALL_SOURCE +# define _ALL_SOURCE 1 +#endif +/* Enable GNU extensions on systems that have them. */ +#ifndef _GNU_SOURCE +# define _GNU_SOURCE 1 +#endif +/* Enable threading extensions on Solaris. */ +#ifndef _POSIX_PTHREAD_SEMANTICS +# define _POSIX_PTHREAD_SEMANTICS 1 +#endif +/* Enable extensions on HP NonStop. */ +#ifndef _TANDEM_SOURCE +# define _TANDEM_SOURCE 1 +#endif +/* Enable general extensions on Solaris. */ +#ifndef __EXTENSIONS__ +# define __EXTENSIONS__ 1 +#endif + + +/* Define if a va_list is an array of some kind */ +/* #undef VA_LIST_IS_ARRAY */ + +/* Define if you want SIGFPE handled (see Include/pyfpe.h). */ +/* #undef WANT_SIGFPE_HANDLER */ + +/* Define if WINDOW in curses.h offers a field _flags. */ +/* #undef WINDOW_HAS_FLAGS */ + +/* Define if you want documentation strings in extension modules */ +#define WITH_DOC_STRINGS 1 + +/* Define if you want to use the new-style (Openstep, Rhapsody, MacOS) dynamic + linker (dyld) instead of the old-style (NextStep) dynamic linker (rld). + Dyld is necessary to support frameworks. */ +/* #undef WITH_DYLD */ + +/* Define to 1 if libintl is needed for locale functions. */ +/* #undef WITH_LIBINTL */ + +/* Define if you want to produce an OpenStep/Rhapsody framework (shared + library plus accessory files). */ +/* #undef WITH_NEXT_FRAMEWORK */ + +/* Define if you want to compile in Python-specific mallocs */ +#define WITH_PYMALLOC 1 + +/* Define if you want to compile in rudimentary thread support */ +#define WITH_THREAD 1 + +/* Define to profile with the Pentium timestamp counter */ +/* #undef WITH_TSC */ + +/* Define if you want pymalloc to be disabled when running under valgrind */ +/* #undef WITH_VALGRIND */ + +/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most + significant byte first (like Motorola and SPARC, unlike Intel). */ +#if defined AC_APPLE_UNIVERSAL_BUILD +# if defined __BIG_ENDIAN__ +# define WORDS_BIGENDIAN 1 +# endif +#else +# ifndef WORDS_BIGENDIAN +/* # undef WORDS_BIGENDIAN */ +# endif +#endif + +/* Define if arithmetic is subject to x87-style double rounding issue */ +/* #undef X87_DOUBLE_ROUNDING */ + +/* Define on OpenBSD to activate all library features */ +/* #undef _BSD_SOURCE */ + +/* Define on Irix to enable u_int */ +#define _BSD_TYPES 1 + +/* Define on Darwin to activate all library features */ +#define _DARWIN_C_SOURCE 1 + +/* This must be set to 64 on some systems to enable large file support. */ +#define _FILE_OFFSET_BITS 64 + +/* Define on Linux to activate all library features */ +#define _GNU_SOURCE 1 + +/* Define to include mbstate_t for mbrtowc */ +/* #undef _INCLUDE__STDC_A1_SOURCE */ + +/* This must be defined on some systems to enable large file support. */ +#define _LARGEFILE_SOURCE 1 + +/* This must be defined on AIX systems to enable large file support. */ +/* #undef _LARGE_FILES */ + +/* Define to 1 if on MINIX. */ +/* #undef _MINIX */ + +/* Define on NetBSD to activate all library features */ +#define _NETBSD_SOURCE 1 + +/* Define to 2 if the system does not provide POSIX.1 features except with + this defined. */ +/* #undef _POSIX_1_SOURCE */ + +/* Define to activate features from IEEE Stds 1003.1-2008 */ +#define _POSIX_C_SOURCE 200809L + +/* Define to 1 if you need to in order for `stat' and other things to work. */ +/* #undef _POSIX_SOURCE */ + +/* Define if you have POSIX threads, and your system does not define that. */ +/* #undef _POSIX_THREADS */ + +/* Define to force use of thread-safe errno, h_errno, and other functions */ +#define _REENTRANT 1 + +/* Define for Solaris 2.5.1 so the uint32_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +/* #undef _UINT32_T */ + +/* Define for Solaris 2.5.1 so the uint64_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +/* #undef _UINT64_T */ + +/* Define to the level of X/Open that your system supports */ +#define _XOPEN_SOURCE 700 + +/* Define to activate Unix95-and-earlier features */ +#define _XOPEN_SOURCE_EXTENDED 1 + +/* Define on FreeBSD to activate all library features */ +#define __BSD_VISIBLE 1 + +/* Define to 1 if type `char' is unsigned and you are not using gcc. */ +#ifndef __CHAR_UNSIGNED__ +/* # undef __CHAR_UNSIGNED__ */ +#endif + +/* Define to 'long' if doesn't define. */ +/* #undef clock_t */ + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ + +/* Define to `int' if doesn't define. */ +/* #undef gid_t */ + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +/* #undef inline */ +#endif + +/* Define to the type of a signed integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +/* #undef int32_t */ + +/* Define to the type of a signed integer type of width exactly 64 bits if + such a type exists and the standard includes do not define it. */ +/* #undef int64_t */ + +/* Define to `int' if does not define. */ +/* #undef mode_t */ + +/* Define to `long int' if does not define. */ +/* #undef off_t */ + +/* Define to `int' if does not define. */ +/* #undef pid_t */ + +/* Define to empty if the keyword does not work. */ +/* #undef signed */ + +/* Define to `unsigned int' if does not define. */ +/* #undef size_t */ + +/* Define to `int' if does not define. */ +/* #undef socklen_t */ + +/* Define to `int' if doesn't define. */ +/* #undef uid_t */ + +/* Define to the type of an unsigned integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint32_t */ + +/* Define to the type of an unsigned integer type of width exactly 64 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint64_t */ + +/* Define to empty if the keyword does not work. */ +/* #undef volatile */ + + +/* Define the macros needed if on a UnixWare 7.x system. */ +#if defined(__USLC__) && defined(__SCO_VERSION__) +#define STRICT_SYSV_CURSES /* Don't use ncurses extensions */ +#endif + +#endif /*Py_PYCONFIG_H*/ + diff --git a/android/python35/include/pyconfig_x86.h b/android/python35/include/pyconfig_x86.h new file mode 100644 index 000000000..d3124927e --- /dev/null +++ b/android/python35/include/pyconfig_x86.h @@ -0,0 +1,1530 @@ +/* pyconfig.h. Generated from pyconfig.h.in by configure. */ +/* pyconfig.h.in. Generated from configure.ac by autoheader. */ + + +#ifndef Py_PYCONFIG_H +#define Py_PYCONFIG_H + + +/* Define if building universal (internal helper macro) */ +/* #undef AC_APPLE_UNIVERSAL_BUILD */ + +/* Define for AIX if your compiler is a genuine IBM xlC/xlC_r and you want + support for AIX C++ shared extension modules. */ +/* #undef AIX_GENUINE_CPLUSPLUS */ + +/* Define if C doubles are 64-bit IEEE 754 binary format, stored in ARM + mixed-endian order (byte order 45670123) */ +/* #undef DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754 */ + +/* Define if C doubles are 64-bit IEEE 754 binary format, stored with the most + significant byte first */ +/* #undef DOUBLE_IS_BIG_ENDIAN_IEEE754 */ + +/* Define if C doubles are 64-bit IEEE 754 binary format, stored with the + least significant byte first */ +/* #undef DOUBLE_IS_LITTLE_ENDIAN_IEEE754 */ + +/* Define if --enable-ipv6 is specified */ +#define ENABLE_IPV6 1 + +/* Define if flock needs to be linked with bsd library. */ +/* #undef FLOCK_NEEDS_LIBBSD */ + +/* Define if getpgrp() must be called as getpgrp(0). */ +/* #undef GETPGRP_HAVE_ARG */ + +/* Define if gettimeofday() does not have second (timezone) argument This is + the case on Motorola V4 (R40V4.2) */ +/* #undef GETTIMEOFDAY_NO_TZ */ + +/* Define to 1 if you have the `accept4' function. */ +/* #undef HAVE_ACCEPT4 */ + +/* Define to 1 if you have the `acosh' function. */ +#define HAVE_ACOSH 1 + +/* struct addrinfo (netdb.h) */ +#define HAVE_ADDRINFO 1 + +/* Define to 1 if you have the `alarm' function. */ +#define HAVE_ALARM 1 + +/* Define if aligned memory access is required */ +#define HAVE_ALIGNED_REQUIRED 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ALLOCA_H 1 + +/* Define this if your time.h defines altzone. */ +/* #undef HAVE_ALTZONE */ + +/* Define to 1 if you have the `asinh' function. */ +#define HAVE_ASINH 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ASM_TYPES_H 1 + +/* Define to 1 if you have the `atanh' function. */ +#define HAVE_ATANH 1 + +/* Define to 1 if you have the `bind_textdomain_codeset' function. */ +/* #undef HAVE_BIND_TEXTDOMAIN_CODESET */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_BLUETOOTH_BLUETOOTH_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_BLUETOOTH_H */ + +/* Define if mbstowcs(NULL, "text", 0) does not return the number of wide + chars that would be converted. */ +/* #undef HAVE_BROKEN_MBSTOWCS */ + +/* Define if nice() returns success/failure instead of the new priority. */ +/* #undef HAVE_BROKEN_NICE */ + +/* Define if the system reports an invalid PIPE_BUF value. */ +/* #undef HAVE_BROKEN_PIPE_BUF */ + +/* Define if poll() sets errno on invalid file descriptors. */ +/* #undef HAVE_BROKEN_POLL */ + +/* Define if the Posix semaphores do not work on your system */ +/* #undef HAVE_BROKEN_POSIX_SEMAPHORES */ + +/* Define if pthread_sigmask() does not work on your system. */ +/* #undef HAVE_BROKEN_PTHREAD_SIGMASK */ + +/* define to 1 if your sem_getvalue is broken. */ +#define HAVE_BROKEN_SEM_GETVALUE 1 + +/* Define if `unsetenv` does not return an int. */ +/* #undef HAVE_BROKEN_UNSETENV */ + +/* Has builtin atomics */ +#define HAVE_BUILTIN_ATOMIC 1 + +/* Define this if you have the type _Bool. */ +#define HAVE_C99_BOOL 1 + +/* Define to 1 if you have the 'chflags' function. */ +/* #undef HAVE_CHFLAGS */ + +/* Define to 1 if you have the `chown' function. */ +#define HAVE_CHOWN 1 + +/* Define if you have the 'chroot' function. */ +#define HAVE_CHROOT 1 + +/* Define to 1 if you have the `clock' function. */ +#define HAVE_CLOCK 1 + +/* Define to 1 if you have the `clock_getres' function. */ +#define HAVE_CLOCK_GETRES 1 + +/* Define to 1 if you have the `clock_gettime' function. */ +#define HAVE_CLOCK_GETTIME 1 + +/* Define if the C compiler supports computed gotos. */ +#define HAVE_COMPUTED_GOTOS 1 + +/* Define to 1 if you have the `confstr' function. */ +/* #undef HAVE_CONFSTR */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_CONIO_H */ + +/* Define to 1 if you have the `copysign' function. */ +#define HAVE_COPYSIGN 1 + +/* Define to 1 if you have the `ctermid' function. */ +/* #undef HAVE_CTERMID */ + +/* Define if you have the 'ctermid_r' function. */ +#define HAVE_CTERMID_R 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_CURSES_H */ + +/* Define if you have the 'is_term_resized' function. */ +/* #undef HAVE_CURSES_IS_TERM_RESIZED */ + +/* Define if you have the 'resizeterm' function. */ +/* #undef HAVE_CURSES_RESIZETERM */ + +/* Define if you have the 'resize_term' function. */ +/* #undef HAVE_CURSES_RESIZE_TERM */ + +/* Define to 1 if you have the declaration of `isfinite', and to 0 if you + don't. */ +#define HAVE_DECL_ISFINITE 1 + +/* Define to 1 if you have the declaration of `isinf', and to 0 if you don't. + */ +#define HAVE_DECL_ISINF 1 + +/* Define to 1 if you have the declaration of `isnan', and to 0 if you don't. + */ +#define HAVE_DECL_ISNAN 1 + +/* Define to 1 if you have the declaration of `tzname', and to 0 if you don't. + */ +/* #undef HAVE_DECL_TZNAME */ + +/* Define to 1 if you have the device macros. */ +#define HAVE_DEVICE_MACROS 1 + +/* Define to 1 if you have the /dev/ptc device file. */ +/* #undef HAVE_DEV_PTC */ + +/* Define to 1 if you have the /dev/ptmx device file. */ +/* #undef HAVE_DEV_PTMX */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_DIRECT_H */ + +/* Define to 1 if the dirent structure has a d_type field */ +#define HAVE_DIRENT_D_TYPE 1 + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#define HAVE_DIRENT_H 1 + +/* Define if you have the 'dirfd' function or macro. */ +#define HAVE_DIRFD 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_DLFCN_H 1 + +/* Define to 1 if you have the `dlopen' function. */ +#define HAVE_DLOPEN 1 + +/* Define to 1 if you have the `dup2' function. */ +#define HAVE_DUP2 1 + +/* Define to 1 if you have the `dup3' function. */ +/* #undef HAVE_DUP3 */ + +/* Defined when any dynamic module loading is enabled. */ +#define HAVE_DYNAMIC_LOADING 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ENDIAN_H 1 + +/* Define if you have the 'epoll' functions. */ +#define HAVE_EPOLL 1 + +/* Define if you have the 'epoll_create1' function. */ +/* #undef HAVE_EPOLL_CREATE1 */ + +/* Define to 1 if you have the `erf' function. */ +#define HAVE_ERF 1 + +/* Define to 1 if you have the `erfc' function. */ +#define HAVE_ERFC 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ERRNO_H 1 + +/* Define to 1 if you have the `execv' function. */ +#define HAVE_EXECV 1 + +/* Define to 1 if you have the `expm1' function. */ +#define HAVE_EXPM1 1 + +/* Define to 1 if you have the `faccessat' function. */ +/* #undef HAVE_FACCESSAT */ + +/* Define if you have the 'fchdir' function. */ +#define HAVE_FCHDIR 1 + +/* Define to 1 if you have the `fchmod' function. */ +#define HAVE_FCHMOD 1 + +/* Define to 1 if you have the `fchmodat' function. */ +#define HAVE_FCHMODAT 1 + +/* Define to 1 if you have the `fchown' function. */ +#define HAVE_FCHOWN 1 + +/* Define to 1 if you have the `fchownat' function. */ +#define HAVE_FCHOWNAT 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* Define if you have the 'fdatasync' function. */ +#define HAVE_FDATASYNC 1 + +/* Define to 1 if you have the `fdopendir' function. */ +#define HAVE_FDOPENDIR 1 + +/* Define to 1 if you have the `fexecve' function. */ +/* #undef HAVE_FEXECVE */ + +/* Define to 1 if you have the `finite' function. */ +#define HAVE_FINITE 1 + +/* Define to 1 if you have the `flock' function. */ +#define HAVE_FLOCK 1 + +/* Define to 1 if you have the `fork' function. */ +#define HAVE_FORK 1 + +/* Define to 1 if you have the `forkpty' function. */ +/* #undef HAVE_FORKPTY */ + +/* Define to 1 if you have the `fpathconf' function. */ +#define HAVE_FPATHCONF 1 + +/* Define to 1 if you have the `fseek64' function. */ +/* #undef HAVE_FSEEK64 */ + +/* Define to 1 if you have the `fseeko' function. */ +#define HAVE_FSEEKO 1 + +/* Define to 1 if you have the `fstatat' function. */ +#define HAVE_FSTATAT 1 + +/* Define to 1 if you have the `fstatvfs' function. */ +/* #undef HAVE_FSTATVFS */ + +/* Define if you have the 'fsync' function. */ +#define HAVE_FSYNC 1 + +/* Define to 1 if you have the `ftell64' function. */ +/* #undef HAVE_FTELL64 */ + +/* Define to 1 if you have the `ftello' function. */ +#define HAVE_FTELLO 1 + +/* Define to 1 if you have the `ftime' function. */ +#define HAVE_FTIME 1 + +/* Define to 1 if you have the `ftruncate' function. */ +#define HAVE_FTRUNCATE 1 + +/* Define to 1 if you have the `futimens' function. */ +/* #undef HAVE_FUTIMENS */ + +/* Define to 1 if you have the `futimes' function. */ +/* #undef HAVE_FUTIMES */ + +/* Define to 1 if you have the `futimesat' function. */ +/* #undef HAVE_FUTIMESAT */ + +/* Define to 1 if you have the `gai_strerror' function. */ +#define HAVE_GAI_STRERROR 1 + +/* Define to 1 if you have the `gamma' function. */ +/* #undef HAVE_GAMMA */ + +/* Define if we can use gcc inline assembler to get and set mc68881 fpcr */ +/* #undef HAVE_GCC_ASM_FOR_MC68881 */ + +/* Define if we can use x64 gcc inline assembler */ +/* #undef HAVE_GCC_ASM_FOR_X64 */ + +/* Define if we can use gcc inline assembler to get and set x87 control word + */ +#define HAVE_GCC_ASM_FOR_X87 1 + +/* Define if your compiler provides __uint128_t */ +/* #undef HAVE_GCC_UINT128_T */ + +/* Define if you have the getaddrinfo function. */ +#define HAVE_GETADDRINFO 1 + +/* Define this if you have flockfile(), getc_unlocked(), and funlockfile() */ +#define HAVE_GETC_UNLOCKED 1 + +/* Define to 1 if you have the `getentropy' function. */ +/* #undef HAVE_GETENTROPY */ + +/* Define to 1 if you have the `getgrouplist' function. */ +#define HAVE_GETGROUPLIST 1 + +/* Define to 1 if you have the `getgroups' function. */ +#define HAVE_GETGROUPS 1 + +/* Define to 1 if you have the `gethostbyname' function. */ +#define HAVE_GETHOSTBYNAME 1 + +/* Define this if you have some version of gethostbyname_r() */ +/* #undef HAVE_GETHOSTBYNAME_R */ + +/* Define this if you have the 3-arg version of gethostbyname_r(). */ +/* #undef HAVE_GETHOSTBYNAME_R_3_ARG */ + +/* Define this if you have the 5-arg version of gethostbyname_r(). */ +/* #undef HAVE_GETHOSTBYNAME_R_5_ARG */ + +/* Define this if you have the 6-arg version of gethostbyname_r(). */ +/* #undef HAVE_GETHOSTBYNAME_R_6_ARG */ + +/* Define to 1 if you have the `getitimer' function. */ +#define HAVE_GETITIMER 1 + +/* Define to 1 if you have the `getloadavg' function. */ +#define HAVE_GETLOADAVG 1 + +/* Define to 1 if you have the `getlogin' function. */ +#define HAVE_GETLOGIN 1 + +/* Define to 1 if you have the `getnameinfo' function. */ +#define HAVE_GETNAMEINFO 1 + +/* Define if you have the 'getpagesize' function. */ +#define HAVE_GETPAGESIZE 1 + +/* Define to 1 if you have the `getpeername' function. */ +#define HAVE_GETPEERNAME 1 + +/* Define to 1 if you have the `getpgid' function. */ +#define HAVE_GETPGID 1 + +/* Define to 1 if you have the `getpgrp' function. */ +#define HAVE_GETPGRP 1 + +/* Define to 1 if you have the `getpid' function. */ +#define HAVE_GETPID 1 + +/* Define to 1 if you have the `getpriority' function. */ +#define HAVE_GETPRIORITY 1 + +/* Define to 1 if you have the `getpwent' function. */ +#define HAVE_GETPWENT 1 + +/* Define to 1 if the Linux getrandom() syscall is available */ +/* #undef HAVE_GETRANDOM_SYSCALL */ + +/* Define to 1 if you have the `getresgid' function. */ +#define HAVE_GETRESGID 1 + +/* Define to 1 if you have the `getresuid' function. */ +#define HAVE_GETRESUID 1 + +/* Define to 1 if you have the `getsid' function. */ +/* #undef HAVE_GETSID */ + +/* Define to 1 if you have the `getspent' function. */ +/* #undef HAVE_GETSPENT */ + +/* Define to 1 if you have the `getspnam' function. */ +/* #undef HAVE_GETSPNAM */ + +/* Define to 1 if you have the `gettimeofday' function. */ +#define HAVE_GETTIMEOFDAY 1 + +/* Define to 1 if you have the `getwd' function. */ +/* #undef HAVE_GETWD */ + +/* Define if glibc has incorrect _FORTIFY_SOURCE wrappers for memmove and + bcopy. */ +/* #undef HAVE_GLIBC_MEMMOVE_BUG */ + +/* Define to 1 if you have the header file. */ +#define HAVE_GRP_H 1 + +/* Define if you have the 'hstrerror' function. */ +#define HAVE_HSTRERROR 1 + +/* Define this if you have le64toh() */ +#define HAVE_HTOLE64 1 + +/* Define to 1 if you have the `hypot' function. */ +#define HAVE_HYPOT 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_IEEEFP_H 1 + +/* Define to 1 if you have the `if_nameindex' function. */ +/* #undef HAVE_IF_NAMEINDEX */ + +/* Define if you have the 'inet_aton' function. */ +#define HAVE_INET_ATON 1 + +/* Define if you have the 'inet_pton' function. */ +#define HAVE_INET_PTON 1 + +/* Define to 1 if you have the `initgroups' function. */ +#define HAVE_INITGROUPS 1 + +/* Define if your compiler provides int32_t. */ +#define HAVE_INT32_T 1 + +/* Define if your compiler provides int64_t. */ +#define HAVE_INT64_T 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_IO_H */ + +/* Define if gcc has the ipa-pure-const bug. */ +/* #undef HAVE_IPA_PURE_CONST_BUG */ + +/* Define to 1 if you have the `kill' function. */ +#define HAVE_KILL 1 + +/* Define to 1 if you have the `killpg' function. */ +#define HAVE_KILLPG 1 + +/* Define if you have the 'kqueue' functions. */ +#define HAVE_KQUEUE 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_LANGINFO_H 1 + +/* Defined to enable large file support when an off_t is bigger than a long + and long long is available and at least as big as an off_t. You may need to + add some flags for configuration and compilation to enable this mode. (For + Solaris and Linux, the necessary defines are already defined.) */ +/* #undef HAVE_LARGEFILE_SUPPORT */ + +/* Define to 1 if you have the 'lchflags' function. */ +/* #undef HAVE_LCHFLAGS */ + +/* Define to 1 if you have the `lchmod' function. */ +/* #undef HAVE_LCHMOD */ + +/* Define to 1 if you have the `lchown' function. */ +#define HAVE_LCHOWN 1 + +/* Define to 1 if you have the `lgamma' function. */ +#define HAVE_LGAMMA 1 + +/* Define to 1 if you have the `dl' library (-ldl). */ +#define HAVE_LIBDL 1 + +/* Define to 1 if you have the `dld' library (-ldld). */ +/* #undef HAVE_LIBDLD */ + +/* Define to 1 if you have the `ieee' library (-lieee). */ +/* #undef HAVE_LIBIEEE */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LIBINTL_H */ + +/* Define if you have the readline library (-lreadline). */ +/* #undef HAVE_LIBREADLINE */ + +/* Define to 1 if you have the `resolv' library (-lresolv). */ +/* #undef HAVE_LIBRESOLV */ + +/* Define to 1 if you have the `sendfile' library (-lsendfile). */ +/* #undef HAVE_LIBSENDFILE */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LIBUTIL_H */ + +/* Define if you have the 'link' function. */ +#define HAVE_LINK 1 + +/* Define to 1 if you have the `linkat' function. */ +/* #undef HAVE_LINKAT */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LINUX_CAN_BCM_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LINUX_CAN_H */ + +/* Define if compiling using Linux 3.6 or later. */ +/* #undef HAVE_LINUX_CAN_RAW_FD_FRAMES */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LINUX_CAN_RAW_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_LINUX_NETLINK_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LINUX_TIPC_H */ + +/* Define to 1 if you have the `lockf' function. */ +#define HAVE_LOCKF 1 + +/* Define to 1 if you have the `log1p' function. */ +#define HAVE_LOG1P 1 + +/* Define to 1 if you have the `log2' function. */ +#define HAVE_LOG2 1 + +/* Define this if you have the type long double. */ +#define HAVE_LONG_DOUBLE 1 + +/* Define this if you have the type long long. */ +#define HAVE_LONG_LONG 1 + +/* Define to 1 if you have the `lstat' function. */ +#define HAVE_LSTAT 1 + +/* Define to 1 if you have the `lutimes' function. */ +/* #undef HAVE_LUTIMES */ + +/* Define this if you have the makedev macro. */ +#define HAVE_MAKEDEV 1 + +/* Define to 1 if you have the `mbrtowc' function. */ +#define HAVE_MBRTOWC 1 + +/* Define to 1 if you have the `memmove' function. */ +#define HAVE_MEMMOVE 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `memrchr' function. */ +#define HAVE_MEMRCHR 1 + +/* Define to 1 if you have the `mkdirat' function. */ +#define HAVE_MKDIRAT 1 + +/* Define to 1 if you have the `mkfifo' function. */ +/* #undef HAVE_MKFIFO */ + +/* Define to 1 if you have the `mkfifoat' function. */ +/* #undef HAVE_MKFIFOAT */ + +/* Define to 1 if you have the `mknod' function. */ +#define HAVE_MKNOD 1 + +/* Define to 1 if you have the `mknodat' function. */ +/* #undef HAVE_MKNODAT */ + +/* Define to 1 if you have the `mktime' function. */ +#define HAVE_MKTIME 1 + +/* Define to 1 if you have the `mmap' function. */ +#define HAVE_MMAP 1 + +/* Define to 1 if you have the `mremap' function. */ +#define HAVE_MREMAP 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NCURSES_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. */ +/* #undef HAVE_NDIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_NETPACKET_PACKET_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_NET_IF_H 1 + +/* Define to 1 if you have the `nice' function. */ +#define HAVE_NICE 1 + +/* Define to 1 if you have the `openat' function. */ +#define HAVE_OPENAT 1 + +/* Define to 1 if you have the `openpty' function. */ +/* #undef HAVE_OPENPTY */ + +/* Define if compiling using MacOS X 10.5 SDK or later. */ +/* #undef HAVE_OSX105_SDK */ + +/* Define to 1 if you have the `pathconf' function. */ +#define HAVE_PATHCONF 1 + +/* Define to 1 if you have the `pause' function. */ +#define HAVE_PAUSE 1 + +/* Define to 1 if you have the `pipe2' function. */ +#define HAVE_PIPE2 1 + +/* Define to 1 if you have the `plock' function. */ +/* #undef HAVE_PLOCK */ + +/* Define to 1 if you have the `poll' function. */ +#define HAVE_POLL 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_POLL_H 1 + +/* Define to 1 if you have the `posix_fadvise' function. */ +#define HAVE_POSIX_FADVISE 1 + +/* Define to 1 if you have the `posix_fallocate' function. */ +#define HAVE_POSIX_FALLOCATE 1 + +/* Define to 1 if you have the `pread' function. */ +#define HAVE_PREAD 1 + +/* Define if you have the 'prlimit' functions. */ +/* #undef HAVE_PRLIMIT */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PROCESS_H */ + +/* Define if your compiler supports function prototype */ +#define HAVE_PROTOTYPES 1 + +/* Define to 1 if you have the `pthread_atfork' function. */ +/* #undef HAVE_PTHREAD_ATFORK */ + +/* Defined for Solaris 2.6 bug in pthread header. */ +/* #undef HAVE_PTHREAD_DESTRUCTOR */ + +/* Define to 1 if you have the header file. */ +#define HAVE_PTHREAD_H 1 + +/* Define to 1 if you have the `pthread_init' function. */ +/* #undef HAVE_PTHREAD_INIT */ + +/* Define to 1 if you have the `pthread_kill' function. */ +#define HAVE_PTHREAD_KILL 1 + +/* Define to 1 if you have the `pthread_sigmask' function. */ +#define HAVE_PTHREAD_SIGMASK 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PTY_H */ + +/* Define to 1 if you have the `putenv' function. */ +#define HAVE_PUTENV 1 + +/* Define to 1 if you have the `pwrite' function. */ +#define HAVE_PWRITE 1 + +/* Define if the libcrypto has RAND_egd */ +/* #undef HAVE_RAND_EGD */ + +/* Define to 1 if you have the `readlink' function. */ +#define HAVE_READLINK 1 + +/* Define to 1 if you have the `readlinkat' function. */ +/* #undef HAVE_READLINKAT */ + +/* Define to 1 if you have the `readv' function. */ +#define HAVE_READV 1 + +/* Define to 1 if you have the `realpath' function. */ +#define HAVE_REALPATH 1 + +/* Define to 1 if you have the `renameat' function. */ +#define HAVE_RENAMEAT 1 + +/* Define if readline supports append_history */ +/* #undef HAVE_RL_APPEND_HISTORY */ + +/* Define if you have readline 2.1 */ +/* #undef HAVE_RL_CALLBACK */ + +/* Define if you can turn off readline's signal handling. */ +/* #undef HAVE_RL_CATCH_SIGNAL */ + +/* Define if you have readline 2.2 */ +/* #undef HAVE_RL_COMPLETION_APPEND_CHARACTER */ + +/* Define if you have readline 4.0 */ +/* #undef HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK */ + +/* Define if you have readline 4.2 */ +/* #undef HAVE_RL_COMPLETION_MATCHES */ + +/* Define if you have rl_completion_suppress_append */ +/* #undef HAVE_RL_COMPLETION_SUPPRESS_APPEND */ + +/* Define if you have readline 4.0 */ +/* #undef HAVE_RL_PRE_INPUT_HOOK */ + +/* Define to 1 if you have the `round' function. */ +#define HAVE_ROUND 1 + +/* Define to 1 if you have the `sched_get_priority_max' function. */ +#define HAVE_SCHED_GET_PRIORITY_MAX 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SCHED_H 1 + +/* Define to 1 if you have the `sched_rr_get_interval' function. */ +#define HAVE_SCHED_RR_GET_INTERVAL 1 + +/* Define to 1 if you have the `sched_setaffinity' function. */ +#define HAVE_SCHED_SETAFFINITY 1 + +/* Define to 1 if you have the `sched_setparam' function. */ +#define HAVE_SCHED_SETPARAM 1 + +/* Define to 1 if you have the `sched_setscheduler' function. */ +#define HAVE_SCHED_SETSCHEDULER 1 + +/* Define to 1 if you have the `select' function. */ +#define HAVE_SELECT 1 + +/* Define to 1 if you have the `sem_getvalue' function. */ +#define HAVE_SEM_GETVALUE 1 + +/* Define to 1 if you have the `sem_open' function. */ +#define HAVE_SEM_OPEN 1 + +/* Define to 1 if you have the `sem_timedwait' function. */ +#define HAVE_SEM_TIMEDWAIT 1 + +/* Define to 1 if you have the `sem_unlink' function. */ +#define HAVE_SEM_UNLINK 1 + +/* Define to 1 if you have the `sendfile' function. */ +#define HAVE_SENDFILE 1 + +/* Define to 1 if you have the `setegid' function. */ +#define HAVE_SETEGID 1 + +/* Define to 1 if you have the `seteuid' function. */ +#define HAVE_SETEUID 1 + +/* Define to 1 if you have the `setgid' function. */ +#define HAVE_SETGID 1 + +/* Define if you have the 'setgroups' function. */ +#define HAVE_SETGROUPS 1 + +/* Define to 1 if you have the `sethostname' function. */ +/* #undef HAVE_SETHOSTNAME */ + +/* Define to 1 if you have the `setitimer' function. */ +#define HAVE_SETITIMER 1 + +/* Define to 1 if you have the `setlocale' function. */ +#define HAVE_SETLOCALE 1 + +/* Define to 1 if you have the `setpgid' function. */ +#define HAVE_SETPGID 1 + +/* Define to 1 if you have the `setpgrp' function. */ +#define HAVE_SETPGRP 1 + +/* Define to 1 if you have the `setpriority' function. */ +#define HAVE_SETPRIORITY 1 + +/* Define to 1 if you have the `setregid' function. */ +#define HAVE_SETREGID 1 + +/* Define to 1 if you have the `setresgid' function. */ +#define HAVE_SETRESGID 1 + +/* Define to 1 if you have the `setresuid' function. */ +#define HAVE_SETRESUID 1 + +/* Define to 1 if you have the `setreuid' function. */ +#define HAVE_SETREUID 1 + +/* Define to 1 if you have the `setsid' function. */ +#define HAVE_SETSID 1 + +/* Define to 1 if you have the `setuid' function. */ +#define HAVE_SETUID 1 + +/* Define to 1 if you have the `setvbuf' function. */ +#define HAVE_SETVBUF 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SHADOW_H */ + +/* Define to 1 if you have the `sigaction' function. */ +#define HAVE_SIGACTION 1 + +/* Define to 1 if you have the `sigaltstack' function. */ +#define HAVE_SIGALTSTACK 1 + +/* Define to 1 if you have the `siginterrupt' function. */ +#define HAVE_SIGINTERRUPT 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SIGNAL_H 1 + +/* Define to 1 if you have the `sigpending' function. */ +#define HAVE_SIGPENDING 1 + +/* Define to 1 if you have the `sigrelse' function. */ +/* #undef HAVE_SIGRELSE */ + +/* Define to 1 if you have the `sigtimedwait' function. */ +/* #undef HAVE_SIGTIMEDWAIT */ + +/* Define to 1 if you have the `sigwait' function. */ +#define HAVE_SIGWAIT 1 + +/* Define to 1 if you have the `sigwaitinfo' function. */ +/* #undef HAVE_SIGWAITINFO */ + +/* Define to 1 if you have the `snprintf' function. */ +#define HAVE_SNPRINTF 1 + +/* Define if sockaddr has sa_len member */ +/* #undef HAVE_SOCKADDR_SA_LEN */ + +/* struct sockaddr_storage (sys/socket.h) */ +#define HAVE_SOCKADDR_STORAGE 1 + +/* Define if you have the 'socketpair' function. */ +#define HAVE_SOCKETPAIR 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SPAWN_H */ + +/* Define if your compiler provides ssize_t */ +#define HAVE_SSIZE_T 1 + +/* Define to 1 if you have the `statvfs' function. */ +/* #undef HAVE_STATVFS */ + +/* Define if you have struct stat.st_mtim.tv_nsec */ +/* #undef HAVE_STAT_TV_NSEC */ + +/* Define if you have struct stat.st_mtimensec */ +/* #undef HAVE_STAT_TV_NSEC2 */ + +/* Define if your compiler supports variable length function prototypes (e.g. + void fprintf(FILE *, char *, ...);) *and* */ +#define HAVE_STDARG_PROTOTYPES 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Has stdatomic.h, atomic_int and _Atomic void* types work */ +#define HAVE_STD_ATOMIC 1 + +/* Define to 1 if you have the `strdup' function. */ +#define HAVE_STRDUP 1 + +/* Define to 1 if you have the `strftime' function. */ +#define HAVE_STRFTIME 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the `strlcpy' function. */ +#define HAVE_STRLCPY 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_STROPTS_H */ + +/* Define to 1 if `st_birthtime' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_BIRTHTIME */ + +/* Define to 1 if `st_blksize' is a member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_BLKSIZE 1 + +/* Define to 1 if `st_blocks' is a member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_BLOCKS 1 + +/* Define to 1 if `st_flags' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_FLAGS */ + +/* Define to 1 if `st_gen' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_GEN */ + +/* Define to 1 if `st_rdev' is a member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_RDEV 1 + +/* Define to 1 if `tm_zone' is a member of `struct tm'. */ +#define HAVE_STRUCT_TM_TM_ZONE 1 + +/* Define to 1 if your `struct stat' has `st_blocks'. Deprecated, use + `HAVE_STRUCT_STAT_ST_BLOCKS' instead. */ +#define HAVE_ST_BLOCKS 1 + +/* Define if you have the 'symlink' function. */ +#define HAVE_SYMLINK 1 + +/* Define to 1 if you have the `symlinkat' function. */ +/* #undef HAVE_SYMLINKAT */ + +/* Define to 1 if you have the `sync' function. */ +#define HAVE_SYNC 1 + +/* Define to 1 if you have the `sysconf' function. */ +#define HAVE_SYSCONF 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYSEXITS_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_AUDIOIO_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_BSDTTY_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_DEVPOLL_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +/* #undef HAVE_SYS_DIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_ENDIAN_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_EPOLL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_EVENT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_FILE_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_IOCTL_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_KERN_CONTROL_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_LOADAVG_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_LOCK_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_MKDEV_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_MODEM_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +/* #undef HAVE_SYS_NDIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_PARAM_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_POLL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_RESOURCE_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SELECT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SENDFILE_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SOCKET_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_STATVFS_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SYSCALL_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_SYS_DOMAIN_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_TERMIO_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIMES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UIO_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UN_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UTSNAME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_WAIT_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_XATTR_H */ + +/* Define to 1 if you have the `tcgetpgrp' function. */ +#define HAVE_TCGETPGRP 1 + +/* Define to 1 if you have the `tcsetpgrp' function. */ +#define HAVE_TCSETPGRP 1 + +/* Define to 1 if you have the `tempnam' function. */ +#define HAVE_TEMPNAM 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_TERMIOS_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_TERM_H */ + +/* Define to 1 if you have the `tgamma' function. */ +#define HAVE_TGAMMA 1 + +/* Define to 1 if you have the `timegm' function. */ +/* #undef HAVE_TIMEGM */ + +/* Define to 1 if you have the `times' function. */ +#define HAVE_TIMES 1 + +/* Define to 1 if you have the `tmpfile' function. */ +#define HAVE_TMPFILE 1 + +/* Define to 1 if you have the `tmpnam' function. */ +#define HAVE_TMPNAM 1 + +/* Define to 1 if you have the `tmpnam_r' function. */ +/* #undef HAVE_TMPNAM_R */ + +/* Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use + `HAVE_STRUCT_TM_TM_ZONE' instead. */ +#define HAVE_TM_ZONE 1 + +/* Define to 1 if you have the `truncate' function. */ +#define HAVE_TRUNCATE 1 + +/* Define to 1 if you don't have `tm_zone' but do have the external array + `tzname'. */ +/* #undef HAVE_TZNAME */ + +/* Define this if you have tcl and TCL_UTF_MAX==6 */ +/* #undef HAVE_UCS4_TCL */ + +/* Define if your compiler provides uint32_t. */ +#define HAVE_UINT32_T 1 + +/* Define if your compiler provides uint64_t. */ +#define HAVE_UINT64_T 1 + +/* Define to 1 if the system has the type `uintptr_t'. */ +#define HAVE_UINTPTR_T 1 + +/* Define to 1 if you have the `uname' function. */ +#define HAVE_UNAME 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you have the `unlinkat' function. */ +#define HAVE_UNLINKAT 1 + +/* Define to 1 if you have the `unsetenv' function. */ +#define HAVE_UNSETENV 1 + +/* Define if you have a useable wchar_t type defined in wchar.h; useable means + wchar_t must be an unsigned type with at least 16 bits. (see + Include/unicodeobject.h). */ +/* #undef HAVE_USABLE_WCHAR_T */ + +/* Define to 1 if you have the header file. */ +#define HAVE_UTIL_H 1 + +/* Define to 1 if you have the `utimensat' function. */ +/* #undef HAVE_UTIMENSAT */ + +/* Define to 1 if you have the `utimes' function. */ +#define HAVE_UTIMES 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UTIME_H 1 + +/* Define to 1 if you have the `wait3' function. */ +#define HAVE_WAIT3 1 + +/* Define to 1 if you have the `wait4' function. */ +/* #undef HAVE_WAIT4 */ + +/* Define to 1 if you have the `waitid' function. */ +#define HAVE_WAITID 1 + +/* Define to 1 if you have the `waitpid' function. */ +#define HAVE_WAITPID 1 + +/* Define if the compiler provides a wchar.h header file. */ +#define HAVE_WCHAR_H 1 + +/* Define to 1 if you have the `wcscoll' function. */ +#define HAVE_WCSCOLL 1 + +/* Define to 1 if you have the `wcsftime' function. */ +#define HAVE_WCSFTIME 1 + +/* Define to 1 if you have the `wcsxfrm' function. */ +#define HAVE_WCSXFRM 1 + +/* Define to 1 if you have the `wmemcmp' function. */ +#define HAVE_WMEMCMP 1 + +/* Define if tzset() actually switches the local timezone in a meaningful way. + */ +/* #undef HAVE_WORKING_TZSET */ + +/* Define to 1 if you have the `writev' function. */ +#define HAVE_WRITEV 1 + +/* Define if the zlib library has inflateCopy */ +#define HAVE_ZLIB_COPY 1 + +/* Define to 1 if you have the `_getpty' function. */ +/* #undef HAVE__GETPTY */ + +/* Define if log1p(-0.) is 0. rather than -0. */ +/* #undef LOG1P_DROPS_ZERO_SIGN */ + +/* Define to 1 if `major', `minor', and `makedev' are declared in . + */ +/* #undef MAJOR_IN_MKDEV */ + +/* Define to 1 if `major', `minor', and `makedev' are declared in + . */ +#define MAJOR_IN_SYSMACROS 1 + +/* Define if mvwdelch in curses.h is an expression. */ +/* #undef MVWDELCH_IS_EXPRESSION */ + +/* Define to the address where bug reports for this package should be sent. */ +/* #undef PACKAGE_BUGREPORT */ + +/* Define to the full name of this package. */ +/* #undef PACKAGE_NAME */ + +/* Define to the full name and version of this package. */ +/* #undef PACKAGE_STRING */ + +/* Define to the one symbol short name of this package. */ +/* #undef PACKAGE_TARNAME */ + +/* Define to the home page for this package. */ +/* #undef PACKAGE_URL */ + +/* Define to the version of this package. */ +/* #undef PACKAGE_VERSION */ + +/* Define if POSIX semaphores aren't enabled on your system */ +/* #undef POSIX_SEMAPHORES_NOT_ENABLED */ + +/* Defined if PTHREAD_SCOPE_SYSTEM supported. */ +/* #undef PTHREAD_SYSTEM_SCHED_SUPPORTED */ + +/* Define as the preferred size in bits of long digits */ +/* #undef PYLONG_BITS_IN_DIGIT */ + +/* Define to printf format modifier for long long type */ +#define PY_FORMAT_LONG_LONG "ll" + +/* Define to printf format modifier for Py_ssize_t */ +#define PY_FORMAT_SIZE_T "z" + +/* Define if you want to build an interpreter with many run-time checks. */ +/* #undef Py_DEBUG */ + +/* Defined if Python is built as a shared library. */ +#define Py_ENABLE_SHARED 1 + +/* Define hash algorithm for str, bytes and memoryview. SipHash24: 1, FNV: 2, + externally defined: 0 */ +/* #undef Py_HASH_ALGORITHM */ + +/* assume C89 semantics that RETSIGTYPE is always void */ +#define RETSIGTYPE void + +/* Define if setpgrp() must be called as setpgrp(0, 0). */ +/* #undef SETPGRP_HAVE_ARG */ + +/* Define if i>>j for signed int i does not extend the sign bit when i < 0 */ +/* #undef SIGNED_RIGHT_SHIFT_ZERO_FILLS */ + +/* The size of `double', as computed by sizeof. */ +#define SIZEOF_DOUBLE 8 + +/* The size of `float', as computed by sizeof. */ +#define SIZEOF_FLOAT 4 + +/* The size of `fpos_t', as computed by sizeof. */ +#define SIZEOF_FPOS_T 4 + +/* The size of `int', as computed by sizeof. */ +#define SIZEOF_INT 4 + +/* The size of `long', as computed by sizeof. */ +#define SIZEOF_LONG 4 + +/* The size of `long double', as computed by sizeof. */ +#define SIZEOF_LONG_DOUBLE 8 + +/* The size of `long long', as computed by sizeof. */ +#define SIZEOF_LONG_LONG 8 + +/* The size of `off_t', as computed by sizeof. */ +#define SIZEOF_OFF_T 4 + +/* The size of `pid_t', as computed by sizeof. */ +#define SIZEOF_PID_T 4 + +/* The size of `pthread_t', as computed by sizeof. */ +#define SIZEOF_PTHREAD_T 4 + +/* The size of `short', as computed by sizeof. */ +#define SIZEOF_SHORT 2 + +/* The size of `size_t', as computed by sizeof. */ +#define SIZEOF_SIZE_T 4 + +/* The size of `time_t', as computed by sizeof. */ +#define SIZEOF_TIME_T 4 + +/* The size of `uintptr_t', as computed by sizeof. */ +#define SIZEOF_UINTPTR_T 4 + +/* The size of `void *', as computed by sizeof. */ +#define SIZEOF_VOID_P 4 + +/* The size of `wchar_t', as computed by sizeof. */ +#define SIZEOF_WCHAR_T 4 + +/* The size of `_Bool', as computed by sizeof. */ +#define SIZEOF__BOOL 1 + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define if you can safely include both and + (which you can't on SCO ODT 3.0). */ +#define SYS_SELECT_WITH_SYS_TIME 1 + +/* Define if tanh(-0.) is -0., or if platform doesn't have signed zeros */ +/* #undef TANH_PRESERVES_ZERO_SIGN */ + +/* Library needed by timemodule.c: librt may be needed for clock_gettime() */ +/* #undef TIMEMODULE_LIB */ + +/* Define to 1 if you can safely include both and . */ +#define TIME_WITH_SYS_TIME 1 + +/* Define to 1 if your declares `struct tm'. */ +/* #undef TM_IN_SYS_TIME */ + +/* Define if you want to use computed gotos in ceval.c. */ +#define USE_COMPUTED_GOTOS 1 + +/* Define to use the C99 inline keyword. */ +#define USE_INLINE 1 + +/* Enable extensions on AIX 3, Interix. */ +#ifndef _ALL_SOURCE +# define _ALL_SOURCE 1 +#endif +/* Enable GNU extensions on systems that have them. */ +#ifndef _GNU_SOURCE +# define _GNU_SOURCE 1 +#endif +/* Enable threading extensions on Solaris. */ +#ifndef _POSIX_PTHREAD_SEMANTICS +# define _POSIX_PTHREAD_SEMANTICS 1 +#endif +/* Enable extensions on HP NonStop. */ +#ifndef _TANDEM_SOURCE +# define _TANDEM_SOURCE 1 +#endif +/* Enable general extensions on Solaris. */ +#ifndef __EXTENSIONS__ +# define __EXTENSIONS__ 1 +#endif + + +/* Define if a va_list is an array of some kind */ +/* #undef VA_LIST_IS_ARRAY */ + +/* Define if you want SIGFPE handled (see Include/pyfpe.h). */ +/* #undef WANT_SIGFPE_HANDLER */ + +/* Define if WINDOW in curses.h offers a field _flags. */ +/* #undef WINDOW_HAS_FLAGS */ + +/* Define if you want documentation strings in extension modules */ +#define WITH_DOC_STRINGS 1 + +/* Define if you want to use the new-style (Openstep, Rhapsody, MacOS) dynamic + linker (dyld) instead of the old-style (NextStep) dynamic linker (rld). + Dyld is necessary to support frameworks. */ +/* #undef WITH_DYLD */ + +/* Define to 1 if libintl is needed for locale functions. */ +/* #undef WITH_LIBINTL */ + +/* Define if you want to produce an OpenStep/Rhapsody framework (shared + library plus accessory files). */ +/* #undef WITH_NEXT_FRAMEWORK */ + +/* Define if you want to compile in Python-specific mallocs */ +#define WITH_PYMALLOC 1 + +/* Define if you want to compile in rudimentary thread support */ +#define WITH_THREAD 1 + +/* Define to profile with the Pentium timestamp counter */ +/* #undef WITH_TSC */ + +/* Define if you want pymalloc to be disabled when running under valgrind */ +/* #undef WITH_VALGRIND */ + +/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most + significant byte first (like Motorola and SPARC, unlike Intel). */ +#if defined AC_APPLE_UNIVERSAL_BUILD +# if defined __BIG_ENDIAN__ +# define WORDS_BIGENDIAN 1 +# endif +#else +# ifndef WORDS_BIGENDIAN +/* # undef WORDS_BIGENDIAN */ +# endif +#endif + +/* Define if arithmetic is subject to x87-style double rounding issue */ +/* #undef X87_DOUBLE_ROUNDING */ + +/* Define on OpenBSD to activate all library features */ +/* #undef _BSD_SOURCE */ + +/* Define on Irix to enable u_int */ +#define _BSD_TYPES 1 + +/* Define on Darwin to activate all library features */ +#define _DARWIN_C_SOURCE 1 + +/* This must be set to 64 on some systems to enable large file support. */ +#define _FILE_OFFSET_BITS 64 + +/* Define on Linux to activate all library features */ +#define _GNU_SOURCE 1 + +/* Define to include mbstate_t for mbrtowc */ +/* #undef _INCLUDE__STDC_A1_SOURCE */ + +/* This must be defined on some systems to enable large file support. */ +#define _LARGEFILE_SOURCE 1 + +/* This must be defined on AIX systems to enable large file support. */ +/* #undef _LARGE_FILES */ + +/* Define to 1 if on MINIX. */ +/* #undef _MINIX */ + +/* Define on NetBSD to activate all library features */ +#define _NETBSD_SOURCE 1 + +/* Define to 2 if the system does not provide POSIX.1 features except with + this defined. */ +/* #undef _POSIX_1_SOURCE */ + +/* Define to activate features from IEEE Stds 1003.1-2008 */ +#define _POSIX_C_SOURCE 200809L + +/* Define to 1 if you need to in order for `stat' and other things to work. */ +/* #undef _POSIX_SOURCE */ + +/* Define if you have POSIX threads, and your system does not define that. */ +/* #undef _POSIX_THREADS */ + +/* Define to force use of thread-safe errno, h_errno, and other functions */ +#define _REENTRANT 1 + +/* Define for Solaris 2.5.1 so the uint32_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +/* #undef _UINT32_T */ + +/* Define for Solaris 2.5.1 so the uint64_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +/* #undef _UINT64_T */ + +/* Define to the level of X/Open that your system supports */ +#define _XOPEN_SOURCE 700 + +/* Define to activate Unix95-and-earlier features */ +#define _XOPEN_SOURCE_EXTENDED 1 + +/* Define on FreeBSD to activate all library features */ +#define __BSD_VISIBLE 1 + +/* Define to 1 if type `char' is unsigned and you are not using gcc. */ +#ifndef __CHAR_UNSIGNED__ +/* # undef __CHAR_UNSIGNED__ */ +#endif + +/* Define to 'long' if doesn't define. */ +/* #undef clock_t */ + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ + +/* Define to `int' if doesn't define. */ +/* #undef gid_t */ + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +/* #undef inline */ +#endif + +/* Define to the type of a signed integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +/* #undef int32_t */ + +/* Define to the type of a signed integer type of width exactly 64 bits if + such a type exists and the standard includes do not define it. */ +/* #undef int64_t */ + +/* Define to `int' if does not define. */ +/* #undef mode_t */ + +/* Define to `long int' if does not define. */ +/* #undef off_t */ + +/* Define to `int' if does not define. */ +/* #undef pid_t */ + +/* Define to empty if the keyword does not work. */ +/* #undef signed */ + +/* Define to `unsigned int' if does not define. */ +/* #undef size_t */ + +/* Define to `int' if does not define. */ +/* #undef socklen_t */ + +/* Define to `int' if doesn't define. */ +/* #undef uid_t */ + +/* Define to the type of an unsigned integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint32_t */ + +/* Define to the type of an unsigned integer type of width exactly 64 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint64_t */ + +/* Define to empty if the keyword does not work. */ +/* #undef volatile */ + + +/* Define the macros needed if on a UnixWare 7.x system. */ +#if defined(__USLC__) && defined(__SCO_VERSION__) +#define STRICT_SYSV_CURSES /* Don't use ncurses extensions */ +#endif + +#endif /*Py_PYCONFIG_H*/ + diff --git a/android/python35/include/pyconfig_x86_64.h b/android/python35/include/pyconfig_x86_64.h new file mode 100644 index 000000000..d0037be57 --- /dev/null +++ b/android/python35/include/pyconfig_x86_64.h @@ -0,0 +1,1530 @@ +/* pyconfig.h. Generated from pyconfig.h.in by configure. */ +/* pyconfig.h.in. Generated from configure.ac by autoheader. */ + + +#ifndef Py_PYCONFIG_H +#define Py_PYCONFIG_H + + +/* Define if building universal (internal helper macro) */ +/* #undef AC_APPLE_UNIVERSAL_BUILD */ + +/* Define for AIX if your compiler is a genuine IBM xlC/xlC_r and you want + support for AIX C++ shared extension modules. */ +/* #undef AIX_GENUINE_CPLUSPLUS */ + +/* Define if C doubles are 64-bit IEEE 754 binary format, stored in ARM + mixed-endian order (byte order 45670123) */ +/* #undef DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754 */ + +/* Define if C doubles are 64-bit IEEE 754 binary format, stored with the most + significant byte first */ +/* #undef DOUBLE_IS_BIG_ENDIAN_IEEE754 */ + +/* Define if C doubles are 64-bit IEEE 754 binary format, stored with the + least significant byte first */ +/* #undef DOUBLE_IS_LITTLE_ENDIAN_IEEE754 */ + +/* Define if --enable-ipv6 is specified */ +#define ENABLE_IPV6 1 + +/* Define if flock needs to be linked with bsd library. */ +/* #undef FLOCK_NEEDS_LIBBSD */ + +/* Define if getpgrp() must be called as getpgrp(0). */ +/* #undef GETPGRP_HAVE_ARG */ + +/* Define if gettimeofday() does not have second (timezone) argument This is + the case on Motorola V4 (R40V4.2) */ +/* #undef GETTIMEOFDAY_NO_TZ */ + +/* Define to 1 if you have the `accept4' function. */ +#define HAVE_ACCEPT4 1 + +/* Define to 1 if you have the `acosh' function. */ +#define HAVE_ACOSH 1 + +/* struct addrinfo (netdb.h) */ +#define HAVE_ADDRINFO 1 + +/* Define to 1 if you have the `alarm' function. */ +#define HAVE_ALARM 1 + +/* Define if aligned memory access is required */ +#define HAVE_ALIGNED_REQUIRED 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ALLOCA_H 1 + +/* Define this if your time.h defines altzone. */ +/* #undef HAVE_ALTZONE */ + +/* Define to 1 if you have the `asinh' function. */ +#define HAVE_ASINH 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ASM_TYPES_H 1 + +/* Define to 1 if you have the `atanh' function. */ +#define HAVE_ATANH 1 + +/* Define to 1 if you have the `bind_textdomain_codeset' function. */ +/* #undef HAVE_BIND_TEXTDOMAIN_CODESET */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_BLUETOOTH_BLUETOOTH_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_BLUETOOTH_H */ + +/* Define if mbstowcs(NULL, "text", 0) does not return the number of wide + chars that would be converted. */ +/* #undef HAVE_BROKEN_MBSTOWCS */ + +/* Define if nice() returns success/failure instead of the new priority. */ +/* #undef HAVE_BROKEN_NICE */ + +/* Define if the system reports an invalid PIPE_BUF value. */ +/* #undef HAVE_BROKEN_PIPE_BUF */ + +/* Define if poll() sets errno on invalid file descriptors. */ +/* #undef HAVE_BROKEN_POLL */ + +/* Define if the Posix semaphores do not work on your system */ +/* #undef HAVE_BROKEN_POSIX_SEMAPHORES */ + +/* Define if pthread_sigmask() does not work on your system. */ +/* #undef HAVE_BROKEN_PTHREAD_SIGMASK */ + +/* define to 1 if your sem_getvalue is broken. */ +#define HAVE_BROKEN_SEM_GETVALUE 1 + +/* Define if `unsetenv` does not return an int. */ +/* #undef HAVE_BROKEN_UNSETENV */ + +/* Has builtin atomics */ +#define HAVE_BUILTIN_ATOMIC 1 + +/* Define this if you have the type _Bool. */ +#define HAVE_C99_BOOL 1 + +/* Define to 1 if you have the 'chflags' function. */ +/* #undef HAVE_CHFLAGS */ + +/* Define to 1 if you have the `chown' function. */ +#define HAVE_CHOWN 1 + +/* Define if you have the 'chroot' function. */ +#define HAVE_CHROOT 1 + +/* Define to 1 if you have the `clock' function. */ +#define HAVE_CLOCK 1 + +/* Define to 1 if you have the `clock_getres' function. */ +#define HAVE_CLOCK_GETRES 1 + +/* Define to 1 if you have the `clock_gettime' function. */ +#define HAVE_CLOCK_GETTIME 1 + +/* Define if the C compiler supports computed gotos. */ +#define HAVE_COMPUTED_GOTOS 1 + +/* Define to 1 if you have the `confstr' function. */ +/* #undef HAVE_CONFSTR */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_CONIO_H */ + +/* Define to 1 if you have the `copysign' function. */ +#define HAVE_COPYSIGN 1 + +/* Define to 1 if you have the `ctermid' function. */ +/* #undef HAVE_CTERMID */ + +/* Define if you have the 'ctermid_r' function. */ +#define HAVE_CTERMID_R 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_CURSES_H */ + +/* Define if you have the 'is_term_resized' function. */ +/* #undef HAVE_CURSES_IS_TERM_RESIZED */ + +/* Define if you have the 'resizeterm' function. */ +/* #undef HAVE_CURSES_RESIZETERM */ + +/* Define if you have the 'resize_term' function. */ +/* #undef HAVE_CURSES_RESIZE_TERM */ + +/* Define to 1 if you have the declaration of `isfinite', and to 0 if you + don't. */ +#define HAVE_DECL_ISFINITE 1 + +/* Define to 1 if you have the declaration of `isinf', and to 0 if you don't. + */ +#define HAVE_DECL_ISINF 1 + +/* Define to 1 if you have the declaration of `isnan', and to 0 if you don't. + */ +#define HAVE_DECL_ISNAN 1 + +/* Define to 1 if you have the declaration of `tzname', and to 0 if you don't. + */ +/* #undef HAVE_DECL_TZNAME */ + +/* Define to 1 if you have the device macros. */ +#define HAVE_DEVICE_MACROS 1 + +/* Define to 1 if you have the /dev/ptc device file. */ +/* #undef HAVE_DEV_PTC */ + +/* Define to 1 if you have the /dev/ptmx device file. */ +/* #undef HAVE_DEV_PTMX */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_DIRECT_H */ + +/* Define to 1 if the dirent structure has a d_type field */ +#define HAVE_DIRENT_D_TYPE 1 + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +#define HAVE_DIRENT_H 1 + +/* Define if you have the 'dirfd' function or macro. */ +#define HAVE_DIRFD 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_DLFCN_H 1 + +/* Define to 1 if you have the `dlopen' function. */ +#define HAVE_DLOPEN 1 + +/* Define to 1 if you have the `dup2' function. */ +#define HAVE_DUP2 1 + +/* Define to 1 if you have the `dup3' function. */ +#define HAVE_DUP3 1 + +/* Defined when any dynamic module loading is enabled. */ +#define HAVE_DYNAMIC_LOADING 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ENDIAN_H 1 + +/* Define if you have the 'epoll' functions. */ +#define HAVE_EPOLL 1 + +/* Define if you have the 'epoll_create1' function. */ +#define HAVE_EPOLL_CREATE1 1 + +/* Define to 1 if you have the `erf' function. */ +#define HAVE_ERF 1 + +/* Define to 1 if you have the `erfc' function. */ +#define HAVE_ERFC 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_ERRNO_H 1 + +/* Define to 1 if you have the `execv' function. */ +#define HAVE_EXECV 1 + +/* Define to 1 if you have the `expm1' function. */ +#define HAVE_EXPM1 1 + +/* Define to 1 if you have the `faccessat' function. */ +/* #undef HAVE_FACCESSAT */ + +/* Define if you have the 'fchdir' function. */ +#define HAVE_FCHDIR 1 + +/* Define to 1 if you have the `fchmod' function. */ +#define HAVE_FCHMOD 1 + +/* Define to 1 if you have the `fchmodat' function. */ +#define HAVE_FCHMODAT 1 + +/* Define to 1 if you have the `fchown' function. */ +#define HAVE_FCHOWN 1 + +/* Define to 1 if you have the `fchownat' function. */ +#define HAVE_FCHOWNAT 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_FCNTL_H 1 + +/* Define if you have the 'fdatasync' function. */ +#define HAVE_FDATASYNC 1 + +/* Define to 1 if you have the `fdopendir' function. */ +#define HAVE_FDOPENDIR 1 + +/* Define to 1 if you have the `fexecve' function. */ +/* #undef HAVE_FEXECVE */ + +/* Define to 1 if you have the `finite' function. */ +#define HAVE_FINITE 1 + +/* Define to 1 if you have the `flock' function. */ +#define HAVE_FLOCK 1 + +/* Define to 1 if you have the `fork' function. */ +#define HAVE_FORK 1 + +/* Define to 1 if you have the `forkpty' function. */ +/* #undef HAVE_FORKPTY */ + +/* Define to 1 if you have the `fpathconf' function. */ +#define HAVE_FPATHCONF 1 + +/* Define to 1 if you have the `fseek64' function. */ +/* #undef HAVE_FSEEK64 */ + +/* Define to 1 if you have the `fseeko' function. */ +#define HAVE_FSEEKO 1 + +/* Define to 1 if you have the `fstatat' function. */ +#define HAVE_FSTATAT 1 + +/* Define to 1 if you have the `fstatvfs' function. */ +#define HAVE_FSTATVFS 1 + +/* Define if you have the 'fsync' function. */ +#define HAVE_FSYNC 1 + +/* Define to 1 if you have the `ftell64' function. */ +/* #undef HAVE_FTELL64 */ + +/* Define to 1 if you have the `ftello' function. */ +#define HAVE_FTELLO 1 + +/* Define to 1 if you have the `ftime' function. */ +/* #undef HAVE_FTIME */ + +/* Define to 1 if you have the `ftruncate' function. */ +#define HAVE_FTRUNCATE 1 + +/* Define to 1 if you have the `futimens' function. */ +#define HAVE_FUTIMENS 1 + +/* Define to 1 if you have the `futimes' function. */ +/* #undef HAVE_FUTIMES */ + +/* Define to 1 if you have the `futimesat' function. */ +/* #undef HAVE_FUTIMESAT */ + +/* Define to 1 if you have the `gai_strerror' function. */ +#define HAVE_GAI_STRERROR 1 + +/* Define to 1 if you have the `gamma' function. */ +/* #undef HAVE_GAMMA */ + +/* Define if we can use gcc inline assembler to get and set mc68881 fpcr */ +/* #undef HAVE_GCC_ASM_FOR_MC68881 */ + +/* Define if we can use x64 gcc inline assembler */ +#define HAVE_GCC_ASM_FOR_X64 1 + +/* Define if we can use gcc inline assembler to get and set x87 control word + */ +#define HAVE_GCC_ASM_FOR_X87 1 + +/* Define if your compiler provides __uint128_t */ +#define HAVE_GCC_UINT128_T 1 + +/* Define if you have the getaddrinfo function. */ +#define HAVE_GETADDRINFO 1 + +/* Define this if you have flockfile(), getc_unlocked(), and funlockfile() */ +#define HAVE_GETC_UNLOCKED 1 + +/* Define to 1 if you have the `getentropy' function. */ +/* #undef HAVE_GETENTROPY */ + +/* Define to 1 if you have the `getgrouplist' function. */ +#define HAVE_GETGROUPLIST 1 + +/* Define to 1 if you have the `getgroups' function. */ +#define HAVE_GETGROUPS 1 + +/* Define to 1 if you have the `gethostbyname' function. */ +#define HAVE_GETHOSTBYNAME 1 + +/* Define this if you have some version of gethostbyname_r() */ +/* #undef HAVE_GETHOSTBYNAME_R */ + +/* Define this if you have the 3-arg version of gethostbyname_r(). */ +/* #undef HAVE_GETHOSTBYNAME_R_3_ARG */ + +/* Define this if you have the 5-arg version of gethostbyname_r(). */ +/* #undef HAVE_GETHOSTBYNAME_R_5_ARG */ + +/* Define this if you have the 6-arg version of gethostbyname_r(). */ +/* #undef HAVE_GETHOSTBYNAME_R_6_ARG */ + +/* Define to 1 if you have the `getitimer' function. */ +#define HAVE_GETITIMER 1 + +/* Define to 1 if you have the `getloadavg' function. */ +#define HAVE_GETLOADAVG 1 + +/* Define to 1 if you have the `getlogin' function. */ +#define HAVE_GETLOGIN 1 + +/* Define to 1 if you have the `getnameinfo' function. */ +#define HAVE_GETNAMEINFO 1 + +/* Define if you have the 'getpagesize' function. */ +#define HAVE_GETPAGESIZE 1 + +/* Define to 1 if you have the `getpeername' function. */ +#define HAVE_GETPEERNAME 1 + +/* Define to 1 if you have the `getpgid' function. */ +#define HAVE_GETPGID 1 + +/* Define to 1 if you have the `getpgrp' function. */ +#define HAVE_GETPGRP 1 + +/* Define to 1 if you have the `getpid' function. */ +#define HAVE_GETPID 1 + +/* Define to 1 if you have the `getpriority' function. */ +#define HAVE_GETPRIORITY 1 + +/* Define to 1 if you have the `getpwent' function. */ +#define HAVE_GETPWENT 1 + +/* Define to 1 if the Linux getrandom() syscall is available */ +/* #undef HAVE_GETRANDOM_SYSCALL */ + +/* Define to 1 if you have the `getresgid' function. */ +#define HAVE_GETRESGID 1 + +/* Define to 1 if you have the `getresuid' function. */ +#define HAVE_GETRESUID 1 + +/* Define to 1 if you have the `getsid' function. */ +#define HAVE_GETSID 1 + +/* Define to 1 if you have the `getspent' function. */ +/* #undef HAVE_GETSPENT */ + +/* Define to 1 if you have the `getspnam' function. */ +/* #undef HAVE_GETSPNAM */ + +/* Define to 1 if you have the `gettimeofday' function. */ +#define HAVE_GETTIMEOFDAY 1 + +/* Define to 1 if you have the `getwd' function. */ +/* #undef HAVE_GETWD */ + +/* Define if glibc has incorrect _FORTIFY_SOURCE wrappers for memmove and + bcopy. */ +/* #undef HAVE_GLIBC_MEMMOVE_BUG */ + +/* Define to 1 if you have the header file. */ +#define HAVE_GRP_H 1 + +/* Define if you have the 'hstrerror' function. */ +#define HAVE_HSTRERROR 1 + +/* Define this if you have le64toh() */ +#define HAVE_HTOLE64 1 + +/* Define to 1 if you have the `hypot' function. */ +#define HAVE_HYPOT 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_IEEEFP_H */ + +/* Define to 1 if you have the `if_nameindex' function. */ +/* #undef HAVE_IF_NAMEINDEX */ + +/* Define if you have the 'inet_aton' function. */ +#define HAVE_INET_ATON 1 + +/* Define if you have the 'inet_pton' function. */ +#define HAVE_INET_PTON 1 + +/* Define to 1 if you have the `initgroups' function. */ +#define HAVE_INITGROUPS 1 + +/* Define if your compiler provides int32_t. */ +#define HAVE_INT32_T 1 + +/* Define if your compiler provides int64_t. */ +#define HAVE_INT64_T 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_IO_H */ + +/* Define if gcc has the ipa-pure-const bug. */ +/* #undef HAVE_IPA_PURE_CONST_BUG */ + +/* Define to 1 if you have the `kill' function. */ +#define HAVE_KILL 1 + +/* Define to 1 if you have the `killpg' function. */ +#define HAVE_KILLPG 1 + +/* Define if you have the 'kqueue' functions. */ +#define HAVE_KQUEUE 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_LANGINFO_H 1 + +/* Defined to enable large file support when an off_t is bigger than a long + and long long is available and at least as big as an off_t. You may need to + add some flags for configuration and compilation to enable this mode. (For + Solaris and Linux, the necessary defines are already defined.) */ +/* #undef HAVE_LARGEFILE_SUPPORT */ + +/* Define to 1 if you have the 'lchflags' function. */ +/* #undef HAVE_LCHFLAGS */ + +/* Define to 1 if you have the `lchmod' function. */ +/* #undef HAVE_LCHMOD */ + +/* Define to 1 if you have the `lchown' function. */ +#define HAVE_LCHOWN 1 + +/* Define to 1 if you have the `lgamma' function. */ +#define HAVE_LGAMMA 1 + +/* Define to 1 if you have the `dl' library (-ldl). */ +#define HAVE_LIBDL 1 + +/* Define to 1 if you have the `dld' library (-ldld). */ +/* #undef HAVE_LIBDLD */ + +/* Define to 1 if you have the `ieee' library (-lieee). */ +/* #undef HAVE_LIBIEEE */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LIBINTL_H */ + +/* Define if you have the readline library (-lreadline). */ +/* #undef HAVE_LIBREADLINE */ + +/* Define to 1 if you have the `resolv' library (-lresolv). */ +/* #undef HAVE_LIBRESOLV */ + +/* Define to 1 if you have the `sendfile' library (-lsendfile). */ +/* #undef HAVE_LIBSENDFILE */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LIBUTIL_H */ + +/* Define if you have the 'link' function. */ +#define HAVE_LINK 1 + +/* Define to 1 if you have the `linkat' function. */ +#define HAVE_LINKAT 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_LINUX_CAN_BCM_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_LINUX_CAN_H 1 + +/* Define if compiling using Linux 3.6 or later. */ +#define HAVE_LINUX_CAN_RAW_FD_FRAMES 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_LINUX_CAN_RAW_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_LINUX_NETLINK_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_LINUX_TIPC_H 1 + +/* Define to 1 if you have the `lockf' function. */ +#define HAVE_LOCKF 1 + +/* Define to 1 if you have the `log1p' function. */ +#define HAVE_LOG1P 1 + +/* Define to 1 if you have the `log2' function. */ +#define HAVE_LOG2 1 + +/* Define this if you have the type long double. */ +#define HAVE_LONG_DOUBLE 1 + +/* Define this if you have the type long long. */ +#define HAVE_LONG_LONG 1 + +/* Define to 1 if you have the `lstat' function. */ +#define HAVE_LSTAT 1 + +/* Define to 1 if you have the `lutimes' function. */ +/* #undef HAVE_LUTIMES */ + +/* Define this if you have the makedev macro. */ +#define HAVE_MAKEDEV 1 + +/* Define to 1 if you have the `mbrtowc' function. */ +#define HAVE_MBRTOWC 1 + +/* Define to 1 if you have the `memmove' function. */ +#define HAVE_MEMMOVE 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the `memrchr' function. */ +#define HAVE_MEMRCHR 1 + +/* Define to 1 if you have the `mkdirat' function. */ +#define HAVE_MKDIRAT 1 + +/* Define to 1 if you have the `mkfifo' function. */ +#define HAVE_MKFIFO 1 + +/* Define to 1 if you have the `mkfifoat' function. */ +/* #undef HAVE_MKFIFOAT */ + +/* Define to 1 if you have the `mknod' function. */ +#define HAVE_MKNOD 1 + +/* Define to 1 if you have the `mknodat' function. */ +#define HAVE_MKNODAT 1 + +/* Define to 1 if you have the `mktime' function. */ +#define HAVE_MKTIME 1 + +/* Define to 1 if you have the `mmap' function. */ +#define HAVE_MMAP 1 + +/* Define to 1 if you have the `mremap' function. */ +#define HAVE_MREMAP 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_NCURSES_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. */ +/* #undef HAVE_NDIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_NETPACKET_PACKET_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_NET_IF_H 1 + +/* Define to 1 if you have the `nice' function. */ +#define HAVE_NICE 1 + +/* Define to 1 if you have the `openat' function. */ +#define HAVE_OPENAT 1 + +/* Define to 1 if you have the `openpty' function. */ +/* #undef HAVE_OPENPTY */ + +/* Define if compiling using MacOS X 10.5 SDK or later. */ +/* #undef HAVE_OSX105_SDK */ + +/* Define to 1 if you have the `pathconf' function. */ +#define HAVE_PATHCONF 1 + +/* Define to 1 if you have the `pause' function. */ +#define HAVE_PAUSE 1 + +/* Define to 1 if you have the `pipe2' function. */ +#define HAVE_PIPE2 1 + +/* Define to 1 if you have the `plock' function. */ +/* #undef HAVE_PLOCK */ + +/* Define to 1 if you have the `poll' function. */ +#define HAVE_POLL 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_POLL_H 1 + +/* Define to 1 if you have the `posix_fadvise' function. */ +#define HAVE_POSIX_FADVISE 1 + +/* Define to 1 if you have the `posix_fallocate' function. */ +#define HAVE_POSIX_FALLOCATE 1 + +/* Define to 1 if you have the `pread' function. */ +#define HAVE_PREAD 1 + +/* Define if you have the 'prlimit' functions. */ +#define HAVE_PRLIMIT 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PROCESS_H */ + +/* Define if your compiler supports function prototype */ +#define HAVE_PROTOTYPES 1 + +/* Define to 1 if you have the `pthread_atfork' function. */ +#define HAVE_PTHREAD_ATFORK 1 + +/* Defined for Solaris 2.6 bug in pthread header. */ +/* #undef HAVE_PTHREAD_DESTRUCTOR */ + +/* Define to 1 if you have the header file. */ +#define HAVE_PTHREAD_H 1 + +/* Define to 1 if you have the `pthread_init' function. */ +/* #undef HAVE_PTHREAD_INIT */ + +/* Define to 1 if you have the `pthread_kill' function. */ +#define HAVE_PTHREAD_KILL 1 + +/* Define to 1 if you have the `pthread_sigmask' function. */ +#define HAVE_PTHREAD_SIGMASK 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_PTY_H */ + +/* Define to 1 if you have the `putenv' function. */ +#define HAVE_PUTENV 1 + +/* Define to 1 if you have the `pwrite' function. */ +#define HAVE_PWRITE 1 + +/* Define if the libcrypto has RAND_egd */ +/* #undef HAVE_RAND_EGD */ + +/* Define to 1 if you have the `readlink' function. */ +#define HAVE_READLINK 1 + +/* Define to 1 if you have the `readlinkat' function. */ +#define HAVE_READLINKAT 1 + +/* Define to 1 if you have the `readv' function. */ +#define HAVE_READV 1 + +/* Define to 1 if you have the `realpath' function. */ +#define HAVE_REALPATH 1 + +/* Define to 1 if you have the `renameat' function. */ +#define HAVE_RENAMEAT 1 + +/* Define if readline supports append_history */ +/* #undef HAVE_RL_APPEND_HISTORY */ + +/* Define if you have readline 2.1 */ +/* #undef HAVE_RL_CALLBACK */ + +/* Define if you can turn off readline's signal handling. */ +/* #undef HAVE_RL_CATCH_SIGNAL */ + +/* Define if you have readline 2.2 */ +/* #undef HAVE_RL_COMPLETION_APPEND_CHARACTER */ + +/* Define if you have readline 4.0 */ +/* #undef HAVE_RL_COMPLETION_DISPLAY_MATCHES_HOOK */ + +/* Define if you have readline 4.2 */ +/* #undef HAVE_RL_COMPLETION_MATCHES */ + +/* Define if you have rl_completion_suppress_append */ +/* #undef HAVE_RL_COMPLETION_SUPPRESS_APPEND */ + +/* Define if you have readline 4.0 */ +/* #undef HAVE_RL_PRE_INPUT_HOOK */ + +/* Define to 1 if you have the `round' function. */ +#define HAVE_ROUND 1 + +/* Define to 1 if you have the `sched_get_priority_max' function. */ +#define HAVE_SCHED_GET_PRIORITY_MAX 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SCHED_H 1 + +/* Define to 1 if you have the `sched_rr_get_interval' function. */ +#define HAVE_SCHED_RR_GET_INTERVAL 1 + +/* Define to 1 if you have the `sched_setaffinity' function. */ +#define HAVE_SCHED_SETAFFINITY 1 + +/* Define to 1 if you have the `sched_setparam' function. */ +#define HAVE_SCHED_SETPARAM 1 + +/* Define to 1 if you have the `sched_setscheduler' function. */ +#define HAVE_SCHED_SETSCHEDULER 1 + +/* Define to 1 if you have the `select' function. */ +#define HAVE_SELECT 1 + +/* Define to 1 if you have the `sem_getvalue' function. */ +#define HAVE_SEM_GETVALUE 1 + +/* Define to 1 if you have the `sem_open' function. */ +#define HAVE_SEM_OPEN 1 + +/* Define to 1 if you have the `sem_timedwait' function. */ +#define HAVE_SEM_TIMEDWAIT 1 + +/* Define to 1 if you have the `sem_unlink' function. */ +#define HAVE_SEM_UNLINK 1 + +/* Define to 1 if you have the `sendfile' function. */ +#define HAVE_SENDFILE 1 + +/* Define to 1 if you have the `setegid' function. */ +#define HAVE_SETEGID 1 + +/* Define to 1 if you have the `seteuid' function. */ +#define HAVE_SETEUID 1 + +/* Define to 1 if you have the `setgid' function. */ +#define HAVE_SETGID 1 + +/* Define if you have the 'setgroups' function. */ +#define HAVE_SETGROUPS 1 + +/* Define to 1 if you have the `sethostname' function. */ +/* #undef HAVE_SETHOSTNAME */ + +/* Define to 1 if you have the `setitimer' function. */ +#define HAVE_SETITIMER 1 + +/* Define to 1 if you have the `setlocale' function. */ +#define HAVE_SETLOCALE 1 + +/* Define to 1 if you have the `setpgid' function. */ +#define HAVE_SETPGID 1 + +/* Define to 1 if you have the `setpgrp' function. */ +#define HAVE_SETPGRP 1 + +/* Define to 1 if you have the `setpriority' function. */ +#define HAVE_SETPRIORITY 1 + +/* Define to 1 if you have the `setregid' function. */ +#define HAVE_SETREGID 1 + +/* Define to 1 if you have the `setresgid' function. */ +#define HAVE_SETRESGID 1 + +/* Define to 1 if you have the `setresuid' function. */ +#define HAVE_SETRESUID 1 + +/* Define to 1 if you have the `setreuid' function. */ +#define HAVE_SETREUID 1 + +/* Define to 1 if you have the `setsid' function. */ +#define HAVE_SETSID 1 + +/* Define to 1 if you have the `setuid' function. */ +#define HAVE_SETUID 1 + +/* Define to 1 if you have the `setvbuf' function. */ +#define HAVE_SETVBUF 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SHADOW_H */ + +/* Define to 1 if you have the `sigaction' function. */ +#define HAVE_SIGACTION 1 + +/* Define to 1 if you have the `sigaltstack' function. */ +#define HAVE_SIGALTSTACK 1 + +/* Define to 1 if you have the `siginterrupt' function. */ +#define HAVE_SIGINTERRUPT 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SIGNAL_H 1 + +/* Define to 1 if you have the `sigpending' function. */ +#define HAVE_SIGPENDING 1 + +/* Define to 1 if you have the `sigrelse' function. */ +/* #undef HAVE_SIGRELSE */ + +/* Define to 1 if you have the `sigtimedwait' function. */ +/* #undef HAVE_SIGTIMEDWAIT */ + +/* Define to 1 if you have the `sigwait' function. */ +#define HAVE_SIGWAIT 1 + +/* Define to 1 if you have the `sigwaitinfo' function. */ +/* #undef HAVE_SIGWAITINFO */ + +/* Define to 1 if you have the `snprintf' function. */ +#define HAVE_SNPRINTF 1 + +/* Define if sockaddr has sa_len member */ +/* #undef HAVE_SOCKADDR_SA_LEN */ + +/* struct sockaddr_storage (sys/socket.h) */ +#define HAVE_SOCKADDR_STORAGE 1 + +/* Define if you have the 'socketpair' function. */ +#define HAVE_SOCKETPAIR 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SPAWN_H */ + +/* Define if your compiler provides ssize_t */ +#define HAVE_SSIZE_T 1 + +/* Define to 1 if you have the `statvfs' function. */ +#define HAVE_STATVFS 1 + +/* Define if you have struct stat.st_mtim.tv_nsec */ +/* #undef HAVE_STAT_TV_NSEC */ + +/* Define if you have struct stat.st_mtimensec */ +/* #undef HAVE_STAT_TV_NSEC2 */ + +/* Define if your compiler supports variable length function prototypes (e.g. + void fprintf(FILE *, char *, ...);) *and* */ +#define HAVE_STDARG_PROTOTYPES 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Has stdatomic.h, atomic_int and _Atomic void* types work */ +#define HAVE_STD_ATOMIC 1 + +/* Define to 1 if you have the `strdup' function. */ +#define HAVE_STRDUP 1 + +/* Define to 1 if you have the `strftime' function. */ +#define HAVE_STRFTIME 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the `strlcpy' function. */ +#define HAVE_STRLCPY 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_STROPTS_H */ + +/* Define to 1 if `st_birthtime' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_BIRTHTIME */ + +/* Define to 1 if `st_blksize' is a member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_BLKSIZE 1 + +/* Define to 1 if `st_blocks' is a member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_BLOCKS 1 + +/* Define to 1 if `st_flags' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_FLAGS */ + +/* Define to 1 if `st_gen' is a member of `struct stat'. */ +/* #undef HAVE_STRUCT_STAT_ST_GEN */ + +/* Define to 1 if `st_rdev' is a member of `struct stat'. */ +#define HAVE_STRUCT_STAT_ST_RDEV 1 + +/* Define to 1 if `tm_zone' is a member of `struct tm'. */ +#define HAVE_STRUCT_TM_TM_ZONE 1 + +/* Define to 1 if your `struct stat' has `st_blocks'. Deprecated, use + `HAVE_STRUCT_STAT_ST_BLOCKS' instead. */ +#define HAVE_ST_BLOCKS 1 + +/* Define if you have the 'symlink' function. */ +#define HAVE_SYMLINK 1 + +/* Define to 1 if you have the `symlinkat' function. */ +#define HAVE_SYMLINKAT 1 + +/* Define to 1 if you have the `sync' function. */ +#define HAVE_SYNC 1 + +/* Define to 1 if you have the `sysconf' function. */ +#define HAVE_SYSCONF 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYSEXITS_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_AUDIOIO_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_BSDTTY_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_DEVPOLL_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +/* #undef HAVE_SYS_DIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_ENDIAN_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_EPOLL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_EVENT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_FILE_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_IOCTL_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_KERN_CONTROL_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_LOADAVG_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_LOCK_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_MKDEV_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_MODEM_H */ + +/* Define to 1 if you have the header file, and it defines `DIR'. + */ +/* #undef HAVE_SYS_NDIR_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_PARAM_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_POLL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_RESOURCE_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SELECT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SENDFILE_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SOCKET_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STATVFS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SYSCALL_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_SYS_DOMAIN_H */ + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_SYS_TERMIO_H */ + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIMES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UIO_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UN_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_UTSNAME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_WAIT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_XATTR_H 1 + +/* Define to 1 if you have the `tcgetpgrp' function. */ +#define HAVE_TCGETPGRP 1 + +/* Define to 1 if you have the `tcsetpgrp' function. */ +#define HAVE_TCSETPGRP 1 + +/* Define to 1 if you have the `tempnam' function. */ +#define HAVE_TEMPNAM 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_TERMIOS_H 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_TERM_H */ + +/* Define to 1 if you have the `tgamma' function. */ +#define HAVE_TGAMMA 1 + +/* Define to 1 if you have the `timegm' function. */ +#define HAVE_TIMEGM 1 + +/* Define to 1 if you have the `times' function. */ +#define HAVE_TIMES 1 + +/* Define to 1 if you have the `tmpfile' function. */ +#define HAVE_TMPFILE 1 + +/* Define to 1 if you have the `tmpnam' function. */ +#define HAVE_TMPNAM 1 + +/* Define to 1 if you have the `tmpnam_r' function. */ +/* #undef HAVE_TMPNAM_R */ + +/* Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use + `HAVE_STRUCT_TM_TM_ZONE' instead. */ +#define HAVE_TM_ZONE 1 + +/* Define to 1 if you have the `truncate' function. */ +#define HAVE_TRUNCATE 1 + +/* Define to 1 if you don't have `tm_zone' but do have the external array + `tzname'. */ +/* #undef HAVE_TZNAME */ + +/* Define this if you have tcl and TCL_UTF_MAX==6 */ +/* #undef HAVE_UCS4_TCL */ + +/* Define if your compiler provides uint32_t. */ +#define HAVE_UINT32_T 1 + +/* Define if your compiler provides uint64_t. */ +#define HAVE_UINT64_T 1 + +/* Define to 1 if the system has the type `uintptr_t'. */ +#define HAVE_UINTPTR_T 1 + +/* Define to 1 if you have the `uname' function. */ +#define HAVE_UNAME 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you have the `unlinkat' function. */ +#define HAVE_UNLINKAT 1 + +/* Define to 1 if you have the `unsetenv' function. */ +#define HAVE_UNSETENV 1 + +/* Define if you have a useable wchar_t type defined in wchar.h; useable means + wchar_t must be an unsigned type with at least 16 bits. (see + Include/unicodeobject.h). */ +/* #undef HAVE_USABLE_WCHAR_T */ + +/* Define to 1 if you have the header file. */ +#define HAVE_UTIL_H 1 + +/* Define to 1 if you have the `utimensat' function. */ +#define HAVE_UTIMENSAT 1 + +/* Define to 1 if you have the `utimes' function. */ +#define HAVE_UTIMES 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UTIME_H 1 + +/* Define to 1 if you have the `wait3' function. */ +/* #undef HAVE_WAIT3 */ + +/* Define to 1 if you have the `wait4' function. */ +#define HAVE_WAIT4 1 + +/* Define to 1 if you have the `waitid' function. */ +#define HAVE_WAITID 1 + +/* Define to 1 if you have the `waitpid' function. */ +#define HAVE_WAITPID 1 + +/* Define if the compiler provides a wchar.h header file. */ +#define HAVE_WCHAR_H 1 + +/* Define to 1 if you have the `wcscoll' function. */ +#define HAVE_WCSCOLL 1 + +/* Define to 1 if you have the `wcsftime' function. */ +#define HAVE_WCSFTIME 1 + +/* Define to 1 if you have the `wcsxfrm' function. */ +#define HAVE_WCSXFRM 1 + +/* Define to 1 if you have the `wmemcmp' function. */ +#define HAVE_WMEMCMP 1 + +/* Define if tzset() actually switches the local timezone in a meaningful way. + */ +/* #undef HAVE_WORKING_TZSET */ + +/* Define to 1 if you have the `writev' function. */ +#define HAVE_WRITEV 1 + +/* Define if the zlib library has inflateCopy */ +#define HAVE_ZLIB_COPY 1 + +/* Define to 1 if you have the `_getpty' function. */ +/* #undef HAVE__GETPTY */ + +/* Define if log1p(-0.) is 0. rather than -0. */ +/* #undef LOG1P_DROPS_ZERO_SIGN */ + +/* Define to 1 if `major', `minor', and `makedev' are declared in . + */ +/* #undef MAJOR_IN_MKDEV */ + +/* Define to 1 if `major', `minor', and `makedev' are declared in + . */ +#define MAJOR_IN_SYSMACROS 1 + +/* Define if mvwdelch in curses.h is an expression. */ +/* #undef MVWDELCH_IS_EXPRESSION */ + +/* Define to the address where bug reports for this package should be sent. */ +/* #undef PACKAGE_BUGREPORT */ + +/* Define to the full name of this package. */ +/* #undef PACKAGE_NAME */ + +/* Define to the full name and version of this package. */ +/* #undef PACKAGE_STRING */ + +/* Define to the one symbol short name of this package. */ +/* #undef PACKAGE_TARNAME */ + +/* Define to the home page for this package. */ +/* #undef PACKAGE_URL */ + +/* Define to the version of this package. */ +/* #undef PACKAGE_VERSION */ + +/* Define if POSIX semaphores aren't enabled on your system */ +/* #undef POSIX_SEMAPHORES_NOT_ENABLED */ + +/* Defined if PTHREAD_SCOPE_SYSTEM supported. */ +/* #undef PTHREAD_SYSTEM_SCHED_SUPPORTED */ + +/* Define as the preferred size in bits of long digits */ +/* #undef PYLONG_BITS_IN_DIGIT */ + +/* Define to printf format modifier for long long type */ +#define PY_FORMAT_LONG_LONG "ll" + +/* Define to printf format modifier for Py_ssize_t */ +#define PY_FORMAT_SIZE_T "z" + +/* Define if you want to build an interpreter with many run-time checks. */ +/* #undef Py_DEBUG */ + +/* Defined if Python is built as a shared library. */ +#define Py_ENABLE_SHARED 1 + +/* Define hash algorithm for str, bytes and memoryview. SipHash24: 1, FNV: 2, + externally defined: 0 */ +/* #undef Py_HASH_ALGORITHM */ + +/* assume C89 semantics that RETSIGTYPE is always void */ +#define RETSIGTYPE void + +/* Define if setpgrp() must be called as setpgrp(0, 0). */ +/* #undef SETPGRP_HAVE_ARG */ + +/* Define if i>>j for signed int i does not extend the sign bit when i < 0 */ +/* #undef SIGNED_RIGHT_SHIFT_ZERO_FILLS */ + +/* The size of `double', as computed by sizeof. */ +#define SIZEOF_DOUBLE 8 + +/* The size of `float', as computed by sizeof. */ +#define SIZEOF_FLOAT 4 + +/* The size of `fpos_t', as computed by sizeof. */ +#define SIZEOF_FPOS_T 8 + +/* The size of `int', as computed by sizeof. */ +#define SIZEOF_INT 4 + +/* The size of `long', as computed by sizeof. */ +#define SIZEOF_LONG 8 + +/* The size of `long double', as computed by sizeof. */ +#define SIZEOF_LONG_DOUBLE 16 + +/* The size of `long long', as computed by sizeof. */ +#define SIZEOF_LONG_LONG 8 + +/* The size of `off_t', as computed by sizeof. */ +#define SIZEOF_OFF_T 8 + +/* The size of `pid_t', as computed by sizeof. */ +#define SIZEOF_PID_T 4 + +/* The size of `pthread_t', as computed by sizeof. */ +#define SIZEOF_PTHREAD_T 8 + +/* The size of `short', as computed by sizeof. */ +#define SIZEOF_SHORT 2 + +/* The size of `size_t', as computed by sizeof. */ +#define SIZEOF_SIZE_T 8 + +/* The size of `time_t', as computed by sizeof. */ +#define SIZEOF_TIME_T 8 + +/* The size of `uintptr_t', as computed by sizeof. */ +#define SIZEOF_UINTPTR_T 8 + +/* The size of `void *', as computed by sizeof. */ +#define SIZEOF_VOID_P 8 + +/* The size of `wchar_t', as computed by sizeof. */ +#define SIZEOF_WCHAR_T 4 + +/* The size of `_Bool', as computed by sizeof. */ +#define SIZEOF__BOOL 1 + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define if you can safely include both and + (which you can't on SCO ODT 3.0). */ +#define SYS_SELECT_WITH_SYS_TIME 1 + +/* Define if tanh(-0.) is -0., or if platform doesn't have signed zeros */ +/* #undef TANH_PRESERVES_ZERO_SIGN */ + +/* Library needed by timemodule.c: librt may be needed for clock_gettime() */ +/* #undef TIMEMODULE_LIB */ + +/* Define to 1 if you can safely include both and . */ +#define TIME_WITH_SYS_TIME 1 + +/* Define to 1 if your declares `struct tm'. */ +/* #undef TM_IN_SYS_TIME */ + +/* Define if you want to use computed gotos in ceval.c. */ +#define USE_COMPUTED_GOTOS 1 + +/* Define to use the C99 inline keyword. */ +#define USE_INLINE 1 + +/* Enable extensions on AIX 3, Interix. */ +#ifndef _ALL_SOURCE +# define _ALL_SOURCE 1 +#endif +/* Enable GNU extensions on systems that have them. */ +#ifndef _GNU_SOURCE +# define _GNU_SOURCE 1 +#endif +/* Enable threading extensions on Solaris. */ +#ifndef _POSIX_PTHREAD_SEMANTICS +# define _POSIX_PTHREAD_SEMANTICS 1 +#endif +/* Enable extensions on HP NonStop. */ +#ifndef _TANDEM_SOURCE +# define _TANDEM_SOURCE 1 +#endif +/* Enable general extensions on Solaris. */ +#ifndef __EXTENSIONS__ +# define __EXTENSIONS__ 1 +#endif + + +/* Define if a va_list is an array of some kind */ +#define VA_LIST_IS_ARRAY 1 + +/* Define if you want SIGFPE handled (see Include/pyfpe.h). */ +/* #undef WANT_SIGFPE_HANDLER */ + +/* Define if WINDOW in curses.h offers a field _flags. */ +/* #undef WINDOW_HAS_FLAGS */ + +/* Define if you want documentation strings in extension modules */ +#define WITH_DOC_STRINGS 1 + +/* Define if you want to use the new-style (Openstep, Rhapsody, MacOS) dynamic + linker (dyld) instead of the old-style (NextStep) dynamic linker (rld). + Dyld is necessary to support frameworks. */ +/* #undef WITH_DYLD */ + +/* Define to 1 if libintl is needed for locale functions. */ +/* #undef WITH_LIBINTL */ + +/* Define if you want to produce an OpenStep/Rhapsody framework (shared + library plus accessory files). */ +/* #undef WITH_NEXT_FRAMEWORK */ + +/* Define if you want to compile in Python-specific mallocs */ +#define WITH_PYMALLOC 1 + +/* Define if you want to compile in rudimentary thread support */ +#define WITH_THREAD 1 + +/* Define to profile with the Pentium timestamp counter */ +/* #undef WITH_TSC */ + +/* Define if you want pymalloc to be disabled when running under valgrind */ +/* #undef WITH_VALGRIND */ + +/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most + significant byte first (like Motorola and SPARC, unlike Intel). */ +#if defined AC_APPLE_UNIVERSAL_BUILD +# if defined __BIG_ENDIAN__ +# define WORDS_BIGENDIAN 1 +# endif +#else +# ifndef WORDS_BIGENDIAN +/* # undef WORDS_BIGENDIAN */ +# endif +#endif + +/* Define if arithmetic is subject to x87-style double rounding issue */ +/* #undef X87_DOUBLE_ROUNDING */ + +/* Define on OpenBSD to activate all library features */ +/* #undef _BSD_SOURCE */ + +/* Define on Irix to enable u_int */ +#define _BSD_TYPES 1 + +/* Define on Darwin to activate all library features */ +#define _DARWIN_C_SOURCE 1 + +/* This must be set to 64 on some systems to enable large file support. */ +#define _FILE_OFFSET_BITS 64 + +/* Define on Linux to activate all library features */ +#define _GNU_SOURCE 1 + +/* Define to include mbstate_t for mbrtowc */ +/* #undef _INCLUDE__STDC_A1_SOURCE */ + +/* This must be defined on some systems to enable large file support. */ +#define _LARGEFILE_SOURCE 1 + +/* This must be defined on AIX systems to enable large file support. */ +/* #undef _LARGE_FILES */ + +/* Define to 1 if on MINIX. */ +/* #undef _MINIX */ + +/* Define on NetBSD to activate all library features */ +#define _NETBSD_SOURCE 1 + +/* Define to 2 if the system does not provide POSIX.1 features except with + this defined. */ +/* #undef _POSIX_1_SOURCE */ + +/* Define to activate features from IEEE Stds 1003.1-2008 */ +#define _POSIX_C_SOURCE 200809L + +/* Define to 1 if you need to in order for `stat' and other things to work. */ +/* #undef _POSIX_SOURCE */ + +/* Define if you have POSIX threads, and your system does not define that. */ +/* #undef _POSIX_THREADS */ + +/* Define to force use of thread-safe errno, h_errno, and other functions */ +#define _REENTRANT 1 + +/* Define for Solaris 2.5.1 so the uint32_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +/* #undef _UINT32_T */ + +/* Define for Solaris 2.5.1 so the uint64_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +/* #undef _UINT64_T */ + +/* Define to the level of X/Open that your system supports */ +#define _XOPEN_SOURCE 700 + +/* Define to activate Unix95-and-earlier features */ +#define _XOPEN_SOURCE_EXTENDED 1 + +/* Define on FreeBSD to activate all library features */ +#define __BSD_VISIBLE 1 + +/* Define to 1 if type `char' is unsigned and you are not using gcc. */ +#ifndef __CHAR_UNSIGNED__ +/* # undef __CHAR_UNSIGNED__ */ +#endif + +/* Define to 'long' if doesn't define. */ +/* #undef clock_t */ + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ + +/* Define to `int' if doesn't define. */ +/* #undef gid_t */ + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +/* #undef inline */ +#endif + +/* Define to the type of a signed integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +/* #undef int32_t */ + +/* Define to the type of a signed integer type of width exactly 64 bits if + such a type exists and the standard includes do not define it. */ +/* #undef int64_t */ + +/* Define to `int' if does not define. */ +/* #undef mode_t */ + +/* Define to `long int' if does not define. */ +/* #undef off_t */ + +/* Define to `int' if does not define. */ +/* #undef pid_t */ + +/* Define to empty if the keyword does not work. */ +/* #undef signed */ + +/* Define to `unsigned int' if does not define. */ +/* #undef size_t */ + +/* Define to `int' if does not define. */ +/* #undef socklen_t */ + +/* Define to `int' if doesn't define. */ +/* #undef uid_t */ + +/* Define to the type of an unsigned integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint32_t */ + +/* Define to the type of an unsigned integer type of width exactly 64 bits if + such a type exists and the standard includes do not define it. */ +/* #undef uint64_t */ + +/* Define to empty if the keyword does not work. */ +/* #undef volatile */ + + +/* Define the macros needed if on a UnixWare 7.x system. */ +#if defined(__USLC__) && defined(__SCO_VERSION__) +#define STRICT_SYSV_CURSES /* Don't use ncurses extensions */ +#endif + +#endif /*Py_PYCONFIG_H*/ + diff --git a/android/python35/include/pyctype.h b/android/python35/include/pyctype.h new file mode 100644 index 000000000..6bce63eeb --- /dev/null +++ b/android/python35/include/pyctype.h @@ -0,0 +1,33 @@ +#ifndef Py_LIMITED_API +#ifndef PYCTYPE_H +#define PYCTYPE_H + +#define PY_CTF_LOWER 0x01 +#define PY_CTF_UPPER 0x02 +#define PY_CTF_ALPHA (PY_CTF_LOWER|PY_CTF_UPPER) +#define PY_CTF_DIGIT 0x04 +#define PY_CTF_ALNUM (PY_CTF_ALPHA|PY_CTF_DIGIT) +#define PY_CTF_SPACE 0x08 +#define PY_CTF_XDIGIT 0x10 + +PyAPI_DATA(const unsigned int) _Py_ctype_table[256]; + +/* Unlike their C counterparts, the following macros are not meant to + * handle an int with any of the values [EOF, 0-UCHAR_MAX]. The argument + * must be a signed/unsigned char. */ +#define Py_ISLOWER(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_LOWER) +#define Py_ISUPPER(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_UPPER) +#define Py_ISALPHA(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_ALPHA) +#define Py_ISDIGIT(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_DIGIT) +#define Py_ISXDIGIT(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_XDIGIT) +#define Py_ISALNUM(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_ALNUM) +#define Py_ISSPACE(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_SPACE) + +PyAPI_DATA(const unsigned char) _Py_ctype_tolower[256]; +PyAPI_DATA(const unsigned char) _Py_ctype_toupper[256]; + +#define Py_TOLOWER(c) (_Py_ctype_tolower[Py_CHARMASK(c)]) +#define Py_TOUPPER(c) (_Py_ctype_toupper[Py_CHARMASK(c)]) + +#endif /* !PYCTYPE_H */ +#endif /* !Py_LIMITED_API */ diff --git a/android/python35/include/pydebug.h b/android/python35/include/pydebug.h new file mode 100644 index 000000000..19bec2bd8 --- /dev/null +++ b/android/python35/include/pydebug.h @@ -0,0 +1,36 @@ +#ifndef Py_LIMITED_API +#ifndef Py_PYDEBUG_H +#define Py_PYDEBUG_H +#ifdef __cplusplus +extern "C" { +#endif + +/* These global variable are defined in pylifecycle.c */ +/* XXX (ncoghlan): move these declarations to pylifecycle.h? */ +PyAPI_DATA(int) Py_DebugFlag; +PyAPI_DATA(int) Py_VerboseFlag; +PyAPI_DATA(int) Py_QuietFlag; +PyAPI_DATA(int) Py_InteractiveFlag; +PyAPI_DATA(int) Py_InspectFlag; +PyAPI_DATA(int) Py_OptimizeFlag; +PyAPI_DATA(int) Py_NoSiteFlag; +PyAPI_DATA(int) Py_BytesWarningFlag; +PyAPI_DATA(int) Py_UseClassExceptionsFlag; +PyAPI_DATA(int) Py_FrozenFlag; +PyAPI_DATA(int) Py_IgnoreEnvironmentFlag; +PyAPI_DATA(int) Py_DontWriteBytecodeFlag; +PyAPI_DATA(int) Py_NoUserSiteDirectory; +PyAPI_DATA(int) Py_UnbufferedStdioFlag; +PyAPI_DATA(int) Py_HashRandomizationFlag; +PyAPI_DATA(int) Py_IsolatedFlag; + +/* this is a wrapper around getenv() that pays attention to + Py_IgnoreEnvironmentFlag. It should be used for getting variables like + PYTHONPATH and PYTHONHOME from the environment */ +#define Py_GETENV(s) (Py_IgnoreEnvironmentFlag ? NULL : getenv(s)) + +#ifdef __cplusplus +} +#endif +#endif /* !Py_PYDEBUG_H */ +#endif /* Py_LIMITED_API */ diff --git a/android/python35/include/pyerrors.h b/android/python35/include/pyerrors.h new file mode 100644 index 000000000..35aedb734 --- /dev/null +++ b/android/python35/include/pyerrors.h @@ -0,0 +1,475 @@ +#ifndef Py_ERRORS_H +#define Py_ERRORS_H +#ifdef __cplusplus +extern "C" { +#endif + +/* Error objects */ + +#ifndef Py_LIMITED_API +/* PyException_HEAD defines the initial segment of every exception class. */ +#define PyException_HEAD PyObject_HEAD PyObject *dict;\ + PyObject *args; PyObject *traceback;\ + PyObject *context; PyObject *cause;\ + char suppress_context; + +typedef struct { + PyException_HEAD +} PyBaseExceptionObject; + +typedef struct { + PyException_HEAD + PyObject *msg; + PyObject *filename; + PyObject *lineno; + PyObject *offset; + PyObject *text; + PyObject *print_file_and_line; +} PySyntaxErrorObject; + +typedef struct { + PyException_HEAD + PyObject *msg; + PyObject *name; + PyObject *path; +} PyImportErrorObject; + +typedef struct { + PyException_HEAD + PyObject *encoding; + PyObject *object; + Py_ssize_t start; + Py_ssize_t end; + PyObject *reason; +} PyUnicodeErrorObject; + +typedef struct { + PyException_HEAD + PyObject *code; +} PySystemExitObject; + +typedef struct { + PyException_HEAD + PyObject *myerrno; + PyObject *strerror; + PyObject *filename; + PyObject *filename2; +#ifdef MS_WINDOWS + PyObject *winerror; +#endif + Py_ssize_t written; /* only for BlockingIOError, -1 otherwise */ +} PyOSErrorObject; + +typedef struct { + PyException_HEAD + PyObject *value; +} PyStopIterationObject; + +/* Compatibility typedefs */ +typedef PyOSErrorObject PyEnvironmentErrorObject; +#ifdef MS_WINDOWS +typedef PyOSErrorObject PyWindowsErrorObject; +#endif +#endif /* !Py_LIMITED_API */ + +/* Error handling definitions */ + +PyAPI_FUNC(void) PyErr_SetNone(PyObject *); +PyAPI_FUNC(void) PyErr_SetObject(PyObject *, PyObject *); +#ifndef Py_LIMITED_API +PyAPI_FUNC(void) _PyErr_SetKeyError(PyObject *); +#endif +PyAPI_FUNC(void) PyErr_SetString( + PyObject *exception, + const char *string /* decoded from utf-8 */ + ); +PyAPI_FUNC(PyObject *) PyErr_Occurred(void); +PyAPI_FUNC(void) PyErr_Clear(void); +PyAPI_FUNC(void) PyErr_Fetch(PyObject **, PyObject **, PyObject **); +PyAPI_FUNC(void) PyErr_Restore(PyObject *, PyObject *, PyObject *); +PyAPI_FUNC(void) PyErr_GetExcInfo(PyObject **, PyObject **, PyObject **); +PyAPI_FUNC(void) PyErr_SetExcInfo(PyObject *, PyObject *, PyObject *); + +#if defined(__clang__) || \ + (defined(__GNUC_MAJOR__) && \ + ((__GNUC_MAJOR__ >= 3) || \ + (__GNUC_MAJOR__ == 2) && (__GNUC_MINOR__ >= 5))) +#define _Py_NO_RETURN __attribute__((__noreturn__)) +#else +#define _Py_NO_RETURN +#endif + +/* Defined in Python/pylifecycle.c */ +PyAPI_FUNC(void) Py_FatalError(const char *message) _Py_NO_RETURN; + +#if defined(Py_DEBUG) || defined(Py_LIMITED_API) +#define _PyErr_OCCURRED() PyErr_Occurred() +#else +#define _PyErr_OCCURRED() (PyThreadState_GET()->curexc_type) +#endif + +/* Error testing and normalization */ +PyAPI_FUNC(int) PyErr_GivenExceptionMatches(PyObject *, PyObject *); +PyAPI_FUNC(int) PyErr_ExceptionMatches(PyObject *); +PyAPI_FUNC(void) PyErr_NormalizeException(PyObject**, PyObject**, PyObject**); + +/* Traceback manipulation (PEP 3134) */ +PyAPI_FUNC(int) PyException_SetTraceback(PyObject *, PyObject *); +PyAPI_FUNC(PyObject *) PyException_GetTraceback(PyObject *); + +/* Cause manipulation (PEP 3134) */ +PyAPI_FUNC(PyObject *) PyException_GetCause(PyObject *); +PyAPI_FUNC(void) PyException_SetCause(PyObject *, PyObject *); + +/* Context manipulation (PEP 3134) */ +PyAPI_FUNC(PyObject *) PyException_GetContext(PyObject *); +PyAPI_FUNC(void) PyException_SetContext(PyObject *, PyObject *); +#ifndef Py_LIMITED_API +PyAPI_FUNC(void) _PyErr_ChainExceptions(PyObject *, PyObject *, PyObject *); +#endif + +/* */ + +#define PyExceptionClass_Check(x) \ + (PyType_Check((x)) && \ + PyType_FastSubclass((PyTypeObject*)(x), Py_TPFLAGS_BASE_EXC_SUBCLASS)) + +#define PyExceptionInstance_Check(x) \ + PyType_FastSubclass((x)->ob_type, Py_TPFLAGS_BASE_EXC_SUBCLASS) + +#define PyExceptionClass_Name(x) \ + ((char *)(((PyTypeObject*)(x))->tp_name)) + +#define PyExceptionInstance_Class(x) ((PyObject*)((x)->ob_type)) + + +/* Predefined exceptions */ + +PyAPI_DATA(PyObject *) PyExc_BaseException; +PyAPI_DATA(PyObject *) PyExc_Exception; +PyAPI_DATA(PyObject *) PyExc_StopAsyncIteration; +PyAPI_DATA(PyObject *) PyExc_StopIteration; +PyAPI_DATA(PyObject *) PyExc_GeneratorExit; +PyAPI_DATA(PyObject *) PyExc_ArithmeticError; +PyAPI_DATA(PyObject *) PyExc_LookupError; + +PyAPI_DATA(PyObject *) PyExc_AssertionError; +PyAPI_DATA(PyObject *) PyExc_AttributeError; +PyAPI_DATA(PyObject *) PyExc_BufferError; +PyAPI_DATA(PyObject *) PyExc_EOFError; +PyAPI_DATA(PyObject *) PyExc_FloatingPointError; +PyAPI_DATA(PyObject *) PyExc_OSError; +PyAPI_DATA(PyObject *) PyExc_ImportError; +PyAPI_DATA(PyObject *) PyExc_IndexError; +PyAPI_DATA(PyObject *) PyExc_KeyError; +PyAPI_DATA(PyObject *) PyExc_KeyboardInterrupt; +PyAPI_DATA(PyObject *) PyExc_MemoryError; +PyAPI_DATA(PyObject *) PyExc_NameError; +PyAPI_DATA(PyObject *) PyExc_OverflowError; +PyAPI_DATA(PyObject *) PyExc_RuntimeError; +PyAPI_DATA(PyObject *) PyExc_RecursionError; +PyAPI_DATA(PyObject *) PyExc_NotImplementedError; +PyAPI_DATA(PyObject *) PyExc_SyntaxError; +PyAPI_DATA(PyObject *) PyExc_IndentationError; +PyAPI_DATA(PyObject *) PyExc_TabError; +PyAPI_DATA(PyObject *) PyExc_ReferenceError; +PyAPI_DATA(PyObject *) PyExc_SystemError; +PyAPI_DATA(PyObject *) PyExc_SystemExit; +PyAPI_DATA(PyObject *) PyExc_TypeError; +PyAPI_DATA(PyObject *) PyExc_UnboundLocalError; +PyAPI_DATA(PyObject *) PyExc_UnicodeError; +PyAPI_DATA(PyObject *) PyExc_UnicodeEncodeError; +PyAPI_DATA(PyObject *) PyExc_UnicodeDecodeError; +PyAPI_DATA(PyObject *) PyExc_UnicodeTranslateError; +PyAPI_DATA(PyObject *) PyExc_ValueError; +PyAPI_DATA(PyObject *) PyExc_ZeroDivisionError; + +PyAPI_DATA(PyObject *) PyExc_BlockingIOError; +PyAPI_DATA(PyObject *) PyExc_BrokenPipeError; +PyAPI_DATA(PyObject *) PyExc_ChildProcessError; +PyAPI_DATA(PyObject *) PyExc_ConnectionError; +PyAPI_DATA(PyObject *) PyExc_ConnectionAbortedError; +PyAPI_DATA(PyObject *) PyExc_ConnectionRefusedError; +PyAPI_DATA(PyObject *) PyExc_ConnectionResetError; +PyAPI_DATA(PyObject *) PyExc_FileExistsError; +PyAPI_DATA(PyObject *) PyExc_FileNotFoundError; +PyAPI_DATA(PyObject *) PyExc_InterruptedError; +PyAPI_DATA(PyObject *) PyExc_IsADirectoryError; +PyAPI_DATA(PyObject *) PyExc_NotADirectoryError; +PyAPI_DATA(PyObject *) PyExc_PermissionError; +PyAPI_DATA(PyObject *) PyExc_ProcessLookupError; +PyAPI_DATA(PyObject *) PyExc_TimeoutError; + + +/* Compatibility aliases */ +PyAPI_DATA(PyObject *) PyExc_EnvironmentError; +PyAPI_DATA(PyObject *) PyExc_IOError; +#ifdef MS_WINDOWS +PyAPI_DATA(PyObject *) PyExc_WindowsError; +#endif + +PyAPI_DATA(PyObject *) PyExc_RecursionErrorInst; + +/* Predefined warning categories */ +PyAPI_DATA(PyObject *) PyExc_Warning; +PyAPI_DATA(PyObject *) PyExc_UserWarning; +PyAPI_DATA(PyObject *) PyExc_DeprecationWarning; +PyAPI_DATA(PyObject *) PyExc_PendingDeprecationWarning; +PyAPI_DATA(PyObject *) PyExc_SyntaxWarning; +PyAPI_DATA(PyObject *) PyExc_RuntimeWarning; +PyAPI_DATA(PyObject *) PyExc_FutureWarning; +PyAPI_DATA(PyObject *) PyExc_ImportWarning; +PyAPI_DATA(PyObject *) PyExc_UnicodeWarning; +PyAPI_DATA(PyObject *) PyExc_BytesWarning; +PyAPI_DATA(PyObject *) PyExc_ResourceWarning; + + +/* Convenience functions */ + +PyAPI_FUNC(int) PyErr_BadArgument(void); +PyAPI_FUNC(PyObject *) PyErr_NoMemory(void); +PyAPI_FUNC(PyObject *) PyErr_SetFromErrno(PyObject *); +PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithFilenameObject( + PyObject *, PyObject *); +PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithFilenameObjects( + PyObject *, PyObject *, PyObject *); +PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithFilename( + PyObject *exc, + const char *filename /* decoded from the filesystem encoding */ + ); +#if defined(MS_WINDOWS) && !defined(Py_LIMITED_API) +PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithUnicodeFilename( + PyObject *, const Py_UNICODE *); +#endif /* MS_WINDOWS */ + +PyAPI_FUNC(PyObject *) PyErr_Format( + PyObject *exception, + const char *format, /* ASCII-encoded string */ + ... + ); +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000 +PyAPI_FUNC(PyObject *) PyErr_FormatV( + PyObject *exception, + const char *format, + va_list vargs); +#endif + +#ifdef MS_WINDOWS +PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithFilename( + int ierr, + const char *filename /* decoded from the filesystem encoding */ + ); +#ifndef Py_LIMITED_API +/* XXX redeclare to use WSTRING */ +PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithUnicodeFilename( + int, const Py_UNICODE *); +#endif +PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErr(int); +PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithFilenameObject( + PyObject *,int, PyObject *); +PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithFilenameObjects( + PyObject *,int, PyObject *, PyObject *); +PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithFilename( + PyObject *exc, + int ierr, + const char *filename /* decoded from the filesystem encoding */ + ); +#ifndef Py_LIMITED_API +PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithUnicodeFilename( + PyObject *,int, const Py_UNICODE *); +#endif +PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErr(PyObject *, int); +#endif /* MS_WINDOWS */ + +PyAPI_FUNC(PyObject *) PyErr_SetExcWithArgsKwargs(PyObject *, PyObject *, + PyObject *); +PyAPI_FUNC(PyObject *) PyErr_SetImportError(PyObject *, PyObject *, + PyObject *); + +/* Export the old function so that the existing API remains available: */ +PyAPI_FUNC(void) PyErr_BadInternalCall(void); +PyAPI_FUNC(void) _PyErr_BadInternalCall(const char *filename, int lineno); +/* Mask the old API with a call to the new API for code compiled under + Python 2.0: */ +#define PyErr_BadInternalCall() _PyErr_BadInternalCall(__FILE__, __LINE__) + +/* Function to create a new exception */ +PyAPI_FUNC(PyObject *) PyErr_NewException( + const char *name, PyObject *base, PyObject *dict); +PyAPI_FUNC(PyObject *) PyErr_NewExceptionWithDoc( + const char *name, const char *doc, PyObject *base, PyObject *dict); +PyAPI_FUNC(void) PyErr_WriteUnraisable(PyObject *); + +/* In exceptions.c */ +#ifndef Py_LIMITED_API +/* Helper that attempts to replace the current exception with one of the + * same type but with a prefix added to the exception text. The resulting + * exception description looks like: + * + * prefix (exc_type: original_exc_str) + * + * Only some exceptions can be safely replaced. If the function determines + * it isn't safe to perform the replacement, it will leave the original + * unmodified exception in place. + * + * Returns a borrowed reference to the new exception (if any), NULL if the + * existing exception was left in place. + */ +PyAPI_FUNC(PyObject *) _PyErr_TrySetFromCause( + const char *prefix_format, /* ASCII-encoded string */ + ... + ); +#endif + + +/* In sigcheck.c or signalmodule.c */ +PyAPI_FUNC(int) PyErr_CheckSignals(void); +PyAPI_FUNC(void) PyErr_SetInterrupt(void); + +/* In signalmodule.c */ +#ifndef Py_LIMITED_API +int PySignal_SetWakeupFd(int fd); +#endif + +/* Support for adding program text to SyntaxErrors */ +PyAPI_FUNC(void) PyErr_SyntaxLocation( + const char *filename, /* decoded from the filesystem encoding */ + int lineno); +PyAPI_FUNC(void) PyErr_SyntaxLocationEx( + const char *filename, /* decoded from the filesystem encoding */ + int lineno, + int col_offset); +#ifndef Py_LIMITED_API +PyAPI_FUNC(void) PyErr_SyntaxLocationObject( + PyObject *filename, + int lineno, + int col_offset); +#endif +PyAPI_FUNC(PyObject *) PyErr_ProgramText( + const char *filename, /* decoded from the filesystem encoding */ + int lineno); +#ifndef Py_LIMITED_API +PyAPI_FUNC(PyObject *) PyErr_ProgramTextObject( + PyObject *filename, + int lineno); +#endif + +/* The following functions are used to create and modify unicode + exceptions from C */ + +/* create a UnicodeDecodeError object */ +PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_Create( + const char *encoding, /* UTF-8 encoded string */ + const char *object, + Py_ssize_t length, + Py_ssize_t start, + Py_ssize_t end, + const char *reason /* UTF-8 encoded string */ + ); + +/* create a UnicodeEncodeError object */ +#ifndef Py_LIMITED_API +PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_Create( + const char *encoding, /* UTF-8 encoded string */ + const Py_UNICODE *object, + Py_ssize_t length, + Py_ssize_t start, + Py_ssize_t end, + const char *reason /* UTF-8 encoded string */ + ); +#endif + +/* create a UnicodeTranslateError object */ +#ifndef Py_LIMITED_API +PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_Create( + const Py_UNICODE *object, + Py_ssize_t length, + Py_ssize_t start, + Py_ssize_t end, + const char *reason /* UTF-8 encoded string */ + ); +PyAPI_FUNC(PyObject *) _PyUnicodeTranslateError_Create( + PyObject *object, + Py_ssize_t start, + Py_ssize_t end, + const char *reason /* UTF-8 encoded string */ + ); +#endif + +/* get the encoding attribute */ +PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_GetEncoding(PyObject *); +PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_GetEncoding(PyObject *); + +/* get the object attribute */ +PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_GetObject(PyObject *); +PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_GetObject(PyObject *); +PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_GetObject(PyObject *); + +/* get the value of the start attribute (the int * may not be NULL) + return 0 on success, -1 on failure */ +PyAPI_FUNC(int) PyUnicodeEncodeError_GetStart(PyObject *, Py_ssize_t *); +PyAPI_FUNC(int) PyUnicodeDecodeError_GetStart(PyObject *, Py_ssize_t *); +PyAPI_FUNC(int) PyUnicodeTranslateError_GetStart(PyObject *, Py_ssize_t *); + +/* assign a new value to the start attribute + return 0 on success, -1 on failure */ +PyAPI_FUNC(int) PyUnicodeEncodeError_SetStart(PyObject *, Py_ssize_t); +PyAPI_FUNC(int) PyUnicodeDecodeError_SetStart(PyObject *, Py_ssize_t); +PyAPI_FUNC(int) PyUnicodeTranslateError_SetStart(PyObject *, Py_ssize_t); + +/* get the value of the end attribute (the int *may not be NULL) + return 0 on success, -1 on failure */ +PyAPI_FUNC(int) PyUnicodeEncodeError_GetEnd(PyObject *, Py_ssize_t *); +PyAPI_FUNC(int) PyUnicodeDecodeError_GetEnd(PyObject *, Py_ssize_t *); +PyAPI_FUNC(int) PyUnicodeTranslateError_GetEnd(PyObject *, Py_ssize_t *); + +/* assign a new value to the end attribute + return 0 on success, -1 on failure */ +PyAPI_FUNC(int) PyUnicodeEncodeError_SetEnd(PyObject *, Py_ssize_t); +PyAPI_FUNC(int) PyUnicodeDecodeError_SetEnd(PyObject *, Py_ssize_t); +PyAPI_FUNC(int) PyUnicodeTranslateError_SetEnd(PyObject *, Py_ssize_t); + +/* get the value of the reason attribute */ +PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_GetReason(PyObject *); +PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_GetReason(PyObject *); +PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_GetReason(PyObject *); + +/* assign a new value to the reason attribute + return 0 on success, -1 on failure */ +PyAPI_FUNC(int) PyUnicodeEncodeError_SetReason( + PyObject *exc, + const char *reason /* UTF-8 encoded string */ + ); +PyAPI_FUNC(int) PyUnicodeDecodeError_SetReason( + PyObject *exc, + const char *reason /* UTF-8 encoded string */ + ); +PyAPI_FUNC(int) PyUnicodeTranslateError_SetReason( + PyObject *exc, + const char *reason /* UTF-8 encoded string */ + ); + +/* These APIs aren't really part of the error implementation, but + often needed to format error messages; the native C lib APIs are + not available on all platforms, which is why we provide emulations + for those platforms in Python/mysnprintf.c, + WARNING: The return value of snprintf varies across platforms; do + not rely on any particular behavior; eventually the C99 defn may + be reliable. +*/ +#if defined(MS_WIN32) && !defined(HAVE_SNPRINTF) +# define HAVE_SNPRINTF +# define snprintf _snprintf +# define vsnprintf _vsnprintf +#endif + +#include +PyAPI_FUNC(int) PyOS_snprintf(char *str, size_t size, const char *format, ...) + Py_GCC_ATTRIBUTE((format(printf, 3, 4))); +PyAPI_FUNC(int) PyOS_vsnprintf(char *str, size_t size, const char *format, va_list va) + Py_GCC_ATTRIBUTE((format(printf, 3, 0))); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_ERRORS_H */ diff --git a/android/python35/include/pyexpat.h b/android/python35/include/pyexpat.h new file mode 100644 index 000000000..44259bf6d --- /dev/null +++ b/android/python35/include/pyexpat.h @@ -0,0 +1,53 @@ +/* Stuff to export relevant 'expat' entry points from pyexpat to other + * parser modules, such as cElementTree. */ + +/* note: you must import expat.h before importing this module! */ + +#define PyExpat_CAPI_MAGIC "pyexpat.expat_CAPI 1.0" +#define PyExpat_CAPSULE_NAME "pyexpat.expat_CAPI" + +struct PyExpat_CAPI +{ + char* magic; /* set to PyExpat_CAPI_MAGIC */ + int size; /* set to sizeof(struct PyExpat_CAPI) */ + int MAJOR_VERSION; + int MINOR_VERSION; + int MICRO_VERSION; + /* pointers to selected expat functions. add new functions at + the end, if needed */ + const XML_LChar * (*ErrorString)(enum XML_Error code); + enum XML_Error (*GetErrorCode)(XML_Parser parser); + XML_Size (*GetErrorColumnNumber)(XML_Parser parser); + XML_Size (*GetErrorLineNumber)(XML_Parser parser); + enum XML_Status (*Parse)( + XML_Parser parser, const char *s, int len, int isFinal); + XML_Parser (*ParserCreate_MM)( + const XML_Char *encoding, const XML_Memory_Handling_Suite *memsuite, + const XML_Char *namespaceSeparator); + void (*ParserFree)(XML_Parser parser); + void (*SetCharacterDataHandler)( + XML_Parser parser, XML_CharacterDataHandler handler); + void (*SetCommentHandler)( + XML_Parser parser, XML_CommentHandler handler); + void (*SetDefaultHandlerExpand)( + XML_Parser parser, XML_DefaultHandler handler); + void (*SetElementHandler)( + XML_Parser parser, XML_StartElementHandler start, + XML_EndElementHandler end); + void (*SetNamespaceDeclHandler)( + XML_Parser parser, XML_StartNamespaceDeclHandler start, + XML_EndNamespaceDeclHandler end); + void (*SetProcessingInstructionHandler)( + XML_Parser parser, XML_ProcessingInstructionHandler handler); + void (*SetUnknownEncodingHandler)( + XML_Parser parser, XML_UnknownEncodingHandler handler, + void *encodingHandlerData); + void (*SetUserData)(XML_Parser parser, void *userData); + void (*SetStartDoctypeDeclHandler)(XML_Parser parser, + XML_StartDoctypeDeclHandler start); + enum XML_Status (*SetEncoding)(XML_Parser parser, const XML_Char *encoding); + int (*DefaultUnknownEncodingHandler)( + void *encodingHandlerData, const XML_Char *name, XML_Encoding *info); + /* always add new stuff to the end! */ +}; + diff --git a/android/python35/include/pyfpe.h b/android/python35/include/pyfpe.h new file mode 100644 index 000000000..e957119dd --- /dev/null +++ b/android/python35/include/pyfpe.h @@ -0,0 +1,176 @@ +#ifndef Py_PYFPE_H +#define Py_PYFPE_H +#ifdef __cplusplus +extern "C" { +#endif +/* + --------------------------------------------------------------------- + / Copyright (c) 1996. \ + | The Regents of the University of California. | + | All rights reserved. | + | | + | Permission to use, copy, modify, and distribute this software for | + | any purpose without fee is hereby granted, provided that this en- | + | tire notice is included in all copies of any software which is or | + | includes a copy or modification of this software and in all | + | copies of the supporting documentation for such software. | + | | + | This work was produced at the University of California, Lawrence | + | Livermore National Laboratory under contract no. W-7405-ENG-48 | + | between the U.S. Department of Energy and The Regents of the | + | University of California for the operation of UC LLNL. | + | | + | DISCLAIMER | + | | + | This software was prepared as an account of work sponsored by an | + | agency of the United States Government. Neither the United States | + | Government nor the University of California nor any of their em- | + | ployees, makes any warranty, express or implied, or assumes any | + | liability or responsibility for the accuracy, completeness, or | + | usefulness of any information, apparatus, product, or process | + | disclosed, or represents that its use would not infringe | + | privately-owned rights. Reference herein to any specific commer- | + | cial products, process, or service by trade name, trademark, | + | manufacturer, or otherwise, does not necessarily constitute or | + | imply its endorsement, recommendation, or favoring by the United | + | States Government or the University of California. The views and | + | opinions of authors expressed herein do not necessarily state or | + | reflect those of the United States Government or the University | + | of California, and shall not be used for advertising or product | + \ endorsement purposes. / + --------------------------------------------------------------------- +*/ + +/* + * Define macros for handling SIGFPE. + * Lee Busby, LLNL, November, 1996 + * busby1@llnl.gov + * + ********************************************* + * Overview of the system for handling SIGFPE: + * + * This file (Include/pyfpe.h) defines a couple of "wrapper" macros for + * insertion into your Python C code of choice. Their proper use is + * discussed below. The file Python/pyfpe.c defines a pair of global + * variables PyFPE_jbuf and PyFPE_counter which are used by the signal + * handler for SIGFPE to decide if a particular exception was protected + * by the macros. The signal handler itself, and code for enabling the + * generation of SIGFPE in the first place, is in a (new) Python module + * named fpectl. This module is standard in every respect. It can be loaded + * either statically or dynamically as you choose, and like any other + * Python module, has no effect until you import it. + * + * In the general case, there are three steps toward handling SIGFPE in any + * Python code: + * + * 1) Add the *_PROTECT macros to your C code as required to protect + * dangerous floating point sections. + * + * 2) Turn on the inclusion of the code by adding the ``--with-fpectl'' + * flag at the time you run configure. If the fpectl or other modules + * which use the *_PROTECT macros are to be dynamically loaded, be + * sure they are compiled with WANT_SIGFPE_HANDLER defined. + * + * 3) When python is built and running, import fpectl, and execute + * fpectl.turnon_sigfpe(). This sets up the signal handler and enables + * generation of SIGFPE whenever an exception occurs. From this point + * on, any properly trapped SIGFPE should result in the Python + * FloatingPointError exception. + * + * Step 1 has been done already for the Python kernel code, and should be + * done soon for the NumPy array package. Step 2 is usually done once at + * python install time. Python's behavior with respect to SIGFPE is not + * changed unless you also do step 3. Thus you can control this new + * facility at compile time, or run time, or both. + * + ******************************** + * Using the macros in your code: + * + * static PyObject *foobar(PyObject *self,PyObject *args) + * { + * .... + * PyFPE_START_PROTECT("Error in foobar", return 0) + * result = dangerous_op(somearg1, somearg2, ...); + * PyFPE_END_PROTECT(result) + * .... + * } + * + * If a floating point error occurs in dangerous_op, foobar returns 0 (NULL), + * after setting the associated value of the FloatingPointError exception to + * "Error in foobar". ``Dangerous_op'' can be a single operation, or a block + * of code, function calls, or any combination, so long as no alternate + * return is possible before the PyFPE_END_PROTECT macro is reached. + * + * The macros can only be used in a function context where an error return + * can be recognized as signaling a Python exception. (Generally, most + * functions that return a PyObject * will qualify.) + * + * Guido's original design suggestion for PyFPE_START_PROTECT and + * PyFPE_END_PROTECT had them open and close a local block, with a locally + * defined jmp_buf and jmp_buf pointer. This would allow recursive nesting + * of the macros. The Ansi C standard makes it clear that such local + * variables need to be declared with the "volatile" type qualifier to keep + * setjmp from corrupting their values. Some current implementations seem + * to be more restrictive. For example, the HPUX man page for setjmp says + * + * Upon the return from a setjmp() call caused by a longjmp(), the + * values of any non-static local variables belonging to the routine + * from which setjmp() was called are undefined. Code which depends on + * such values is not guaranteed to be portable. + * + * I therefore decided on a more limited form of nesting, using a counter + * variable (PyFPE_counter) to keep track of any recursion. If an exception + * occurs in an ``inner'' pair of macros, the return will apparently + * come from the outermost level. + * + */ + +#ifdef WANT_SIGFPE_HANDLER +#include +#include +#include +extern jmp_buf PyFPE_jbuf; +extern int PyFPE_counter; +extern double PyFPE_dummy(void *); + +#define PyFPE_START_PROTECT(err_string, leave_stmt) \ +if (!PyFPE_counter++ && setjmp(PyFPE_jbuf)) { \ + PyErr_SetString(PyExc_FloatingPointError, err_string); \ + PyFPE_counter = 0; \ + leave_stmt; \ +} + +/* + * This (following) is a heck of a way to decrement a counter. However, + * unless the macro argument is provided, code optimizers will sometimes move + * this statement so that it gets executed *before* the unsafe expression + * which we're trying to protect. That pretty well messes things up, + * of course. + * + * If the expression(s) you're trying to protect don't happen to return a + * value, you will need to manufacture a dummy result just to preserve the + * correct ordering of statements. Note that the macro passes the address + * of its argument (so you need to give it something which is addressable). + * If your expression returns multiple results, pass the last such result + * to PyFPE_END_PROTECT. + * + * Note that PyFPE_dummy returns a double, which is cast to int. + * This seeming insanity is to tickle the Floating Point Unit (FPU). + * If an exception has occurred in a preceding floating point operation, + * some architectures (notably Intel 80x86) will not deliver the interrupt + * until the *next* floating point operation. This is painful if you've + * already decremented PyFPE_counter. + */ +#define PyFPE_END_PROTECT(v) PyFPE_counter -= (int)PyFPE_dummy(&(v)); + +#else + +#define PyFPE_START_PROTECT(err_string, leave_stmt) +#define PyFPE_END_PROTECT(v) + +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_PYFPE_H */ diff --git a/android/python35/include/pygetopt.h b/android/python35/include/pygetopt.h new file mode 100644 index 000000000..425c7dd65 --- /dev/null +++ b/android/python35/include/pygetopt.h @@ -0,0 +1,21 @@ + +#ifndef Py_PYGETOPT_H +#define Py_PYGETOPT_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_LIMITED_API +PyAPI_DATA(int) _PyOS_opterr; +PyAPI_DATA(int) _PyOS_optind; +PyAPI_DATA(wchar_t *) _PyOS_optarg; + +PyAPI_FUNC(void) _PyOS_ResetGetOpt(void); +#endif + +PyAPI_FUNC(int) _PyOS_GetOpt(int argc, wchar_t **argv, wchar_t *optstring); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_PYGETOPT_H */ diff --git a/android/python35/include/pyhash.h b/android/python35/include/pyhash.h new file mode 100644 index 000000000..a7ca93758 --- /dev/null +++ b/android/python35/include/pyhash.h @@ -0,0 +1,149 @@ +#ifndef Py_HASH_H + +#define Py_HASH_H +#ifdef __cplusplus +extern "C" { +#endif + +/* Helpers for hash functions */ +#ifndef Py_LIMITED_API +PyAPI_FUNC(Py_hash_t) _Py_HashDouble(double); +PyAPI_FUNC(Py_hash_t) _Py_HashPointer(void*); +PyAPI_FUNC(Py_hash_t) _Py_HashBytes(const void*, Py_ssize_t); +#endif + +/* Prime multiplier used in string and various other hashes. */ +#define _PyHASH_MULTIPLIER 1000003UL /* 0xf4243 */ + +/* Parameters used for the numeric hash implementation. See notes for + _Py_HashDouble in Objects/object.c. Numeric hashes are based on + reduction modulo the prime 2**_PyHASH_BITS - 1. */ + +#if SIZEOF_VOID_P >= 8 +# define _PyHASH_BITS 61 +#else +# define _PyHASH_BITS 31 +#endif + +#define _PyHASH_MODULUS (((size_t)1 << _PyHASH_BITS) - 1) +#define _PyHASH_INF 314159 +#define _PyHASH_NAN 0 +#define _PyHASH_IMAG _PyHASH_MULTIPLIER + + +/* hash secret + * + * memory layout on 64 bit systems + * cccccccc cccccccc cccccccc uc -- unsigned char[24] + * pppppppp ssssssss ........ fnv -- two Py_hash_t + * k0k0k0k0 k1k1k1k1 ........ siphash -- two PY_UINT64_T + * ........ ........ ssssssss djbx33a -- 16 bytes padding + one Py_hash_t + * ........ ........ eeeeeeee pyexpat XML hash salt + * + * memory layout on 32 bit systems + * cccccccc cccccccc cccccccc uc + * ppppssss ........ ........ fnv -- two Py_hash_t + * k0k0k0k0 k1k1k1k1 ........ siphash -- two PY_UINT64_T (*) + * ........ ........ ssss.... djbx33a -- 16 bytes padding + one Py_hash_t + * ........ ........ eeee.... pyexpat XML hash salt + * + * (*) The siphash member may not be available on 32 bit platforms without + * an unsigned int64 data type. + */ +#ifndef Py_LIMITED_API +typedef union { + /* ensure 24 bytes */ + unsigned char uc[24]; + /* two Py_hash_t for FNV */ + struct { + Py_hash_t prefix; + Py_hash_t suffix; + } fnv; +#ifdef PY_UINT64_T + /* two uint64 for SipHash24 */ + struct { + PY_UINT64_T k0; + PY_UINT64_T k1; + } siphash; +#endif + /* a different (!) Py_hash_t for small string optimization */ + struct { + unsigned char padding[16]; + Py_hash_t suffix; + } djbx33a; + struct { + unsigned char padding[16]; + Py_hash_t hashsalt; + } expat; +} _Py_HashSecret_t; +PyAPI_DATA(_Py_HashSecret_t) _Py_HashSecret; +#endif + +#ifdef Py_DEBUG +PyAPI_DATA(int) _Py_HashSecret_Initialized; +#endif + + +/* hash function definition */ +#ifndef Py_LIMITED_API +typedef struct { + Py_hash_t (*const hash)(const void *, Py_ssize_t); + const char *name; + const int hash_bits; + const int seed_bits; +} PyHash_FuncDef; + +PyAPI_FUNC(PyHash_FuncDef*) PyHash_GetFuncDef(void); +#endif + + +/* cutoff for small string DJBX33A optimization in range [1, cutoff). + * + * About 50% of the strings in a typical Python application are smaller than + * 6 to 7 chars. However DJBX33A is vulnerable to hash collision attacks. + * NEVER use DJBX33A for long strings! + * + * A Py_HASH_CUTOFF of 0 disables small string optimization. 32 bit platforms + * should use a smaller cutoff because it is easier to create colliding + * strings. A cutoff of 7 on 64bit platforms and 5 on 32bit platforms should + * provide a decent safety margin. + */ +#ifndef Py_HASH_CUTOFF +# define Py_HASH_CUTOFF 0 +#elif (Py_HASH_CUTOFF > 7 || Py_HASH_CUTOFF < 0) +# error Py_HASH_CUTOFF must in range 0...7. +#endif /* Py_HASH_CUTOFF */ + + +/* hash algorithm selection + * + * The values for Py_HASH_SIPHASH24 and Py_HASH_FNV are hard-coded in the + * configure script. + * + * - FNV is available on all platforms and architectures. + * - SIPHASH24 only works on plaforms that provide PY_UINT64_T and doesn't + * require aligned memory for integers. + * - With EXTERNAL embedders can provide an alternative implementation with:: + * + * PyHash_FuncDef PyHash_Func = {...}; + * + * XXX: Figure out __declspec() for extern PyHash_FuncDef. + */ +#define Py_HASH_EXTERNAL 0 +#define Py_HASH_SIPHASH24 1 +#define Py_HASH_FNV 2 + +#ifndef Py_HASH_ALGORITHM +# if (defined(PY_UINT64_T) && defined(PY_UINT32_T) \ + && !defined(HAVE_ALIGNED_REQUIRED)) +# define Py_HASH_ALGORITHM Py_HASH_SIPHASH24 +# else +# define Py_HASH_ALGORITHM Py_HASH_FNV +# endif /* uint64_t && uint32_t && aligned */ +#endif /* Py_HASH_ALGORITHM */ + +#ifdef __cplusplus +} +#endif + +#endif /* !Py_HASH_H */ diff --git a/android/python35/include/pylifecycle.h b/android/python35/include/pylifecycle.h new file mode 100644 index 000000000..ccdebe26a --- /dev/null +++ b/android/python35/include/pylifecycle.h @@ -0,0 +1,124 @@ + +/* Interfaces to configure, query, create & destroy the Python runtime */ + +#ifndef Py_PYLIFECYCLE_H +#define Py_PYLIFECYCLE_H +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_FUNC(void) Py_SetProgramName(wchar_t *); +PyAPI_FUNC(wchar_t *) Py_GetProgramName(void); + +PyAPI_FUNC(void) Py_SetPythonHome(wchar_t *); +PyAPI_FUNC(wchar_t *) Py_GetPythonHome(void); + +#ifndef Py_LIMITED_API +/* Only used by applications that embed the interpreter and need to + * override the standard encoding determination mechanism + */ +PyAPI_FUNC(int) Py_SetStandardStreamEncoding(const char *encoding, + const char *errors); +#endif + +PyAPI_FUNC(void) Py_Initialize(void); +PyAPI_FUNC(void) Py_InitializeEx(int); +#ifndef Py_LIMITED_API +PyAPI_FUNC(void) _Py_InitializeEx_Private(int, int); +#endif +PyAPI_FUNC(void) Py_Finalize(void); +PyAPI_FUNC(int) Py_IsInitialized(void); +PyAPI_FUNC(PyThreadState *) Py_NewInterpreter(void); +PyAPI_FUNC(void) Py_EndInterpreter(PyThreadState *); + + +/* Py_PyAtExit is for the atexit module, Py_AtExit is for low-level + * exit functions. + */ +#ifndef Py_LIMITED_API +PyAPI_FUNC(void) _Py_PyAtExit(void (*func)(void)); +#endif +PyAPI_FUNC(int) Py_AtExit(void (*func)(void)); + +PyAPI_FUNC(void) Py_Exit(int); + +/* Restore signals that the interpreter has called SIG_IGN on to SIG_DFL. */ +#ifndef Py_LIMITED_API +PyAPI_FUNC(void) _Py_RestoreSignals(void); + +PyAPI_FUNC(int) Py_FdIsInteractive(FILE *, const char *); +#endif + +/* Bootstrap __main__ (defined in Modules/main.c) */ +PyAPI_FUNC(int) Py_Main(int argc, wchar_t **argv); + +/* In getpath.c */ +PyAPI_FUNC(wchar_t *) Py_GetProgramFullPath(void); +PyAPI_FUNC(wchar_t *) Py_GetPrefix(void); +PyAPI_FUNC(wchar_t *) Py_GetExecPrefix(void); +PyAPI_FUNC(wchar_t *) Py_GetPath(void); +PyAPI_FUNC(void) Py_SetPath(const wchar_t *); +#ifdef MS_WINDOWS +int _Py_CheckPython3(); +#endif + +/* In their own files */ +PyAPI_FUNC(const char *) Py_GetVersion(void); +PyAPI_FUNC(const char *) Py_GetPlatform(void); +PyAPI_FUNC(const char *) Py_GetCopyright(void); +PyAPI_FUNC(const char *) Py_GetCompiler(void); +PyAPI_FUNC(const char *) Py_GetBuildInfo(void); +#ifndef Py_LIMITED_API +PyAPI_FUNC(const char *) _Py_hgidentifier(void); +PyAPI_FUNC(const char *) _Py_hgversion(void); +#endif + +/* Internal -- various one-time initializations */ +#ifndef Py_LIMITED_API +PyAPI_FUNC(PyObject *) _PyBuiltin_Init(void); +PyAPI_FUNC(PyObject *) _PySys_Init(void); +PyAPI_FUNC(void) _PyImport_Init(void); +PyAPI_FUNC(void) _PyExc_Init(PyObject * bltinmod); +PyAPI_FUNC(void) _PyImportHooks_Init(void); +PyAPI_FUNC(int) _PyFrame_Init(void); +PyAPI_FUNC(int) _PyFloat_Init(void); +PyAPI_FUNC(int) PyByteArray_Init(void); +PyAPI_FUNC(void) _PyRandom_Init(void); +#endif + +/* Various internal finalizers */ +#ifndef Py_LIMITED_API +PyAPI_FUNC(void) _PyExc_Fini(void); +PyAPI_FUNC(void) _PyImport_Fini(void); +PyAPI_FUNC(void) PyMethod_Fini(void); +PyAPI_FUNC(void) PyFrame_Fini(void); +PyAPI_FUNC(void) PyCFunction_Fini(void); +PyAPI_FUNC(void) PyDict_Fini(void); +PyAPI_FUNC(void) PyTuple_Fini(void); +PyAPI_FUNC(void) PyList_Fini(void); +PyAPI_FUNC(void) PySet_Fini(void); +PyAPI_FUNC(void) PyBytes_Fini(void); +PyAPI_FUNC(void) PyByteArray_Fini(void); +PyAPI_FUNC(void) PyFloat_Fini(void); +PyAPI_FUNC(void) PyOS_FiniInterrupts(void); +PyAPI_FUNC(void) _PyGC_DumpShutdownStats(void); +PyAPI_FUNC(void) _PyGC_Fini(void); +PyAPI_FUNC(void) PySlice_Fini(void); +PyAPI_FUNC(void) _PyType_Fini(void); +PyAPI_FUNC(void) _PyRandom_Fini(void); + +PyAPI_DATA(PyThreadState *) _Py_Finalizing; +#endif + +/* Signals */ +typedef void (*PyOS_sighandler_t)(int); +PyAPI_FUNC(PyOS_sighandler_t) PyOS_getsig(int); +PyAPI_FUNC(PyOS_sighandler_t) PyOS_setsig(int, PyOS_sighandler_t); + +/* Random */ +PyAPI_FUNC(int) _PyOS_URandom (void *buffer, Py_ssize_t size); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_PYLIFECYCLE_H */ diff --git a/android/python35/include/pymacconfig.h b/android/python35/include/pymacconfig.h new file mode 100644 index 000000000..24e7b8dac --- /dev/null +++ b/android/python35/include/pymacconfig.h @@ -0,0 +1,102 @@ +#ifndef PYMACCONFIG_H +#define PYMACCONFIG_H + /* + * This file moves some of the autoconf magic to compile-time + * when building on MacOSX. This is needed for building 4-way + * universal binaries and for 64-bit universal binaries because + * the values redefined below aren't configure-time constant but + * only compile-time constant in these scenarios. + */ + +#if defined(__APPLE__) + +# undef SIZEOF_LONG +# undef SIZEOF_PTHREAD_T +# undef SIZEOF_SIZE_T +# undef SIZEOF_TIME_T +# undef SIZEOF_VOID_P +# undef SIZEOF__BOOL +# undef SIZEOF_UINTPTR_T +# undef SIZEOF_PTHREAD_T +# undef WORDS_BIGENDIAN +# undef DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754 +# undef DOUBLE_IS_BIG_ENDIAN_IEEE754 +# undef DOUBLE_IS_LITTLE_ENDIAN_IEEE754 +# undef HAVE_GCC_ASM_FOR_X87 + +# undef VA_LIST_IS_ARRAY +# if defined(__LP64__) && defined(__x86_64__) +# define VA_LIST_IS_ARRAY 1 +# endif + +# undef HAVE_LARGEFILE_SUPPORT +# ifndef __LP64__ +# define HAVE_LARGEFILE_SUPPORT 1 +# endif + +# undef SIZEOF_LONG +# ifdef __LP64__ +# define SIZEOF__BOOL 1 +# define SIZEOF__BOOL 1 +# define SIZEOF_LONG 8 +# define SIZEOF_PTHREAD_T 8 +# define SIZEOF_SIZE_T 8 +# define SIZEOF_TIME_T 8 +# define SIZEOF_VOID_P 8 +# define SIZEOF_UINTPTR_T 8 +# define SIZEOF_PTHREAD_T 8 +# else +# ifdef __ppc__ +# define SIZEOF__BOOL 4 +# else +# define SIZEOF__BOOL 1 +# endif +# define SIZEOF_LONG 4 +# define SIZEOF_PTHREAD_T 4 +# define SIZEOF_SIZE_T 4 +# define SIZEOF_TIME_T 4 +# define SIZEOF_VOID_P 4 +# define SIZEOF_UINTPTR_T 4 +# define SIZEOF_PTHREAD_T 4 +# endif + +# if defined(__LP64__) + /* MacOSX 10.4 (the first release to support 64-bit code + * at all) only supports 64-bit in the UNIX layer. + * Therefore surpress the toolbox-glue in 64-bit mode. + */ + + /* In 64-bit mode setpgrp always has no argments, in 32-bit + * mode that depends on the compilation environment + */ +# undef SETPGRP_HAVE_ARG + +# endif + +#ifdef __BIG_ENDIAN__ +#define WORDS_BIGENDIAN 1 +#define DOUBLE_IS_BIG_ENDIAN_IEEE754 +#else +#define DOUBLE_IS_LITTLE_ENDIAN_IEEE754 +#endif /* __BIG_ENDIAN */ + +#ifdef __i386__ +# define HAVE_GCC_ASM_FOR_X87 +#endif + + /* + * The definition in pyconfig.h is only valid on the OS release + * where configure ran on and not necessarily for all systems where + * the executable can be used on. + * + * Specifically: OSX 10.4 has limited supported for '%zd', while + * 10.5 has full support for '%zd'. A binary built on 10.5 won't + * work properly on 10.4 unless we surpress the definition + * of PY_FORMAT_SIZE_T + */ +#undef PY_FORMAT_SIZE_T + + +#endif /* defined(_APPLE__) */ + +#endif /* PYMACCONFIG_H */ diff --git a/android/python35/include/pymacro.h b/android/python35/include/pymacro.h new file mode 100644 index 000000000..3f6f5dce6 --- /dev/null +++ b/android/python35/include/pymacro.h @@ -0,0 +1,91 @@ +#ifndef Py_PYMACRO_H +#define Py_PYMACRO_H + +/* Minimum value between x and y */ +#define Py_MIN(x, y) (((x) > (y)) ? (y) : (x)) + +/* Maximum value between x and y */ +#define Py_MAX(x, y) (((x) > (y)) ? (x) : (y)) + +/* Absolute value of the number x */ +#define Py_ABS(x) ((x) < 0 ? -(x) : (x)) + +#define _Py_XSTRINGIFY(x) #x + +/* Convert the argument to a string. For example, Py_STRINGIFY(123) is replaced + with "123" by the preprocessor. Defines are also replaced by their value. + For example Py_STRINGIFY(__LINE__) is replaced by the line number, not + by "__LINE__". */ +#define Py_STRINGIFY(x) _Py_XSTRINGIFY(x) + +/* Argument must be a char or an int in [-128, 127] or [0, 255]. */ +#define Py_CHARMASK(c) ((unsigned char)((c) & 0xff)) + +/* Assert a build-time dependency, as an expression. + + Your compile will fail if the condition isn't true, or can't be evaluated + by the compiler. This can be used in an expression: its value is 0. + + Example: + + #define foo_to_char(foo) \ + ((char *)(foo) \ + + Py_BUILD_ASSERT_EXPR(offsetof(struct foo, string) == 0)) + + Written by Rusty Russell, public domain, http://ccodearchive.net/ */ +#define Py_BUILD_ASSERT_EXPR(cond) \ + (sizeof(char [1 - 2*!(cond)]) - 1) + +/* Get the number of elements in a visible array + + This does not work on pointers, or arrays declared as [], or function + parameters. With correct compiler support, such usage will cause a build + error (see Py_BUILD_ASSERT_EXPR). + + Written by Rusty Russell, public domain, http://ccodearchive.net/ + + Requires at GCC 3.1+ */ +#if (defined(__GNUC__) && !defined(__STRICT_ANSI__) && \ + (((__GNUC__ == 3) && (__GNU_MINOR__ >= 1)) || (__GNUC__ >= 4))) +/* Two gcc extensions. + &a[0] degrades to a pointer: a different type from an array */ +#define Py_ARRAY_LENGTH(array) \ + (sizeof(array) / sizeof((array)[0]) \ + + Py_BUILD_ASSERT_EXPR(!__builtin_types_compatible_p(typeof(array), \ + typeof(&(array)[0])))) +#else +#define Py_ARRAY_LENGTH(array) \ + (sizeof(array) / sizeof((array)[0])) +#endif + + +/* Define macros for inline documentation. */ +#define PyDoc_VAR(name) static char name[] +#define PyDoc_STRVAR(name,str) PyDoc_VAR(name) = PyDoc_STR(str) +#ifdef WITH_DOC_STRINGS +#define PyDoc_STR(str) str +#else +#define PyDoc_STR(str) "" +#endif + +/* Below "a" is a power of 2. */ +/* Round down size "n" to be a multiple of "a". */ +#define _Py_SIZE_ROUND_DOWN(n, a) ((size_t)(n) & ~(size_t)((a) - 1)) +/* Round up size "n" to be a multiple of "a". */ +#define _Py_SIZE_ROUND_UP(n, a) (((size_t)(n) + \ + (size_t)((a) - 1)) & ~(size_t)((a) - 1)) +/* Round pointer "p" down to the closest "a"-aligned address <= "p". */ +#define _Py_ALIGN_DOWN(p, a) ((void *)((Py_uintptr_t)(p) & ~(Py_uintptr_t)((a) - 1))) +/* Round pointer "p" up to the closest "a"-aligned address >= "p". */ +#define _Py_ALIGN_UP(p, a) ((void *)(((Py_uintptr_t)(p) + \ + (Py_uintptr_t)((a) - 1)) & ~(Py_uintptr_t)((a) - 1))) +/* Check if pointer "p" is aligned to "a"-bytes boundary. */ +#define _Py_IS_ALIGNED(p, a) (!((Py_uintptr_t)(p) & (Py_uintptr_t)((a) - 1))) + +#ifdef __GNUC__ +#define Py_UNUSED(name) _unused_ ## name __attribute__((unused)) +#else +#define Py_UNUSED(name) _unused_ ## name +#endif + +#endif /* Py_PYMACRO_H */ diff --git a/android/python35/include/pymath.h b/android/python35/include/pymath.h new file mode 100644 index 000000000..1ea9ac143 --- /dev/null +++ b/android/python35/include/pymath.h @@ -0,0 +1,212 @@ +#ifndef Py_PYMATH_H +#define Py_PYMATH_H + +#include "pyconfig.h" /* include for defines */ + +/************************************************************************** +Symbols and macros to supply platform-independent interfaces to mathematical +functions and constants +**************************************************************************/ + +/* Python provides implementations for copysign, round and hypot in + * Python/pymath.c just in case your math library doesn't provide the + * functions. + * + *Note: PC/pyconfig.h defines copysign as _copysign + */ +#ifndef HAVE_COPYSIGN +extern double copysign(double, double); +#endif + +#ifndef HAVE_ROUND +extern double round(double); +#endif + +#ifndef HAVE_HYPOT +extern double hypot(double, double); +#endif + +/* extra declarations */ +#ifndef _MSC_VER +#ifndef __STDC__ +extern double fmod (double, double); +extern double frexp (double, int *); +extern double ldexp (double, int); +extern double modf (double, double *); +extern double pow(double, double); +#endif /* __STDC__ */ +#endif /* _MSC_VER */ + +/* High precision defintion of pi and e (Euler) + * The values are taken from libc6's math.h. + */ +#ifndef Py_MATH_PIl +#define Py_MATH_PIl 3.1415926535897932384626433832795029L +#endif +#ifndef Py_MATH_PI +#define Py_MATH_PI 3.14159265358979323846 +#endif + +#ifndef Py_MATH_El +#define Py_MATH_El 2.7182818284590452353602874713526625L +#endif + +#ifndef Py_MATH_E +#define Py_MATH_E 2.7182818284590452354 +#endif + +/* On x86, Py_FORCE_DOUBLE forces a floating-point number out of an x87 FPU + register and into a 64-bit memory location, rounding from extended + precision to double precision in the process. On other platforms it does + nothing. */ + +/* we take double rounding as evidence of x87 usage */ +#ifndef Py_LIMITED_API +#ifndef Py_FORCE_DOUBLE +# ifdef X87_DOUBLE_ROUNDING +PyAPI_FUNC(double) _Py_force_double(double); +# define Py_FORCE_DOUBLE(X) (_Py_force_double(X)) +# else +# define Py_FORCE_DOUBLE(X) (X) +# endif +#endif +#endif + +#ifndef Py_LIMITED_API +#ifdef HAVE_GCC_ASM_FOR_X87 +PyAPI_FUNC(unsigned short) _Py_get_387controlword(void); +PyAPI_FUNC(void) _Py_set_387controlword(unsigned short); +#endif +#endif + +/* Py_IS_NAN(X) + * Return 1 if float or double arg is a NaN, else 0. + * Caution: + * X is evaluated more than once. + * This may not work on all platforms. Each platform has *some* + * way to spell this, though -- override in pyconfig.h if you have + * a platform where it doesn't work. + * Note: PC/pyconfig.h defines Py_IS_NAN as _isnan + */ +#ifndef Py_IS_NAN +#if defined HAVE_DECL_ISNAN && HAVE_DECL_ISNAN == 1 +#define Py_IS_NAN(X) isnan(X) +#else +#define Py_IS_NAN(X) ((X) != (X)) +#endif +#endif + +/* Py_IS_INFINITY(X) + * Return 1 if float or double arg is an infinity, else 0. + * Caution: + * X is evaluated more than once. + * This implementation may set the underflow flag if |X| is very small; + * it really can't be implemented correctly (& easily) before C99. + * Override in pyconfig.h if you have a better spelling on your platform. + * Py_FORCE_DOUBLE is used to avoid getting false negatives from a + * non-infinite value v sitting in an 80-bit x87 register such that + * v becomes infinite when spilled from the register to 64-bit memory. + * Note: PC/pyconfig.h defines Py_IS_INFINITY as _isinf + */ +#ifndef Py_IS_INFINITY +# if defined HAVE_DECL_ISINF && HAVE_DECL_ISINF == 1 +# define Py_IS_INFINITY(X) isinf(X) +# else +# define Py_IS_INFINITY(X) ((X) && \ + (Py_FORCE_DOUBLE(X)*0.5 == Py_FORCE_DOUBLE(X))) +# endif +#endif + +/* Py_IS_FINITE(X) + * Return 1 if float or double arg is neither infinite nor NAN, else 0. + * Some compilers (e.g. VisualStudio) have intrisics for this, so a special + * macro for this particular test is useful + * Note: PC/pyconfig.h defines Py_IS_FINITE as _finite + */ +#ifndef Py_IS_FINITE +#if defined HAVE_DECL_ISFINITE && HAVE_DECL_ISFINITE == 1 +#define Py_IS_FINITE(X) isfinite(X) +#elif defined HAVE_FINITE +#define Py_IS_FINITE(X) finite(X) +#else +#define Py_IS_FINITE(X) (!Py_IS_INFINITY(X) && !Py_IS_NAN(X)) +#endif +#endif + +/* HUGE_VAL is supposed to expand to a positive double infinity. Python + * uses Py_HUGE_VAL instead because some platforms are broken in this + * respect. We used to embed code in pyport.h to try to worm around that, + * but different platforms are broken in conflicting ways. If you're on + * a platform where HUGE_VAL is defined incorrectly, fiddle your Python + * config to #define Py_HUGE_VAL to something that works on your platform. + */ +#ifndef Py_HUGE_VAL +#define Py_HUGE_VAL HUGE_VAL +#endif + +/* Py_NAN + * A value that evaluates to a NaN. On IEEE 754 platforms INF*0 or + * INF/INF works. Define Py_NO_NAN in pyconfig.h if your platform + * doesn't support NaNs. + */ +#if !defined(Py_NAN) && !defined(Py_NO_NAN) +#if !defined(__INTEL_COMPILER) + #define Py_NAN (Py_HUGE_VAL * 0.) +#else /* __INTEL_COMPILER */ + #if defined(ICC_NAN_STRICT) + #pragma float_control(push) + #pragma float_control(precise, on) + #pragma float_control(except, on) + #if defined(_MSC_VER) + __declspec(noinline) + #else /* Linux */ + __attribute__((noinline)) + #endif /* _MSC_VER */ + static double __icc_nan() + { + return sqrt(-1.0); + } + #pragma float_control (pop) + #define Py_NAN __icc_nan() + #else /* ICC_NAN_RELAXED as default for Intel Compiler */ + static union { unsigned char buf[8]; double __icc_nan; } __nan_store = {0,0,0,0,0,0,0xf8,0x7f}; + #define Py_NAN (__nan_store.__icc_nan) + #endif /* ICC_NAN_STRICT */ +#endif /* __INTEL_COMPILER */ +#endif + +/* Py_OVERFLOWED(X) + * Return 1 iff a libm function overflowed. Set errno to 0 before calling + * a libm function, and invoke this macro after, passing the function + * result. + * Caution: + * This isn't reliable. C99 no longer requires libm to set errno under + * any exceptional condition, but does require +- HUGE_VAL return + * values on overflow. A 754 box *probably* maps HUGE_VAL to a + * double infinity, and we're cool if that's so, unless the input + * was an infinity and an infinity is the expected result. A C89 + * system sets errno to ERANGE, so we check for that too. We're + * out of luck if a C99 754 box doesn't map HUGE_VAL to +Inf, or + * if the returned result is a NaN, or if a C89 box returns HUGE_VAL + * in non-overflow cases. + * X is evaluated more than once. + * Some platforms have better way to spell this, so expect some #ifdef'ery. + * + * OpenBSD uses 'isinf()' because a compiler bug on that platform causes + * the longer macro version to be mis-compiled. This isn't optimal, and + * should be removed once a newer compiler is available on that platform. + * The system that had the failure was running OpenBSD 3.2 on Intel, with + * gcc 2.95.3. + * + * According to Tim's checkin, the FreeBSD systems use isinf() to work + * around a FPE bug on that platform. + */ +#if defined(__FreeBSD__) || defined(__OpenBSD__) +#define Py_OVERFLOWED(X) isinf(X) +#else +#define Py_OVERFLOWED(X) ((X) != 0.0 && (errno == ERANGE || \ + (X) == Py_HUGE_VAL || \ + (X) == -Py_HUGE_VAL)) +#endif + +#endif /* Py_PYMATH_H */ diff --git a/android/python35/include/pymem.h b/android/python35/include/pymem.h new file mode 100644 index 000000000..043db64de --- /dev/null +++ b/android/python35/include/pymem.h @@ -0,0 +1,188 @@ +/* The PyMem_ family: low-level memory allocation interfaces. + See objimpl.h for the PyObject_ memory family. +*/ + +#ifndef Py_PYMEM_H +#define Py_PYMEM_H + +#include "pyport.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_LIMITED_API +PyAPI_FUNC(void *) PyMem_RawMalloc(size_t size); +PyAPI_FUNC(void *) PyMem_RawCalloc(size_t nelem, size_t elsize); +PyAPI_FUNC(void *) PyMem_RawRealloc(void *ptr, size_t new_size); +PyAPI_FUNC(void) PyMem_RawFree(void *ptr); +#endif + + +/* BEWARE: + + Each interface exports both functions and macros. Extension modules should + use the functions, to ensure binary compatibility across Python versions. + Because the Python implementation is free to change internal details, and + the macros may (or may not) expose details for speed, if you do use the + macros you must recompile your extensions with each Python release. + + Never mix calls to PyMem_ with calls to the platform malloc/realloc/ + calloc/free. For example, on Windows different DLLs may end up using + different heaps, and if you use PyMem_Malloc you'll get the memory from the + heap used by the Python DLL; it could be a disaster if you free()'ed that + directly in your own extension. Using PyMem_Free instead ensures Python + can return the memory to the proper heap. As another example, in + PYMALLOC_DEBUG mode, Python wraps all calls to all PyMem_ and PyObject_ + memory functions in special debugging wrappers that add additional + debugging info to dynamic memory blocks. The system routines have no idea + what to do with that stuff, and the Python wrappers have no idea what to do + with raw blocks obtained directly by the system routines then. + + The GIL must be held when using these APIs. +*/ + +/* + * Raw memory interface + * ==================== + */ + +/* Functions + + Functions supplying platform-independent semantics for malloc/realloc/ + free. These functions make sure that allocating 0 bytes returns a distinct + non-NULL pointer (whenever possible -- if we're flat out of memory, NULL + may be returned), even if the platform malloc and realloc don't. + Returned pointers must be checked for NULL explicitly. No action is + performed on failure (no exception is set, no warning is printed, etc). +*/ + +PyAPI_FUNC(void *) PyMem_Malloc(size_t size); +PyAPI_FUNC(void *) PyMem_Calloc(size_t nelem, size_t elsize); +PyAPI_FUNC(void *) PyMem_Realloc(void *ptr, size_t new_size); +PyAPI_FUNC(void) PyMem_Free(void *ptr); + +#ifndef Py_LIMITED_API +PyAPI_FUNC(char *) _PyMem_RawStrdup(const char *str); +PyAPI_FUNC(char *) _PyMem_Strdup(const char *str); +#endif + +/* Macros. */ + +/* PyMem_MALLOC(0) means malloc(1). Some systems would return NULL + for malloc(0), which would be treated as an error. Some platforms + would return a pointer with no memory behind it, which would break + pymalloc. To solve these problems, allocate an extra byte. */ +/* Returns NULL to indicate error if a negative size or size larger than + Py_ssize_t can represent is supplied. Helps prevents security holes. */ +#define PyMem_MALLOC(n) PyMem_Malloc(n) +#define PyMem_REALLOC(p, n) PyMem_Realloc(p, n) +#define PyMem_FREE(p) PyMem_Free(p) + +/* + * Type-oriented memory interface + * ============================== + * + * Allocate memory for n objects of the given type. Returns a new pointer + * or NULL if the request was too large or memory allocation failed. Use + * these macros rather than doing the multiplication yourself so that proper + * overflow checking is always done. + */ + +#define PyMem_New(type, n) \ + ( ((size_t)(n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \ + ( (type *) PyMem_Malloc((n) * sizeof(type)) ) ) +#define PyMem_NEW(type, n) \ + ( ((size_t)(n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \ + ( (type *) PyMem_MALLOC((n) * sizeof(type)) ) ) + +/* + * The value of (p) is always clobbered by this macro regardless of success. + * The caller MUST check if (p) is NULL afterwards and deal with the memory + * error if so. This means the original value of (p) MUST be saved for the + * caller's memory error handler to not lose track of it. + */ +#define PyMem_Resize(p, type, n) \ + ( (p) = ((size_t)(n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \ + (type *) PyMem_Realloc((p), (n) * sizeof(type)) ) +#define PyMem_RESIZE(p, type, n) \ + ( (p) = ((size_t)(n) > PY_SSIZE_T_MAX / sizeof(type)) ? NULL : \ + (type *) PyMem_REALLOC((p), (n) * sizeof(type)) ) + +/* PyMem{Del,DEL} are left over from ancient days, and shouldn't be used + * anymore. They're just confusing aliases for PyMem_{Free,FREE} now. + */ +#define PyMem_Del PyMem_Free +#define PyMem_DEL PyMem_FREE + +#ifndef Py_LIMITED_API +typedef enum { + /* PyMem_RawMalloc(), PyMem_RawRealloc() and PyMem_RawFree() */ + PYMEM_DOMAIN_RAW, + + /* PyMem_Malloc(), PyMem_Realloc() and PyMem_Free() */ + PYMEM_DOMAIN_MEM, + + /* PyObject_Malloc(), PyObject_Realloc() and PyObject_Free() */ + PYMEM_DOMAIN_OBJ +} PyMemAllocatorDomain; + +typedef struct { + /* user context passed as the first argument to the 4 functions */ + void *ctx; + + /* allocate a memory block */ + void* (*malloc) (void *ctx, size_t size); + + /* allocate a memory block initialized by zeros */ + void* (*calloc) (void *ctx, size_t nelem, size_t elsize); + + /* allocate or resize a memory block */ + void* (*realloc) (void *ctx, void *ptr, size_t new_size); + + /* release a memory block */ + void (*free) (void *ctx, void *ptr); +} PyMemAllocatorEx; + +/* Get the memory block allocator of the specified domain. */ +PyAPI_FUNC(void) PyMem_GetAllocator(PyMemAllocatorDomain domain, + PyMemAllocatorEx *allocator); + +/* Set the memory block allocator of the specified domain. + + The new allocator must return a distinct non-NULL pointer when requesting + zero bytes. + + For the PYMEM_DOMAIN_RAW domain, the allocator must be thread-safe: the GIL + is not held when the allocator is called. + + If the new allocator is not a hook (don't call the previous allocator), the + PyMem_SetupDebugHooks() function must be called to reinstall the debug hooks + on top on the new allocator. */ +PyAPI_FUNC(void) PyMem_SetAllocator(PyMemAllocatorDomain domain, + PyMemAllocatorEx *allocator); + +/* Setup hooks to detect bugs in the following Python memory allocator + functions: + + - PyMem_RawMalloc(), PyMem_RawRealloc(), PyMem_RawFree() + - PyMem_Malloc(), PyMem_Realloc(), PyMem_Free() + - PyObject_Malloc(), PyObject_Realloc() and PyObject_Free() + + Newly allocated memory is filled with the byte 0xCB, freed memory is filled + with the byte 0xDB. Additionnal checks: + + - detect API violations, ex: PyObject_Free() called on a buffer allocated + by PyMem_Malloc() + - detect write before the start of the buffer (buffer underflow) + - detect write after the end of the buffer (buffer overflow) + + The function does nothing if Python is not compiled is debug mode. */ +PyAPI_FUNC(void) PyMem_SetupDebugHooks(void); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* !Py_PYMEM_H */ diff --git a/android/python35/include/pyport.h b/android/python35/include/pyport.h new file mode 100644 index 000000000..66e00d4e6 --- /dev/null +++ b/android/python35/include/pyport.h @@ -0,0 +1,900 @@ +#ifndef Py_PYPORT_H +#define Py_PYPORT_H + +#include "pyconfig.h" /* include for defines */ + +/* Some versions of HP-UX & Solaris need inttypes.h for int32_t, + INT32_MAX, etc. */ +#ifdef HAVE_INTTYPES_H +#include +#endif + +#ifdef HAVE_STDINT_H +#include +#endif + +/************************************************************************** +Symbols and macros to supply platform-independent interfaces to basic +C language & library operations whose spellings vary across platforms. + +Please try to make documentation here as clear as possible: by definition, +the stuff here is trying to illuminate C's darkest corners. + +Config #defines referenced here: + +SIGNED_RIGHT_SHIFT_ZERO_FILLS +Meaning: To be defined iff i>>j does not extend the sign bit when i is a + signed integral type and i < 0. +Used in: Py_ARITHMETIC_RIGHT_SHIFT + +Py_DEBUG +Meaning: Extra checks compiled in for debug mode. +Used in: Py_SAFE_DOWNCAST + +HAVE_UINTPTR_T +Meaning: The C9X type uintptr_t is supported by the compiler +Used in: Py_uintptr_t + +HAVE_LONG_LONG +Meaning: The compiler supports the C type "long long" +Used in: PY_LONG_LONG + +**************************************************************************/ + +/* typedefs for some C9X-defined synonyms for integral types. + * + * The names in Python are exactly the same as the C9X names, except with a + * Py_ prefix. Until C9X is universally implemented, this is the only way + * to ensure that Python gets reliable names that don't conflict with names + * in non-Python code that are playing their own tricks to define the C9X + * names. + * + * NOTE: don't go nuts here! Python has no use for *most* of the C9X + * integral synonyms. Only define the ones we actually need. + */ + +#ifdef HAVE_LONG_LONG +#ifndef PY_LONG_LONG +#define PY_LONG_LONG long long +#if defined(LLONG_MAX) +/* If LLONG_MAX is defined in limits.h, use that. */ +#define PY_LLONG_MIN LLONG_MIN +#define PY_LLONG_MAX LLONG_MAX +#define PY_ULLONG_MAX ULLONG_MAX +#elif defined(__LONG_LONG_MAX__) +/* Otherwise, if GCC has a builtin define, use that. (Definition of + * PY_LLONG_MIN assumes two's complement with no trap representation.) */ +#define PY_LLONG_MAX __LONG_LONG_MAX__ +#define PY_LLONG_MIN (-PY_LLONG_MAX - 1) +#define PY_ULLONG_MAX (PY_LLONG_MAX * Py_ULL(2) + 1) +#elif defined(SIZEOF_LONG_LONG) +/* Otherwise compute from SIZEOF_LONG_LONG, assuming two's complement, no + padding bits, and no trap representation. Note: PY_ULLONG_MAX was + previously #defined as (~0ULL) here; but that'll give the wrong value in a + preprocessor expression on systems where long long != intmax_t. */ +#define PY_LLONG_MAX \ + (1 + 2 * ((Py_LL(1) << (CHAR_BIT * SIZEOF_LONG_LONG - 2)) - 1)) +#define PY_LLONG_MIN (-PY_LLONG_MAX - 1) +#define PY_ULLONG_MAX (PY_LLONG_MAX * Py_ULL(2) + 1) +#endif /* LLONG_MAX */ +#endif +#endif /* HAVE_LONG_LONG */ + +/* a build with 30-bit digits for Python integers needs an exact-width + * 32-bit unsigned integer type to store those digits. (We could just use + * type 'unsigned long', but that would be wasteful on a system where longs + * are 64-bits.) On Unix systems, the autoconf macro AC_TYPE_UINT32_T defines + * uint32_t to be such a type unless stdint.h or inttypes.h defines uint32_t. + * However, it doesn't set HAVE_UINT32_T, so we do that here. + */ +#ifdef uint32_t +#define HAVE_UINT32_T 1 +#endif + +#ifdef HAVE_UINT32_T +#ifndef PY_UINT32_T +#define PY_UINT32_T uint32_t +#endif +#endif + +/* Macros for a 64-bit unsigned integer type; used for type 'twodigits' in the + * integer implementation, when 30-bit digits are enabled. + */ +#ifdef uint64_t +#define HAVE_UINT64_T 1 +#endif + +#ifdef HAVE_UINT64_T +#ifndef PY_UINT64_T +#define PY_UINT64_T uint64_t +#endif +#endif + +/* Signed variants of the above */ +#ifdef int32_t +#define HAVE_INT32_T 1 +#endif + +#ifdef HAVE_INT32_T +#ifndef PY_INT32_T +#define PY_INT32_T int32_t +#endif +#endif + +#ifdef int64_t +#define HAVE_INT64_T 1 +#endif + +#ifdef HAVE_INT64_T +#ifndef PY_INT64_T +#define PY_INT64_T int64_t +#endif +#endif + +/* If PYLONG_BITS_IN_DIGIT is not defined then we'll use 30-bit digits if all + the necessary integer types are available, and we're on a 64-bit platform + (as determined by SIZEOF_VOID_P); otherwise we use 15-bit digits. */ + +#ifndef PYLONG_BITS_IN_DIGIT +#if (defined HAVE_UINT64_T && defined HAVE_INT64_T && \ + defined HAVE_UINT32_T && defined HAVE_INT32_T && SIZEOF_VOID_P >= 8) +#define PYLONG_BITS_IN_DIGIT 30 +#else +#define PYLONG_BITS_IN_DIGIT 15 +#endif +#endif + +/* uintptr_t is the C9X name for an unsigned integral type such that a + * legitimate void* can be cast to uintptr_t and then back to void* again + * without loss of information. Similarly for intptr_t, wrt a signed + * integral type. + */ +#ifdef HAVE_UINTPTR_T +typedef uintptr_t Py_uintptr_t; +typedef intptr_t Py_intptr_t; + +#elif SIZEOF_VOID_P <= SIZEOF_INT +typedef unsigned int Py_uintptr_t; +typedef int Py_intptr_t; + +#elif SIZEOF_VOID_P <= SIZEOF_LONG +typedef unsigned long Py_uintptr_t; +typedef long Py_intptr_t; + +#elif defined(HAVE_LONG_LONG) && (SIZEOF_VOID_P <= SIZEOF_LONG_LONG) +typedef unsigned PY_LONG_LONG Py_uintptr_t; +typedef PY_LONG_LONG Py_intptr_t; + +#else +# error "Python needs a typedef for Py_uintptr_t in pyport.h." +#endif /* HAVE_UINTPTR_T */ + +/* Py_ssize_t is a signed integral type such that sizeof(Py_ssize_t) == + * sizeof(size_t). C99 doesn't define such a thing directly (size_t is an + * unsigned integral type). See PEP 353 for details. + */ +#ifdef HAVE_SSIZE_T +typedef ssize_t Py_ssize_t; +#elif SIZEOF_VOID_P == SIZEOF_SIZE_T +typedef Py_intptr_t Py_ssize_t; +#else +# error "Python needs a typedef for Py_ssize_t in pyport.h." +#endif + +/* Py_hash_t is the same size as a pointer. */ +#define SIZEOF_PY_HASH_T SIZEOF_SIZE_T +typedef Py_ssize_t Py_hash_t; +/* Py_uhash_t is the unsigned equivalent needed to calculate numeric hash. */ +#define SIZEOF_PY_UHASH_T SIZEOF_SIZE_T +typedef size_t Py_uhash_t; + +/* Only used for compatibility with code that may not be PY_SSIZE_T_CLEAN. */ +#ifdef PY_SSIZE_T_CLEAN +typedef Py_ssize_t Py_ssize_clean_t; +#else +typedef int Py_ssize_clean_t; +#endif + +/* Largest possible value of size_t. + SIZE_MAX is part of C99, so it might be defined on some + platforms. If it is not defined, (size_t)-1 is a portable + definition for C89, due to the way signed->unsigned + conversion is defined. */ +#ifdef SIZE_MAX +#define PY_SIZE_MAX SIZE_MAX +#else +#define PY_SIZE_MAX ((size_t)-1) +#endif + +/* Largest positive value of type Py_ssize_t. */ +#define PY_SSIZE_T_MAX ((Py_ssize_t)(((size_t)-1)>>1)) +/* Smallest negative value of type Py_ssize_t. */ +#define PY_SSIZE_T_MIN (-PY_SSIZE_T_MAX-1) + +/* PY_FORMAT_SIZE_T is a platform-specific modifier for use in a printf + * format to convert an argument with the width of a size_t or Py_ssize_t. + * C99 introduced "z" for this purpose, but not all platforms support that; + * e.g., MS compilers use "I" instead. + * + * These "high level" Python format functions interpret "z" correctly on + * all platforms (Python interprets the format string itself, and does whatever + * the platform C requires to convert a size_t/Py_ssize_t argument): + * + * PyBytes_FromFormat + * PyErr_Format + * PyBytes_FromFormatV + * PyUnicode_FromFormatV + * + * Lower-level uses require that you interpolate the correct format modifier + * yourself (e.g., calling printf, fprintf, sprintf, PyOS_snprintf); for + * example, + * + * Py_ssize_t index; + * fprintf(stderr, "index %" PY_FORMAT_SIZE_T "d sucks\n", index); + * + * That will expand to %ld, or %Id, or to something else correct for a + * Py_ssize_t on the platform. + */ +#ifndef PY_FORMAT_SIZE_T +# if SIZEOF_SIZE_T == SIZEOF_INT && !defined(__APPLE__) +# define PY_FORMAT_SIZE_T "" +# elif SIZEOF_SIZE_T == SIZEOF_LONG +# define PY_FORMAT_SIZE_T "l" +# elif defined(MS_WINDOWS) +# define PY_FORMAT_SIZE_T "I" +# else +# error "This platform's pyconfig.h needs to define PY_FORMAT_SIZE_T" +# endif +#endif + +/* PY_FORMAT_LONG_LONG is analogous to PY_FORMAT_SIZE_T above, but for + * the long long type instead of the size_t type. It's only available + * when HAVE_LONG_LONG is defined. The "high level" Python format + * functions listed above will interpret "lld" or "llu" correctly on + * all platforms. + */ +#ifdef HAVE_LONG_LONG +# ifndef PY_FORMAT_LONG_LONG +# ifdef MS_WINDOWS +# define PY_FORMAT_LONG_LONG "I64" +# else +# error "This platform's pyconfig.h needs to define PY_FORMAT_LONG_LONG" +# endif +# endif +#endif + +/* Py_LOCAL can be used instead of static to get the fastest possible calling + * convention for functions that are local to a given module. + * + * Py_LOCAL_INLINE does the same thing, and also explicitly requests inlining, + * for platforms that support that. + * + * If PY_LOCAL_AGGRESSIVE is defined before python.h is included, more + * "aggressive" inlining/optimization is enabled for the entire module. This + * may lead to code bloat, and may slow things down for those reasons. It may + * also lead to errors, if the code relies on pointer aliasing. Use with + * care. + * + * NOTE: You can only use this for functions that are entirely local to a + * module; functions that are exported via method tables, callbacks, etc, + * should keep using static. + */ + +#if defined(_MSC_VER) +#if defined(PY_LOCAL_AGGRESSIVE) +/* enable more aggressive optimization for visual studio */ +#pragma optimize("agtw", on) +#endif +/* ignore warnings if the compiler decides not to inline a function */ +#pragma warning(disable: 4710) +/* fastest possible local call under MSVC */ +#define Py_LOCAL(type) static type __fastcall +#define Py_LOCAL_INLINE(type) static __inline type __fastcall +#elif defined(USE_INLINE) +#define Py_LOCAL(type) static type +#define Py_LOCAL_INLINE(type) static inline type +#else +#define Py_LOCAL(type) static type +#define Py_LOCAL_INLINE(type) static type +#endif + +/* Py_MEMCPY can be used instead of memcpy in cases where the copied blocks + * are often very short. While most platforms have highly optimized code for + * large transfers, the setup costs for memcpy are often quite high. MEMCPY + * solves this by doing short copies "in line". + */ + +#if defined(_MSC_VER) +#define Py_MEMCPY(target, source, length) do { \ + size_t i_, n_ = (length); \ + char *t_ = (void*) (target); \ + const char *s_ = (void*) (source); \ + if (n_ >= 16) \ + memcpy(t_, s_, n_); \ + else \ + for (i_ = 0; i_ < n_; i_++) \ + t_[i_] = s_[i_]; \ + } while (0) +#else +#define Py_MEMCPY memcpy +#endif + +#include + +#ifdef HAVE_IEEEFP_H +#include /* needed for 'finite' declaration on some platforms */ +#endif + +#include /* Moved here from the math section, before extern "C" */ + +/******************************************** + * WRAPPER FOR and/or * + ********************************************/ + +#ifdef TIME_WITH_SYS_TIME +#include +#include +#else /* !TIME_WITH_SYS_TIME */ +#ifdef HAVE_SYS_TIME_H +#include +#else /* !HAVE_SYS_TIME_H */ +#include +#endif /* !HAVE_SYS_TIME_H */ +#endif /* !TIME_WITH_SYS_TIME */ + + +/****************************** + * WRAPPER FOR * + ******************************/ + +/* NB caller must include */ + +#ifdef HAVE_SYS_SELECT_H +#include +#endif /* !HAVE_SYS_SELECT_H */ + +/******************************* + * stat() and fstat() fiddling * + *******************************/ + +#ifdef HAVE_SYS_STAT_H +#include +#elif defined(HAVE_STAT_H) +#include +#endif + +#ifndef S_IFMT +/* VisualAge C/C++ Failed to Define MountType Field in sys/stat.h */ +#define S_IFMT 0170000 +#endif + +#ifndef S_IFLNK +/* Windows doesn't define S_IFLNK but posixmodule.c maps + * IO_REPARSE_TAG_SYMLINK to S_IFLNK */ +# define S_IFLNK 0120000 +#endif + +#ifndef S_ISREG +#define S_ISREG(x) (((x) & S_IFMT) == S_IFREG) +#endif + +#ifndef S_ISDIR +#define S_ISDIR(x) (((x) & S_IFMT) == S_IFDIR) +#endif + +#ifndef S_ISCHR +#define S_ISCHR(x) (((x) & S_IFMT) == S_IFCHR) +#endif + +#ifdef __cplusplus +/* Move this down here since some C++ #include's don't like to be included + inside an extern "C" */ +extern "C" { +#endif + + +/* Py_ARITHMETIC_RIGHT_SHIFT + * C doesn't define whether a right-shift of a signed integer sign-extends + * or zero-fills. Here a macro to force sign extension: + * Py_ARITHMETIC_RIGHT_SHIFT(TYPE, I, J) + * Return I >> J, forcing sign extension. Arithmetically, return the + * floor of I/2**J. + * Requirements: + * I should have signed integer type. In the terminology of C99, this can + * be either one of the five standard signed integer types (signed char, + * short, int, long, long long) or an extended signed integer type. + * J is an integer >= 0 and strictly less than the number of bits in the + * type of I (because C doesn't define what happens for J outside that + * range either). + * TYPE used to specify the type of I, but is now ignored. It's been left + * in for backwards compatibility with versions <= 2.6 or 3.0. + * Caution: + * I may be evaluated more than once. + */ +#ifdef SIGNED_RIGHT_SHIFT_ZERO_FILLS +#define Py_ARITHMETIC_RIGHT_SHIFT(TYPE, I, J) \ + ((I) < 0 ? -1-((-1-(I)) >> (J)) : (I) >> (J)) +#else +#define Py_ARITHMETIC_RIGHT_SHIFT(TYPE, I, J) ((I) >> (J)) +#endif + +/* Py_FORCE_EXPANSION(X) + * "Simply" returns its argument. However, macro expansions within the + * argument are evaluated. This unfortunate trickery is needed to get + * token-pasting to work as desired in some cases. + */ +#define Py_FORCE_EXPANSION(X) X + +/* Py_SAFE_DOWNCAST(VALUE, WIDE, NARROW) + * Cast VALUE to type NARROW from type WIDE. In Py_DEBUG mode, this + * assert-fails if any information is lost. + * Caution: + * VALUE may be evaluated more than once. + */ +#ifdef Py_DEBUG +#define Py_SAFE_DOWNCAST(VALUE, WIDE, NARROW) \ + (assert((WIDE)(NARROW)(VALUE) == (VALUE)), (NARROW)(VALUE)) +#else +#define Py_SAFE_DOWNCAST(VALUE, WIDE, NARROW) (NARROW)(VALUE) +#endif + +/* Py_SET_ERRNO_ON_MATH_ERROR(x) + * If a libm function did not set errno, but it looks like the result + * overflowed or not-a-number, set errno to ERANGE or EDOM. Set errno + * to 0 before calling a libm function, and invoke this macro after, + * passing the function result. + * Caution: + * This isn't reliable. See Py_OVERFLOWED comments. + * X is evaluated more than once. + */ +#if defined(__FreeBSD__) || defined(__OpenBSD__) || (defined(__hpux) && defined(__ia64)) +#define _Py_SET_EDOM_FOR_NAN(X) if (isnan(X)) errno = EDOM; +#else +#define _Py_SET_EDOM_FOR_NAN(X) ; +#endif +#define Py_SET_ERRNO_ON_MATH_ERROR(X) \ + do { \ + if (errno == 0) { \ + if ((X) == Py_HUGE_VAL || (X) == -Py_HUGE_VAL) \ + errno = ERANGE; \ + else _Py_SET_EDOM_FOR_NAN(X) \ + } \ + } while(0) + +/* Py_SET_ERANGE_ON_OVERFLOW(x) + * An alias of Py_SET_ERRNO_ON_MATH_ERROR for backward-compatibility. + */ +#define Py_SET_ERANGE_IF_OVERFLOW(X) Py_SET_ERRNO_ON_MATH_ERROR(X) + +/* Py_ADJUST_ERANGE1(x) + * Py_ADJUST_ERANGE2(x, y) + * Set errno to 0 before calling a libm function, and invoke one of these + * macros after, passing the function result(s) (Py_ADJUST_ERANGE2 is useful + * for functions returning complex results). This makes two kinds of + * adjustments to errno: (A) If it looks like the platform libm set + * errno=ERANGE due to underflow, clear errno. (B) If it looks like the + * platform libm overflowed but didn't set errno, force errno to ERANGE. In + * effect, we're trying to force a useful implementation of C89 errno + * behavior. + * Caution: + * This isn't reliable. See Py_OVERFLOWED comments. + * X and Y may be evaluated more than once. + */ +#define Py_ADJUST_ERANGE1(X) \ + do { \ + if (errno == 0) { \ + if ((X) == Py_HUGE_VAL || (X) == -Py_HUGE_VAL) \ + errno = ERANGE; \ + } \ + else if (errno == ERANGE && (X) == 0.0) \ + errno = 0; \ + } while(0) + +#define Py_ADJUST_ERANGE2(X, Y) \ + do { \ + if ((X) == Py_HUGE_VAL || (X) == -Py_HUGE_VAL || \ + (Y) == Py_HUGE_VAL || (Y) == -Py_HUGE_VAL) { \ + if (errno == 0) \ + errno = ERANGE; \ + } \ + else if (errno == ERANGE) \ + errno = 0; \ + } while(0) + +/* The functions _Py_dg_strtod and _Py_dg_dtoa in Python/dtoa.c (which are + * required to support the short float repr introduced in Python 3.1) require + * that the floating-point unit that's being used for arithmetic operations + * on C doubles is set to use 53-bit precision. It also requires that the + * FPU rounding mode is round-half-to-even, but that's less often an issue. + * + * If your FPU isn't already set to 53-bit precision/round-half-to-even, and + * you want to make use of _Py_dg_strtod and _Py_dg_dtoa, then you should + * + * #define HAVE_PY_SET_53BIT_PRECISION 1 + * + * and also give appropriate definitions for the following three macros: + * + * _PY_SET_53BIT_PRECISION_START : store original FPU settings, and + * set FPU to 53-bit precision/round-half-to-even + * _PY_SET_53BIT_PRECISION_END : restore original FPU settings + * _PY_SET_53BIT_PRECISION_HEADER : any variable declarations needed to + * use the two macros above. + * + * The macros are designed to be used within a single C function: see + * Python/pystrtod.c for an example of their use. + */ + +/* get and set x87 control word for gcc/x86 */ +#ifdef HAVE_GCC_ASM_FOR_X87 +#define HAVE_PY_SET_53BIT_PRECISION 1 +/* _Py_get/set_387controlword functions are defined in Python/pymath.c */ +#define _Py_SET_53BIT_PRECISION_HEADER \ + unsigned short old_387controlword, new_387controlword +#define _Py_SET_53BIT_PRECISION_START \ + do { \ + old_387controlword = _Py_get_387controlword(); \ + new_387controlword = (old_387controlword & ~0x0f00) | 0x0200; \ + if (new_387controlword != old_387controlword) \ + _Py_set_387controlword(new_387controlword); \ + } while (0) +#define _Py_SET_53BIT_PRECISION_END \ + if (new_387controlword != old_387controlword) \ + _Py_set_387controlword(old_387controlword) +#endif + +/* get and set x87 control word for VisualStudio/x86 */ +#if defined(_MSC_VER) && !defined(_WIN64) /* x87 not supported in 64-bit */ +#define HAVE_PY_SET_53BIT_PRECISION 1 +#define _Py_SET_53BIT_PRECISION_HEADER \ + unsigned int old_387controlword, new_387controlword, out_387controlword +/* We use the __control87_2 function to set only the x87 control word. + The SSE control word is unaffected. */ +#define _Py_SET_53BIT_PRECISION_START \ + do { \ + __control87_2(0, 0, &old_387controlword, NULL); \ + new_387controlword = \ + (old_387controlword & ~(_MCW_PC | _MCW_RC)) | (_PC_53 | _RC_NEAR); \ + if (new_387controlword != old_387controlword) \ + __control87_2(new_387controlword, _MCW_PC | _MCW_RC, \ + &out_387controlword, NULL); \ + } while (0) +#define _Py_SET_53BIT_PRECISION_END \ + do { \ + if (new_387controlword != old_387controlword) \ + __control87_2(old_387controlword, _MCW_PC | _MCW_RC, \ + &out_387controlword, NULL); \ + } while (0) +#endif + +#ifdef HAVE_GCC_ASM_FOR_MC68881 +#define HAVE_PY_SET_53BIT_PRECISION 1 +#define _Py_SET_53BIT_PRECISION_HEADER \ + unsigned int old_fpcr, new_fpcr +#define _Py_SET_53BIT_PRECISION_START \ + do { \ + __asm__ ("fmove.l %%fpcr,%0" : "=g" (old_fpcr)); \ + /* Set double precision / round to nearest. */ \ + new_fpcr = (old_fpcr & ~0xf0) | 0x80; \ + if (new_fpcr != old_fpcr) \ + __asm__ volatile ("fmove.l %0,%%fpcr" : : "g" (new_fpcr)); \ + } while (0) +#define _Py_SET_53BIT_PRECISION_END \ + do { \ + if (new_fpcr != old_fpcr) \ + __asm__ volatile ("fmove.l %0,%%fpcr" : : "g" (old_fpcr)); \ + } while (0) +#endif + +/* default definitions are empty */ +#ifndef HAVE_PY_SET_53BIT_PRECISION +#define _Py_SET_53BIT_PRECISION_HEADER +#define _Py_SET_53BIT_PRECISION_START +#define _Py_SET_53BIT_PRECISION_END +#endif + +/* If we can't guarantee 53-bit precision, don't use the code + in Python/dtoa.c, but fall back to standard code. This + means that repr of a float will be long (17 sig digits). + + Realistically, there are two things that could go wrong: + + (1) doubles aren't IEEE 754 doubles, or + (2) we're on x86 with the rounding precision set to 64-bits + (extended precision), and we don't know how to change + the rounding precision. + */ + +#if !defined(DOUBLE_IS_LITTLE_ENDIAN_IEEE754) && \ + !defined(DOUBLE_IS_BIG_ENDIAN_IEEE754) && \ + !defined(DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754) +#define PY_NO_SHORT_FLOAT_REPR +#endif + +/* double rounding is symptomatic of use of extended precision on x86. If + we're seeing double rounding, and we don't have any mechanism available for + changing the FPU rounding precision, then don't use Python/dtoa.c. */ +#if defined(X87_DOUBLE_ROUNDING) && !defined(HAVE_PY_SET_53BIT_PRECISION) +#define PY_NO_SHORT_FLOAT_REPR +#endif + + +/* Py_DEPRECATED(version) + * Declare a variable, type, or function deprecated. + * Usage: + * extern int old_var Py_DEPRECATED(2.3); + * typedef int T1 Py_DEPRECATED(2.4); + * extern int x() Py_DEPRECATED(2.5); + */ +#if defined(__GNUC__) && ((__GNUC__ >= 4) || \ + (__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)) +#define Py_DEPRECATED(VERSION_UNUSED) __attribute__((__deprecated__)) +#else +#define Py_DEPRECATED(VERSION_UNUSED) +#endif + +/************************************************************************** +Prototypes that are missing from the standard include files on some systems +(and possibly only some versions of such systems.) + +Please be conservative with adding new ones, document them and enclose them +in platform-specific #ifdefs. +**************************************************************************/ + +#ifdef SOLARIS +/* Unchecked */ +extern int gethostname(char *, int); +#endif + +#ifdef HAVE__GETPTY +#include /* we need to import mode_t */ +extern char * _getpty(int *, int, mode_t, int); +#endif + +/* On QNX 6, struct termio must be declared by including sys/termio.h + if TCGETA, TCSETA, TCSETAW, or TCSETAF are used. sys/termio.h must + be included before termios.h or it will generate an error. */ +#if defined(HAVE_SYS_TERMIO_H) && !defined(__hpux) +#include +#endif + +#if defined(HAVE_OPENPTY) || defined(HAVE_FORKPTY) +#if !defined(HAVE_PTY_H) && !defined(HAVE_LIBUTIL_H) +/* BSDI does not supply a prototype for the 'openpty' and 'forkpty' + functions, even though they are included in libutil. */ +#include +extern int openpty(int *, int *, char *, struct termios *, struct winsize *); +extern pid_t forkpty(int *, char *, struct termios *, struct winsize *); +#endif /* !defined(HAVE_PTY_H) && !defined(HAVE_LIBUTIL_H) */ +#endif /* defined(HAVE_OPENPTY) || defined(HAVE_FORKPTY) */ + + +/* On 4.4BSD-descendants, ctype functions serves the whole range of + * wchar_t character set rather than single byte code points only. + * This characteristic can break some operations of string object + * including str.upper() and str.split() on UTF-8 locales. This + * workaround was provided by Tim Robbins of FreeBSD project. + */ + +#ifdef __FreeBSD__ +#include +#if __FreeBSD_version > 500039 +# define _PY_PORT_CTYPE_UTF8_ISSUE +#endif +#endif + + +#if defined(__APPLE__) +# define _PY_PORT_CTYPE_UTF8_ISSUE +#endif + +#ifdef _PY_PORT_CTYPE_UTF8_ISSUE +#include +#include +#undef isalnum +#define isalnum(c) iswalnum(btowc(c)) +#undef isalpha +#define isalpha(c) iswalpha(btowc(c)) +#undef islower +#define islower(c) iswlower(btowc(c)) +#undef isspace +#define isspace(c) iswspace(btowc(c)) +#undef isupper +#define isupper(c) iswupper(btowc(c)) +#undef tolower +#define tolower(c) towlower(btowc(c)) +#undef toupper +#define toupper(c) towupper(btowc(c)) +#endif + + +/* Declarations for symbol visibility. + + PyAPI_FUNC(type): Declares a public Python API function and return type + PyAPI_DATA(type): Declares public Python data and its type + PyMODINIT_FUNC: A Python module init function. If these functions are + inside the Python core, they are private to the core. + If in an extension module, it may be declared with + external linkage depending on the platform. + + As a number of platforms support/require "__declspec(dllimport/dllexport)", + we support a HAVE_DECLSPEC_DLL macro to save duplication. +*/ + +/* + All windows ports, except cygwin, are handled in PC/pyconfig.h. + + Cygwin is the only other autoconf platform requiring special + linkage handling and it uses __declspec(). +*/ +#if defined(__CYGWIN__) +# define HAVE_DECLSPEC_DLL +#endif + +/* only get special linkage if built as shared or platform is Cygwin */ +#if defined(Py_ENABLE_SHARED) || defined(__CYGWIN__) +# if defined(HAVE_DECLSPEC_DLL) +# ifdef Py_BUILD_CORE +# define PyAPI_FUNC(RTYPE) __declspec(dllexport) RTYPE +# define PyAPI_DATA(RTYPE) extern __declspec(dllexport) RTYPE + /* module init functions inside the core need no external linkage */ + /* except for Cygwin to handle embedding */ +# if defined(__CYGWIN__) +# define PyMODINIT_FUNC __declspec(dllexport) PyObject* +# else /* __CYGWIN__ */ +# define PyMODINIT_FUNC PyObject* +# endif /* __CYGWIN__ */ +# else /* Py_BUILD_CORE */ + /* Building an extension module, or an embedded situation */ + /* public Python functions and data are imported */ + /* Under Cygwin, auto-import functions to prevent compilation */ + /* failures similar to those described at the bottom of 4.1: */ + /* http://docs.python.org/extending/windows.html#a-cookbook-approach */ +# if !defined(__CYGWIN__) +# define PyAPI_FUNC(RTYPE) __declspec(dllimport) RTYPE +# endif /* !__CYGWIN__ */ +# define PyAPI_DATA(RTYPE) extern __declspec(dllimport) RTYPE + /* module init functions outside the core must be exported */ +# if defined(__cplusplus) +# define PyMODINIT_FUNC extern "C" __declspec(dllexport) PyObject* +# else /* __cplusplus */ +# define PyMODINIT_FUNC __declspec(dllexport) PyObject* +# endif /* __cplusplus */ +# endif /* Py_BUILD_CORE */ +# endif /* HAVE_DECLSPEC */ +#endif /* Py_ENABLE_SHARED */ + +/* If no external linkage macros defined by now, create defaults */ +#ifndef PyAPI_FUNC +# define PyAPI_FUNC(RTYPE) RTYPE +#endif +#ifndef PyAPI_DATA +# define PyAPI_DATA(RTYPE) extern RTYPE +#endif +#ifndef PyMODINIT_FUNC +# if defined(__cplusplus) +# define PyMODINIT_FUNC extern "C" PyObject* +# else /* __cplusplus */ +# define PyMODINIT_FUNC PyObject* +# endif /* __cplusplus */ +#endif + +/* limits.h constants that may be missing */ + +#ifndef INT_MAX +#define INT_MAX 2147483647 +#endif + +#ifndef LONG_MAX +#if SIZEOF_LONG == 4 +#define LONG_MAX 0X7FFFFFFFL +#elif SIZEOF_LONG == 8 +#define LONG_MAX 0X7FFFFFFFFFFFFFFFL +#else +#error "could not set LONG_MAX in pyport.h" +#endif +#endif + +#ifndef LONG_MIN +#define LONG_MIN (-LONG_MAX-1) +#endif + +#ifndef LONG_BIT +#define LONG_BIT (8 * SIZEOF_LONG) +#endif + +#if LONG_BIT != 8 * SIZEOF_LONG +/* 04-Oct-2000 LONG_BIT is apparently (mis)defined as 64 on some recent + * 32-bit platforms using gcc. We try to catch that here at compile-time + * rather than waiting for integer multiplication to trigger bogus + * overflows. + */ +#error "LONG_BIT definition appears wrong for platform (bad gcc/glibc config?)." +#endif + +#ifdef __cplusplus +} +#endif + +/* + * Hide GCC attributes from compilers that don't support them. + */ +#if (!defined(__GNUC__) || __GNUC__ < 2 || \ + (__GNUC__ == 2 && __GNUC_MINOR__ < 7) ) +#define Py_GCC_ATTRIBUTE(x) +#else +#define Py_GCC_ATTRIBUTE(x) __attribute__(x) +#endif + +/* + * Specify alignment on compilers that support it. + */ +#if defined(__GNUC__) && __GNUC__ >= 3 +#define Py_ALIGNED(x) __attribute__((aligned(x))) +#else +#define Py_ALIGNED(x) +#endif + +/* Eliminate end-of-loop code not reached warnings from SunPro C + * when using do{...}while(0) macros + */ +#ifdef __SUNPRO_C +#pragma error_messages (off,E_END_OF_LOOP_CODE_NOT_REACHED) +#endif + +/* + * Older Microsoft compilers don't support the C99 long long literal suffixes, + * so these will be defined in PC/pyconfig.h for those compilers. + */ +#ifndef Py_LL +#define Py_LL(x) x##LL +#endif + +#ifndef Py_ULL +#define Py_ULL(x) Py_LL(x##U) +#endif + +#ifdef VA_LIST_IS_ARRAY +#define Py_VA_COPY(x, y) Py_MEMCPY((x), (y), sizeof(va_list)) +#else +#ifdef __va_copy +#define Py_VA_COPY __va_copy +#else +#define Py_VA_COPY(x, y) (x) = (y) +#endif +#endif + +/* + * Convenient macros to deal with endianness of the platform. WORDS_BIGENDIAN is + * detected by configure and defined in pyconfig.h. The code in pyconfig.h + * also takes care of Apple's universal builds. + */ + +#ifdef WORDS_BIGENDIAN +#define PY_BIG_ENDIAN 1 +#define PY_LITTLE_ENDIAN 0 +#else +#define PY_BIG_ENDIAN 0 +#define PY_LITTLE_ENDIAN 1 +#endif + +#ifdef Py_BUILD_CORE +/* + * Macros to protect CRT calls against instant termination when passed an + * invalid parameter (issue23524). + */ +#if defined _MSC_VER && _MSC_VER >= 1900 + +extern _invalid_parameter_handler _Py_silent_invalid_parameter_handler; +#define _Py_BEGIN_SUPPRESS_IPH { _invalid_parameter_handler _Py_old_handler = \ + _set_thread_local_invalid_parameter_handler(_Py_silent_invalid_parameter_handler); +#define _Py_END_SUPPRESS_IPH _set_thread_local_invalid_parameter_handler(_Py_old_handler); } + +#else + +#define _Py_BEGIN_SUPPRESS_IPH +#define _Py_END_SUPPRESS_IPH + +#endif /* _MSC_VER >= 1900 */ +#endif /* Py_BUILD_CORE */ + +#endif /* Py_PYPORT_H */ diff --git a/android/python35/include/pystate.h b/android/python35/include/pystate.h new file mode 100644 index 000000000..a2fd8031d --- /dev/null +++ b/android/python35/include/pystate.h @@ -0,0 +1,278 @@ + +/* Thread and interpreter state structures and their interfaces */ + + +#ifndef Py_PYSTATE_H +#define Py_PYSTATE_H +#ifdef __cplusplus +extern "C" { +#endif + +/* State shared between threads */ + +struct _ts; /* Forward */ +struct _is; /* Forward */ + +#ifdef Py_LIMITED_API +typedef struct _is PyInterpreterState; +#else +typedef struct _is { + + struct _is *next; + struct _ts *tstate_head; + + PyObject *modules; + PyObject *modules_by_index; + PyObject *sysdict; + PyObject *builtins; + PyObject *importlib; + + PyObject *codec_search_path; + PyObject *codec_search_cache; + PyObject *codec_error_registry; + int codecs_initialized; + int fscodec_initialized; + +#ifdef HAVE_DLOPEN + int dlopenflags; +#endif +#ifdef WITH_TSC + int tscdump; +#endif + + PyObject *builtins_copy; +} PyInterpreterState; +#endif + + +/* State unique per thread */ + +struct _frame; /* Avoid including frameobject.h */ + +#ifndef Py_LIMITED_API +/* Py_tracefunc return -1 when raising an exception, or 0 for success. */ +typedef int (*Py_tracefunc)(PyObject *, struct _frame *, int, PyObject *); + +/* The following values are used for 'what' for tracefunc functions: */ +#define PyTrace_CALL 0 +#define PyTrace_EXCEPTION 1 +#define PyTrace_LINE 2 +#define PyTrace_RETURN 3 +#define PyTrace_C_CALL 4 +#define PyTrace_C_EXCEPTION 5 +#define PyTrace_C_RETURN 6 +#endif + +#ifdef Py_LIMITED_API +typedef struct _ts PyThreadState; +#else +typedef struct _ts { + /* See Python/ceval.c for comments explaining most fields */ + + struct _ts *prev; + struct _ts *next; + PyInterpreterState *interp; + + struct _frame *frame; + int recursion_depth; + char overflowed; /* The stack has overflowed. Allow 50 more calls + to handle the runtime error. */ + char recursion_critical; /* The current calls must not cause + a stack overflow. */ + /* 'tracing' keeps track of the execution depth when tracing/profiling. + This is to prevent the actual trace/profile code from being recorded in + the trace/profile. */ + int tracing; + int use_tracing; + + Py_tracefunc c_profilefunc; + Py_tracefunc c_tracefunc; + PyObject *c_profileobj; + PyObject *c_traceobj; + + PyObject *curexc_type; + PyObject *curexc_value; + PyObject *curexc_traceback; + + PyObject *exc_type; + PyObject *exc_value; + PyObject *exc_traceback; + + PyObject *dict; /* Stores per-thread state */ + + int gilstate_counter; + + PyObject *async_exc; /* Asynchronous exception to raise */ + long thread_id; /* Thread id where this tstate was created */ + + int trash_delete_nesting; + PyObject *trash_delete_later; + + /* Called when a thread state is deleted normally, but not when it + * is destroyed after fork(). + * Pain: to prevent rare but fatal shutdown errors (issue 18808), + * Thread.join() must wait for the join'ed thread's tstate to be unlinked + * from the tstate chain. That happens at the end of a thread's life, + * in pystate.c. + * The obvious way doesn't quite work: create a lock which the tstate + * unlinking code releases, and have Thread.join() wait to acquire that + * lock. The problem is that we _are_ at the end of the thread's life: + * if the thread holds the last reference to the lock, decref'ing the + * lock will delete the lock, and that may trigger arbitrary Python code + * if there's a weakref, with a callback, to the lock. But by this time + * _PyThreadState_Current is already NULL, so only the simplest of C code + * can be allowed to run (in particular it must not be possible to + * release the GIL). + * So instead of holding the lock directly, the tstate holds a weakref to + * the lock: that's the value of on_delete_data below. Decref'ing a + * weakref is harmless. + * on_delete points to _threadmodule.c's static release_sentinel() function. + * After the tstate is unlinked, release_sentinel is called with the + * weakref-to-lock (on_delete_data) argument, and release_sentinel releases + * the indirectly held lock. + */ + void (*on_delete)(void *); + void *on_delete_data; + + PyObject *coroutine_wrapper; + int in_coroutine_wrapper; + + /* XXX signal handlers should also be here */ + +} PyThreadState; +#endif + + +PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_New(void); +PyAPI_FUNC(void) PyInterpreterState_Clear(PyInterpreterState *); +PyAPI_FUNC(void) PyInterpreterState_Delete(PyInterpreterState *); +PyAPI_FUNC(int) _PyState_AddModule(PyObject*, struct PyModuleDef*); +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000 +/* New in 3.3 */ +PyAPI_FUNC(int) PyState_AddModule(PyObject*, struct PyModuleDef*); +PyAPI_FUNC(int) PyState_RemoveModule(struct PyModuleDef*); +#endif +PyAPI_FUNC(PyObject*) PyState_FindModule(struct PyModuleDef*); +#ifndef Py_LIMITED_API +PyAPI_FUNC(void) _PyState_ClearModules(void); +#endif + +PyAPI_FUNC(PyThreadState *) PyThreadState_New(PyInterpreterState *); +PyAPI_FUNC(PyThreadState *) _PyThreadState_Prealloc(PyInterpreterState *); +PyAPI_FUNC(void) _PyThreadState_Init(PyThreadState *); +PyAPI_FUNC(void) PyThreadState_Clear(PyThreadState *); +PyAPI_FUNC(void) PyThreadState_Delete(PyThreadState *); +PyAPI_FUNC(void) _PyThreadState_DeleteExcept(PyThreadState *tstate); +#ifdef WITH_THREAD +PyAPI_FUNC(void) PyThreadState_DeleteCurrent(void); +PyAPI_FUNC(void) _PyGILState_Reinit(void); +#endif + +PyAPI_FUNC(PyThreadState *) PyThreadState_Get(void); +PyAPI_FUNC(PyThreadState *) PyThreadState_Swap(PyThreadState *); +PyAPI_FUNC(PyObject *) PyThreadState_GetDict(void); +PyAPI_FUNC(int) PyThreadState_SetAsyncExc(long, PyObject *); + + +/* Variable and macro for in-line access to current thread state */ + +/* Assuming the current thread holds the GIL, this is the + PyThreadState for the current thread. + + Issue #23644: pyatomic.h is incompatible with C++ (yet). Disable + PyThreadState_GET() optimization: declare it as an alias to + PyThreadState_Get(), as done for limited API. */ +#if !defined(Py_LIMITED_API) && !defined(__cplusplus) +PyAPI_DATA(_Py_atomic_address) _PyThreadState_Current; +#endif + +#if defined(Py_DEBUG) || defined(Py_LIMITED_API) || defined(__cplusplus) +#define PyThreadState_GET() PyThreadState_Get() +#else +#define PyThreadState_GET() \ + ((PyThreadState*)_Py_atomic_load_relaxed(&_PyThreadState_Current)) +#endif + +typedef + enum {PyGILState_LOCKED, PyGILState_UNLOCKED} + PyGILState_STATE; + +#ifdef WITH_THREAD + +/* Ensure that the current thread is ready to call the Python + C API, regardless of the current state of Python, or of its + thread lock. This may be called as many times as desired + by a thread so long as each call is matched with a call to + PyGILState_Release(). In general, other thread-state APIs may + be used between _Ensure() and _Release() calls, so long as the + thread-state is restored to its previous state before the Release(). + For example, normal use of the Py_BEGIN_ALLOW_THREADS/ + Py_END_ALLOW_THREADS macros are acceptable. + + The return value is an opaque "handle" to the thread state when + PyGILState_Ensure() was called, and must be passed to + PyGILState_Release() to ensure Python is left in the same state. Even + though recursive calls are allowed, these handles can *not* be shared - + each unique call to PyGILState_Ensure must save the handle for its + call to PyGILState_Release. + + When the function returns, the current thread will hold the GIL. + + Failure is a fatal error. +*/ +PyAPI_FUNC(PyGILState_STATE) PyGILState_Ensure(void); + +/* Release any resources previously acquired. After this call, Python's + state will be the same as it was prior to the corresponding + PyGILState_Ensure() call (but generally this state will be unknown to + the caller, hence the use of the GILState API.) + + Every call to PyGILState_Ensure must be matched by a call to + PyGILState_Release on the same thread. +*/ +PyAPI_FUNC(void) PyGILState_Release(PyGILState_STATE); + +/* Helper/diagnostic function - get the current thread state for + this thread. May return NULL if no GILState API has been used + on the current thread. Note that the main thread always has such a + thread-state, even if no auto-thread-state call has been made + on the main thread. +*/ +PyAPI_FUNC(PyThreadState *) PyGILState_GetThisThreadState(void); + +/* Helper/diagnostic function - return 1 if the current thread + * currently holds the GIL, 0 otherwise + */ +#ifndef Py_LIMITED_API +PyAPI_FUNC(int) PyGILState_Check(void); +#endif + +#endif /* #ifdef WITH_THREAD */ + +/* The implementation of sys._current_frames() Returns a dict mapping + thread id to that thread's current frame. +*/ +#ifndef Py_LIMITED_API +PyAPI_FUNC(PyObject *) _PyThread_CurrentFrames(void); +#endif + +/* Routines for advanced debuggers, requested by David Beazley. + Don't use unless you know what you are doing! */ +#ifndef Py_LIMITED_API +PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_Head(void); +PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_Next(PyInterpreterState *); +PyAPI_FUNC(PyThreadState *) PyInterpreterState_ThreadHead(PyInterpreterState *); +PyAPI_FUNC(PyThreadState *) PyThreadState_Next(PyThreadState *); + +typedef struct _frame *(*PyThreadFrameGetter)(PyThreadState *self_); +#endif + +/* hook for PyEval_GetFrame(), requested for Psyco */ +#ifndef Py_LIMITED_API +PyAPI_DATA(PyThreadFrameGetter) _PyThreadState_GetFrame; +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_PYSTATE_H */ diff --git a/android/python35/include/pystrcmp.h b/android/python35/include/pystrcmp.h new file mode 100644 index 000000000..edb12397e --- /dev/null +++ b/android/python35/include/pystrcmp.h @@ -0,0 +1,23 @@ +#ifndef Py_STRCMP_H +#define Py_STRCMP_H + +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_FUNC(int) PyOS_mystrnicmp(const char *, const char *, Py_ssize_t); +PyAPI_FUNC(int) PyOS_mystricmp(const char *, const char *); + +#ifdef MS_WINDOWS +#define PyOS_strnicmp strnicmp +#define PyOS_stricmp stricmp +#else +#define PyOS_strnicmp PyOS_mystrnicmp +#define PyOS_stricmp PyOS_mystricmp +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* !Py_STRCMP_H */ diff --git a/android/python35/include/pystrhex.h b/android/python35/include/pystrhex.h new file mode 100644 index 000000000..1dc125575 --- /dev/null +++ b/android/python35/include/pystrhex.h @@ -0,0 +1,17 @@ +#ifndef Py_STRHEX_H +#define Py_STRHEX_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Returns a str() containing the hex representation of argbuf. */ +PyAPI_FUNC(PyObject*) _Py_strhex(const char* argbuf, const Py_ssize_t arglen); +/* Returns a bytes() containing the ASCII hex representation of argbuf. */ +PyAPI_FUNC(PyObject*) _Py_strhex_bytes(const char* argbuf, const Py_ssize_t arglen); + +#ifdef __cplusplus +} +#endif + +#endif /* !Py_STRHEX_H */ diff --git a/android/python35/include/pystrtod.h b/android/python35/include/pystrtod.h new file mode 100644 index 000000000..23fd1c625 --- /dev/null +++ b/android/python35/include/pystrtod.h @@ -0,0 +1,41 @@ +#ifndef Py_STRTOD_H +#define Py_STRTOD_H + +#ifdef __cplusplus +extern "C" { +#endif + + +PyAPI_FUNC(double) PyOS_string_to_double(const char *str, + char **endptr, + PyObject *overflow_exception); + +/* The caller is responsible for calling PyMem_Free to free the buffer + that's is returned. */ +PyAPI_FUNC(char *) PyOS_double_to_string(double val, + char format_code, + int precision, + int flags, + int *type); + +#ifndef Py_LIMITED_API +PyAPI_FUNC(double) _Py_parse_inf_or_nan(const char *p, char **endptr); +#endif + + +/* PyOS_double_to_string's "flags" parameter can be set to 0 or more of: */ +#define Py_DTSF_SIGN 0x01 /* always add the sign */ +#define Py_DTSF_ADD_DOT_0 0x02 /* if the result is an integer add ".0" */ +#define Py_DTSF_ALT 0x04 /* "alternate" formatting. it's format_code + specific */ + +/* PyOS_double_to_string's "type", if non-NULL, will be set to one of: */ +#define Py_DTST_FINITE 0 +#define Py_DTST_INFINITE 1 +#define Py_DTST_NAN 2 + +#ifdef __cplusplus +} +#endif + +#endif /* !Py_STRTOD_H */ diff --git a/android/python35/include/pythonrun.h b/android/python35/include/pythonrun.h new file mode 100644 index 000000000..f92148da0 --- /dev/null +++ b/android/python35/include/pythonrun.h @@ -0,0 +1,195 @@ + +/* Interfaces to parse and execute pieces of python code */ + +#ifndef Py_PYTHONRUN_H +#define Py_PYTHONRUN_H +#ifdef __cplusplus +extern "C" { +#endif + +#define PyCF_MASK (CO_FUTURE_DIVISION | CO_FUTURE_ABSOLUTE_IMPORT | \ + CO_FUTURE_WITH_STATEMENT | CO_FUTURE_PRINT_FUNCTION | \ + CO_FUTURE_UNICODE_LITERALS | CO_FUTURE_BARRY_AS_BDFL | \ + CO_FUTURE_GENERATOR_STOP) +#define PyCF_MASK_OBSOLETE (CO_NESTED) +#define PyCF_SOURCE_IS_UTF8 0x0100 +#define PyCF_DONT_IMPLY_DEDENT 0x0200 +#define PyCF_ONLY_AST 0x0400 +#define PyCF_IGNORE_COOKIE 0x0800 + +#ifndef Py_LIMITED_API +typedef struct { + int cf_flags; /* bitmask of CO_xxx flags relevant to future */ +} PyCompilerFlags; +#endif + +#ifndef Py_LIMITED_API +PyAPI_FUNC(int) PyRun_SimpleStringFlags(const char *, PyCompilerFlags *); +PyAPI_FUNC(int) PyRun_AnyFileFlags(FILE *, const char *, PyCompilerFlags *); +PyAPI_FUNC(int) PyRun_AnyFileExFlags( + FILE *fp, + const char *filename, /* decoded from the filesystem encoding */ + int closeit, + PyCompilerFlags *flags); +PyAPI_FUNC(int) PyRun_SimpleFileExFlags( + FILE *fp, + const char *filename, /* decoded from the filesystem encoding */ + int closeit, + PyCompilerFlags *flags); +PyAPI_FUNC(int) PyRun_InteractiveOneFlags( + FILE *fp, + const char *filename, /* decoded from the filesystem encoding */ + PyCompilerFlags *flags); +PyAPI_FUNC(int) PyRun_InteractiveOneObject( + FILE *fp, + PyObject *filename, + PyCompilerFlags *flags); +PyAPI_FUNC(int) PyRun_InteractiveLoopFlags( + FILE *fp, + const char *filename, /* decoded from the filesystem encoding */ + PyCompilerFlags *flags); + +PyAPI_FUNC(struct _mod *) PyParser_ASTFromString( + const char *s, + const char *filename, /* decoded from the filesystem encoding */ + int start, + PyCompilerFlags *flags, + PyArena *arena); +PyAPI_FUNC(struct _mod *) PyParser_ASTFromStringObject( + const char *s, + PyObject *filename, + int start, + PyCompilerFlags *flags, + PyArena *arena); +PyAPI_FUNC(struct _mod *) PyParser_ASTFromFile( + FILE *fp, + const char *filename, /* decoded from the filesystem encoding */ + const char* enc, + int start, + char *ps1, + char *ps2, + PyCompilerFlags *flags, + int *errcode, + PyArena *arena); +PyAPI_FUNC(struct _mod *) PyParser_ASTFromFileObject( + FILE *fp, + PyObject *filename, + const char* enc, + int start, + char *ps1, + char *ps2, + PyCompilerFlags *flags, + int *errcode, + PyArena *arena); +#endif + +#ifndef PyParser_SimpleParseString +#define PyParser_SimpleParseString(S, B) \ + PyParser_SimpleParseStringFlags(S, B, 0) +#define PyParser_SimpleParseFile(FP, S, B) \ + PyParser_SimpleParseFileFlags(FP, S, B, 0) +#endif +PyAPI_FUNC(struct _node *) PyParser_SimpleParseStringFlags(const char *, int, + int); +PyAPI_FUNC(struct _node *) PyParser_SimpleParseStringFlagsFilename(const char *, + const char *, + int, int); +PyAPI_FUNC(struct _node *) PyParser_SimpleParseFileFlags(FILE *, const char *, + int, int); + +#ifndef Py_LIMITED_API +PyAPI_FUNC(PyObject *) PyRun_StringFlags(const char *, int, PyObject *, + PyObject *, PyCompilerFlags *); + +PyAPI_FUNC(PyObject *) PyRun_FileExFlags( + FILE *fp, + const char *filename, /* decoded from the filesystem encoding */ + int start, + PyObject *globals, + PyObject *locals, + int closeit, + PyCompilerFlags *flags); +#endif + +#ifdef Py_LIMITED_API +PyAPI_FUNC(PyObject *) Py_CompileString(const char *, const char *, int); +#else +#define Py_CompileString(str, p, s) Py_CompileStringExFlags(str, p, s, NULL, -1) +#define Py_CompileStringFlags(str, p, s, f) Py_CompileStringExFlags(str, p, s, f, -1) +PyAPI_FUNC(PyObject *) Py_CompileStringExFlags( + const char *str, + const char *filename, /* decoded from the filesystem encoding */ + int start, + PyCompilerFlags *flags, + int optimize); +PyAPI_FUNC(PyObject *) Py_CompileStringObject( + const char *str, + PyObject *filename, int start, + PyCompilerFlags *flags, + int optimize); +#endif +PyAPI_FUNC(struct symtable *) Py_SymtableString( + const char *str, + const char *filename, /* decoded from the filesystem encoding */ + int start); +#ifndef Py_LIMITED_API +PyAPI_FUNC(struct symtable *) Py_SymtableStringObject( + const char *str, + PyObject *filename, + int start); +#endif + +PyAPI_FUNC(void) PyErr_Print(void); +PyAPI_FUNC(void) PyErr_PrintEx(int); +PyAPI_FUNC(void) PyErr_Display(PyObject *, PyObject *, PyObject *); + +#ifndef Py_LIMITED_API +/* Use macros for a bunch of old variants */ +#define PyRun_String(str, s, g, l) PyRun_StringFlags(str, s, g, l, NULL) +#define PyRun_AnyFile(fp, name) PyRun_AnyFileExFlags(fp, name, 0, NULL) +#define PyRun_AnyFileEx(fp, name, closeit) \ + PyRun_AnyFileExFlags(fp, name, closeit, NULL) +#define PyRun_AnyFileFlags(fp, name, flags) \ + PyRun_AnyFileExFlags(fp, name, 0, flags) +#define PyRun_SimpleString(s) PyRun_SimpleStringFlags(s, NULL) +#define PyRun_SimpleFile(f, p) PyRun_SimpleFileExFlags(f, p, 0, NULL) +#define PyRun_SimpleFileEx(f, p, c) PyRun_SimpleFileExFlags(f, p, c, NULL) +#define PyRun_InteractiveOne(f, p) PyRun_InteractiveOneFlags(f, p, NULL) +#define PyRun_InteractiveLoop(f, p) PyRun_InteractiveLoopFlags(f, p, NULL) +#define PyRun_File(fp, p, s, g, l) \ + PyRun_FileExFlags(fp, p, s, g, l, 0, NULL) +#define PyRun_FileEx(fp, p, s, g, l, c) \ + PyRun_FileExFlags(fp, p, s, g, l, c, NULL) +#define PyRun_FileFlags(fp, p, s, g, l, flags) \ + PyRun_FileExFlags(fp, p, s, g, l, 0, flags) +#endif + +/* Stuff with no proper home (yet) */ +#ifndef Py_LIMITED_API +PyAPI_FUNC(char *) PyOS_Readline(FILE *, FILE *, const char *); +#endif +PyAPI_DATA(int) (*PyOS_InputHook)(void); +PyAPI_DATA(char) *(*PyOS_ReadlineFunctionPointer)(FILE *, FILE *, const char *); +#ifndef Py_LIMITED_API +PyAPI_DATA(PyThreadState*) _PyOS_ReadlineTState; +#endif + +/* Stack size, in "pointers" (so we get extra safety margins + on 64-bit platforms). On a 32-bit platform, this translates + to a 8k margin. */ +#define PYOS_STACK_MARGIN 2048 + +#if defined(WIN32) && !defined(MS_WIN64) && defined(_MSC_VER) && _MSC_VER >= 1300 +/* Enable stack checking under Microsoft C */ +#define USE_STACKCHECK +#endif + +#ifdef USE_STACKCHECK +/* Check that we aren't overflowing our stack */ +PyAPI_FUNC(int) PyOS_CheckStack(void); +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_PYTHONRUN_H */ diff --git a/android/python35/include/pythread.h b/android/python35/include/pythread.h new file mode 100644 index 000000000..6e9f30337 --- /dev/null +++ b/android/python35/include/pythread.h @@ -0,0 +1,93 @@ + +#ifndef Py_PYTHREAD_H +#define Py_PYTHREAD_H + +typedef void *PyThread_type_lock; +typedef void *PyThread_type_sema; + +#ifdef __cplusplus +extern "C" { +#endif + +/* Return status codes for Python lock acquisition. Chosen for maximum + * backwards compatibility, ie failure -> 0, success -> 1. */ +typedef enum PyLockStatus { + PY_LOCK_FAILURE = 0, + PY_LOCK_ACQUIRED = 1, + PY_LOCK_INTR +} PyLockStatus; + +PyAPI_FUNC(void) PyThread_init_thread(void); +PyAPI_FUNC(long) PyThread_start_new_thread(void (*)(void *), void *); +PyAPI_FUNC(void) PyThread_exit_thread(void); +PyAPI_FUNC(long) PyThread_get_thread_ident(void); + +PyAPI_FUNC(PyThread_type_lock) PyThread_allocate_lock(void); +PyAPI_FUNC(void) PyThread_free_lock(PyThread_type_lock); +PyAPI_FUNC(int) PyThread_acquire_lock(PyThread_type_lock, int); +#define WAIT_LOCK 1 +#define NOWAIT_LOCK 0 + +/* PY_TIMEOUT_T is the integral type used to specify timeouts when waiting + on a lock (see PyThread_acquire_lock_timed() below). + PY_TIMEOUT_MAX is the highest usable value (in microseconds) of that + type, and depends on the system threading API. + + NOTE: this isn't the same value as `_thread.TIMEOUT_MAX`. The _thread + module exposes a higher-level API, with timeouts expressed in seconds + and floating-point numbers allowed. +*/ +#if defined(HAVE_LONG_LONG) +#define PY_TIMEOUT_T PY_LONG_LONG +#define PY_TIMEOUT_MAX PY_LLONG_MAX +#else +#define PY_TIMEOUT_T long +#define PY_TIMEOUT_MAX LONG_MAX +#endif + +/* In the NT API, the timeout is a DWORD and is expressed in milliseconds */ +#if defined (NT_THREADS) +#if (Py_LL(0xFFFFFFFF) * 1000 < PY_TIMEOUT_MAX) +#undef PY_TIMEOUT_MAX +#define PY_TIMEOUT_MAX (Py_LL(0xFFFFFFFF) * 1000) +#endif +#endif + +/* If microseconds == 0, the call is non-blocking: it returns immediately + even when the lock can't be acquired. + If microseconds > 0, the call waits up to the specified duration. + If microseconds < 0, the call waits until success (or abnormal failure) + + microseconds must be less than PY_TIMEOUT_MAX. Behaviour otherwise is + undefined. + + If intr_flag is true and the acquire is interrupted by a signal, then the + call will return PY_LOCK_INTR. The caller may reattempt to acquire the + lock. +*/ +PyAPI_FUNC(PyLockStatus) PyThread_acquire_lock_timed(PyThread_type_lock, + PY_TIMEOUT_T microseconds, + int intr_flag); + +PyAPI_FUNC(void) PyThread_release_lock(PyThread_type_lock); + +PyAPI_FUNC(size_t) PyThread_get_stacksize(void); +PyAPI_FUNC(int) PyThread_set_stacksize(size_t); + +PyAPI_FUNC(PyObject*) PyThread_GetInfo(void); + +/* Thread Local Storage (TLS) API */ +PyAPI_FUNC(int) PyThread_create_key(void); +PyAPI_FUNC(void) PyThread_delete_key(int); +PyAPI_FUNC(int) PyThread_set_key_value(int, void *); +PyAPI_FUNC(void *) PyThread_get_key_value(int); +PyAPI_FUNC(void) PyThread_delete_key_value(int key); + +/* Cleanup after a fork */ +PyAPI_FUNC(void) PyThread_ReInitTLS(void); + +#ifdef __cplusplus +} +#endif + +#endif /* !Py_PYTHREAD_H */ diff --git a/android/python35/include/pytime.h b/android/python35/include/pytime.h new file mode 100644 index 000000000..027c3d803 --- /dev/null +++ b/android/python35/include/pytime.h @@ -0,0 +1,181 @@ +#ifndef Py_LIMITED_API +#ifndef Py_PYTIME_H +#define Py_PYTIME_H + +#include "pyconfig.h" /* include for defines */ +#include "object.h" + +/************************************************************************** +Symbols and macros to supply platform-independent interfaces to time related +functions and constants +**************************************************************************/ +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef PY_INT64_T +/* _PyTime_t: Python timestamp with subsecond precision. It can be used to + store a duration, and so indirectly a date (related to another date, like + UNIX epoch). */ +typedef PY_INT64_T _PyTime_t; +#define _PyTime_MIN PY_LLONG_MIN +#define _PyTime_MAX PY_LLONG_MAX +#else +# error "_PyTime_t need signed 64-bit integer type" +#endif + +typedef enum { + /* Round towards minus infinity (-inf). + For example, used to read a clock. */ + _PyTime_ROUND_FLOOR=0, + /* Round towards infinity (+inf). + For example, used for timeout to wait "at least" N seconds. */ + _PyTime_ROUND_CEILING +} _PyTime_round_t; + +/* Convert a time_t to a PyLong. */ +PyAPI_FUNC(PyObject *) _PyLong_FromTime_t( + time_t sec); + +/* Convert a PyLong to a time_t. */ +PyAPI_FUNC(time_t) _PyLong_AsTime_t( + PyObject *obj); + +/* Convert a number of seconds, int or float, to time_t. */ +PyAPI_FUNC(int) _PyTime_ObjectToTime_t( + PyObject *obj, + time_t *sec, + _PyTime_round_t); + +/* Convert a number of seconds, int or float, to a timeval structure. + usec is in the range [0; 999999] and rounded towards zero. + For example, -1.2 is converted to (-2, 800000). */ +PyAPI_FUNC(int) _PyTime_ObjectToTimeval( + PyObject *obj, + time_t *sec, + long *usec, + _PyTime_round_t); + +/* Convert a number of seconds, int or float, to a timespec structure. + nsec is in the range [0; 999999999] and rounded towards zero. + For example, -1.2 is converted to (-2, 800000000). */ +PyAPI_FUNC(int) _PyTime_ObjectToTimespec( + PyObject *obj, + time_t *sec, + long *nsec, + _PyTime_round_t); + + +/* Create a timestamp from a number of seconds. */ +PyAPI_FUNC(_PyTime_t) _PyTime_FromSeconds(int seconds); + +/* Macro to create a timestamp from a number of seconds, no integer overflow. + Only use the macro for small values, prefer _PyTime_FromSeconds(). */ +#define _PYTIME_FROMSECONDS(seconds) \ + ((_PyTime_t)(seconds) * (1000 * 1000 * 1000)) + +/* Create a timestamp from a number of nanoseconds. */ +PyAPI_FUNC(_PyTime_t) _PyTime_FromNanoseconds(PY_LONG_LONG ns); + +/* Convert a number of seconds (Python float or int) to a timetamp. + Raise an exception and return -1 on error, return 0 on success. */ +PyAPI_FUNC(int) _PyTime_FromSecondsObject(_PyTime_t *t, + PyObject *obj, + _PyTime_round_t round); + +/* Convert a number of milliseconds (Python float or int, 10^-3) to a timetamp. + Raise an exception and return -1 on error, return 0 on success. */ +PyAPI_FUNC(int) _PyTime_FromMillisecondsObject(_PyTime_t *t, + PyObject *obj, + _PyTime_round_t round); + +/* Convert a timestamp to a number of seconds as a C double. */ +PyAPI_FUNC(double) _PyTime_AsSecondsDouble(_PyTime_t t); + +/* Convert timestamp to a number of milliseconds (10^-3 seconds). */ +PyAPI_FUNC(_PyTime_t) _PyTime_AsMilliseconds(_PyTime_t t, + _PyTime_round_t round); + +/* Convert timestamp to a number of microseconds (10^-6 seconds). */ +PyAPI_FUNC(_PyTime_t) _PyTime_AsMicroseconds(_PyTime_t t, + _PyTime_round_t round); + +/* Convert timestamp to a number of nanoseconds (10^-9 seconds) as a Python int + object. */ +PyAPI_FUNC(PyObject *) _PyTime_AsNanosecondsObject(_PyTime_t t); + +/* Convert a timestamp to a timeval structure (microsecond resolution). + tv_usec is always positive. + Raise an exception and return -1 if the conversion overflowed, + return 0 on success. */ +PyAPI_FUNC(int) _PyTime_AsTimeval(_PyTime_t t, + struct timeval *tv, + _PyTime_round_t round); + +/* Similar to _PyTime_AsTimeval(), but don't raise an exception on error. */ +PyAPI_FUNC(int) _PyTime_AsTimeval_noraise(_PyTime_t t, + struct timeval *tv, + _PyTime_round_t round); + +#if defined(HAVE_CLOCK_GETTIME) || defined(HAVE_KQUEUE) +/* Convert a timestamp to a timespec structure (nanosecond resolution). + tv_nsec is always positive. + Raise an exception and return -1 on error, return 0 on success. */ +PyAPI_FUNC(int) _PyTime_AsTimespec(_PyTime_t t, struct timespec *ts); +#endif + +/* Get the current time from the system clock. + + The function cannot fail. _PyTime_Init() ensures that the system clock + works. */ +PyAPI_FUNC(_PyTime_t) _PyTime_GetSystemClock(void); + +/* Get the time of a monotonic clock, i.e. a clock that cannot go backwards. + The clock is not affected by system clock updates. The reference point of + the returned value is undefined, so that only the difference between the + results of consecutive calls is valid. + + The function cannot fail. _PyTime_Init() ensures that a monotonic clock + is available and works. */ +PyAPI_FUNC(_PyTime_t) _PyTime_GetMonotonicClock(void); + + +/* Structure used by time.get_clock_info() */ +typedef struct { + const char *implementation; + int monotonic; + int adjustable; + double resolution; +} _Py_clock_info_t; + +/* Get the current time from the system clock. + * Fill clock information if info is not NULL. + * Raise an exception and return -1 on error, return 0 on success. + */ +PyAPI_FUNC(int) _PyTime_GetSystemClockWithInfo( + _PyTime_t *t, + _Py_clock_info_t *info); + +/* Get the time of a monotonic clock, i.e. a clock that cannot go backwards. + The clock is not affected by system clock updates. The reference point of + the returned value is undefined, so that only the difference between the + results of consecutive calls is valid. + + Fill info (if set) with information of the function used to get the time. + + Return 0 on success, raise an exception and return -1 on error. */ +PyAPI_FUNC(int) _PyTime_GetMonotonicClockWithInfo( + _PyTime_t *t, + _Py_clock_info_t *info); + + +/* Initialize time. + Return 0 on success, raise an exception and return -1 on error. */ +PyAPI_FUNC(int) _PyTime_Init(void); + +#ifdef __cplusplus +} +#endif + +#endif /* Py_PYTIME_H */ +#endif /* Py_LIMITED_API */ diff --git a/android/python35/include/rangeobject.h b/android/python35/include/rangeobject.h new file mode 100644 index 000000000..7e4dc2889 --- /dev/null +++ b/android/python35/include/rangeobject.h @@ -0,0 +1,27 @@ + +/* Range object interface */ + +#ifndef Py_RANGEOBJECT_H +#define Py_RANGEOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +/* +A range object represents an integer range. This is an immutable object; +a range cannot change its value after creation. + +Range objects behave like the corresponding tuple objects except that +they are represented by a start, stop, and step datamembers. +*/ + +PyAPI_DATA(PyTypeObject) PyRange_Type; +PyAPI_DATA(PyTypeObject) PyRangeIter_Type; +PyAPI_DATA(PyTypeObject) PyLongRangeIter_Type; + +#define PyRange_Check(op) (Py_TYPE(op) == &PyRange_Type) + +#ifdef __cplusplus +} +#endif +#endif /* !Py_RANGEOBJECT_H */ diff --git a/android/python35/include/setobject.h b/android/python35/include/setobject.h new file mode 100644 index 000000000..f17bc1b03 --- /dev/null +++ b/android/python35/include/setobject.h @@ -0,0 +1,107 @@ +/* Set object interface */ + +#ifndef Py_SETOBJECT_H +#define Py_SETOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_LIMITED_API + +/* There are three kinds of entries in the table: + +1. Unused: key == NULL +2. Active: key != NULL and key != dummy +3. Dummy: key == dummy + +The hash field of Unused slots have no meaning. +The hash field of Dummny slots are set to -1 +meaning that dummy entries can be detected by +either entry->key==dummy or by entry->hash==-1. +*/ + +#define PySet_MINSIZE 8 + +typedef struct { + PyObject *key; + Py_hash_t hash; /* Cached hash code of the key */ +} setentry; + +/* The SetObject data structure is shared by set and frozenset objects. + +Invariant for sets: + - hash is -1 + +Invariants for frozensets: + - data is immutable. + - hash is the hash of the frozenset or -1 if not computed yet. + +*/ + +typedef struct { + PyObject_HEAD + + Py_ssize_t fill; /* Number active and dummy entries*/ + Py_ssize_t used; /* Number active entries */ + + /* The table contains mask + 1 slots, and that's a power of 2. + * We store the mask instead of the size because the mask is more + * frequently needed. + */ + Py_ssize_t mask; + + /* The table points to a fixed-size smalltable for small tables + * or to additional malloc'ed memory for bigger tables. + * The table pointer is never NULL which saves us from repeated + * runtime null-tests. + */ + setentry *table; + Py_hash_t hash; /* Only used by frozenset objects */ + Py_ssize_t finger; /* Search finger for pop() */ + + setentry smalltable[PySet_MINSIZE]; + PyObject *weakreflist; /* List of weak references */ +} PySetObject; + +#define PySet_GET_SIZE(so) (((PySetObject *)(so))->used) + +PyAPI_DATA(PyObject *) _PySet_Dummy; + +PyAPI_FUNC(int) _PySet_NextEntry(PyObject *set, Py_ssize_t *pos, PyObject **key, Py_hash_t *hash); +PyAPI_FUNC(int) _PySet_Update(PyObject *set, PyObject *iterable); +PyAPI_FUNC(int) PySet_ClearFreeList(void); + +#endif /* Section excluded by Py_LIMITED_API */ + +PyAPI_DATA(PyTypeObject) PySet_Type; +PyAPI_DATA(PyTypeObject) PyFrozenSet_Type; +PyAPI_DATA(PyTypeObject) PySetIter_Type; + +PyAPI_FUNC(PyObject *) PySet_New(PyObject *); +PyAPI_FUNC(PyObject *) PyFrozenSet_New(PyObject *); + +PyAPI_FUNC(int) PySet_Add(PyObject *set, PyObject *key); +PyAPI_FUNC(int) PySet_Clear(PyObject *set); +PyAPI_FUNC(int) PySet_Contains(PyObject *anyset, PyObject *key); +PyAPI_FUNC(int) PySet_Discard(PyObject *set, PyObject *key); +PyAPI_FUNC(PyObject *) PySet_Pop(PyObject *set); +PyAPI_FUNC(Py_ssize_t) PySet_Size(PyObject *anyset); + +#define PyFrozenSet_CheckExact(ob) (Py_TYPE(ob) == &PyFrozenSet_Type) +#define PyAnySet_CheckExact(ob) \ + (Py_TYPE(ob) == &PySet_Type || Py_TYPE(ob) == &PyFrozenSet_Type) +#define PyAnySet_Check(ob) \ + (Py_TYPE(ob) == &PySet_Type || Py_TYPE(ob) == &PyFrozenSet_Type || \ + PyType_IsSubtype(Py_TYPE(ob), &PySet_Type) || \ + PyType_IsSubtype(Py_TYPE(ob), &PyFrozenSet_Type)) +#define PySet_Check(ob) \ + (Py_TYPE(ob) == &PySet_Type || \ + PyType_IsSubtype(Py_TYPE(ob), &PySet_Type)) +#define PyFrozenSet_Check(ob) \ + (Py_TYPE(ob) == &PyFrozenSet_Type || \ + PyType_IsSubtype(Py_TYPE(ob), &PyFrozenSet_Type)) + +#ifdef __cplusplus +} +#endif +#endif /* !Py_SETOBJECT_H */ diff --git a/android/python35/include/sliceobject.h b/android/python35/include/sliceobject.h new file mode 100644 index 000000000..26370e017 --- /dev/null +++ b/android/python35/include/sliceobject.h @@ -0,0 +1,50 @@ +#ifndef Py_SLICEOBJECT_H +#define Py_SLICEOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +/* The unique ellipsis object "..." */ + +PyAPI_DATA(PyObject) _Py_EllipsisObject; /* Don't use this directly */ + +#define Py_Ellipsis (&_Py_EllipsisObject) + +/* Slice object interface */ + +/* + +A slice object containing start, stop, and step data members (the +names are from range). After much talk with Guido, it was decided to +let these be any arbitrary python type. Py_None stands for omitted values. +*/ +#ifndef Py_LIMITED_API +typedef struct { + PyObject_HEAD + PyObject *start, *stop, *step; /* not NULL */ +} PySliceObject; +#endif + +PyAPI_DATA(PyTypeObject) PySlice_Type; +PyAPI_DATA(PyTypeObject) PyEllipsis_Type; + +#define PySlice_Check(op) (Py_TYPE(op) == &PySlice_Type) + +PyAPI_FUNC(PyObject *) PySlice_New(PyObject* start, PyObject* stop, + PyObject* step); +#ifndef Py_LIMITED_API +PyAPI_FUNC(PyObject *) _PySlice_FromIndices(Py_ssize_t start, Py_ssize_t stop); +PyAPI_FUNC(int) _PySlice_GetLongIndices(PySliceObject *self, PyObject *length, + PyObject **start_ptr, PyObject **stop_ptr, + PyObject **step_ptr); +#endif +PyAPI_FUNC(int) PySlice_GetIndices(PyObject *r, Py_ssize_t length, + Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step); +PyAPI_FUNC(int) PySlice_GetIndicesEx(PyObject *r, Py_ssize_t length, + Py_ssize_t *start, Py_ssize_t *stop, + Py_ssize_t *step, Py_ssize_t *slicelength); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_SLICEOBJECT_H */ diff --git a/android/python35/include/structmember.h b/android/python35/include/structmember.h new file mode 100644 index 000000000..948f69030 --- /dev/null +++ b/android/python35/include/structmember.h @@ -0,0 +1,76 @@ +#ifndef Py_STRUCTMEMBER_H +#define Py_STRUCTMEMBER_H +#ifdef __cplusplus +extern "C" { +#endif + + +/* Interface to map C struct members to Python object attributes */ + +#include /* For offsetof */ + +/* An array of PyMemberDef structures defines the name, type and offset + of selected members of a C structure. These can be read by + PyMember_GetOne() and set by PyMember_SetOne() (except if their READONLY + flag is set). The array must be terminated with an entry whose name + pointer is NULL. */ + +typedef struct PyMemberDef { + char *name; + int type; + Py_ssize_t offset; + int flags; + char *doc; +} PyMemberDef; + +/* Types */ +#define T_SHORT 0 +#define T_INT 1 +#define T_LONG 2 +#define T_FLOAT 3 +#define T_DOUBLE 4 +#define T_STRING 5 +#define T_OBJECT 6 +/* XXX the ordering here is weird for binary compatibility */ +#define T_CHAR 7 /* 1-character string */ +#define T_BYTE 8 /* 8-bit signed int */ +/* unsigned variants: */ +#define T_UBYTE 9 +#define T_USHORT 10 +#define T_UINT 11 +#define T_ULONG 12 + +/* Added by Jack: strings contained in the structure */ +#define T_STRING_INPLACE 13 + +/* Added by Lillo: bools contained in the structure (assumed char) */ +#define T_BOOL 14 + +#define T_OBJECT_EX 16 /* Like T_OBJECT, but raises AttributeError + when the value is NULL, instead of + converting to None. */ +#ifdef HAVE_LONG_LONG +#define T_LONGLONG 17 +#define T_ULONGLONG 18 +#endif /* HAVE_LONG_LONG */ + +#define T_PYSSIZET 19 /* Py_ssize_t */ +#define T_NONE 20 /* Value is always None */ + + +/* Flags */ +#define READONLY 1 +#define READ_RESTRICTED 2 +#define PY_WRITE_RESTRICTED 4 +#define RESTRICTED (READ_RESTRICTED | PY_WRITE_RESTRICTED) + + +/* Current API, use this */ +PyAPI_FUNC(PyObject *) PyMember_GetOne(const char *, struct PyMemberDef *); +PyAPI_FUNC(int) PyMember_SetOne(char *, struct PyMemberDef *, PyObject *); + + +#ifdef __cplusplus +} +#endif +#endif /* !Py_STRUCTMEMBER_H */ diff --git a/android/python35/include/structseq.h b/android/python35/include/structseq.h new file mode 100644 index 000000000..af227164c --- /dev/null +++ b/android/python35/include/structseq.h @@ -0,0 +1,49 @@ + +/* Named tuple object interface */ + +#ifndef Py_STRUCTSEQ_H +#define Py_STRUCTSEQ_H +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct PyStructSequence_Field { + char *name; + char *doc; +} PyStructSequence_Field; + +typedef struct PyStructSequence_Desc { + char *name; + char *doc; + struct PyStructSequence_Field *fields; + int n_in_sequence; +} PyStructSequence_Desc; + +extern char* PyStructSequence_UnnamedField; + +#ifndef Py_LIMITED_API +PyAPI_FUNC(void) PyStructSequence_InitType(PyTypeObject *type, + PyStructSequence_Desc *desc); +PyAPI_FUNC(int) PyStructSequence_InitType2(PyTypeObject *type, + PyStructSequence_Desc *desc); +#endif +PyAPI_FUNC(PyTypeObject*) PyStructSequence_NewType(PyStructSequence_Desc *desc); + +PyAPI_FUNC(PyObject *) PyStructSequence_New(PyTypeObject* type); + +#ifndef Py_LIMITED_API +typedef PyTupleObject PyStructSequence; + +/* Macro, *only* to be used to fill in brand new objects */ +#define PyStructSequence_SET_ITEM(op, i, v) PyTuple_SET_ITEM(op, i, v) + +#define PyStructSequence_GET_ITEM(op, i) PyTuple_GET_ITEM(op, i) +#endif + +PyAPI_FUNC(void) PyStructSequence_SetItem(PyObject*, Py_ssize_t, PyObject*); +PyAPI_FUNC(PyObject*) PyStructSequence_GetItem(PyObject*, Py_ssize_t); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_STRUCTSEQ_H */ diff --git a/android/python35/include/symtable.h b/android/python35/include/symtable.h new file mode 100644 index 000000000..1409cd91c --- /dev/null +++ b/android/python35/include/symtable.h @@ -0,0 +1,117 @@ +#ifndef Py_LIMITED_API +#ifndef Py_SYMTABLE_H +#define Py_SYMTABLE_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* XXX(ncoghlan): This is a weird mix of public names and interpreter internal + * names. + */ + +typedef enum _block_type { FunctionBlock, ClassBlock, ModuleBlock } + _Py_block_ty; + +struct _symtable_entry; + +struct symtable { + PyObject *st_filename; /* name of file being compiled, + decoded from the filesystem encoding */ + struct _symtable_entry *st_cur; /* current symbol table entry */ + struct _symtable_entry *st_top; /* symbol table entry for module */ + PyObject *st_blocks; /* dict: map AST node addresses + * to symbol table entries */ + PyObject *st_stack; /* list: stack of namespace info */ + PyObject *st_global; /* borrowed ref to st_top->ste_symbols */ + int st_nblocks; /* number of blocks used. kept for + consistency with the corresponding + compiler structure */ + PyObject *st_private; /* name of current class or NULL */ + PyFutureFeatures *st_future; /* module's future features that affect + the symbol table */ + int recursion_depth; /* current recursion depth */ + int recursion_limit; /* recursion limit */ +}; + +typedef struct _symtable_entry { + PyObject_HEAD + PyObject *ste_id; /* int: key in ste_table->st_blocks */ + PyObject *ste_symbols; /* dict: variable names to flags */ + PyObject *ste_name; /* string: name of current block */ + PyObject *ste_varnames; /* list of function parameters */ + PyObject *ste_children; /* list of child blocks */ + PyObject *ste_directives;/* locations of global and nonlocal statements */ + _Py_block_ty ste_type; /* module, class, or function */ + int ste_nested; /* true if block is nested */ + unsigned ste_free : 1; /* true if block has free variables */ + unsigned ste_child_free : 1; /* true if a child block has free vars, + including free refs to globals */ + unsigned ste_generator : 1; /* true if namespace is a generator */ + unsigned ste_varargs : 1; /* true if block has varargs */ + unsigned ste_varkeywords : 1; /* true if block has varkeywords */ + unsigned ste_returns_value : 1; /* true if namespace uses return with + an argument */ + unsigned ste_needs_class_closure : 1; /* for class scopes, true if a + closure over __class__ + should be created */ + int ste_lineno; /* first line of block */ + int ste_col_offset; /* offset of first line of block */ + int ste_opt_lineno; /* lineno of last exec or import * */ + int ste_opt_col_offset; /* offset of last exec or import * */ + int ste_tmpname; /* counter for listcomp temp vars */ + struct symtable *ste_table; +} PySTEntryObject; + +PyAPI_DATA(PyTypeObject) PySTEntry_Type; + +#define PySTEntry_Check(op) (Py_TYPE(op) == &PySTEntry_Type) + +PyAPI_FUNC(int) PyST_GetScope(PySTEntryObject *, PyObject *); + +PyAPI_FUNC(struct symtable *) PySymtable_Build( + mod_ty mod, + const char *filename, /* decoded from the filesystem encoding */ + PyFutureFeatures *future); +PyAPI_FUNC(struct symtable *) PySymtable_BuildObject( + mod_ty mod, + PyObject *filename, + PyFutureFeatures *future); +PyAPI_FUNC(PySTEntryObject *) PySymtable_Lookup(struct symtable *, void *); + +PyAPI_FUNC(void) PySymtable_Free(struct symtable *); + +/* Flags for def-use information */ + +#define DEF_GLOBAL 1 /* global stmt */ +#define DEF_LOCAL 2 /* assignment in code block */ +#define DEF_PARAM 2<<1 /* formal parameter */ +#define DEF_NONLOCAL 2<<2 /* nonlocal stmt */ +#define USE 2<<3 /* name is used */ +#define DEF_FREE 2<<4 /* name used but not defined in nested block */ +#define DEF_FREE_CLASS 2<<5 /* free variable from class's method */ +#define DEF_IMPORT 2<<6 /* assignment occurred via import */ + +#define DEF_BOUND (DEF_LOCAL | DEF_PARAM | DEF_IMPORT) + +/* GLOBAL_EXPLICIT and GLOBAL_IMPLICIT are used internally by the symbol + table. GLOBAL is returned from PyST_GetScope() for either of them. + It is stored in ste_symbols at bits 12-15. +*/ +#define SCOPE_OFFSET 11 +#define SCOPE_MASK (DEF_GLOBAL | DEF_LOCAL | DEF_PARAM | DEF_NONLOCAL) + +#define LOCAL 1 +#define GLOBAL_EXPLICIT 2 +#define GLOBAL_IMPLICIT 3 +#define FREE 4 +#define CELL 5 + +#define GENERATOR 1 +#define GENERATOR_EXPRESSION 2 + +#ifdef __cplusplus +} +#endif +#endif /* !Py_SYMTABLE_H */ +#endif /* Py_LIMITED_API */ diff --git a/android/python35/include/sysmodule.h b/android/python35/include/sysmodule.h new file mode 100644 index 000000000..cde10ac4c --- /dev/null +++ b/android/python35/include/sysmodule.h @@ -0,0 +1,43 @@ + +/* System module interface */ + +#ifndef Py_SYSMODULE_H +#define Py_SYSMODULE_H +#ifdef __cplusplus +extern "C" { +#endif + +PyAPI_FUNC(PyObject *) PySys_GetObject(const char *); +#ifndef Py_LIMITED_API +PyAPI_FUNC(PyObject *) _PySys_GetObjectId(_Py_Identifier *key); +#endif +PyAPI_FUNC(int) PySys_SetObject(const char *, PyObject *); +PyAPI_FUNC(int) _PySys_SetObjectId(_Py_Identifier *key, PyObject *); + +PyAPI_FUNC(void) PySys_SetArgv(int, wchar_t **); +PyAPI_FUNC(void) PySys_SetArgvEx(int, wchar_t **, int); +PyAPI_FUNC(void) PySys_SetPath(const wchar_t *); + +PyAPI_FUNC(void) PySys_WriteStdout(const char *format, ...) + Py_GCC_ATTRIBUTE((format(printf, 1, 2))); +PyAPI_FUNC(void) PySys_WriteStderr(const char *format, ...) + Py_GCC_ATTRIBUTE((format(printf, 1, 2))); +PyAPI_FUNC(void) PySys_FormatStdout(const char *format, ...); +PyAPI_FUNC(void) PySys_FormatStderr(const char *format, ...); + +PyAPI_FUNC(void) PySys_ResetWarnOptions(void); +PyAPI_FUNC(void) PySys_AddWarnOption(const wchar_t *); +PyAPI_FUNC(void) PySys_AddWarnOptionUnicode(PyObject *); +PyAPI_FUNC(int) PySys_HasWarnOptions(void); + +PyAPI_FUNC(void) PySys_AddXOption(const wchar_t *); +PyAPI_FUNC(PyObject *) PySys_GetXOptions(void); + +#ifndef Py_LIMITED_API +PyAPI_FUNC(size_t) _PySys_GetSizeOf(PyObject *); +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_SYSMODULE_H */ diff --git a/android/python35/include/token.h b/android/python35/include/token.h new file mode 100644 index 000000000..595afa015 --- /dev/null +++ b/android/python35/include/token.h @@ -0,0 +1,90 @@ + +/* Token types */ +#ifndef Py_LIMITED_API +#ifndef Py_TOKEN_H +#define Py_TOKEN_H +#ifdef __cplusplus +extern "C" { +#endif + +#undef TILDE /* Prevent clash of our definition with system macro. Ex AIX, ioctl.h */ + +#define ENDMARKER 0 +#define NAME 1 +#define NUMBER 2 +#define STRING 3 +#define NEWLINE 4 +#define INDENT 5 +#define DEDENT 6 +#define LPAR 7 +#define RPAR 8 +#define LSQB 9 +#define RSQB 10 +#define COLON 11 +#define COMMA 12 +#define SEMI 13 +#define PLUS 14 +#define MINUS 15 +#define STAR 16 +#define SLASH 17 +#define VBAR 18 +#define AMPER 19 +#define LESS 20 +#define GREATER 21 +#define EQUAL 22 +#define DOT 23 +#define PERCENT 24 +#define LBRACE 25 +#define RBRACE 26 +#define EQEQUAL 27 +#define NOTEQUAL 28 +#define LESSEQUAL 29 +#define GREATEREQUAL 30 +#define TILDE 31 +#define CIRCUMFLEX 32 +#define LEFTSHIFT 33 +#define RIGHTSHIFT 34 +#define DOUBLESTAR 35 +#define PLUSEQUAL 36 +#define MINEQUAL 37 +#define STAREQUAL 38 +#define SLASHEQUAL 39 +#define PERCENTEQUAL 40 +#define AMPEREQUAL 41 +#define VBAREQUAL 42 +#define CIRCUMFLEXEQUAL 43 +#define LEFTSHIFTEQUAL 44 +#define RIGHTSHIFTEQUAL 45 +#define DOUBLESTAREQUAL 46 +#define DOUBLESLASH 47 +#define DOUBLESLASHEQUAL 48 +#define AT 49 +#define ATEQUAL 50 +#define RARROW 51 +#define ELLIPSIS 52 +/* Don't forget to update the table _PyParser_TokenNames in tokenizer.c! */ +#define OP 53 +#define AWAIT 54 +#define ASYNC 55 +#define ERRORTOKEN 56 +#define N_TOKENS 57 + +/* Special definitions for cooperation with parser */ + +#define NT_OFFSET 256 + +#define ISTERMINAL(x) ((x) < NT_OFFSET) +#define ISNONTERMINAL(x) ((x) >= NT_OFFSET) +#define ISEOF(x) ((x) == ENDMARKER) + + +PyAPI_DATA(const char *) _PyParser_TokenNames[]; /* Token names */ +PyAPI_FUNC(int) PyToken_OneChar(int); +PyAPI_FUNC(int) PyToken_TwoChars(int, int); +PyAPI_FUNC(int) PyToken_ThreeChars(int, int, int); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_TOKEN_H */ +#endif /* Py_LIMITED_API */ diff --git a/android/python35/include/traceback.h b/android/python35/include/traceback.h new file mode 100644 index 000000000..891000c8f --- /dev/null +++ b/android/python35/include/traceback.h @@ -0,0 +1,73 @@ + +#ifndef Py_TRACEBACK_H +#define Py_TRACEBACK_H +#ifdef __cplusplus +extern "C" { +#endif + +#include "pystate.h" + +struct _frame; + +/* Traceback interface */ +#ifndef Py_LIMITED_API +typedef struct _traceback { + PyObject_HEAD + struct _traceback *tb_next; + struct _frame *tb_frame; + int tb_lasti; + int tb_lineno; +} PyTracebackObject; +#endif + +PyAPI_FUNC(int) PyTraceBack_Here(struct _frame *); +PyAPI_FUNC(int) PyTraceBack_Print(PyObject *, PyObject *); +#ifndef Py_LIMITED_API +PyAPI_FUNC(int) _Py_DisplaySourceLine(PyObject *, PyObject *, int, int); +PyAPI_FUNC(void) _PyTraceback_Add(const char *, const char *, int); +#endif + +/* Reveal traceback type so we can typecheck traceback objects */ +PyAPI_DATA(PyTypeObject) PyTraceBack_Type; +#define PyTraceBack_Check(v) (Py_TYPE(v) == &PyTraceBack_Type) + +/* Write the Python traceback into the file 'fd'. For example: + + Traceback (most recent call first): + File "xxx", line xxx in + File "xxx", line xxx in + ... + File "xxx", line xxx in + + This function is written for debug purpose only, to dump the traceback in + the worst case: after a segmentation fault, at fatal error, etc. That's why, + it is very limited. Strings are truncated to 100 characters and encoded to + ASCII with backslashreplace. It doesn't write the source code, only the + function name, filename and line number of each frame. Write only the first + 100 frames: if the traceback is truncated, write the line " ...". + + This function is signal safe. */ + +PyAPI_DATA(void) _Py_DumpTraceback( + int fd, + PyThreadState *tstate); + +/* Write the traceback of all threads into the file 'fd'. current_thread can be + NULL. Return NULL on success, or an error message on error. + + This function is written for debug purpose only. It calls + _Py_DumpTraceback() for each thread, and so has the same limitations. It + only write the traceback of the first 100 threads: write "..." if there are + more threads. + + This function is signal safe. */ + +PyAPI_DATA(const char*) _Py_DumpTracebackThreads( + int fd, PyInterpreterState *interp, + PyThreadState *current_thread); + + +#ifdef __cplusplus +} +#endif +#endif /* !Py_TRACEBACK_H */ diff --git a/android/python35/include/tupleobject.h b/android/python35/include/tupleobject.h new file mode 100644 index 000000000..c273ce7dc --- /dev/null +++ b/android/python35/include/tupleobject.h @@ -0,0 +1,73 @@ + +/* Tuple object interface */ + +#ifndef Py_TUPLEOBJECT_H +#define Py_TUPLEOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + +/* +Another generally useful object type is a tuple of object pointers. +For Python, this is an immutable type. C code can change the tuple items +(but not their number), and even use tuples are general-purpose arrays of +object references, but in general only brand new tuples should be mutated, +not ones that might already have been exposed to Python code. + +*** WARNING *** PyTuple_SetItem does not increment the new item's reference +count, but does decrement the reference count of the item it replaces, +if not nil. It does *decrement* the reference count if it is *not* +inserted in the tuple. Similarly, PyTuple_GetItem does not increment the +returned item's reference count. +*/ + +#ifndef Py_LIMITED_API +typedef struct { + PyObject_VAR_HEAD + PyObject *ob_item[1]; + + /* ob_item contains space for 'ob_size' elements. + * Items must normally not be NULL, except during construction when + * the tuple is not yet visible outside the function that builds it. + */ +} PyTupleObject; +#endif + +PyAPI_DATA(PyTypeObject) PyTuple_Type; +PyAPI_DATA(PyTypeObject) PyTupleIter_Type; + +#define PyTuple_Check(op) \ + PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_TUPLE_SUBCLASS) +#define PyTuple_CheckExact(op) (Py_TYPE(op) == &PyTuple_Type) + +PyAPI_FUNC(PyObject *) PyTuple_New(Py_ssize_t size); +PyAPI_FUNC(Py_ssize_t) PyTuple_Size(PyObject *); +PyAPI_FUNC(PyObject *) PyTuple_GetItem(PyObject *, Py_ssize_t); +PyAPI_FUNC(int) PyTuple_SetItem(PyObject *, Py_ssize_t, PyObject *); +PyAPI_FUNC(PyObject *) PyTuple_GetSlice(PyObject *, Py_ssize_t, Py_ssize_t); +#ifndef Py_LIMITED_API +PyAPI_FUNC(int) _PyTuple_Resize(PyObject **, Py_ssize_t); +#endif +PyAPI_FUNC(PyObject *) PyTuple_Pack(Py_ssize_t, ...); +#ifndef Py_LIMITED_API +PyAPI_FUNC(void) _PyTuple_MaybeUntrack(PyObject *); +#endif + +/* Macro, trading safety for speed */ +#ifndef Py_LIMITED_API +#define PyTuple_GET_ITEM(op, i) (((PyTupleObject *)(op))->ob_item[i]) +#define PyTuple_GET_SIZE(op) Py_SIZE(op) + +/* Macro, *only* to be used to fill in brand new tuples */ +#define PyTuple_SET_ITEM(op, i, v) (((PyTupleObject *)(op))->ob_item[i] = v) +#endif + +PyAPI_FUNC(int) PyTuple_ClearFreeList(void); +#ifndef Py_LIMITED_API +PyAPI_FUNC(void) _PyTuple_DebugMallocStats(FILE *out); +#endif /* Py_LIMITED_API */ + +#ifdef __cplusplus +} +#endif +#endif /* !Py_TUPLEOBJECT_H */ diff --git a/android/python35/include/typeslots.h b/android/python35/include/typeslots.h new file mode 100644 index 000000000..0ce6a377d --- /dev/null +++ b/android/python35/include/typeslots.h @@ -0,0 +1,85 @@ +/* Do not renumber the file; these numbers are part of the stable ABI. */ +/* Disabled, see #10181 */ +#undef Py_bf_getbuffer +#undef Py_bf_releasebuffer +#define Py_mp_ass_subscript 3 +#define Py_mp_length 4 +#define Py_mp_subscript 5 +#define Py_nb_absolute 6 +#define Py_nb_add 7 +#define Py_nb_and 8 +#define Py_nb_bool 9 +#define Py_nb_divmod 10 +#define Py_nb_float 11 +#define Py_nb_floor_divide 12 +#define Py_nb_index 13 +#define Py_nb_inplace_add 14 +#define Py_nb_inplace_and 15 +#define Py_nb_inplace_floor_divide 16 +#define Py_nb_inplace_lshift 17 +#define Py_nb_inplace_multiply 18 +#define Py_nb_inplace_or 19 +#define Py_nb_inplace_power 20 +#define Py_nb_inplace_remainder 21 +#define Py_nb_inplace_rshift 22 +#define Py_nb_inplace_subtract 23 +#define Py_nb_inplace_true_divide 24 +#define Py_nb_inplace_xor 25 +#define Py_nb_int 26 +#define Py_nb_invert 27 +#define Py_nb_lshift 28 +#define Py_nb_multiply 29 +#define Py_nb_negative 30 +#define Py_nb_or 31 +#define Py_nb_positive 32 +#define Py_nb_power 33 +#define Py_nb_remainder 34 +#define Py_nb_rshift 35 +#define Py_nb_subtract 36 +#define Py_nb_true_divide 37 +#define Py_nb_xor 38 +#define Py_sq_ass_item 39 +#define Py_sq_concat 40 +#define Py_sq_contains 41 +#define Py_sq_inplace_concat 42 +#define Py_sq_inplace_repeat 43 +#define Py_sq_item 44 +#define Py_sq_length 45 +#define Py_sq_repeat 46 +#define Py_tp_alloc 47 +#define Py_tp_base 48 +#define Py_tp_bases 49 +#define Py_tp_call 50 +#define Py_tp_clear 51 +#define Py_tp_dealloc 52 +#define Py_tp_del 53 +#define Py_tp_descr_get 54 +#define Py_tp_descr_set 55 +#define Py_tp_doc 56 +#define Py_tp_getattr 57 +#define Py_tp_getattro 58 +#define Py_tp_hash 59 +#define Py_tp_init 60 +#define Py_tp_is_gc 61 +#define Py_tp_iter 62 +#define Py_tp_iternext 63 +#define Py_tp_methods 64 +#define Py_tp_new 65 +#define Py_tp_repr 66 +#define Py_tp_richcompare 67 +#define Py_tp_setattr 68 +#define Py_tp_setattro 69 +#define Py_tp_str 70 +#define Py_tp_traverse 71 +#define Py_tp_members 72 +#define Py_tp_getset 73 +#define Py_tp_free 74 +#define Py_nb_matrix_multiply 75 +#define Py_nb_inplace_matrix_multiply 76 +#define Py_am_await 77 +#define Py_am_aiter 78 +#define Py_am_anext 79 +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000 +/* New in 3.5 */ +#define Py_tp_finalize 80 +#endif diff --git a/android/python35/include/ucnhash.h b/android/python35/include/ucnhash.h new file mode 100644 index 000000000..45362e997 --- /dev/null +++ b/android/python35/include/ucnhash.h @@ -0,0 +1,36 @@ +/* Unicode name database interface */ +#ifndef Py_LIMITED_API +#ifndef Py_UCNHASH_H +#define Py_UCNHASH_H +#ifdef __cplusplus +extern "C" { +#endif + +/* revised ucnhash CAPI interface (exported through a "wrapper") */ + +#define PyUnicodeData_CAPSULE_NAME "unicodedata.ucnhash_CAPI" + +typedef struct { + + /* Size of this struct */ + int size; + + /* Get name for a given character code. Returns non-zero if + success, zero if not. Does not set Python exceptions. + If self is NULL, data come from the default version of the database. + If it is not NULL, it should be a unicodedata.ucd_X_Y_Z object */ + int (*getname)(PyObject *self, Py_UCS4 code, char* buffer, int buflen, + int with_alias_and_seq); + + /* Get character code for a given name. Same error handling + as for getname. */ + int (*getcode)(PyObject *self, const char* name, int namelen, Py_UCS4* code, + int with_named_seq); + +} _PyUnicode_Name_CAPI; + +#ifdef __cplusplus +} +#endif +#endif /* !Py_UCNHASH_H */ +#endif /* !Py_LIMITED_API */ diff --git a/android/python35/include/unicodeobject.h b/android/python35/include/unicodeobject.h new file mode 100644 index 000000000..4ba632803 --- /dev/null +++ b/android/python35/include/unicodeobject.h @@ -0,0 +1,2267 @@ +#ifndef Py_UNICODEOBJECT_H +#define Py_UNICODEOBJECT_H + +#include + +/* + +Unicode implementation based on original code by Fredrik Lundh, +modified by Marc-Andre Lemburg (mal@lemburg.com) according to the +Unicode Integration Proposal. (See +http://www.egenix.com/files/python/unicode-proposal.txt). + +Copyright (c) Corporation for National Research Initiatives. + + + Original header: + -------------------------------------------------------------------- + + * Yet another Unicode string type for Python. This type supports the + * 16-bit Basic Multilingual Plane (BMP) only. + * + * Written by Fredrik Lundh, January 1999. + * + * Copyright (c) 1999 by Secret Labs AB. + * Copyright (c) 1999 by Fredrik Lundh. + * + * fredrik@pythonware.com + * http://www.pythonware.com + * + * -------------------------------------------------------------------- + * This Unicode String Type is + * + * Copyright (c) 1999 by Secret Labs AB + * Copyright (c) 1999 by Fredrik Lundh + * + * By obtaining, using, and/or copying this software and/or its + * associated documentation, you agree that you have read, understood, + * and will comply with the following terms and conditions: + * + * Permission to use, copy, modify, and distribute this software and its + * associated documentation for any purpose and without fee is hereby + * granted, provided that the above copyright notice appears in all + * copies, and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of Secret Labs + * AB or the author not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. + * + * SECRET LABS AB AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO + * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS. IN NO EVENT SHALL SECRET LABS AB OR THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * -------------------------------------------------------------------- */ + +#include + +/* === Internal API ======================================================= */ + +/* --- Internal Unicode Format -------------------------------------------- */ + +/* Python 3.x requires unicode */ +#define Py_USING_UNICODE + +#ifndef SIZEOF_WCHAR_T +#error Must define SIZEOF_WCHAR_T +#endif + +#define Py_UNICODE_SIZE SIZEOF_WCHAR_T + +/* If wchar_t can be used for UCS-4 storage, set Py_UNICODE_WIDE. + Otherwise, Unicode strings are stored as UCS-2 (with limited support + for UTF-16) */ + +#if Py_UNICODE_SIZE >= 4 +#define Py_UNICODE_WIDE +#endif + +/* Set these flags if the platform has "wchar.h" and the + wchar_t type is a 16-bit unsigned type */ +/* #define HAVE_WCHAR_H */ +/* #define HAVE_USABLE_WCHAR_T */ + +/* Py_UNICODE was the native Unicode storage format (code unit) used by + Python and represents a single Unicode element in the Unicode type. + With PEP 393, Py_UNICODE is deprecated and replaced with a + typedef to wchar_t. */ + +#ifndef Py_LIMITED_API +#define PY_UNICODE_TYPE wchar_t +typedef wchar_t Py_UNICODE; +#endif + +/* If the compiler provides a wchar_t type we try to support it + through the interface functions PyUnicode_FromWideChar(), + PyUnicode_AsWideChar() and PyUnicode_AsWideCharString(). */ + +#ifdef HAVE_USABLE_WCHAR_T +# ifndef HAVE_WCHAR_H +# define HAVE_WCHAR_H +# endif +#endif + +#if defined(MS_WINDOWS) +# define HAVE_MBCS +#endif + +#ifdef HAVE_WCHAR_H +/* Work around a cosmetic bug in BSDI 4.x wchar.h; thanks to Thomas Wouters */ +# ifdef _HAVE_BSDI +# include +# endif +# include +#endif + +/* Py_UCS4 and Py_UCS2 are typedefs for the respective + unicode representations. */ +#if SIZEOF_INT == 4 +typedef unsigned int Py_UCS4; +#elif SIZEOF_LONG == 4 +typedef unsigned long Py_UCS4; +#else +#error "Could not find a proper typedef for Py_UCS4" +#endif + +#if SIZEOF_SHORT == 2 +typedef unsigned short Py_UCS2; +#else +#error "Could not find a proper typedef for Py_UCS2" +#endif + +typedef unsigned char Py_UCS1; + +/* --- Internal Unicode Operations ---------------------------------------- */ + +/* Since splitting on whitespace is an important use case, and + whitespace in most situations is solely ASCII whitespace, we + optimize for the common case by using a quick look-up table + _Py_ascii_whitespace (see below) with an inlined check. + + */ +#ifndef Py_LIMITED_API +#define Py_UNICODE_ISSPACE(ch) \ + ((ch) < 128U ? _Py_ascii_whitespace[(ch)] : _PyUnicode_IsWhitespace(ch)) + +#define Py_UNICODE_ISLOWER(ch) _PyUnicode_IsLowercase(ch) +#define Py_UNICODE_ISUPPER(ch) _PyUnicode_IsUppercase(ch) +#define Py_UNICODE_ISTITLE(ch) _PyUnicode_IsTitlecase(ch) +#define Py_UNICODE_ISLINEBREAK(ch) _PyUnicode_IsLinebreak(ch) + +#define Py_UNICODE_TOLOWER(ch) _PyUnicode_ToLowercase(ch) +#define Py_UNICODE_TOUPPER(ch) _PyUnicode_ToUppercase(ch) +#define Py_UNICODE_TOTITLE(ch) _PyUnicode_ToTitlecase(ch) + +#define Py_UNICODE_ISDECIMAL(ch) _PyUnicode_IsDecimalDigit(ch) +#define Py_UNICODE_ISDIGIT(ch) _PyUnicode_IsDigit(ch) +#define Py_UNICODE_ISNUMERIC(ch) _PyUnicode_IsNumeric(ch) +#define Py_UNICODE_ISPRINTABLE(ch) _PyUnicode_IsPrintable(ch) + +#define Py_UNICODE_TODECIMAL(ch) _PyUnicode_ToDecimalDigit(ch) +#define Py_UNICODE_TODIGIT(ch) _PyUnicode_ToDigit(ch) +#define Py_UNICODE_TONUMERIC(ch) _PyUnicode_ToNumeric(ch) + +#define Py_UNICODE_ISALPHA(ch) _PyUnicode_IsAlpha(ch) + +#define Py_UNICODE_ISALNUM(ch) \ + (Py_UNICODE_ISALPHA(ch) || \ + Py_UNICODE_ISDECIMAL(ch) || \ + Py_UNICODE_ISDIGIT(ch) || \ + Py_UNICODE_ISNUMERIC(ch)) + +#define Py_UNICODE_COPY(target, source, length) \ + Py_MEMCPY((target), (source), (length)*sizeof(Py_UNICODE)) + +#define Py_UNICODE_FILL(target, value, length) \ + do {Py_ssize_t i_; Py_UNICODE *t_ = (target); Py_UNICODE v_ = (value);\ + for (i_ = 0; i_ < (length); i_++) t_[i_] = v_;\ + } while (0) + +/* macros to work with surrogates */ +#define Py_UNICODE_IS_SURROGATE(ch) (0xD800 <= (ch) && (ch) <= 0xDFFF) +#define Py_UNICODE_IS_HIGH_SURROGATE(ch) (0xD800 <= (ch) && (ch) <= 0xDBFF) +#define Py_UNICODE_IS_LOW_SURROGATE(ch) (0xDC00 <= (ch) && (ch) <= 0xDFFF) +/* Join two surrogate characters and return a single Py_UCS4 value. */ +#define Py_UNICODE_JOIN_SURROGATES(high, low) \ + (((((Py_UCS4)(high) & 0x03FF) << 10) | \ + ((Py_UCS4)(low) & 0x03FF)) + 0x10000) +/* high surrogate = top 10 bits added to D800 */ +#define Py_UNICODE_HIGH_SURROGATE(ch) (0xD800 - (0x10000 >> 10) + ((ch) >> 10)) +/* low surrogate = bottom 10 bits added to DC00 */ +#define Py_UNICODE_LOW_SURROGATE(ch) (0xDC00 + ((ch) & 0x3FF)) + +/* Check if substring matches at given offset. The offset must be + valid, and the substring must not be empty. */ + +#define Py_UNICODE_MATCH(string, offset, substring) \ + ((*((string)->wstr + (offset)) == *((substring)->wstr)) && \ + ((*((string)->wstr + (offset) + (substring)->wstr_length-1) == *((substring)->wstr + (substring)->wstr_length-1))) && \ + !memcmp((string)->wstr + (offset), (substring)->wstr, (substring)->wstr_length*sizeof(Py_UNICODE))) + +#endif /* Py_LIMITED_API */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* --- Unicode Type ------------------------------------------------------- */ + +#ifndef Py_LIMITED_API + +/* ASCII-only strings created through PyUnicode_New use the PyASCIIObject + structure. state.ascii and state.compact are set, and the data + immediately follow the structure. utf8_length and wstr_length can be found + in the length field; the utf8 pointer is equal to the data pointer. */ +typedef struct { + /* There are 4 forms of Unicode strings: + + - compact ascii: + + * structure = PyASCIIObject + * test: PyUnicode_IS_COMPACT_ASCII(op) + * kind = PyUnicode_1BYTE_KIND + * compact = 1 + * ascii = 1 + * ready = 1 + * (length is the length of the utf8 and wstr strings) + * (data starts just after the structure) + * (since ASCII is decoded from UTF-8, the utf8 string are the data) + + - compact: + + * structure = PyCompactUnicodeObject + * test: PyUnicode_IS_COMPACT(op) && !PyUnicode_IS_ASCII(op) + * kind = PyUnicode_1BYTE_KIND, PyUnicode_2BYTE_KIND or + PyUnicode_4BYTE_KIND + * compact = 1 + * ready = 1 + * ascii = 0 + * utf8 is not shared with data + * utf8_length = 0 if utf8 is NULL + * wstr is shared with data and wstr_length=length + if kind=PyUnicode_2BYTE_KIND and sizeof(wchar_t)=2 + or if kind=PyUnicode_4BYTE_KIND and sizeof(wchar_t)=4 + * wstr_length = 0 if wstr is NULL + * (data starts just after the structure) + + - legacy string, not ready: + + * structure = PyUnicodeObject + * test: kind == PyUnicode_WCHAR_KIND + * length = 0 (use wstr_length) + * hash = -1 + * kind = PyUnicode_WCHAR_KIND + * compact = 0 + * ascii = 0 + * ready = 0 + * interned = SSTATE_NOT_INTERNED + * wstr is not NULL + * data.any is NULL + * utf8 is NULL + * utf8_length = 0 + + - legacy string, ready: + + * structure = PyUnicodeObject structure + * test: !PyUnicode_IS_COMPACT(op) && kind != PyUnicode_WCHAR_KIND + * kind = PyUnicode_1BYTE_KIND, PyUnicode_2BYTE_KIND or + PyUnicode_4BYTE_KIND + * compact = 0 + * ready = 1 + * data.any is not NULL + * utf8 is shared and utf8_length = length with data.any if ascii = 1 + * utf8_length = 0 if utf8 is NULL + * wstr is shared with data.any and wstr_length = length + if kind=PyUnicode_2BYTE_KIND and sizeof(wchar_t)=2 + or if kind=PyUnicode_4BYTE_KIND and sizeof(wchar_4)=4 + * wstr_length = 0 if wstr is NULL + + Compact strings use only one memory block (structure + characters), + whereas legacy strings use one block for the structure and one block + for characters. + + Legacy strings are created by PyUnicode_FromUnicode() and + PyUnicode_FromStringAndSize(NULL, size) functions. They become ready + when PyUnicode_READY() is called. + + See also _PyUnicode_CheckConsistency(). + */ + PyObject_HEAD + Py_ssize_t length; /* Number of code points in the string */ + Py_hash_t hash; /* Hash value; -1 if not set */ + struct { + /* + SSTATE_NOT_INTERNED (0) + SSTATE_INTERNED_MORTAL (1) + SSTATE_INTERNED_IMMORTAL (2) + + If interned != SSTATE_NOT_INTERNED, the two references from the + dictionary to this object are *not* counted in ob_refcnt. + */ + unsigned int interned:2; + /* Character size: + + - PyUnicode_WCHAR_KIND (0): + + * character type = wchar_t (16 or 32 bits, depending on the + platform) + + - PyUnicode_1BYTE_KIND (1): + + * character type = Py_UCS1 (8 bits, unsigned) + * all characters are in the range U+0000-U+00FF (latin1) + * if ascii is set, all characters are in the range U+0000-U+007F + (ASCII), otherwise at least one character is in the range + U+0080-U+00FF + + - PyUnicode_2BYTE_KIND (2): + + * character type = Py_UCS2 (16 bits, unsigned) + * all characters are in the range U+0000-U+FFFF (BMP) + * at least one character is in the range U+0100-U+FFFF + + - PyUnicode_4BYTE_KIND (4): + + * character type = Py_UCS4 (32 bits, unsigned) + * all characters are in the range U+0000-U+10FFFF + * at least one character is in the range U+10000-U+10FFFF + */ + unsigned int kind:3; + /* Compact is with respect to the allocation scheme. Compact unicode + objects only require one memory block while non-compact objects use + one block for the PyUnicodeObject struct and another for its data + buffer. */ + unsigned int compact:1; + /* The string only contains characters in the range U+0000-U+007F (ASCII) + and the kind is PyUnicode_1BYTE_KIND. If ascii is set and compact is + set, use the PyASCIIObject structure. */ + unsigned int ascii:1; + /* The ready flag indicates whether the object layout is initialized + completely. This means that this is either a compact object, or + the data pointer is filled out. The bit is redundant, and helps + to minimize the test in PyUnicode_IS_READY(). */ + unsigned int ready:1; + /* Padding to ensure that PyUnicode_DATA() is always aligned to + 4 bytes (see issue #19537 on m68k). */ + unsigned int :24; + } state; + wchar_t *wstr; /* wchar_t representation (null-terminated) */ +} PyASCIIObject; + +/* Non-ASCII strings allocated through PyUnicode_New use the + PyCompactUnicodeObject structure. state.compact is set, and the data + immediately follow the structure. */ +typedef struct { + PyASCIIObject _base; + Py_ssize_t utf8_length; /* Number of bytes in utf8, excluding the + * terminating \0. */ + char *utf8; /* UTF-8 representation (null-terminated) */ + Py_ssize_t wstr_length; /* Number of code points in wstr, possible + * surrogates count as two code points. */ +} PyCompactUnicodeObject; + +/* Strings allocated through PyUnicode_FromUnicode(NULL, len) use the + PyUnicodeObject structure. The actual string data is initially in the wstr + block, and copied into the data block using _PyUnicode_Ready. */ +typedef struct { + PyCompactUnicodeObject _base; + union { + void *any; + Py_UCS1 *latin1; + Py_UCS2 *ucs2; + Py_UCS4 *ucs4; + } data; /* Canonical, smallest-form Unicode buffer */ +} PyUnicodeObject; +#endif + +PyAPI_DATA(PyTypeObject) PyUnicode_Type; +PyAPI_DATA(PyTypeObject) PyUnicodeIter_Type; + +#define PyUnicode_Check(op) \ + PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_UNICODE_SUBCLASS) +#define PyUnicode_CheckExact(op) (Py_TYPE(op) == &PyUnicode_Type) + +/* Fast access macros */ +#ifndef Py_LIMITED_API + +#define PyUnicode_WSTR_LENGTH(op) \ + (PyUnicode_IS_COMPACT_ASCII(op) ? \ + ((PyASCIIObject*)op)->length : \ + ((PyCompactUnicodeObject*)op)->wstr_length) + +/* Returns the deprecated Py_UNICODE representation's size in code units + (this includes surrogate pairs as 2 units). + If the Py_UNICODE representation is not available, it will be computed + on request. Use PyUnicode_GET_LENGTH() for the length in code points. */ + +#define PyUnicode_GET_SIZE(op) \ + (assert(PyUnicode_Check(op)), \ + (((PyASCIIObject *)(op))->wstr) ? \ + PyUnicode_WSTR_LENGTH(op) : \ + ((void)PyUnicode_AsUnicode((PyObject *)(op)), \ + assert(((PyASCIIObject *)(op))->wstr), \ + PyUnicode_WSTR_LENGTH(op))) + +#define PyUnicode_GET_DATA_SIZE(op) \ + (PyUnicode_GET_SIZE(op) * Py_UNICODE_SIZE) + +/* Alias for PyUnicode_AsUnicode(). This will create a wchar_t/Py_UNICODE + representation on demand. Using this macro is very inefficient now, + try to port your code to use the new PyUnicode_*BYTE_DATA() macros or + use PyUnicode_WRITE() and PyUnicode_READ(). */ + +#define PyUnicode_AS_UNICODE(op) \ + (assert(PyUnicode_Check(op)), \ + (((PyASCIIObject *)(op))->wstr) ? (((PyASCIIObject *)(op))->wstr) : \ + PyUnicode_AsUnicode((PyObject *)(op))) + +#define PyUnicode_AS_DATA(op) \ + ((const char *)(PyUnicode_AS_UNICODE(op))) + + +/* --- Flexible String Representation Helper Macros (PEP 393) -------------- */ + +/* Values for PyASCIIObject.state: */ + +/* Interning state. */ +#define SSTATE_NOT_INTERNED 0 +#define SSTATE_INTERNED_MORTAL 1 +#define SSTATE_INTERNED_IMMORTAL 2 + +/* Return true if the string contains only ASCII characters, or 0 if not. The + string may be compact (PyUnicode_IS_COMPACT_ASCII) or not, but must be + ready. */ +#define PyUnicode_IS_ASCII(op) \ + (assert(PyUnicode_Check(op)), \ + assert(PyUnicode_IS_READY(op)), \ + ((PyASCIIObject*)op)->state.ascii) + +/* Return true if the string is compact or 0 if not. + No type checks or Ready calls are performed. */ +#define PyUnicode_IS_COMPACT(op) \ + (((PyASCIIObject*)(op))->state.compact) + +/* Return true if the string is a compact ASCII string (use PyASCIIObject + structure), or 0 if not. No type checks or Ready calls are performed. */ +#define PyUnicode_IS_COMPACT_ASCII(op) \ + (((PyASCIIObject*)op)->state.ascii && PyUnicode_IS_COMPACT(op)) + +enum PyUnicode_Kind { +/* String contains only wstr byte characters. This is only possible + when the string was created with a legacy API and _PyUnicode_Ready() + has not been called yet. */ + PyUnicode_WCHAR_KIND = 0, +/* Return values of the PyUnicode_KIND() macro: */ + PyUnicode_1BYTE_KIND = 1, + PyUnicode_2BYTE_KIND = 2, + PyUnicode_4BYTE_KIND = 4 +}; + +/* Return pointers to the canonical representation cast to unsigned char, + Py_UCS2, or Py_UCS4 for direct character access. + No checks are performed, use PyUnicode_KIND() before to ensure + these will work correctly. */ + +#define PyUnicode_1BYTE_DATA(op) ((Py_UCS1*)PyUnicode_DATA(op)) +#define PyUnicode_2BYTE_DATA(op) ((Py_UCS2*)PyUnicode_DATA(op)) +#define PyUnicode_4BYTE_DATA(op) ((Py_UCS4*)PyUnicode_DATA(op)) + +/* Return one of the PyUnicode_*_KIND values defined above. */ +#define PyUnicode_KIND(op) \ + (assert(PyUnicode_Check(op)), \ + assert(PyUnicode_IS_READY(op)), \ + ((PyASCIIObject *)(op))->state.kind) + +/* Return a void pointer to the raw unicode buffer. */ +#define _PyUnicode_COMPACT_DATA(op) \ + (PyUnicode_IS_ASCII(op) ? \ + ((void*)((PyASCIIObject*)(op) + 1)) : \ + ((void*)((PyCompactUnicodeObject*)(op) + 1))) + +#define _PyUnicode_NONCOMPACT_DATA(op) \ + (assert(((PyUnicodeObject*)(op))->data.any), \ + ((((PyUnicodeObject *)(op))->data.any))) + +#define PyUnicode_DATA(op) \ + (assert(PyUnicode_Check(op)), \ + PyUnicode_IS_COMPACT(op) ? _PyUnicode_COMPACT_DATA(op) : \ + _PyUnicode_NONCOMPACT_DATA(op)) + +/* In the access macros below, "kind" may be evaluated more than once. + All other macro parameters are evaluated exactly once, so it is safe + to put side effects into them (such as increasing the index). */ + +/* Write into the canonical representation, this macro does not do any sanity + checks and is intended for usage in loops. The caller should cache the + kind and data pointers obtained from other macro calls. + index is the index in the string (starts at 0) and value is the new + code point value which should be written to that location. */ +#define PyUnicode_WRITE(kind, data, index, value) \ + do { \ + switch ((kind)) { \ + case PyUnicode_1BYTE_KIND: { \ + ((Py_UCS1 *)(data))[(index)] = (Py_UCS1)(value); \ + break; \ + } \ + case PyUnicode_2BYTE_KIND: { \ + ((Py_UCS2 *)(data))[(index)] = (Py_UCS2)(value); \ + break; \ + } \ + default: { \ + assert((kind) == PyUnicode_4BYTE_KIND); \ + ((Py_UCS4 *)(data))[(index)] = (Py_UCS4)(value); \ + } \ + } \ + } while (0) + +/* Read a code point from the string's canonical representation. No checks + or ready calls are performed. */ +#define PyUnicode_READ(kind, data, index) \ + ((Py_UCS4) \ + ((kind) == PyUnicode_1BYTE_KIND ? \ + ((const Py_UCS1 *)(data))[(index)] : \ + ((kind) == PyUnicode_2BYTE_KIND ? \ + ((const Py_UCS2 *)(data))[(index)] : \ + ((const Py_UCS4 *)(data))[(index)] \ + ) \ + )) + +/* PyUnicode_READ_CHAR() is less efficient than PyUnicode_READ() because it + calls PyUnicode_KIND() and might call it twice. For single reads, use + PyUnicode_READ_CHAR, for multiple consecutive reads callers should + cache kind and use PyUnicode_READ instead. */ +#define PyUnicode_READ_CHAR(unicode, index) \ + (assert(PyUnicode_Check(unicode)), \ + assert(PyUnicode_IS_READY(unicode)), \ + (Py_UCS4) \ + (PyUnicode_KIND((unicode)) == PyUnicode_1BYTE_KIND ? \ + ((const Py_UCS1 *)(PyUnicode_DATA((unicode))))[(index)] : \ + (PyUnicode_KIND((unicode)) == PyUnicode_2BYTE_KIND ? \ + ((const Py_UCS2 *)(PyUnicode_DATA((unicode))))[(index)] : \ + ((const Py_UCS4 *)(PyUnicode_DATA((unicode))))[(index)] \ + ) \ + )) + +/* Returns the length of the unicode string. The caller has to make sure that + the string has it's canonical representation set before calling + this macro. Call PyUnicode_(FAST_)Ready to ensure that. */ +#define PyUnicode_GET_LENGTH(op) \ + (assert(PyUnicode_Check(op)), \ + assert(PyUnicode_IS_READY(op)), \ + ((PyASCIIObject *)(op))->length) + + +/* Fast check to determine whether an object is ready. Equivalent to + PyUnicode_IS_COMPACT(op) || ((PyUnicodeObject*)(op))->data.any) */ + +#define PyUnicode_IS_READY(op) (((PyASCIIObject*)op)->state.ready) + +/* PyUnicode_READY() does less work than _PyUnicode_Ready() in the best + case. If the canonical representation is not yet set, it will still call + _PyUnicode_Ready(). + Returns 0 on success and -1 on errors. */ +#define PyUnicode_READY(op) \ + (assert(PyUnicode_Check(op)), \ + (PyUnicode_IS_READY(op) ? \ + 0 : _PyUnicode_Ready((PyObject *)(op)))) + +/* Return a maximum character value which is suitable for creating another + string based on op. This is always an approximation but more efficient + than iterating over the string. */ +#define PyUnicode_MAX_CHAR_VALUE(op) \ + (assert(PyUnicode_IS_READY(op)), \ + (PyUnicode_IS_ASCII(op) ? \ + (0x7f) : \ + (PyUnicode_KIND(op) == PyUnicode_1BYTE_KIND ? \ + (0xffU) : \ + (PyUnicode_KIND(op) == PyUnicode_2BYTE_KIND ? \ + (0xffffU) : \ + (0x10ffffU))))) + +#endif + +/* --- Constants ---------------------------------------------------------- */ + +/* This Unicode character will be used as replacement character during + decoding if the errors argument is set to "replace". Note: the + Unicode character U+FFFD is the official REPLACEMENT CHARACTER in + Unicode 3.0. */ + +#define Py_UNICODE_REPLACEMENT_CHARACTER ((Py_UCS4) 0xFFFD) + +/* === Public API ========================================================= */ + +/* --- Plain Py_UNICODE --------------------------------------------------- */ + +/* With PEP 393, this is the recommended way to allocate a new unicode object. + This function will allocate the object and its buffer in a single memory + block. Objects created using this function are not resizable. */ +#ifndef Py_LIMITED_API +PyAPI_FUNC(PyObject*) PyUnicode_New( + Py_ssize_t size, /* Number of code points in the new string */ + Py_UCS4 maxchar /* maximum code point value in the string */ + ); +#endif + +/* Initializes the canonical string representation from the deprecated + wstr/Py_UNICODE representation. This function is used to convert Unicode + objects which were created using the old API to the new flexible format + introduced with PEP 393. + + Don't call this function directly, use the public PyUnicode_READY() macro + instead. */ +#ifndef Py_LIMITED_API +PyAPI_FUNC(int) _PyUnicode_Ready( + PyObject *unicode /* Unicode object */ + ); +#endif + +/* Get a copy of a Unicode string. */ +#ifndef Py_LIMITED_API +PyAPI_FUNC(PyObject*) _PyUnicode_Copy( + PyObject *unicode + ); +#endif + +/* Copy character from one unicode object into another, this function performs + character conversion when necessary and falls back to memcpy() if possible. + + Fail if to is too small (smaller than *how_many* or smaller than + len(from)-from_start), or if kind(from[from_start:from_start+how_many]) > + kind(to), or if *to* has more than 1 reference. + + Return the number of written character, or return -1 and raise an exception + on error. + + Pseudo-code: + + how_many = min(how_many, len(from) - from_start) + to[to_start:to_start+how_many] = from[from_start:from_start+how_many] + return how_many + + Note: The function doesn't write a terminating null character. + */ +#ifndef Py_LIMITED_API +PyAPI_FUNC(Py_ssize_t) PyUnicode_CopyCharacters( + PyObject *to, + Py_ssize_t to_start, + PyObject *from, + Py_ssize_t from_start, + Py_ssize_t how_many + ); + +/* Unsafe version of PyUnicode_CopyCharacters(): don't check arguments and so + may crash if parameters are invalid (e.g. if the output string + is too short). */ +PyAPI_FUNC(void) _PyUnicode_FastCopyCharacters( + PyObject *to, + Py_ssize_t to_start, + PyObject *from, + Py_ssize_t from_start, + Py_ssize_t how_many + ); +#endif + +#ifndef Py_LIMITED_API +/* Fill a string with a character: write fill_char into + unicode[start:start+length]. + + Fail if fill_char is bigger than the string maximum character, or if the + string has more than 1 reference. + + Return the number of written character, or return -1 and raise an exception + on error. */ +PyAPI_FUNC(Py_ssize_t) PyUnicode_Fill( + PyObject *unicode, + Py_ssize_t start, + Py_ssize_t length, + Py_UCS4 fill_char + ); + +/* Unsafe version of PyUnicode_Fill(): don't check arguments and so may crash + if parameters are invalid (e.g. if length is longer than the string). */ +PyAPI_FUNC(void) _PyUnicode_FastFill( + PyObject *unicode, + Py_ssize_t start, + Py_ssize_t length, + Py_UCS4 fill_char + ); +#endif + +/* Create a Unicode Object from the Py_UNICODE buffer u of the given + size. + + u may be NULL which causes the contents to be undefined. It is the + user's responsibility to fill in the needed data afterwards. Note + that modifying the Unicode object contents after construction is + only allowed if u was set to NULL. + + The buffer is copied into the new object. */ + +#ifndef Py_LIMITED_API +PyAPI_FUNC(PyObject*) PyUnicode_FromUnicode( + const Py_UNICODE *u, /* Unicode buffer */ + Py_ssize_t size /* size of buffer */ + ); +#endif + +/* Similar to PyUnicode_FromUnicode(), but u points to UTF-8 encoded bytes */ +PyAPI_FUNC(PyObject*) PyUnicode_FromStringAndSize( + const char *u, /* UTF-8 encoded string */ + Py_ssize_t size /* size of buffer */ + ); + +/* Similar to PyUnicode_FromUnicode(), but u points to null-terminated + UTF-8 encoded bytes. The size is determined with strlen(). */ +PyAPI_FUNC(PyObject*) PyUnicode_FromString( + const char *u /* UTF-8 encoded string */ + ); + +#ifndef Py_LIMITED_API +/* Create a new string from a buffer of Py_UCS1, Py_UCS2 or Py_UCS4 characters. + Scan the string to find the maximum character. */ +PyAPI_FUNC(PyObject*) PyUnicode_FromKindAndData( + int kind, + const void *buffer, + Py_ssize_t size); + +/* Create a new string from a buffer of ASCII characters. + WARNING: Don't check if the string contains any non-ASCII character. */ +PyAPI_FUNC(PyObject*) _PyUnicode_FromASCII( + const char *buffer, + Py_ssize_t size); +#endif + +PyAPI_FUNC(PyObject*) PyUnicode_Substring( + PyObject *str, + Py_ssize_t start, + Py_ssize_t end); + +#ifndef Py_LIMITED_API +/* Compute the maximum character of the substring unicode[start:end]. + Return 127 for an empty string. */ +PyAPI_FUNC(Py_UCS4) _PyUnicode_FindMaxChar ( + PyObject *unicode, + Py_ssize_t start, + Py_ssize_t end); +#endif + +/* Copy the string into a UCS4 buffer including the null character if copy_null + is set. Return NULL and raise an exception on error. Raise a ValueError if + the buffer is smaller than the string. Return buffer on success. + + buflen is the length of the buffer in (Py_UCS4) characters. */ +PyAPI_FUNC(Py_UCS4*) PyUnicode_AsUCS4( + PyObject *unicode, + Py_UCS4* buffer, + Py_ssize_t buflen, + int copy_null); + +/* Copy the string into a UCS4 buffer. A new buffer is allocated using + * PyMem_Malloc; if this fails, NULL is returned with a memory error + exception set. */ +PyAPI_FUNC(Py_UCS4*) PyUnicode_AsUCS4Copy(PyObject *unicode); + +/* Return a read-only pointer to the Unicode object's internal + Py_UNICODE buffer. + If the wchar_t/Py_UNICODE representation is not yet available, this + function will calculate it. */ + +#ifndef Py_LIMITED_API +PyAPI_FUNC(Py_UNICODE *) PyUnicode_AsUnicode( + PyObject *unicode /* Unicode object */ + ); +#endif + +/* Return a read-only pointer to the Unicode object's internal + Py_UNICODE buffer and save the length at size. + If the wchar_t/Py_UNICODE representation is not yet available, this + function will calculate it. */ + +#ifndef Py_LIMITED_API +PyAPI_FUNC(Py_UNICODE *) PyUnicode_AsUnicodeAndSize( + PyObject *unicode, /* Unicode object */ + Py_ssize_t *size /* location where to save the length */ + ); +#endif + +/* Get the length of the Unicode object. */ + +PyAPI_FUNC(Py_ssize_t) PyUnicode_GetLength( + PyObject *unicode +); + +/* Get the number of Py_UNICODE units in the + string representation. */ + +PyAPI_FUNC(Py_ssize_t) PyUnicode_GetSize( + PyObject *unicode /* Unicode object */ + ); + +/* Read a character from the string. */ + +PyAPI_FUNC(Py_UCS4) PyUnicode_ReadChar( + PyObject *unicode, + Py_ssize_t index + ); + +/* Write a character to the string. The string must have been created through + PyUnicode_New, must not be shared, and must not have been hashed yet. + + Return 0 on success, -1 on error. */ + +PyAPI_FUNC(int) PyUnicode_WriteChar( + PyObject *unicode, + Py_ssize_t index, + Py_UCS4 character + ); + +#ifndef Py_LIMITED_API +/* Get the maximum ordinal for a Unicode character. */ +PyAPI_FUNC(Py_UNICODE) PyUnicode_GetMax(void); +#endif + +/* Resize an Unicode object. The length is the number of characters, except + if the kind of the string is PyUnicode_WCHAR_KIND: in this case, the length + is the number of Py_UNICODE characters. + + *unicode is modified to point to the new (resized) object and 0 + returned on success. + + Try to resize the string in place (which is usually faster than allocating + a new string and copy characters), or create a new string. + + Error handling is implemented as follows: an exception is set, -1 + is returned and *unicode left untouched. + + WARNING: The function doesn't check string content, the result may not be a + string in canonical representation. */ + +PyAPI_FUNC(int) PyUnicode_Resize( + PyObject **unicode, /* Pointer to the Unicode object */ + Py_ssize_t length /* New length */ + ); + +/* Coerce obj to an Unicode object and return a reference with + *incremented* refcount. + + Coercion is done in the following way: + + 1. bytes, bytearray and other bytes-like objects are decoded + under the assumptions that they contain data using the UTF-8 + encoding. Decoding is done in "strict" mode. + + 2. All other objects (including Unicode objects) raise an + exception. + + The API returns NULL in case of an error. The caller is responsible + for decref'ing the returned objects. + +*/ + +PyAPI_FUNC(PyObject*) PyUnicode_FromEncodedObject( + PyObject *obj, /* Object */ + const char *encoding, /* encoding */ + const char *errors /* error handling */ + ); + +/* Coerce obj to an Unicode object and return a reference with + *incremented* refcount. + + Unicode objects are passed back as-is (subclasses are converted to + true Unicode objects), all other objects are delegated to + PyUnicode_FromEncodedObject(obj, NULL, "strict") which results in + using UTF-8 encoding as basis for decoding the object. + + The API returns NULL in case of an error. The caller is responsible + for decref'ing the returned objects. + +*/ + +PyAPI_FUNC(PyObject*) PyUnicode_FromObject( + PyObject *obj /* Object */ + ); + +PyAPI_FUNC(PyObject *) PyUnicode_FromFormatV( + const char *format, /* ASCII-encoded string */ + va_list vargs + ); +PyAPI_FUNC(PyObject *) PyUnicode_FromFormat( + const char *format, /* ASCII-encoded string */ + ... + ); + +#ifndef Py_LIMITED_API +typedef struct { + PyObject *buffer; + void *data; + enum PyUnicode_Kind kind; + Py_UCS4 maxchar; + Py_ssize_t size; + Py_ssize_t pos; + + /* minimum number of allocated characters (default: 0) */ + Py_ssize_t min_length; + + /* minimum character (default: 127, ASCII) */ + Py_UCS4 min_char; + + /* If non-zero, overallocate the buffer by 25% (default: 0). */ + unsigned char overallocate; + + /* If readonly is 1, buffer is a shared string (cannot be modified) + and size is set to 0. */ + unsigned char readonly; +} _PyUnicodeWriter ; + +/* Initialize a Unicode writer. + * + * By default, the minimum buffer size is 0 character and overallocation is + * disabled. Set min_length, min_char and overallocate attributes to control + * the allocation of the buffer. */ +PyAPI_FUNC(void) +_PyUnicodeWriter_Init(_PyUnicodeWriter *writer); + +/* Prepare the buffer to write 'length' characters + with the specified maximum character. + + Return 0 on success, raise an exception and return -1 on error. */ +#define _PyUnicodeWriter_Prepare(WRITER, LENGTH, MAXCHAR) \ + (((MAXCHAR) <= (WRITER)->maxchar \ + && (LENGTH) <= (WRITER)->size - (WRITER)->pos) \ + ? 0 \ + : (((LENGTH) == 0) \ + ? 0 \ + : _PyUnicodeWriter_PrepareInternal((WRITER), (LENGTH), (MAXCHAR)))) + +/* Don't call this function directly, use the _PyUnicodeWriter_Prepare() macro + instead. */ +PyAPI_FUNC(int) +_PyUnicodeWriter_PrepareInternal(_PyUnicodeWriter *writer, + Py_ssize_t length, Py_UCS4 maxchar); + +/* Append a Unicode character. + Return 0 on success, raise an exception and return -1 on error. */ +PyAPI_FUNC(int) +_PyUnicodeWriter_WriteChar(_PyUnicodeWriter *writer, + Py_UCS4 ch + ); + +/* Append a Unicode string. + Return 0 on success, raise an exception and return -1 on error. */ +PyAPI_FUNC(int) +_PyUnicodeWriter_WriteStr(_PyUnicodeWriter *writer, + PyObject *str /* Unicode string */ + ); + +/* Append a substring of a Unicode string. + Return 0 on success, raise an exception and return -1 on error. */ +PyAPI_FUNC(int) +_PyUnicodeWriter_WriteSubstring(_PyUnicodeWriter *writer, + PyObject *str, /* Unicode string */ + Py_ssize_t start, + Py_ssize_t end + ); + +/* Append a ASCII-encoded byte string. + Return 0 on success, raise an exception and return -1 on error. */ +PyAPI_FUNC(int) +_PyUnicodeWriter_WriteASCIIString(_PyUnicodeWriter *writer, + const char *str, /* ASCII-encoded byte string */ + Py_ssize_t len /* number of bytes, or -1 if unknown */ + ); + +/* Append a latin1-encoded byte string. + Return 0 on success, raise an exception and return -1 on error. */ +PyAPI_FUNC(int) +_PyUnicodeWriter_WriteLatin1String(_PyUnicodeWriter *writer, + const char *str, /* latin1-encoded byte string */ + Py_ssize_t len /* length in bytes */ + ); + +/* Get the value of the writer as an Unicode string. Clear the + buffer of the writer. Raise an exception and return NULL + on error. */ +PyAPI_FUNC(PyObject *) +_PyUnicodeWriter_Finish(_PyUnicodeWriter *writer); + +/* Deallocate memory of a writer (clear its internal buffer). */ +PyAPI_FUNC(void) +_PyUnicodeWriter_Dealloc(_PyUnicodeWriter *writer); +#endif + +#ifndef Py_LIMITED_API +/* Format the object based on the format_spec, as defined in PEP 3101 + (Advanced String Formatting). */ +PyAPI_FUNC(int) _PyUnicode_FormatAdvancedWriter( + _PyUnicodeWriter *writer, + PyObject *obj, + PyObject *format_spec, + Py_ssize_t start, + Py_ssize_t end); +#endif + +PyAPI_FUNC(void) PyUnicode_InternInPlace(PyObject **); +PyAPI_FUNC(void) PyUnicode_InternImmortal(PyObject **); +PyAPI_FUNC(PyObject *) PyUnicode_InternFromString( + const char *u /* UTF-8 encoded string */ + ); +#ifndef Py_LIMITED_API +PyAPI_FUNC(void) _Py_ReleaseInternedUnicodeStrings(void); +#endif + +/* Use only if you know it's a string */ +#define PyUnicode_CHECK_INTERNED(op) \ + (((PyASCIIObject *)(op))->state.interned) + +/* --- wchar_t support for platforms which support it --------------------- */ + +#ifdef HAVE_WCHAR_H + +/* Create a Unicode Object from the wchar_t buffer w of the given + size. + + The buffer is copied into the new object. */ + +PyAPI_FUNC(PyObject*) PyUnicode_FromWideChar( + const wchar_t *w, /* wchar_t buffer */ + Py_ssize_t size /* size of buffer */ + ); + +/* Copies the Unicode Object contents into the wchar_t buffer w. At + most size wchar_t characters are copied. + + Note that the resulting wchar_t string may or may not be + 0-terminated. It is the responsibility of the caller to make sure + that the wchar_t string is 0-terminated in case this is required by + the application. + + Returns the number of wchar_t characters copied (excluding a + possibly trailing 0-termination character) or -1 in case of an + error. */ + +PyAPI_FUNC(Py_ssize_t) PyUnicode_AsWideChar( + PyObject *unicode, /* Unicode object */ + wchar_t *w, /* wchar_t buffer */ + Py_ssize_t size /* size of buffer */ + ); + +/* Convert the Unicode object to a wide character string. The output string + always ends with a nul character. If size is not NULL, write the number of + wide characters (excluding the null character) into *size. + + Returns a buffer allocated by PyMem_Malloc() (use PyMem_Free() to free it) + on success. On error, returns NULL, *size is undefined and raises a + MemoryError. */ + +PyAPI_FUNC(wchar_t*) PyUnicode_AsWideCharString( + PyObject *unicode, /* Unicode object */ + Py_ssize_t *size /* number of characters of the result */ + ); + +#ifndef Py_LIMITED_API +PyAPI_FUNC(void*) _PyUnicode_AsKind(PyObject *s, unsigned int kind); +#endif + +#endif + +/* --- Unicode ordinals --------------------------------------------------- */ + +/* Create a Unicode Object from the given Unicode code point ordinal. + + The ordinal must be in range(0x110000). A ValueError is + raised in case it is not. + +*/ + +PyAPI_FUNC(PyObject*) PyUnicode_FromOrdinal(int ordinal); + +/* --- Free-list management ----------------------------------------------- */ + +/* Clear the free list used by the Unicode implementation. + + This can be used to release memory used for objects on the free + list back to the Python memory allocator. + +*/ + +PyAPI_FUNC(int) PyUnicode_ClearFreeList(void); + +/* === Builtin Codecs ===================================================== + + Many of these APIs take two arguments encoding and errors. These + parameters encoding and errors have the same semantics as the ones + of the builtin str() API. + + Setting encoding to NULL causes the default encoding (UTF-8) to be used. + + Error handling is set by errors which may also be set to NULL + meaning to use the default handling defined for the codec. Default + error handling for all builtin codecs is "strict" (ValueErrors are + raised). + + The codecs all use a similar interface. Only deviation from the + generic ones are documented. + +*/ + +/* --- Manage the default encoding ---------------------------------------- */ + +/* Returns a pointer to the default encoding (UTF-8) of the + Unicode object unicode and the size of the encoded representation + in bytes stored in *size. + + In case of an error, no *size is set. + + This function caches the UTF-8 encoded string in the unicodeobject + and subsequent calls will return the same string. The memory is released + when the unicodeobject is deallocated. + + _PyUnicode_AsStringAndSize is a #define for PyUnicode_AsUTF8AndSize to + support the previous internal function with the same behaviour. + + *** This API is for interpreter INTERNAL USE ONLY and will likely + *** be removed or changed in the future. + + *** If you need to access the Unicode object as UTF-8 bytes string, + *** please use PyUnicode_AsUTF8String() instead. +*/ + +#ifndef Py_LIMITED_API +PyAPI_FUNC(char *) PyUnicode_AsUTF8AndSize( + PyObject *unicode, + Py_ssize_t *size); +#define _PyUnicode_AsStringAndSize PyUnicode_AsUTF8AndSize +#endif + +/* Returns a pointer to the default encoding (UTF-8) of the + Unicode object unicode. + + Like PyUnicode_AsUTF8AndSize(), this also caches the UTF-8 representation + in the unicodeobject. + + _PyUnicode_AsString is a #define for PyUnicode_AsUTF8 to + support the previous internal function with the same behaviour. + + Use of this API is DEPRECATED since no size information can be + extracted from the returned data. + + *** This API is for interpreter INTERNAL USE ONLY and will likely + *** be removed or changed for Python 3.1. + + *** If you need to access the Unicode object as UTF-8 bytes string, + *** please use PyUnicode_AsUTF8String() instead. + +*/ + +#ifndef Py_LIMITED_API +PyAPI_FUNC(char *) PyUnicode_AsUTF8(PyObject *unicode); +#define _PyUnicode_AsString PyUnicode_AsUTF8 +#endif + +/* Returns "utf-8". */ + +PyAPI_FUNC(const char*) PyUnicode_GetDefaultEncoding(void); + +/* --- Generic Codecs ----------------------------------------------------- */ + +/* Create a Unicode object by decoding the encoded string s of the + given size. */ + +PyAPI_FUNC(PyObject*) PyUnicode_Decode( + const char *s, /* encoded string */ + Py_ssize_t size, /* size of buffer */ + const char *encoding, /* encoding */ + const char *errors /* error handling */ + ); + +/* Decode a Unicode object unicode and return the result as Python + object. */ + +PyAPI_FUNC(PyObject*) PyUnicode_AsDecodedObject( + PyObject *unicode, /* Unicode object */ + const char *encoding, /* encoding */ + const char *errors /* error handling */ + ); + +/* Decode a Unicode object unicode and return the result as Unicode + object. */ + +PyAPI_FUNC(PyObject*) PyUnicode_AsDecodedUnicode( + PyObject *unicode, /* Unicode object */ + const char *encoding, /* encoding */ + const char *errors /* error handling */ + ); + +/* Encodes a Py_UNICODE buffer of the given size and returns a + Python string object. */ + +#ifndef Py_LIMITED_API +PyAPI_FUNC(PyObject*) PyUnicode_Encode( + const Py_UNICODE *s, /* Unicode char buffer */ + Py_ssize_t size, /* number of Py_UNICODE chars to encode */ + const char *encoding, /* encoding */ + const char *errors /* error handling */ + ); +#endif + +/* Encodes a Unicode object and returns the result as Python + object. */ + +PyAPI_FUNC(PyObject*) PyUnicode_AsEncodedObject( + PyObject *unicode, /* Unicode object */ + const char *encoding, /* encoding */ + const char *errors /* error handling */ + ); + +/* Encodes a Unicode object and returns the result as Python string + object. */ + +PyAPI_FUNC(PyObject*) PyUnicode_AsEncodedString( + PyObject *unicode, /* Unicode object */ + const char *encoding, /* encoding */ + const char *errors /* error handling */ + ); + +/* Encodes a Unicode object and returns the result as Unicode + object. */ + +PyAPI_FUNC(PyObject*) PyUnicode_AsEncodedUnicode( + PyObject *unicode, /* Unicode object */ + const char *encoding, /* encoding */ + const char *errors /* error handling */ + ); + +/* Build an encoding map. */ + +PyAPI_FUNC(PyObject*) PyUnicode_BuildEncodingMap( + PyObject* string /* 256 character map */ + ); + +/* --- UTF-7 Codecs ------------------------------------------------------- */ + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF7( + const char *string, /* UTF-7 encoded string */ + Py_ssize_t length, /* size of string */ + const char *errors /* error handling */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF7Stateful( + const char *string, /* UTF-7 encoded string */ + Py_ssize_t length, /* size of string */ + const char *errors, /* error handling */ + Py_ssize_t *consumed /* bytes consumed */ + ); + +#ifndef Py_LIMITED_API +PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF7( + const Py_UNICODE *data, /* Unicode char buffer */ + Py_ssize_t length, /* number of Py_UNICODE chars to encode */ + int base64SetO, /* Encode RFC2152 Set O characters in base64 */ + int base64WhiteSpace, /* Encode whitespace (sp, ht, nl, cr) in base64 */ + const char *errors /* error handling */ + ); +PyAPI_FUNC(PyObject*) _PyUnicode_EncodeUTF7( + PyObject *unicode, /* Unicode object */ + int base64SetO, /* Encode RFC2152 Set O characters in base64 */ + int base64WhiteSpace, /* Encode whitespace (sp, ht, nl, cr) in base64 */ + const char *errors /* error handling */ + ); +#endif + +/* --- UTF-8 Codecs ------------------------------------------------------- */ + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF8( + const char *string, /* UTF-8 encoded string */ + Py_ssize_t length, /* size of string */ + const char *errors /* error handling */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF8Stateful( + const char *string, /* UTF-8 encoded string */ + Py_ssize_t length, /* size of string */ + const char *errors, /* error handling */ + Py_ssize_t *consumed /* bytes consumed */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_AsUTF8String( + PyObject *unicode /* Unicode object */ + ); + +#ifndef Py_LIMITED_API +PyAPI_FUNC(PyObject*) _PyUnicode_AsUTF8String( + PyObject *unicode, + const char *errors); + +PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF8( + const Py_UNICODE *data, /* Unicode char buffer */ + Py_ssize_t length, /* number of Py_UNICODE chars to encode */ + const char *errors /* error handling */ + ); +#endif + +/* --- UTF-32 Codecs ------------------------------------------------------ */ + +/* Decodes length bytes from a UTF-32 encoded buffer string and returns + the corresponding Unicode object. + + errors (if non-NULL) defines the error handling. It defaults + to "strict". + + If byteorder is non-NULL, the decoder starts decoding using the + given byte order: + + *byteorder == -1: little endian + *byteorder == 0: native order + *byteorder == 1: big endian + + In native mode, the first four bytes of the stream are checked for a + BOM mark. If found, the BOM mark is analysed, the byte order + adjusted and the BOM skipped. In the other modes, no BOM mark + interpretation is done. After completion, *byteorder is set to the + current byte order at the end of input data. + + If byteorder is NULL, the codec starts in native order mode. + +*/ + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF32( + const char *string, /* UTF-32 encoded string */ + Py_ssize_t length, /* size of string */ + const char *errors, /* error handling */ + int *byteorder /* pointer to byteorder to use + 0=native;-1=LE,1=BE; updated on + exit */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF32Stateful( + const char *string, /* UTF-32 encoded string */ + Py_ssize_t length, /* size of string */ + const char *errors, /* error handling */ + int *byteorder, /* pointer to byteorder to use + 0=native;-1=LE,1=BE; updated on + exit */ + Py_ssize_t *consumed /* bytes consumed */ + ); + +/* Returns a Python string using the UTF-32 encoding in native byte + order. The string always starts with a BOM mark. */ + +PyAPI_FUNC(PyObject*) PyUnicode_AsUTF32String( + PyObject *unicode /* Unicode object */ + ); + +/* Returns a Python string object holding the UTF-32 encoded value of + the Unicode data. + + If byteorder is not 0, output is written according to the following + byte order: + + byteorder == -1: little endian + byteorder == 0: native byte order (writes a BOM mark) + byteorder == 1: big endian + + If byteorder is 0, the output string will always start with the + Unicode BOM mark (U+FEFF). In the other two modes, no BOM mark is + prepended. + +*/ + +#ifndef Py_LIMITED_API +PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF32( + const Py_UNICODE *data, /* Unicode char buffer */ + Py_ssize_t length, /* number of Py_UNICODE chars to encode */ + const char *errors, /* error handling */ + int byteorder /* byteorder to use 0=BOM+native;-1=LE,1=BE */ + ); +PyAPI_FUNC(PyObject*) _PyUnicode_EncodeUTF32( + PyObject *object, /* Unicode object */ + const char *errors, /* error handling */ + int byteorder /* byteorder to use 0=BOM+native;-1=LE,1=BE */ + ); +#endif + +/* --- UTF-16 Codecs ------------------------------------------------------ */ + +/* Decodes length bytes from a UTF-16 encoded buffer string and returns + the corresponding Unicode object. + + errors (if non-NULL) defines the error handling. It defaults + to "strict". + + If byteorder is non-NULL, the decoder starts decoding using the + given byte order: + + *byteorder == -1: little endian + *byteorder == 0: native order + *byteorder == 1: big endian + + In native mode, the first two bytes of the stream are checked for a + BOM mark. If found, the BOM mark is analysed, the byte order + adjusted and the BOM skipped. In the other modes, no BOM mark + interpretation is done. After completion, *byteorder is set to the + current byte order at the end of input data. + + If byteorder is NULL, the codec starts in native order mode. + +*/ + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF16( + const char *string, /* UTF-16 encoded string */ + Py_ssize_t length, /* size of string */ + const char *errors, /* error handling */ + int *byteorder /* pointer to byteorder to use + 0=native;-1=LE,1=BE; updated on + exit */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF16Stateful( + const char *string, /* UTF-16 encoded string */ + Py_ssize_t length, /* size of string */ + const char *errors, /* error handling */ + int *byteorder, /* pointer to byteorder to use + 0=native;-1=LE,1=BE; updated on + exit */ + Py_ssize_t *consumed /* bytes consumed */ + ); + +/* Returns a Python string using the UTF-16 encoding in native byte + order. The string always starts with a BOM mark. */ + +PyAPI_FUNC(PyObject*) PyUnicode_AsUTF16String( + PyObject *unicode /* Unicode object */ + ); + +/* Returns a Python string object holding the UTF-16 encoded value of + the Unicode data. + + If byteorder is not 0, output is written according to the following + byte order: + + byteorder == -1: little endian + byteorder == 0: native byte order (writes a BOM mark) + byteorder == 1: big endian + + If byteorder is 0, the output string will always start with the + Unicode BOM mark (U+FEFF). In the other two modes, no BOM mark is + prepended. + + Note that Py_UNICODE data is being interpreted as UTF-16 reduced to + UCS-2. This trick makes it possible to add full UTF-16 capabilities + at a later point without compromising the APIs. + +*/ + +#ifndef Py_LIMITED_API +PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF16( + const Py_UNICODE *data, /* Unicode char buffer */ + Py_ssize_t length, /* number of Py_UNICODE chars to encode */ + const char *errors, /* error handling */ + int byteorder /* byteorder to use 0=BOM+native;-1=LE,1=BE */ + ); +PyAPI_FUNC(PyObject*) _PyUnicode_EncodeUTF16( + PyObject* unicode, /* Unicode object */ + const char *errors, /* error handling */ + int byteorder /* byteorder to use 0=BOM+native;-1=LE,1=BE */ + ); +#endif + +/* --- Unicode-Escape Codecs ---------------------------------------------- */ + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeUnicodeEscape( + const char *string, /* Unicode-Escape encoded string */ + Py_ssize_t length, /* size of string */ + const char *errors /* error handling */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_AsUnicodeEscapeString( + PyObject *unicode /* Unicode object */ + ); + +#ifndef Py_LIMITED_API +PyAPI_FUNC(PyObject*) PyUnicode_EncodeUnicodeEscape( + const Py_UNICODE *data, /* Unicode char buffer */ + Py_ssize_t length /* Number of Py_UNICODE chars to encode */ + ); +#endif + +/* --- Raw-Unicode-Escape Codecs ------------------------------------------ */ + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeRawUnicodeEscape( + const char *string, /* Raw-Unicode-Escape encoded string */ + Py_ssize_t length, /* size of string */ + const char *errors /* error handling */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_AsRawUnicodeEscapeString( + PyObject *unicode /* Unicode object */ + ); + +#ifndef Py_LIMITED_API +PyAPI_FUNC(PyObject*) PyUnicode_EncodeRawUnicodeEscape( + const Py_UNICODE *data, /* Unicode char buffer */ + Py_ssize_t length /* Number of Py_UNICODE chars to encode */ + ); +#endif + +/* --- Unicode Internal Codec --------------------------------------------- + + Only for internal use in _codecsmodule.c */ + +#ifndef Py_LIMITED_API +PyObject *_PyUnicode_DecodeUnicodeInternal( + const char *string, + Py_ssize_t length, + const char *errors + ); +#endif + +/* --- Latin-1 Codecs ----------------------------------------------------- + + Note: Latin-1 corresponds to the first 256 Unicode ordinals. + +*/ + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeLatin1( + const char *string, /* Latin-1 encoded string */ + Py_ssize_t length, /* size of string */ + const char *errors /* error handling */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_AsLatin1String( + PyObject *unicode /* Unicode object */ + ); + +#ifndef Py_LIMITED_API +PyAPI_FUNC(PyObject*) _PyUnicode_AsLatin1String( + PyObject* unicode, + const char* errors); + +PyAPI_FUNC(PyObject*) PyUnicode_EncodeLatin1( + const Py_UNICODE *data, /* Unicode char buffer */ + Py_ssize_t length, /* Number of Py_UNICODE chars to encode */ + const char *errors /* error handling */ + ); +#endif + +/* --- ASCII Codecs ------------------------------------------------------- + + Only 7-bit ASCII data is excepted. All other codes generate errors. + +*/ + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeASCII( + const char *string, /* ASCII encoded string */ + Py_ssize_t length, /* size of string */ + const char *errors /* error handling */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_AsASCIIString( + PyObject *unicode /* Unicode object */ + ); + +#ifndef Py_LIMITED_API +PyAPI_FUNC(PyObject*) _PyUnicode_AsASCIIString( + PyObject* unicode, + const char* errors); + +PyAPI_FUNC(PyObject*) PyUnicode_EncodeASCII( + const Py_UNICODE *data, /* Unicode char buffer */ + Py_ssize_t length, /* Number of Py_UNICODE chars to encode */ + const char *errors /* error handling */ + ); +#endif + +/* --- Character Map Codecs ----------------------------------------------- + + This codec uses mappings to encode and decode characters. + + Decoding mappings must map single string characters to single + Unicode characters, integers (which are then interpreted as Unicode + ordinals) or None (meaning "undefined mapping" and causing an + error). + + Encoding mappings must map single Unicode characters to single + string characters, integers (which are then interpreted as Latin-1 + ordinals) or None (meaning "undefined mapping" and causing an + error). + + If a character lookup fails with a LookupError, the character is + copied as-is meaning that its ordinal value will be interpreted as + Unicode or Latin-1 ordinal resp. Because of this mappings only need + to contain those mappings which map characters to different code + points. + +*/ + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeCharmap( + const char *string, /* Encoded string */ + Py_ssize_t length, /* size of string */ + PyObject *mapping, /* character mapping + (char ordinal -> unicode ordinal) */ + const char *errors /* error handling */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_AsCharmapString( + PyObject *unicode, /* Unicode object */ + PyObject *mapping /* character mapping + (unicode ordinal -> char ordinal) */ + ); + +#ifndef Py_LIMITED_API +PyAPI_FUNC(PyObject*) PyUnicode_EncodeCharmap( + const Py_UNICODE *data, /* Unicode char buffer */ + Py_ssize_t length, /* Number of Py_UNICODE chars to encode */ + PyObject *mapping, /* character mapping + (unicode ordinal -> char ordinal) */ + const char *errors /* error handling */ + ); +PyAPI_FUNC(PyObject*) _PyUnicode_EncodeCharmap( + PyObject *unicode, /* Unicode object */ + PyObject *mapping, /* character mapping + (unicode ordinal -> char ordinal) */ + const char *errors /* error handling */ + ); +#endif + +/* Translate a Py_UNICODE buffer of the given length by applying a + character mapping table to it and return the resulting Unicode + object. + + The mapping table must map Unicode ordinal integers to Unicode + ordinal integers or None (causing deletion of the character). + + Mapping tables may be dictionaries or sequences. Unmapped character + ordinals (ones which cause a LookupError) are left untouched and + are copied as-is. + +*/ + +#ifndef Py_LIMITED_API +PyAPI_FUNC(PyObject *) PyUnicode_TranslateCharmap( + const Py_UNICODE *data, /* Unicode char buffer */ + Py_ssize_t length, /* Number of Py_UNICODE chars to encode */ + PyObject *table, /* Translate table */ + const char *errors /* error handling */ + ); +#endif + +#ifdef HAVE_MBCS + +/* --- MBCS codecs for Windows -------------------------------------------- */ + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeMBCS( + const char *string, /* MBCS encoded string */ + Py_ssize_t length, /* size of string */ + const char *errors /* error handling */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeMBCSStateful( + const char *string, /* MBCS encoded string */ + Py_ssize_t length, /* size of string */ + const char *errors, /* error handling */ + Py_ssize_t *consumed /* bytes consumed */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeCodePageStateful( + int code_page, /* code page number */ + const char *string, /* encoded string */ + Py_ssize_t length, /* size of string */ + const char *errors, /* error handling */ + Py_ssize_t *consumed /* bytes consumed */ + ); + +PyAPI_FUNC(PyObject*) PyUnicode_AsMBCSString( + PyObject *unicode /* Unicode object */ + ); + +#ifndef Py_LIMITED_API +PyAPI_FUNC(PyObject*) PyUnicode_EncodeMBCS( + const Py_UNICODE *data, /* Unicode char buffer */ + Py_ssize_t length, /* number of Py_UNICODE chars to encode */ + const char *errors /* error handling */ + ); +#endif + +PyAPI_FUNC(PyObject*) PyUnicode_EncodeCodePage( + int code_page, /* code page number */ + PyObject *unicode, /* Unicode object */ + const char *errors /* error handling */ + ); + +#endif /* HAVE_MBCS */ + +/* --- Decimal Encoder ---------------------------------------------------- */ + +/* Takes a Unicode string holding a decimal value and writes it into + an output buffer using standard ASCII digit codes. + + The output buffer has to provide at least length+1 bytes of storage + area. The output string is 0-terminated. + + The encoder converts whitespace to ' ', decimal characters to their + corresponding ASCII digit and all other Latin-1 characters except + \0 as-is. Characters outside this range (Unicode ordinals 1-256) + are treated as errors. This includes embedded NULL bytes. + + Error handling is defined by the errors argument: + + NULL or "strict": raise a ValueError + "ignore": ignore the wrong characters (these are not copied to the + output buffer) + "replace": replaces illegal characters with '?' + + Returns 0 on success, -1 on failure. + +*/ + +#ifndef Py_LIMITED_API +PyAPI_FUNC(int) PyUnicode_EncodeDecimal( + Py_UNICODE *s, /* Unicode buffer */ + Py_ssize_t length, /* Number of Py_UNICODE chars to encode */ + char *output, /* Output buffer; must have size >= length */ + const char *errors /* error handling */ + ); +#endif + +/* Transforms code points that have decimal digit property to the + corresponding ASCII digit code points. + + Returns a new Unicode string on success, NULL on failure. +*/ + +#ifndef Py_LIMITED_API +PyAPI_FUNC(PyObject*) PyUnicode_TransformDecimalToASCII( + Py_UNICODE *s, /* Unicode buffer */ + Py_ssize_t length /* Number of Py_UNICODE chars to transform */ + ); +#endif + +/* Similar to PyUnicode_TransformDecimalToASCII(), but takes a PyObject + as argument instead of a raw buffer and length. This function additionally + transforms spaces to ASCII because this is what the callers in longobject, + floatobject, and complexobject did anyways. */ + +#ifndef Py_LIMITED_API +PyAPI_FUNC(PyObject*) _PyUnicode_TransformDecimalAndSpaceToASCII( + PyObject *unicode /* Unicode object */ + ); +#endif + +/* --- Locale encoding --------------------------------------------------- */ + +/* Decode a string from the current locale encoding. The decoder is strict if + *surrogateescape* is equal to zero, otherwise it uses the 'surrogateescape' + error handler (PEP 383) to escape undecodable bytes. If a byte sequence can + be decoded as a surrogate character and *surrogateescape* is not equal to + zero, the byte sequence is escaped using the 'surrogateescape' error handler + instead of being decoded. *str* must end with a null character but cannot + contain embedded null characters. */ + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeLocaleAndSize( + const char *str, + Py_ssize_t len, + const char *errors); + +/* Similar to PyUnicode_DecodeLocaleAndSize(), but compute the string + length using strlen(). */ + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeLocale( + const char *str, + const char *errors); + +/* Encode a Unicode object to the current locale encoding. The encoder is + strict is *surrogateescape* is equal to zero, otherwise the + "surrogateescape" error handler is used. Return a bytes object. The string + cannot contain embedded null characters. */ + +PyAPI_FUNC(PyObject*) PyUnicode_EncodeLocale( + PyObject *unicode, + const char *errors + ); + +/* --- File system encoding ---------------------------------------------- */ + +/* ParseTuple converter: encode str objects to bytes using + PyUnicode_EncodeFSDefault(); bytes objects are output as-is. */ + +PyAPI_FUNC(int) PyUnicode_FSConverter(PyObject*, void*); + +/* ParseTuple converter: decode bytes objects to unicode using + PyUnicode_DecodeFSDefaultAndSize(); str objects are output as-is. */ + +PyAPI_FUNC(int) PyUnicode_FSDecoder(PyObject*, void*); + +/* Decode a null-terminated string using Py_FileSystemDefaultEncoding + and the "surrogateescape" error handler. + + If Py_FileSystemDefaultEncoding is not set, fall back to the locale + encoding. + + Use PyUnicode_DecodeFSDefaultAndSize() if the string length is known. +*/ + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeFSDefault( + const char *s /* encoded string */ + ); + +/* Decode a string using Py_FileSystemDefaultEncoding + and the "surrogateescape" error handler. + + If Py_FileSystemDefaultEncoding is not set, fall back to the locale + encoding. +*/ + +PyAPI_FUNC(PyObject*) PyUnicode_DecodeFSDefaultAndSize( + const char *s, /* encoded string */ + Py_ssize_t size /* size */ + ); + +/* Encode a Unicode object to Py_FileSystemDefaultEncoding with the + "surrogateescape" error handler, and return bytes. + + If Py_FileSystemDefaultEncoding is not set, fall back to the locale + encoding. +*/ + +PyAPI_FUNC(PyObject*) PyUnicode_EncodeFSDefault( + PyObject *unicode + ); + +/* --- Methods & Slots ---------------------------------------------------- + + These are capable of handling Unicode objects and strings on input + (we refer to them as strings in the descriptions) and return + Unicode objects or integers as appropriate. */ + +/* Concat two strings giving a new Unicode string. */ + +PyAPI_FUNC(PyObject*) PyUnicode_Concat( + PyObject *left, /* Left string */ + PyObject *right /* Right string */ + ); + +/* Concat two strings and put the result in *pleft + (sets *pleft to NULL on error) */ + +PyAPI_FUNC(void) PyUnicode_Append( + PyObject **pleft, /* Pointer to left string */ + PyObject *right /* Right string */ + ); + +/* Concat two strings, put the result in *pleft and drop the right object + (sets *pleft to NULL on error) */ + +PyAPI_FUNC(void) PyUnicode_AppendAndDel( + PyObject **pleft, /* Pointer to left string */ + PyObject *right /* Right string */ + ); + +/* Split a string giving a list of Unicode strings. + + If sep is NULL, splitting will be done at all whitespace + substrings. Otherwise, splits occur at the given separator. + + At most maxsplit splits will be done. If negative, no limit is set. + + Separators are not included in the resulting list. + +*/ + +PyAPI_FUNC(PyObject*) PyUnicode_Split( + PyObject *s, /* String to split */ + PyObject *sep, /* String separator */ + Py_ssize_t maxsplit /* Maxsplit count */ + ); + +/* Dito, but split at line breaks. + + CRLF is considered to be one line break. Line breaks are not + included in the resulting list. */ + +PyAPI_FUNC(PyObject*) PyUnicode_Splitlines( + PyObject *s, /* String to split */ + int keepends /* If true, line end markers are included */ + ); + +/* Partition a string using a given separator. */ + +PyAPI_FUNC(PyObject*) PyUnicode_Partition( + PyObject *s, /* String to partition */ + PyObject *sep /* String separator */ + ); + +/* Partition a string using a given separator, searching from the end of the + string. */ + +PyAPI_FUNC(PyObject*) PyUnicode_RPartition( + PyObject *s, /* String to partition */ + PyObject *sep /* String separator */ + ); + +/* Split a string giving a list of Unicode strings. + + If sep is NULL, splitting will be done at all whitespace + substrings. Otherwise, splits occur at the given separator. + + At most maxsplit splits will be done. But unlike PyUnicode_Split + PyUnicode_RSplit splits from the end of the string. If negative, + no limit is set. + + Separators are not included in the resulting list. + +*/ + +PyAPI_FUNC(PyObject*) PyUnicode_RSplit( + PyObject *s, /* String to split */ + PyObject *sep, /* String separator */ + Py_ssize_t maxsplit /* Maxsplit count */ + ); + +/* Translate a string by applying a character mapping table to it and + return the resulting Unicode object. + + The mapping table must map Unicode ordinal integers to Unicode + ordinal integers or None (causing deletion of the character). + + Mapping tables may be dictionaries or sequences. Unmapped character + ordinals (ones which cause a LookupError) are left untouched and + are copied as-is. + +*/ + +PyAPI_FUNC(PyObject *) PyUnicode_Translate( + PyObject *str, /* String */ + PyObject *table, /* Translate table */ + const char *errors /* error handling */ + ); + +/* Join a sequence of strings using the given separator and return + the resulting Unicode string. */ + +PyAPI_FUNC(PyObject*) PyUnicode_Join( + PyObject *separator, /* Separator string */ + PyObject *seq /* Sequence object */ + ); + +/* Return 1 if substr matches str[start:end] at the given tail end, 0 + otherwise. */ + +PyAPI_FUNC(Py_ssize_t) PyUnicode_Tailmatch( + PyObject *str, /* String */ + PyObject *substr, /* Prefix or Suffix string */ + Py_ssize_t start, /* Start index */ + Py_ssize_t end, /* Stop index */ + int direction /* Tail end: -1 prefix, +1 suffix */ + ); + +/* Return the first position of substr in str[start:end] using the + given search direction or -1 if not found. -2 is returned in case + an error occurred and an exception is set. */ + +PyAPI_FUNC(Py_ssize_t) PyUnicode_Find( + PyObject *str, /* String */ + PyObject *substr, /* Substring to find */ + Py_ssize_t start, /* Start index */ + Py_ssize_t end, /* Stop index */ + int direction /* Find direction: +1 forward, -1 backward */ + ); + +/* Like PyUnicode_Find, but search for single character only. */ +PyAPI_FUNC(Py_ssize_t) PyUnicode_FindChar( + PyObject *str, + Py_UCS4 ch, + Py_ssize_t start, + Py_ssize_t end, + int direction + ); + +/* Count the number of occurrences of substr in str[start:end]. */ + +PyAPI_FUNC(Py_ssize_t) PyUnicode_Count( + PyObject *str, /* String */ + PyObject *substr, /* Substring to count */ + Py_ssize_t start, /* Start index */ + Py_ssize_t end /* Stop index */ + ); + +/* Replace at most maxcount occurrences of substr in str with replstr + and return the resulting Unicode object. */ + +PyAPI_FUNC(PyObject *) PyUnicode_Replace( + PyObject *str, /* String */ + PyObject *substr, /* Substring to find */ + PyObject *replstr, /* Substring to replace */ + Py_ssize_t maxcount /* Max. number of replacements to apply; + -1 = all */ + ); + +/* Compare two strings and return -1, 0, 1 for less than, equal, + greater than resp. + Raise an exception and return -1 on error. */ + +PyAPI_FUNC(int) PyUnicode_Compare( + PyObject *left, /* Left string */ + PyObject *right /* Right string */ + ); + +#ifndef Py_LIMITED_API +PyAPI_FUNC(int) _PyUnicode_CompareWithId( + PyObject *left, /* Left string */ + _Py_Identifier *right /* Right identifier */ + ); +#endif + +PyAPI_FUNC(int) PyUnicode_CompareWithASCIIString( + PyObject *left, + const char *right /* ASCII-encoded string */ + ); + +/* Rich compare two strings and return one of the following: + + - NULL in case an exception was raised + - Py_True or Py_False for successfully comparisons + - Py_NotImplemented in case the type combination is unknown + + Note that Py_EQ and Py_NE comparisons can cause a UnicodeWarning in + case the conversion of the arguments to Unicode fails with a + UnicodeDecodeError. + + Possible values for op: + + Py_GT, Py_GE, Py_EQ, Py_NE, Py_LT, Py_LE + +*/ + +PyAPI_FUNC(PyObject *) PyUnicode_RichCompare( + PyObject *left, /* Left string */ + PyObject *right, /* Right string */ + int op /* Operation: Py_EQ, Py_NE, Py_GT, etc. */ + ); + +/* Apply a argument tuple or dictionary to a format string and return + the resulting Unicode string. */ + +PyAPI_FUNC(PyObject *) PyUnicode_Format( + PyObject *format, /* Format string */ + PyObject *args /* Argument tuple or dictionary */ + ); + +/* Checks whether element is contained in container and return 1/0 + accordingly. + + element has to coerce to an one element Unicode string. -1 is + returned in case of an error. */ + +PyAPI_FUNC(int) PyUnicode_Contains( + PyObject *container, /* Container string */ + PyObject *element /* Element string */ + ); + +/* Checks whether argument is a valid identifier. */ + +PyAPI_FUNC(int) PyUnicode_IsIdentifier(PyObject *s); + +#ifndef Py_LIMITED_API +/* Externally visible for str.strip(unicode) */ +PyAPI_FUNC(PyObject *) _PyUnicode_XStrip( + PyObject *self, + int striptype, + PyObject *sepobj + ); +#endif + +/* Using explicit passed-in values, insert the thousands grouping + into the string pointed to by buffer. For the argument descriptions, + see Objects/stringlib/localeutil.h */ +#ifndef Py_LIMITED_API +PyAPI_FUNC(Py_ssize_t) _PyUnicode_InsertThousandsGrouping( + PyObject *unicode, + Py_ssize_t index, + Py_ssize_t n_buffer, + void *digits, + Py_ssize_t n_digits, + Py_ssize_t min_width, + const char *grouping, + PyObject *thousands_sep, + Py_UCS4 *maxchar); +#endif +/* === Characters Type APIs =============================================== */ + +/* Helper array used by Py_UNICODE_ISSPACE(). */ + +#ifndef Py_LIMITED_API +PyAPI_DATA(const unsigned char) _Py_ascii_whitespace[]; + +/* These should not be used directly. Use the Py_UNICODE_IS* and + Py_UNICODE_TO* macros instead. + + These APIs are implemented in Objects/unicodectype.c. + +*/ + +PyAPI_FUNC(int) _PyUnicode_IsLowercase( + Py_UCS4 ch /* Unicode character */ + ); + +PyAPI_FUNC(int) _PyUnicode_IsUppercase( + Py_UCS4 ch /* Unicode character */ + ); + +PyAPI_FUNC(int) _PyUnicode_IsTitlecase( + Py_UCS4 ch /* Unicode character */ + ); + +PyAPI_FUNC(int) _PyUnicode_IsXidStart( + Py_UCS4 ch /* Unicode character */ + ); + +PyAPI_FUNC(int) _PyUnicode_IsXidContinue( + Py_UCS4 ch /* Unicode character */ + ); + +PyAPI_FUNC(int) _PyUnicode_IsWhitespace( + const Py_UCS4 ch /* Unicode character */ + ); + +PyAPI_FUNC(int) _PyUnicode_IsLinebreak( + const Py_UCS4 ch /* Unicode character */ + ); + +PyAPI_FUNC(Py_UCS4) _PyUnicode_ToLowercase( + Py_UCS4 ch /* Unicode character */ + ); + +PyAPI_FUNC(Py_UCS4) _PyUnicode_ToUppercase( + Py_UCS4 ch /* Unicode character */ + ); + +PyAPI_FUNC(Py_UCS4) _PyUnicode_ToTitlecase( + Py_UCS4 ch /* Unicode character */ + ); + +PyAPI_FUNC(int) _PyUnicode_ToLowerFull( + Py_UCS4 ch, /* Unicode character */ + Py_UCS4 *res + ); + +PyAPI_FUNC(int) _PyUnicode_ToTitleFull( + Py_UCS4 ch, /* Unicode character */ + Py_UCS4 *res + ); + +PyAPI_FUNC(int) _PyUnicode_ToUpperFull( + Py_UCS4 ch, /* Unicode character */ + Py_UCS4 *res + ); + +PyAPI_FUNC(int) _PyUnicode_ToFoldedFull( + Py_UCS4 ch, /* Unicode character */ + Py_UCS4 *res + ); + +PyAPI_FUNC(int) _PyUnicode_IsCaseIgnorable( + Py_UCS4 ch /* Unicode character */ + ); + +PyAPI_FUNC(int) _PyUnicode_IsCased( + Py_UCS4 ch /* Unicode character */ + ); + +PyAPI_FUNC(int) _PyUnicode_ToDecimalDigit( + Py_UCS4 ch /* Unicode character */ + ); + +PyAPI_FUNC(int) _PyUnicode_ToDigit( + Py_UCS4 ch /* Unicode character */ + ); + +PyAPI_FUNC(double) _PyUnicode_ToNumeric( + Py_UCS4 ch /* Unicode character */ + ); + +PyAPI_FUNC(int) _PyUnicode_IsDecimalDigit( + Py_UCS4 ch /* Unicode character */ + ); + +PyAPI_FUNC(int) _PyUnicode_IsDigit( + Py_UCS4 ch /* Unicode character */ + ); + +PyAPI_FUNC(int) _PyUnicode_IsNumeric( + Py_UCS4 ch /* Unicode character */ + ); + +PyAPI_FUNC(int) _PyUnicode_IsPrintable( + Py_UCS4 ch /* Unicode character */ + ); + +PyAPI_FUNC(int) _PyUnicode_IsAlpha( + Py_UCS4 ch /* Unicode character */ + ); + +PyAPI_FUNC(size_t) Py_UNICODE_strlen( + const Py_UNICODE *u + ); + +PyAPI_FUNC(Py_UNICODE*) Py_UNICODE_strcpy( + Py_UNICODE *s1, + const Py_UNICODE *s2); + +PyAPI_FUNC(Py_UNICODE*) Py_UNICODE_strcat( + Py_UNICODE *s1, const Py_UNICODE *s2); + +PyAPI_FUNC(Py_UNICODE*) Py_UNICODE_strncpy( + Py_UNICODE *s1, + const Py_UNICODE *s2, + size_t n); + +PyAPI_FUNC(int) Py_UNICODE_strcmp( + const Py_UNICODE *s1, + const Py_UNICODE *s2 + ); + +PyAPI_FUNC(int) Py_UNICODE_strncmp( + const Py_UNICODE *s1, + const Py_UNICODE *s2, + size_t n + ); + +PyAPI_FUNC(Py_UNICODE*) Py_UNICODE_strchr( + const Py_UNICODE *s, + Py_UNICODE c + ); + +PyAPI_FUNC(Py_UNICODE*) Py_UNICODE_strrchr( + const Py_UNICODE *s, + Py_UNICODE c + ); + +PyAPI_FUNC(PyObject*) _PyUnicode_FormatLong(PyObject *, int, int, int); + +/* Create a copy of a unicode string ending with a nul character. Return NULL + and raise a MemoryError exception on memory allocation failure, otherwise + return a new allocated buffer (use PyMem_Free() to free the buffer). */ + +PyAPI_FUNC(Py_UNICODE*) PyUnicode_AsUnicodeCopy( + PyObject *unicode + ); +#endif /* Py_LIMITED_API */ + +#if defined(Py_DEBUG) && !defined(Py_LIMITED_API) +PyAPI_FUNC(int) _PyUnicode_CheckConsistency( + PyObject *op, + int check_content); +#endif + +/* Return an interned Unicode object for an Identifier; may fail if there is no memory.*/ +PyAPI_FUNC(PyObject*) _PyUnicode_FromId(_Py_Identifier*); +/* Clear all static strings. */ +PyAPI_FUNC(void) _PyUnicode_ClearStaticStrings(void); + +#ifdef __cplusplus +} +#endif +#endif /* !Py_UNICODEOBJECT_H */ diff --git a/android/python35/include/warnings.h b/android/python35/include/warnings.h new file mode 100644 index 000000000..effb9fad7 --- /dev/null +++ b/android/python35/include/warnings.h @@ -0,0 +1,54 @@ +#ifndef Py_WARNINGS_H +#define Py_WARNINGS_H +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef Py_LIMITED_API +PyAPI_FUNC(PyObject*) _PyWarnings_Init(void); +#endif + +PyAPI_FUNC(int) PyErr_WarnEx( + PyObject *category, + const char *message, /* UTF-8 encoded string */ + Py_ssize_t stack_level); +PyAPI_FUNC(int) PyErr_WarnFormat( + PyObject *category, + Py_ssize_t stack_level, + const char *format, /* ASCII-encoded string */ + ...); +#ifndef Py_LIMITED_API +PyAPI_FUNC(int) PyErr_WarnExplicitObject( + PyObject *category, + PyObject *message, + PyObject *filename, + int lineno, + PyObject *module, + PyObject *registry); +#endif +PyAPI_FUNC(int) PyErr_WarnExplicit( + PyObject *category, + const char *message, /* UTF-8 encoded string */ + const char *filename, /* decoded from the filesystem encoding */ + int lineno, + const char *module, /* UTF-8 encoded string */ + PyObject *registry); + +#ifndef Py_LIMITED_API +PyAPI_FUNC(int) +PyErr_WarnExplicitFormat(PyObject *category, + const char *filename, int lineno, + const char *module, PyObject *registry, + const char *format, ...); +#endif + +/* DEPRECATED: Use PyErr_WarnEx() instead. */ +#ifndef Py_LIMITED_API +#define PyErr_Warn(category, msg) PyErr_WarnEx(category, msg, 1) +#endif + +#ifdef __cplusplus +} +#endif +#endif /* !Py_WARNINGS_H */ + diff --git a/android/python35/include/weakrefobject.h b/android/python35/include/weakrefobject.h new file mode 100644 index 000000000..17051568f --- /dev/null +++ b/android/python35/include/weakrefobject.h @@ -0,0 +1,86 @@ +/* Weak references objects for Python. */ + +#ifndef Py_WEAKREFOBJECT_H +#define Py_WEAKREFOBJECT_H +#ifdef __cplusplus +extern "C" { +#endif + + +typedef struct _PyWeakReference PyWeakReference; + +/* PyWeakReference is the base struct for the Python ReferenceType, ProxyType, + * and CallableProxyType. + */ +#ifndef Py_LIMITED_API +struct _PyWeakReference { + PyObject_HEAD + + /* The object to which this is a weak reference, or Py_None if none. + * Note that this is a stealth reference: wr_object's refcount is + * not incremented to reflect this pointer. + */ + PyObject *wr_object; + + /* A callable to invoke when wr_object dies, or NULL if none. */ + PyObject *wr_callback; + + /* A cache for wr_object's hash code. As usual for hashes, this is -1 + * if the hash code isn't known yet. + */ + Py_hash_t hash; + + /* If wr_object is weakly referenced, wr_object has a doubly-linked NULL- + * terminated list of weak references to it. These are the list pointers. + * If wr_object goes away, wr_object is set to Py_None, and these pointers + * have no meaning then. + */ + PyWeakReference *wr_prev; + PyWeakReference *wr_next; +}; +#endif + +PyAPI_DATA(PyTypeObject) _PyWeakref_RefType; +PyAPI_DATA(PyTypeObject) _PyWeakref_ProxyType; +PyAPI_DATA(PyTypeObject) _PyWeakref_CallableProxyType; + +#define PyWeakref_CheckRef(op) PyObject_TypeCheck(op, &_PyWeakref_RefType) +#define PyWeakref_CheckRefExact(op) \ + (Py_TYPE(op) == &_PyWeakref_RefType) +#define PyWeakref_CheckProxy(op) \ + ((Py_TYPE(op) == &_PyWeakref_ProxyType) || \ + (Py_TYPE(op) == &_PyWeakref_CallableProxyType)) + +#define PyWeakref_Check(op) \ + (PyWeakref_CheckRef(op) || PyWeakref_CheckProxy(op)) + + +PyAPI_FUNC(PyObject *) PyWeakref_NewRef(PyObject *ob, + PyObject *callback); +PyAPI_FUNC(PyObject *) PyWeakref_NewProxy(PyObject *ob, + PyObject *callback); +PyAPI_FUNC(PyObject *) PyWeakref_GetObject(PyObject *ref); + +#ifndef Py_LIMITED_API +PyAPI_FUNC(Py_ssize_t) _PyWeakref_GetWeakrefCount(PyWeakReference *head); + +PyAPI_FUNC(void) _PyWeakref_ClearRef(PyWeakReference *self); +#endif + +/* Explanation for the Py_REFCNT() check: when a weakref's target is part + of a long chain of deallocations which triggers the trashcan mechanism, + clearing the weakrefs can be delayed long after the target's refcount + has dropped to zero. In the meantime, code accessing the weakref will + be able to "see" the target object even though it is supposed to be + unreachable. See issue #16602. */ + +#define PyWeakref_GET_OBJECT(ref) \ + (Py_REFCNT(((PyWeakReference *)(ref))->wr_object) > 0 \ + ? ((PyWeakReference *)(ref))->wr_object \ + : Py_None) + + +#ifdef __cplusplus +} +#endif +#endif /* !Py_WEAKREFOBJECT_H */ diff --git a/android/python35/stdlib.zip b/android/python35/stdlib.zip new file mode 100644 index 000000000..7afc6e4c9 Binary files /dev/null and b/android/python35/stdlib.zip differ diff --git a/docs/Android.md b/docs/Android.md new file mode 100644 index 000000000..67b3e36d3 --- /dev/null +++ b/docs/Android.md @@ -0,0 +1,69 @@ +# Deploying on Android devices + +Starting from release 20180723 and engine 4.20 you can deploy the UnrealEnginePython plugin on android devices (both for launching and for packaging). + +The python distribution is the one from the "Crystax NDK" project (https://www.crystax.net/android/ndk), but you do not need to download it as this repository +already contains the required shared libraries and headers as well as the the python standard lib compressed in a zip file: + +https://github.com/20tab/UnrealEnginePython/tree/master/android/armeabi-v7a + +https://github.com/20tab/UnrealEnginePython/tree/master/android/python35 + +Albeit the repository contains the files for python2.7, currently the only supported release is the 3.5. + +Obviously you need UnrealEnginePython source distribution to rebuild the plugin for Android. + +## The First Project + +I am assuming your project is already deployable on Android and now you want to add a simple Python Component to one of its Character: + +```python +import unreal_engine as ue + +class AutoJump: + + def begin_play(self): + self.timer = self.uobject.set_timer(3, self.jump, True) + + def jump(self): + self.uobject.get_owner().Jump() +``` + +Once the script works in the editor you need to prepare your environment to be android-friendly. + +The first step is configuring the packaging system to include the /Content/Scripts directory (where you have your python files, currently the one you created before for your Character): + +![android_packaging](https://github.com/20tab/UnrealEnginePython/raw/master/docs/android_packaging.png) + +just add the Scripts directory as a new item in the "Additional Non Assets Directories to Copy". + +Finally get https://github.com/20tab/UnrealEnginePython/blob/master/android/python35/stdlib.zip and copy into the Scripts directory. + +This is the python standard library required by libpython to correctly bootstrap itself. (DO NOT FORGET THIS STEP, WITHOUT IT YOUR ANDROID APP WILL RUN BUT CRASHES AFTER THE SPLASH SCREEN). + +The stdlib.zip filename is hardcoded, so do not rename it (unless you want to modify UnrealEnginePython sources). + +Now you can Launch your project over the Android device. + +Before launching the UnrealEnginePython plugin will be built for the arm architecture, then an apk will be uploaded as well as your Content directory. If all goes wall you should see your Character auto-jumping in the Android device. + +## Packaging + +Packaging is a bit more complex as Unreal generates a fake .obb file along the .apk file. + +This .obb file is a simple .zip file containing the .pak file as well as your Scripts directory. As this is not a true android .obb file, we cannot mount it as a filesystem (using the android StorageManager api) so we need to treat it as a simple zip file. + +Lucky enough, python supports getting modules from a zip file, so just adding the .obb file to its modules search path will be more than enough (the UnrealEnginePython plugin does it automatically). + +The problem is that python does not support zip files into zip files (stdlib.zip is into the .obb file) so to allow packaged games to run we need to decompress stdlib.zip in the Scripts directory. This will result in our Scripts directory being clobbered with additional .py files (feel free to propose better solutions). + +Once the stdlib.zip file is decompressed you can package your project and upload it to the device. + +## Note + +Try to use python 3.5 even for the editor, otherwise the files extracted from stdlib.zip could cause problems (the SRE exception is the first you should get in such a case) + +Python 3.6, albeit not tested, should work. + +Any python 3 release built from the Crystax NDK should work too. Just compile it, copy the related files into the repository android/ directory and change https://github.com/20tab/UnrealEnginePython/blob/master/Source/UnrealEnginePython/UnrealEnginePython_APL.xml and +https://github.com/20tab/UnrealEnginePython/blob/master/Source/UnrealEnginePython/UnrealEnginePython.Build.cs accordingly. diff --git a/docs/Animation_API.md b/docs/Animation_API.md index a09036209..86472ac2c 100644 --- a/docs/Animation_API.md +++ b/docs/Animation_API.md @@ -4,8 +4,11 @@ You can control animation blueprints variables and events easily: ```py + +from unreal_engine.classes import SkeletalMeshComponent + # get a reference to the skeletal mesh -skeletal = self.uobject.get_component_by_type('SkeletalMeshComponent') +skeletal = self.uobject.get_component_by_type(SkeletalMeshComponent) # get a reference to the animation class animation = skeletal.get_anim_instance() diff --git a/docs/Audio_API.md b/docs/Audio_API.md index a7037e166..95d5665d4 100644 --- a/docs/Audio_API.md +++ b/docs/Audio_API.md @@ -12,10 +12,12 @@ self.uobject.play_sound_at_location(sound, FVector(0, 0, 0)) If you prefer to work with AudioComponent: ```py +from unreal_engine.classes import AudioComponent + class Sounder: def begin_play(self): # find the AudioComponent of this actor - self.audio = self.uobject.get_component_by_type('AudioComponent') + self.audio = self.uobject.get_component_by_type(AudioComponent) self.audio.call('Stop') def tick(self, delta_time): # start the sound when pressing 'A' diff --git a/docs/Foliage_API.md b/docs/Foliage_API.md index 2893045f6..e7e5ac5de 100644 --- a/docs/Foliage_API.md +++ b/docs/Foliage_API.md @@ -38,3 +38,24 @@ You can get a reference to the AInstancedFoliageActor of a world using: ```python foliage_actor = world.get_instanced_foliage_actor_for_current_level() ``` + +## Iterating instances + +You can get a FFoliageInstance struct for each instance (grouped by UFoliageType): + +```python +import unreal_engine as ue + +foliage_actor = ue.get_editor_world().get_instanced_foliage_actor_for_current_level() + +for foliage_type in foliage_actor.get_foliage_types(): + print('Foliage Type: {0}'.format(foliage_type.get_name())) + for foliage_instance in foliage_actor.get_foliage_instances(foliage_type): + print(foliage_instance.location) + print(foliage_instance.draw_scale3d) + print(foliage_instance.pre_align_rotation) + print(foliage_instance.rotation) + print(foliage_instance.flags) + print(foliage_instance.zoffset) + print('*' * 20) +``` diff --git a/docs/ManagingAssets.md b/docs/ManagingAssets.md index 47f6ece72..f93ee3c0f 100644 --- a/docs/ManagingAssets.md +++ b/docs/ManagingAssets.md @@ -63,13 +63,21 @@ materials = ue.get_assets_by_class('Material') Moving/Renaming assets - -The rename_asset() function allows you to change the package and object name of an asset: +The rename_asset() function allows you to change the name of an asset: ```python -ue.rename_asset('/Game/Materials/Mat001.Foobar', '/Game/NewMaterials/Mat001', 'FooBarUpdated') +ue.rename_asset('/Game/Materials/Mat001.Foobar', 'FooBarUpdated') ``` -this will result in the /Game/NewMaterials/Mat001.FooBarUpdated asset. Beware, as the unreal editor retain the so called 'Redirector Object' that is basically a reference to the original object, so you will not be able to re-use the old name until you reload the editor. +this will result in the /Game/Materials/FooBarUpdated.FooBarUpdated asset. Beware, as the unreal editor retain the so called 'Redirector Object' that is basically a reference to the original object, so you will not be able to re-use the old name until you reload the editor. + +If you specify a full path as the destination, you can 'move' the asset: + +```python +ue.rename_asset('/Game/Materials/Mat001.Foobar', '/Game/Ops/FooBarUpdated') +``` + +will results in /Game/Ops/FooBarUpdated.FooBarUpdated asset Duplicating assets - @@ -154,6 +162,27 @@ if asset002.asset_can_reimport(): asset002.asset_reimport() ``` +The signature of asset_reimport() is the following: + +```python +success = asset_reimport(open_file_dialog, report_dialog, filename_to_import) +``` + +open_file_dialog will trigger an open file widget for selecting the file to import if the object has no file mapped to it. + +report_dialog will show the notify widget reporting the status of the operation + +filename_to_import allows you to specify which file to import for the asset + +The function returns a boolean value + +You can programmatically change the filename assigned to an asset in this way: + +```python +mesh.asset_import_data_set_sources('D:/sword.fbx') +``` + + Creating Assets - diff --git a/docs/Material_API.md b/docs/Material_API.md index ec5909798..c802beca0 100644 --- a/docs/Material_API.md +++ b/docs/Material_API.md @@ -54,9 +54,9 @@ You have two ways to create a instanced material: (new_material is a reference to a previously created/loaded material) ```python -from unreal_engine.classes import MaterialInstancedConstant +from unreal_engine.classes import MaterialInstanceConstant -material_instance = MaterialInstancedConstant() +material_instance = MaterialInstanceConstant() material_instance.set_name('New Funny Material Instance') material_instance.set_material_parent(new_material) material_instance.save_package('/Game/Materials/instanced') diff --git a/docs/MemoryManagement.md b/docs/MemoryManagement.md new file mode 100644 index 000000000..fe02f0bd7 --- /dev/null +++ b/docs/MemoryManagement.md @@ -0,0 +1,249 @@ +# Managing Memory + +## UObject + +A UObject is one of the fundamental parts of Unreal Engine. It represents an engine/editor object tracked by Unreal Engine Garbage Collector. + +Each UObject is constantly tracked, and whenever the Garbage Collector runs (generally every 60 seconds or in very specific parts of the engine/editor loop, like when entering PIE mode) +it checks if the UObject has still references to other UObjects, and in negative case (no references) it will be destroyed. + +You can trigger a Garbage Collector run from python with: + +```python +import unreal_engine as ue +ue.console_exec('obj gc') +``` + +## py_UEObject + +this is the low-level C struct representing the python mapping between a PyObject (c struct representing a python object) and a UObject. +Whenever you create a py_UEObject (from the UE python api) another GC (related to the python plugin) will start tracking it. + +Whenever the UE GC runs, the UnrealEnginePython GC will run too, checking if a UObject mapped to a py_UEObject is still alive. + +If the UObject mapped to a python object is dead, an exception will be triggered. + +This is an example: + +```python +import unreal_engine as ue + +from unreal_engine.classes import BlueprintFactory + +factory = BlueprintFactory() +texture = ue.create_transient_texture(512, 512) +# run GC +ue.console_exec('obj gc') + +print(factory) +# this will raise an exception as the UObject mapped to factory has been destroyed by the GC ru +print(texture) +``` + +By running this script you will end with something like this: + +``` +PyUObject is in invalid state +Traceback (most recent call last): + File "", line XX, in +Exception: PyUObject is in invalid state +``` + +Here we are seeing two different behaviours between factory and texture. The first one survived the GC run, the second has been destroyed. + +This is because only UObject's created explicitely by Python with a classic constructor (like BlueprintFactory()) are bound to the related ue_PyUObject. All of the others obey the Unreal GC rules. This is a pretty complex choice aimed at improving performance and avoiding too much competition between the two GCs. + +Very long scripts, that do lot of stuff, often triggering UE4 GC, could be blocked in the middle of their execution by this kind of errors. In such a case (like you would do in C++) you need to inform the UE GC on how to deal with them (for avoiding their destruction). + +Pay attention, as once you tell the UE GC to not destroy a UObject, that UObject (and its python mapping) will stay in memory (so you will end with a leak) + +## Strategy 1: Setting UObject flags to govern the GC + +When you create a UObject (from the C++ side, via the ```NewObject``` api call) you can specify a bitmask of flags. By default the python api only use the RF_Public flag: + +https://api.unrealengine.com/INT/API/Runtime/CoreUObject/UObject/EObjectFlags/index.html + +You can change this bitmask with the set_obj_flags() python function: + +```python +import unreal_engine as ue + +texture = ue.create_transient_texture(512, 512) +# assign mask 0x00000001|0x00000002 +texture.set_obj_flags(ue.RF_PUBLIC|ue.RF_STANDALONE) +# run GC +ue.console_exec('obj gc') +# this will normally print the UObject repr +print(texture) +``` + +The RF_Standalone flag (RF_STANDALONE in python api) will marks a UObject as 'standalone' so it will remain resident in memory forever. + +Eventually you can reset/set the flags: + +```python +import unreal_engine as ue + +texture = ue.create_transient_texture(512, 512) +# assign mask 0x00000001|0x00000002 +texture.set_obj_flags(ue.RF_PUBLIC|ue.RF_STANDALONE) + +ue.console_exec('obj gc') + +print(texture) + +# the second True argument will reset the flags (otherwise set_obj_flags will work in append mode) +# eventually you can call factory.reset_obj_flags() +texture.set_obj_flags(ue.RF_PUBLIC, True) + +ue.console_exec('obj gc') + +print(texture) +``` + +The second print will raise the error. + +This is a pretty raw approach (unless you are sure that you need a resident object). For having more control the second strategy will be way more better... + +## Strategy 2: The Root Set + +The root set is a very specific part of the GC tree. If you want to hold control of a UObject lifecycle in an efficient way, you can use the related python api: + +```python +import unreal_engine as ue + +texture = ue.create_transient_texture(512, 512) +texture.add_to_root() + +ue.console_exec('obj gc') + +print(texture) + +texture.remove_from_root() + +ue.console_exec('obj gc') + +print(texture) +``` + +as before, the first GC run will not destroy the UObject (as it is in the root set), while the second one will remove if from the memory as it is no more in the root set. + +A funny approach to memory management of UObject from python is by using a Tracker object: + +```python +class Tracker: + + def __init__(self): + self.uobjects = [] + + def track(self, uobject): + uobject.add_to_root() + self.uobjects.append(uobject) + return uobject + + def __del__(self): + for uobject in self.uobjects: + uobject.remove_from_root() + +tracker = Tracker() +``` + +Now you can create UObject from python and track them automatically. When the python GC destroys the tracker object, all of the UObject's tracked by it will be destroyed too: + +```python +texture = tracker.track(ue.create_transient_texture(512, 512)) +``` + +As an example when running a script multiple times, the 'tracker' id will be overwritten, triggering the destruction of the mapped python object (and its ```__del__``` method) + +## Low-level UObject creation api + +Til now you have seen how to create new UObject's in a very pythonic way: + +```python +from unreal_engine.classes import BlueprintFactory, Material, MaterialFactoryNew + +bp_factory = BlueprintFactory() +material = Material() +# the first argument here (None) is the outer UObject +material_with_a_name = Material(None, 'FooBar001') +mat_factory = MaterialFactoryNew() +``` + +While the automagic python UObject creation api is really handy, sometime you want lower-level access to the ```NewObject``` C++ api: + +```python +import unreal_engine as ue +from unreal_engine.classes import Material + +material = ue.new_object(Material, None, 'DumbMaterial001', ue.RF_PUBLIC|ue.RF_STANDALONE) +``` + +or for more dynamic class specification: + +```python +import unreal_engine as ue + +# you can reference to Unreal classes with a string +material = ue.new_object(ue.find_class('Material'), None, 'DumbMaterial001', ue.RF_PUBLIC|ue.RF_STANDALONE) +``` + +## Owning + +We have seen how a UObject is differently managed based on the way it has been created: + +```python +# owned by python +material = Material() + + +# owned by unreal +material2 = ue.new_object(Material) +``` + +The interesting thing is that we are allowed to change the owner using the .own() and .disown() methods: + +```python +# owned by unreal +material2 = ue.new_object(Material) + +# now owned by python +material2.own() + +# owned again by unreal + +material2.disown() +``` + +You can check if an object is owned or not by using the .is_owned() method (returns a bool) + +## UStruct + +UStruct's are the UE representation of low-level C/C++ structs. They work both as POD (Plain Old Data, like in C) and as class-like objects (with methods, but no encapsulation). From the Blueprint point of view, UStruct's are POD (generally in the form of User Defined Structs), while in the C++ api, most of them have regular methods. + +```python +from unreal_engine.structs import StaticMeshSourceModel, MeshBuildSettings +lod1 = StaticMeshSourceModel(BuildSettings=MeshBuildSettings(bRecomputeNormals=False, bRecomputeTangents=True, bUseMikkTSpace=True, bBuildAdjacencyBuffer=True, bRemoveDegenerates=True)) +``` + +In this example we are generating a new LOD for a StaticMesh using the StaticMeshSourceModel UStruct (https://api.unrealengine.com/INT/API/Runtime/Engine/Engine/FStaticMeshSourceModel/index.html) + +you can now modify the bRecomputeNormals of lod1: + +```python +lod1.BuildSettings.bRecomputeNormals = True +``` + +This is very python and user-friendly, but note that if the structures you are working with have been not created by python, they could became invalid as the internal memory pointer became a dangling pointer. + +So, to be more clear, there are 2 kind of UStruct's: owned and not-owned. Owned structs are those created by the python api, and are generally safe. Unowned UStruct's are those created by UE4 itself, so it could destroy them at any time (albeit this rarely happens a the vast majority of structs in unreal are passed by value) + +If you want to build an owned struct from an unowned one (or you want to make a simple copy), you can call the .clone() method: + +```python +mesh_build_settings = lod1.BuildSettings.clone() +mesh_build_settings.bRecomputeNormals = True +lod1.BuildSettings = mesh_build_settings +``` + + diff --git a/docs/MigrateAssets.md b/docs/MigrateAssets.md new file mode 100644 index 000000000..69d677532 --- /dev/null +++ b/docs/MigrateAssets.md @@ -0,0 +1,106 @@ +# Assets migration + +Assets migration is a procedure allowing you to export the assets of a project into another unreal engine project. + +When triggering it from the editor, you will get a list of packages to export and where to save them. + +Here we will see how to automate the task from python + +## Step1: getting asset dependencies + +An important topic you need to understand, is that you export packages not single assets. Packages are mapped into real files. + +Packages can contain multiple assets (albeit highly discouraged). + +When we want to migrate an asset we need to get its package and all othe packages referenced by the asset (as an example, a blueprint +with a StaticMeshComponent, holds a reference to the StaticMesh asset, so weneed to export it to). + +The unreal_engine.get_asset_dependencies(package_name) will do the trick: + +```python +import unreal_engine as ue + +# get the currently selected asset +asset = ue.get_selected_assets()[0] + +# retrieve the package path +package_path = asset.get_outermost().get_path_name() +print(package_path) + +def recursive_deps(pkg_path, deps): + deps.append(pkg_path) + for _dep in ue.get_asset_dependencies(pkg_path): + if _dep not in deps: + if not _dep.startswith('/Engine') and not _dep.startswith('/Script'): + recursive_deps(_dep, deps) + + +deps = [] + +recursive_deps(package_path, deps) + +print(deps) +``` + +## Step2: fixing dirty packages + +A package is marked as dirty when it has been modified without saving it. In this step we will check each package we need to +migrate and we will eventually save it: + +```python +for _dep in deps: + # load the package + pkg = ue.load_package(_dep) + # check for dirty packages + if pkg.package_is_dirty(): + pkg.save_package() +``` + +## Step3: copying .uasset files in the destination project + +This is the last step, we retieve the filename of each package and will copy it in the destination directory. + +Full script for migration: + +```python +import unreal_engine as ue +import os +from shutil import copyfile + +# get the currently selected asset +asset = ue.get_selected_assets()[0] + +# retrieve the package path +package_path = asset.get_outermost().get_path_name() +print(package_path) + +def recursive_deps(pkg_path, deps): + deps.append(pkg_path) + for _dep in ue.get_asset_dependencies(pkg_path): + if _dep not in deps: + if not _dep.startswith('/Engine') and not _dep.startswith('/Script'): + recursive_deps(_dep, deps) + + +deps = [] + +recursive_deps(package_path, deps) + +print(deps) + +destination = 'D:/UdemyCast/Content' + +for _dep in deps: + # check for dirty packages + pkg = ue.load_package(_dep) + if pkg.package_is_dirty(): + pkg.save_package() + src = pkg.package_get_filename() + sub = src.split('/Content/', 1)[1] + dst = os.path.join(destination, sub) + copyfile(src, dst) + +print('asset migrated') +``` + +Ensure the destination directory is a /Content directory in UE4 project diff --git a/docs/Slate_API.md b/docs/Slate_API.md index 8b1378917..0008d2b53 100644 --- a/docs/Slate_API.md +++ b/docs/Slate_API.md @@ -1 +1,831 @@ +# The Slate API + +Slate is the GUI toolkit in Unreal Engine 4. It allows you to create windows, buttons, sliders and all of the graphics elements you see in the editor. It is the base for the Blueprint Widgets too. + +UnrealEnginePython allows you to build GUI from python using the Slate api. + +The python wrapper development has been sponsored by Kite & Lightning (http://kiteandlightning.la/) + +This document assumes a python3 environment. If you are using python2, just ensure to use unicode when you see strings. + +It is a 'Work In Progress' and its objective is to give the user enough basis to start building its tools. Only a meaningful subset of the available widgets is explained here, pull requests for extending this page are really welcomed. + +## SWidget and ue_PySWidget + +SWidget is the base C++ class for all the Slate widgets, it is wrapped in a python object (PyObject) named ue_PySWidget. + +Each SWidget exposed to python has its ue_PySWidget representation. You can get the list of exposed SWidget from here: https://github.com/20tab/UnrealEnginePython/tree/master/Source/UnrealEnginePython/Private/Slate (the ones stating with 'UEPyS' prefix) + +## SWindow + +this is the first widget you generally use as it will be the container for the others. It represents a window: + +```python +from unreal_engine import SWindow + +window = SWindow(client_size=(512, 512), title='First Slate Window') +``` + +![SWindow](https://github.com/20tab/UnrealEnginePython/raw/master/docs/screenshots/slate_SWindow.png) + +As you can see just by instancing Slate you will create and show them. + +In the C++ api, each SWidget has its series of FArguments (https://api.unrealengine.com/INT/API/Runtime/Slate/Widgets/Input/SComboBox/FArguments/index.html). + +They are the options of the SWidget, and in the python api you pass them as arguments to the constructor (note the pythonization of the names with lower-case-underscore-delimited conversion). + +In this case the ClientSize FArguments (http://api.unrealengine.com/INT/API/Runtime/SlateCore/Widgets/SWindow/FArguments/ClientSize/index.html) became 'client_size' and Title (http://api.unrealengine.com/INT/API/Runtime/SlateCore/Widgets/SWindow/FArguments/Title/index.html) became 'title'. Note the shortcut from FVector2D to a simple 2-elements float tuple. (both are supported) + + +## STextBlock + +STextBlock (https://api.unrealengine.com/INT/API/Runtime/Slate/Widgets/Text/STextBlock/index.html) shows a simple text label: + +```python +from unreal_engine import SWindow, STextBlock + +window = SWindow(client_size=(512, 512), title='First Slate Window') + +text = STextBlock(text='Hello i am an STextBlock') + +window.set_content(text) +``` + +![STextBlock](https://github.com/20tab/UnrealEnginePython/raw/master/docs/screenshots/slate_STextBlock.png) + +Again using FArguments (https://api.unrealengine.com/INT/API/Runtime/Slate/Widgets/Text/STextBlock/FArguments/index.html) you can (as an example) set the color of the text to red: + +```python +from unreal_engine import SWindow, STextBlock, FLinearColor +from unreal_engine.structs import SlateColor + +window = SWindow(client_size=(512, 512), title='First Slate Window') + +red = SlateColor(SpecifiedColor=FLinearColor(1, 0, 0)) + +text = STextBlock(text='Hello i am an STextBlock', color_and_opacity=red) + +window.set_content(text) +``` + +![STextBlock red](https://github.com/20tab/UnrealEnginePython/raw/master/docs/screenshots/slate_STextBlock_red.png) + +## Dynamic binding for FArguments + +As in C++ Slate, you can map 'delegates' (well, callables in python) to some of the FArguments. As an example you can dynamically change the 'text' attribute of an STextBlock to be constantly updated with the current time: + +```python +from unreal_engine import SWindow, STextBlock, FLinearColor +from unreal_engine.structs import SlateColor +import time + +window = SWindow(client_size=(512, 512), title='First Slate Window') + +red = SlateColor(SpecifiedColor=FLinearColor(1, 0, 0)) + +text = STextBlock(text=lambda: str(time.time()), color_and_opacity=red) + +window.set_content(text) +``` + +Obviously instead of the lambda you could use a plain function (any callable will works): + +```python +from unreal_engine import SWindow, STextBlock, FLinearColor +from unreal_engine.structs import SlateColor +import time + +def what_time_is_it(): + return str(time.time()) + +window = SWindow(client_size=(512, 512), title='First Slate Window') + +red = SlateColor(SpecifiedColor=FLinearColor(1, 0, 0)) + +text = STextBlock(text=what_time_is_it, color_and_opacity=red) + +window.set_content(text) +``` + +## Content assignment shortcut + +In the previous examples we have seen how we added the STextBlock to the SWindow by using set_content(). + +This is a very 'procedural' way of dealing with GUIs. Technically Slate (as well as other toolkits) enforce the developer to a very 'visual' style when describing user interfaces. For this reason, if you do not like the 'procedural' approach you can abuse a specific feature of ue_PySWidget objects: when they are containers, they are 'callable', and calling them will internally call set_content() (or similar). + +Based on this you can rewrite the first STextBlock example in this way: + +```python +from unreal_engine import SWindow, STextBlock + +window = SWindow(client_size=(512, 512), title='First Slate Window')(STextBlock(text='Hello i am an STextBlock')) +``` +or 'visually' better (note the opened bracked in the same line of SWindow) + +```python +from unreal_engine import SWindow, STextBlock + +window = SWindow(client_size=(512, 512), title='First Slate Window')( + STextBlock(text='Hello i am an STextBlock') +) +``` + +## SVerticalBox + +Boxes are one of the many Slate ways to organize/align multiple widgets in a containers. + +SVerticalBox (https://api.unrealengine.com/INT/API/Runtime/SlateCore/Widgets/SVerticalBox/index.html) is a box allowing you to align widgets vertically in a container (each element of the box is named 'slot', a lot effectively contains the widget as well as various attibutes): + +```python +from unreal_engine import SWindow, STextBlock, SVerticalBox + +window = SWindow(client_size=(512, 512), title='First Slate Window') + +vertical_box = SVerticalBox() + +vertical_box.add_slot(STextBlock(text='Hello i am an STextBlock [line 0]')) +vertical_box.add_slot(STextBlock(text='Hello i am an STextBlock [line 1]')) +vertical_box.add_slot(STextBlock(text='Hello i am an STextBlock [line 2]')) + +window.set_content(vertical_box) +``` + +![SVerticalBox](https://github.com/20tab/UnrealEnginePython/raw/master/docs/screenshots/slate_SVerticalBox.png) + +or in 'visual' style (always note the first opened bracked in the same line of SWindow to fake the parser): + +```python +from unreal_engine import SWindow, STextBlock, SVerticalBox + +window = SWindow(client_size=(512, 512), title='First Slate Window')( + SVerticalBox() + ( + STextBlock(text='Hello i am an STextBlock [line 0]') + ) + ( + STextBlock(text='Hello i am an STextBlock [line 1]') + ) + ( + STextBlock(text='Hello i am an STextBlock [line 2]') + ) +) +``` + +## Slot attributes + +We have seen that the mapping between a box and the various widgets is managed by 'slots'. Each slot describes the way a widget is managed in a box (mainly alignment and padding): + +```python +from unreal_engine import SWindow, STextBlock, SVerticalBox +from unreal_engine.enums import EVerticalAlignment, EHorizontalAlignment + +window = SWindow(client_size=(512, 512), title='First Slate Window') + +vertical_box = SVerticalBox() + +vertical_box.add_slot(STextBlock(text='Hello i am an STextBlock [line 0]'), auto_height=True, padding=(10, 20, 10, 100)) +vertical_box.add_slot(STextBlock(text='Hello i am an STextBlock [line 1]'), max_height=173, h_align=EHorizontalAlignment.HAlign_Center) +vertical_box.add_slot(STextBlock(text='Hello i am an STextBlock [line 2]'), h_align=EHorizontalAlignment.HAlign_Right, v_align=EVerticalAlignment.VAlign_Bottom, padding=(0, 0, 50, 50)) + +window.set_content(vertical_box) +``` + +![Slot](https://github.com/20tab/UnrealEnginePython/raw/master/docs/screenshots/slate_Slot.png) + +The first slot will have its height automatically mapped to the height of the contained widget (the STextBlock) and a padding of 10 units on the top, 20 on the left, 10 on the right and 100 on the bottom. (more on padding, later). + +The second slot starts 100 units below the first one (caused by the padding of the first slot). Its content will be aligned to the center and will have a maximum height of 173 unit (we use 'max' wording here as the SVerticalBox alignment could be forced to make it tinier). + +The third slot is aligned to right and vertically to the bottom with a rght/bottom padding of 50 units. + +Useful links: + +https://api.unrealengine.com/INT/API/Runtime/SlateCore/Widgets/SVerticalBox/FSlot/index.html + +https://api.unrealengine.com/INT/API/Runtime/SlateCore/Types/EHorizontalAlignment/index.html + +https://api.unrealengine.com/INT/API/Runtime/SlateCore/Types/EVerticalAlignment/index.html + + + +It is pretty hard to see what is going on here, but adding an SBorder will clarify things... + +## SBorder + +SBorder is a special container what will add a border around its contained widget: + +```python +from unreal_engine import SWindow, STextBlock, SVerticalBox, SBorder +from unreal_engine.enums import EVerticalAlignment, EHorizontalAlignment + +window = SWindow(client_size=(512, 512), title='First Slate Window') + +vertical_box = SVerticalBox() + +vertical_box.add_slot(SBorder()(STextBlock(text='Hello i am an STextBlock [line 0]')), auto_height=True, padding=(10, 20, 10, 100)) +vertical_box.add_slot(SBorder()(STextBlock(text='Hello i am an STextBlock [line 1]')), max_height=173, h_align=EHorizontalAlignment.HAlign_Center) +vertical_box.add_slot(SBorder()(STextBlock(text='Hello i am an STextBlock [line 2]')), h_align=EHorizontalAlignment.HAlign_Right, v_align=EVerticalAlignment.VAlign_Bottom, padding=(0, 0, 50, 20)) + +window.set_content(SBorder()(vertical_box)) +``` + +![SBorder](https://github.com/20tab/UnrealEnginePython/raw/master/docs/screenshots/slate_SBorder.png) + +Now slot attributes should be more clear. Note that SBorder has a set_content() method but here we used the 'visual' style (mixed with procedural one): + +```python +SBorder()(STextBlock(text='Hello i am an STextBlock [line 0]')) +``` + +The list of FArguments for SBorder is avalable here: https://api.unrealengine.com/INT/API/Runtime/Slate/Widgets/Layout/SBorder/FArguments/ + +## Padding + +The padding attributes of slots, defines their margin size. + +Padding in the python api accepts various forms: + +```python +from unreal_engine import SWindow, STextBlock, SVerticalBox, SBorder +from unreal_engine.enums import EVerticalAlignment, EHorizontalAlignment + +window = SWindow(client_size=(512, 512), title='First Slate Window') + +vertical_box = SVerticalBox() + +vertical_box.add_slot(SBorder()(STextBlock(text='Hello i am an STextBlock [line 0]')), padding=100, v_align=EVerticalAlignment.VAlign_Fill) + +window.set_content(SBorder()(vertical_box)) +``` + +passing a single float will specify the same amount of units for top, left, bottom and right: + +![Padding](https://github.com/20tab/UnrealEnginePython/raw/master/docs/screenshots/slate_Padding.png) + +```python +from unreal_engine import SWindow, STextBlock, SVerticalBox, SBorder +from unreal_engine.enums import EVerticalAlignment, EHorizontalAlignment + +window = SWindow(client_size=(512, 512), title='First Slate Window') + +vertical_box = SVerticalBox() + +vertical_box.add_slot(SBorder()(STextBlock(text='Hello i am an STextBlock [line 0]')), padding=(100, 100), v_align=EVerticalAlignment.VAlign_Fill) + +window.set_content(SBorder()(vertical_box)) +``` + +a 2-items float tuple will specify top and left and will force bottom and right to 0: + +![Padding 2](https://github.com/20tab/UnrealEnginePython/raw/master/docs/screenshots/slate_Padding2.png) + +```python +from unreal_engine import SWindow, STextBlock, SVerticalBox, SBorder +from unreal_engine.enums import EVerticalAlignment, EHorizontalAlignment + +window = SWindow(client_size=(512, 512), title='First Slate Window') + +vertical_box = SVerticalBox() + +vertical_box.add_slot(SBorder()(STextBlock(text='Hello i am an STextBlock [line 0]')), padding=(100, 100, 30, 30), v_align=EVerticalAlignment.VAlign_Fill) + +window.set_content(SBorder()(vertical_box)) +``` + +We have alredy seen the 4-items float tuple for specifying top, left, bottom and right: + +![Padding 3](https://github.com/20tab/UnrealEnginePython/raw/master/docs/screenshots/slate_Padding3.png) + +In addition to float/float-tuples you can specify padding using the FMargin struct: + +```python +from unreal_engine.structs import Margin +print(Margin.properties()) +``` +returns + +```python +['Left', 'Top', 'Right', 'Bottom'] +``` + +So: + +```python +from unreal_engine import SWindow, STextBlock, SVerticalBox, SBorder +from unreal_engine.enums import EVerticalAlignment, EHorizontalAlignment +from unreal_engine.structs import Margin + +window = SWindow(client_size=(512, 512), title='First Slate Window') + +vertical_box = SVerticalBox() + +vertical_box.add_slot(SBorder()(STextBlock(text='Hello i am an STextBlock [line 0]')), padding=Margin(Left=100, Right=50), v_align=EVerticalAlignment.VAlign_Fill) + +window.set_content(SBorder()(vertical_box)) +``` + +![Padding 4](https://github.com/20tab/UnrealEnginePython/raw/master/docs/screenshots/slate_Padding4.png) + +## SHorizontalBox + +SHorizontalBox allows you to horizontally align widgets in a containers: + +```python +from unreal_engine import SWindow, STextBlock, SHorizontalBox, SBorder +from unreal_engine.enums import EVerticalAlignment, EHorizontalAlignment +from unreal_engine.structs import Margin + +window = SWindow(client_size=(512, 512), title='First Slate Window') + +horizontal_box = SHorizontalBox() + +horizontal_box.add_slot(SBorder()(STextBlock(text='Left')), padding=Margin(Left=100, Right=50, Bottom=30), v_align=EVerticalAlignment.VAlign_Fill) +horizontal_box.add_slot(SBorder()(STextBlock(text='Right')), padding=Margin(Left=10, Right=20, Top=50), v_align=EVerticalAlignment.VAlign_Fill) + +window.set_content(SBorder()(horizontal_box)) +``` + +![SHorizontalBox](https://github.com/20tab/UnrealEnginePython/raw/master/docs/screenshots/slate_SHorizontalBox.png) + +You can obviously combine vertical and horizontal boxes (this time using 'visual' style) + +```python +from unreal_engine import SWindow, STextBlock, SHorizontalBox, SVerticalBox, SBorder, FLinearColor +from unreal_engine.enums import EVerticalAlignment, EHorizontalAlignment, ETextJustify +from unreal_engine.structs import Margin, SlateColor + +SWindow(client_size=(512, 256), title='Slate Window')( + SVerticalBox() + ( + SHorizontalBox() + ( + SBorder()(STextBlock(text='Left top', justification=ETextJustify.Center)), v_align=EVerticalAlignment.VAlign_Fill + ) + ( + SBorder(border_background_color=SlateColor(SpecifiedColor=FLinearColor.Green))(STextBlock(text='Right top', highlight_text='Right')) + ) + ) + ( + SHorizontalBox() + ( + SBorder(border_background_color=SlateColor(SpecifiedColor=FLinearColor(1, 0, 0)), padding=20) + ( + STextBlock(text='Left bottom') + ), v_align=EVerticalAlignment.VAlign_Fill + ) + ( + SBorder()(STextBlock(text='Middle bottom', justification=ETextJustify.Right)), v_align=EVerticalAlignment.VAlign_Center + ) + ( + SBorder(border_background_color=SlateColor(SpecifiedColor=FLinearColor.Yellow))(STextBlock(text='Right bottom')), v_align=EVerticalAlignment.VAlign_Fill + ) + ) +) +``` + +![SHorizontalBox2](https://github.com/20tab/UnrealEnginePython/raw/master/docs/screenshots/slate_SHorizontalBox2.png) + +More infos on SHorizontalBox: https://api.unrealengine.com/INT/API/Runtime/SlateCore/Widgets/SHorizontalBox/index.html + +## SGridPanel + +This widget allows you to align children in a virtual grid. For each slot you specify the column and row and eventually how much it 'spans' horizontally and verically: + +```python +from unreal_engine import SWindow, STextBlock, SGridPanel, SBorder + +margin = 40 + +SWindow(client_size=(512, 512), title='Slate Window')( + SGridPanel() + ( + SBorder(padding=margin)(STextBlock(text='cell0')), column=0, row=0 + ) + ( + SBorder(padding=margin)(STextBlock(text='cell1')), column=1, row=0 + ) + ( + SBorder(padding=margin)(STextBlock(text='cell2')), column=2, row=0 + ) + ( + SBorder(padding=margin)(STextBlock(text='cell3')), column=0, row=1 + ) + ( + SBorder(padding=margin)(STextBlock(text='cell4')), column=3, row=1, row_span=3 + ) + ( + SBorder(padding=margin)(STextBlock(text='cell5')), column=2, row=2 + ) + ( + SBorder(padding=margin)(STextBlock(text='cell6')), column=0, row=3, column_span=2 + ) +) +``` + +![SGridPanel](https://github.com/20tab/UnrealEnginePython/raw/master/docs/screenshots/slate_SGridPanel.png) + +## SScrollBox + +This container allows you to scroll on big series of widgets: + +```python +from unreal_engine import SWindow, STextBlock, SGridPanel, SBorder, SScrollBox +from unreal_engine.enums import EOrientation + +margin = 40 + +SWindow(client_size=(512, 256), title='Slate Window')( + SScrollBox(orientation=EOrientation.Orient_Vertical) + ( + SGridPanel() + ( + SBorder(padding=margin)(STextBlock(text='cell0')), column=0, row=0 + ) + ( + SBorder(padding=margin)(STextBlock(text='cell1')), column=1, row=0 + ) + ( + SBorder(padding=margin)(STextBlock(text='cell2')), column=2, row=0 + ) + ( + SBorder(padding=margin)(STextBlock(text='cell3')), column=0, row=1 + ) + ( + SBorder(padding=margin)(STextBlock(text='cell4')), column=3, row=1, row_span=3 + ) + ( + SBorder(padding=margin)(STextBlock(text='cell5')), column=2, row=2 + ) + ( + SBorder(padding=margin)(STextBlock(text='cell6')), column=0, row=3, column_span=2 + ) + ) +) +``` + +![SScrollBox](https://github.com/20tab/UnrealEnginePython/raw/master/docs/screenshots/slate_SScrollBox.png) + +More infos here: https://api.unrealengine.com/INT/API/Runtime/Slate/Widgets/Layout/SScrollBox/ + +## SButton + +It's time for user interaction. The SButton widget raises an event whenevr the user clicks on it: + +```python +from unreal_engine import SWindow, SVerticalBox, SButton +from unreal_engine.enums import EHorizontalAlignment +import unreal_engine as ue +import time + +window = SWindow(client_size=(512, 256), title='Slate Window')( + SVerticalBox() + ( + SButton(text='Button 001', on_clicked=lambda: ue.log('Hello i am Button001')) + ) + ( + SButton(text='Button 002', h_align=EHorizontalAlignment.HAlign_Center, on_clicked=lambda: (ue.message_dialog_open(ue.APP_MSG_TYPE_OK, 'Hello i am Button002'), window.bring_to_front())) + ) + ( + SButton(text='Update title with current time', on_clicked=lambda: window.set_title(str(time.time()))) + ) + ( + SButton(text='Close Window', on_clicked=lambda: window.request_destroy()) + ) +) +``` + +![SButton](https://github.com/20tab/UnrealEnginePython/raw/master/docs/screenshots/slate_SButton.png) + +Note that technically SButton's are containers so you can assign to them another widget: + +```python +SButton(on_clicked=lambda: window.request_destroy())(STextBlock(text='Hello')) +``` + +More infos here: https://api.unrealengine.com/INT/API/Runtime/Slate/Widgets/Input/SButton/index.html + +## SImage + +This widget draw graphics resources (images, solid blocks). + +```python +from unreal_engine import SWindow, SImage, SVerticalBox, FLinearColor, SBorder +from unreal_engine.structs import SlateBrush, SlateColor, Vector2D +from unreal_engine.classes import Texture2D +import unreal_engine as ue +import os + +plugin = unreal_engine.find_plugin('UnrealEnginePython') +plugin_base_dir = plugin.get_base_dir() + +image_file = os.path.join(plugin_base_dir, 'Resources/Icon128.png') + +texture = ue.load_object(Texture2D, '/Game/Mannequin/Character/Textures/UE4_LOGO_CARD') + + +window = SWindow(client_size=(128, 512), title='Slate Window', sizing_rule=0)( + SVerticalBox() + ( + SImage(image=SlateBrush(ResourceName=image_file, bIsDynamicallyLoaded=True)), + ) + ( + SImage(image=SlateBrush(ResourceObject=texture)) + ) + ( + SImage(image=SlateBrush(TintColor=SlateColor(SpecifiedColor=FLinearColor(1, 0, 0)))) + ) + ( + SImage(image=SlateBrush(ResourceName=image_file, bIsDynamicallyLoaded=True, TintColor=SlateColor(SpecifiedColor=FLinearColor(0, 1, 0)))) + ) + ( + SBorder()(SImage(image=SlateBrush(ResourceObject=texture, ImageSize=Vector2D(X=64, Y=64)))), auto_height=True + ) +) +``` + +![SImage](https://github.com/20tab/UnrealEnginePython/raw/master/docs/screenshots/slate_SImage.png) + +Pay attention to the bIsDynamicallyLoaded field of SlateBrush, if you are passing a non-ue4 resource (via ResourceName) you have to instruct UE to load the resource as a texture (by setting bIsDynamicallyLoaded to true). This is not required when using ResourceObject. + +Combining SButton and SImage is pretty handy: + +```python +SButton(on_clicked=lambda: ue.log('Image Clicked'))(SImage(image=SlateBrush(ResourceName=image_file, bIsDynamicallyLoaded=True))) +``` + +More infos about SlateBrush: + +https://api.unrealengine.com/INT/API/Runtime/SlateCore/Styling/FSlateBrush/index.html + + +## SEditableTextBox + +This widget allows the user to input a string: + +```python +from unreal_engine import SWindow, SEditableTextBox, SHorizontalBox, SButton +from unreal_engine.classes import Object +import unreal_engine as ue + +asset_name=SEditableTextBox() + +window = SWindow(client_size=(512, 32), title='Open Asset', sizing_rule=0)( + SHorizontalBox() + ( + asset_name + ) + ( + SButton(text='Ok', on_clicked=lambda: ue.open_editor_for_asset(ue.load_object(Object, asset_name.get_text()))), auto_width=True + ) +) +``` + +![SEditableTextBox](https://github.com/20tab/UnrealEnginePython/raw/master/docs/screenshots/slate_SEditableTextBox.png) + +The get_text() method will return the currently inserted text. + +When the user click on 'Ok', the asset specified in the SEditableTextBox will be validated, loaded and opened in the related editor. + +More infos (check FArguments) here: + +https://api.unrealengine.com/INT/API/Runtime/Slate/Widgets/Input/SEditableTextBox/index.html + + +## The .assign() hack + +In the previous example we used a 'mixed' visual style to allow the SEditableTextBox to be assigned to a python variable to be able to reference it in the on_clicked event. + +The python SWidget api supports an alternative way for assigning references to SWidget. It is indeed a hack (and honestly not very pythonic), but for big interfaces should simplify the management a lot: + +```python +from unreal_engine import SWindow, SEditableTextBox, SHorizontalBox, SButton +from unreal_engine.classes import Object +import unreal_engine as ue + +asset_name=None + +window = SWindow(client_size=(512, 32), title='Open Asset', sizing_rule=0)( + SHorizontalBox() + ( + SEditableTextBox().assign('asset_name') + ) + ( + SButton(text='Ok', on_clicked=lambda: ue.open_editor_for_asset(ue.load_object(Object, asset_name.get_text()))), auto_width=True + ) +) +``` + +Basically the .assign(global_name) method, will map the SWidget to the global item specified as global_name. The .assign() method will check for validity of the passed name, so typos will not be a problem. + +## SCheckBox + +Very useful for managing boolean values: + +```python +from unreal_engine import SWindow, SEditableTextBox, SHorizontalBox, SButton, SCheckBox, STextBlock +from unreal_engine.classes import Object +from unreal_engine.enums import EVerticalAlignment +import unreal_engine as ue + +asset_name=None +checkbox_bool=False + +def open_or_validate(path, only_validate): + try: + asset = ue.load_object(Object, path) + except: + ue.message_dialog_open(ue.APP_MSG_TYPE_OK, 'invalid path') + return + + if only_validate: + ue.message_dialog_open(ue.APP_MSG_TYPE_OK, 'path is valid') + else: + ue.open_editor_for_asset(asset) + +window = SWindow(client_size=(512, 32), title='Open Asset', sizing_rule=0)( + SHorizontalBox() + ( + SEditableTextBox().assign('asset_name') + ) + ( + STextBlock(text='only validate path'), auto_width=True, v_align=EVerticalAlignment.VAlign_Center + ) + ( + SCheckBox().assign('checkbox_bool'), auto_width=True + ) + ( + SButton(text='Ok', on_clicked=lambda: open_or_validate(asset_name.get_text(), checkbox_bool.is_checked())), auto_width=True + ) +) +``` + +![SCheckBox](https://github.com/20tab/UnrealEnginePython/raw/master/docs/screenshots/slate_SCheckBox.png) + +## OOP refactoring + +Time to refactor the code to be more elegant, and to allow the reuse of custom/complex widgets: + +```python +from unreal_engine import SWindow, SEditableTextBox, SHorizontalBox, SButton, SCheckBox, STextBlock, SVerticalBox +from unreal_engine.classes import Object +from unreal_engine.enums import EVerticalAlignment +import unreal_engine as ue + +class AssetOpener(SHorizontalBox): + + def __init__(self): + super().__init__(self) + self.asset_name_picker = SEditableTextBox() + self.only_validate_path = SCheckBox() + + self.add_slot(self.asset_name_picker) + self.add_slot(STextBlock(text='only validate path'), auto_width=True, v_align=EVerticalAlignment.VAlign_Center) + self.add_slot(self.only_validate_path, auto_width=True) + self.add_slot(SButton(text='Ok', on_clicked=self.open_or_validate), auto_width=True) + + def open_or_validate(self): + try: + asset = ue.load_object(Object, self.asset_name_picker.get_text()) + except: + ue.message_dialog_open(ue.APP_MSG_TYPE_OK, 'invalid path') + return + + if self.only_validate_path.is_checked(): + ue.message_dialog_open(ue.APP_MSG_TYPE_OK, 'path is valid') + else: + ue.open_editor_for_asset(asset) + + + +window = SWindow(client_size=(512, 64), title='Open Asset', sizing_rule=0)( + SVerticalBox() + ( + STextBlock(text='OOP widget below') + ) + ( + AssetOpener() + ) +) +``` + +![OOP](https://github.com/20tab/UnrealEnginePython/raw/master/docs/screenshots/slate_OOP.png) + +As you can see, you can inherit from SWidget. Obviously you can mix 'visual' style, with fully procedural one, but the use of classes will simplify 'context' management. + +## SObjectPropertyEntryBox + +This widget allows the user to select an asset from a specific class + +```python +from unreal_engine import SWindow, SObjectPropertyEntryBox +from unreal_engine.classes import Material +import unreal_engine as ue + + + +window = SWindow(client_size=(512, 256), title='Material Selector', sizing_rule=0)( + ( + SObjectPropertyEntryBox(allowed_class=Material, on_object_changed=lambda choice: ue.open_editor_for_asset(choice.get_asset())) + ) +) +``` + +![SObjectPropertyEntryBox](https://github.com/20tab/UnrealEnginePython/raw/master/docs/screenshots/slate_SObjectPropertyEntryBox.png) + +note that the callable executed by on_object_changed receives an FAssetData object as argument (this is why we need to call get_asset()) + +More infos here: https://api.unrealengine.com/INT/API/Editor/PropertyEditor/SObjectPropertyEntryBox/index.html + +## SPythonEditorViewport + +This is probably the funniest widget, an EditorViewportClient and a whole World all in a single SWidget: + +```python +from unreal_engine import SWindow, SPythonEditorViewport, FVector, FRotator +from unreal_engine.classes import Blueprint +import unreal_engine as ue + +editor_viewport = SPythonEditorViewport() +world = editor_viewport.get_world() +world.actor_spawn(ue.load_object(Blueprint, '/Game/ThirdPersonCPP/Blueprints/ThirdPersonCharacter').GeneratedClass) +editor_viewport_client = editor_viewport.get_editor_viewport_client() +editor_viewport_client.set_view_location(FVector(-200, 300, 200)) +editor_viewport_client.set_view_rotation(FRotator(0, -30, -90)) + +window = SWindow(client_size=(512, 256), title='Mannequin Properties', sizing_rule=0)( + ( + editor_viewport + ) +) +``` + +![SPythonEditorViewport](https://github.com/20tab/UnrealEnginePython/raw/master/docs/screenshots/slate_SPythonEditorViewport.png) + +Note that by calling the .simulate(bool) method on the SPythonEditorViewport instance you can enable/disable the world ticking + +## Nomad Tabs + +If you plan to make a slate tool, very probably you do not want to spawn a plain SWindow, instead you want a dock (SDockTab) that you can move/rearrange in your editor and (more important) that is unique and runnable from an editor menu. + +This can be accomplished in a single step with nomad tab spawner: + +```python +from unreal_engine import SWindow, SPythonEditorViewport, FVector, FRotator +from unreal_engine.classes import Blueprint +import unreal_engine as ue + + +def create_tab(dock_tab): + editor_viewport = SPythonEditorViewport() + world = editor_viewport.get_world() + world.actor_spawn(ue.load_object(Blueprint, '/Game/ThirdPersonCPP/Blueprints/ThirdPersonCharacter').GeneratedClass) + editor_viewport_client = editor_viewport.get_editor_viewport_client() + editor_viewport_client.set_view_location(FVector(-200, 300, 200)) + editor_viewport_client.set_view_rotation(FRotator(0, -30, -90)) + + editor_viewport.simulate(True) + + dock_tab.set_content(editor_viewport) + +ue.register_nomad_tab_spawner('Hello Nomads !', create_tab) +``` + +![Nomad](https://github.com/20tab/UnrealEnginePython/raw/master/docs/screenshots/slate_Nomad.png) + +To spawn the nomad tab you need to search for 'Hello Nomads !' entry in Window/Developer Tools menu. (currently there is no way to place it in other positions) + +If you want to spawn (or give focus) to a specific tab (as an example for running it over a toolbar button extender), just run + +```python +ue.invoke_tab('Hello Nomads !') +``` + +## Properties Editors + +```python +from unreal_engine import SWindow +import unreal_engine as ue + +window = SWindow(client_size=(512, 256), title='Mannequin Properties', sizing_rule=0)( + ( + ue.create_detail_view(uobject=ue.get_selected_assets()[0].GeneratedClass.get_cdo()) + ) +) +``` + +![SDetailView](https://github.com/20tab/UnrealEnginePython/raw/master/docs/screenshots/slate_SDetailView.png) + +## Extenders + +Extenders allows you to 'extend' menus or toolbar with new entries or buttons. + +Check this example: https://github.com/20tab/UnrealEnginePython/blob/master/examples/extenders_example.py + +It shows even how to register new style sets. + +## SPythonListView + +## SPythonTreeView + +## SPythonWidget diff --git a/docs/Subclassing_API.md b/docs/Subclassing_API.md index ff583ba7e..87c3a23e3 100644 --- a/docs/Subclassing_API.md +++ b/docs/Subclassing_API.md @@ -173,7 +173,7 @@ class Hero(Character): # this new static method will be available to blueprints def FunnyStaticMethod(): ue.print_string('I am a static method') - FunnyNewMethod.static = True + FunnyStaticMethod.static = True ``` Events can be easily exposed like this: diff --git a/docs/Tagging_API.md b/docs/Tagging_API.md new file mode 100644 index 000000000..30246f322 --- /dev/null +++ b/docs/Tagging_API.md @@ -0,0 +1,80 @@ +# The Tagging API + +You can 'tag' actor and components. + +A tag is a string (well, an FName internally) you assign to your actors and components. Each of them can have multiple tags. + +## Tagging Actors + +The 'Tags' properties allows you to tag actors: + +```python +your_actor.Tags = ['foo', 'Bar', tEsT'] +``` + +You can eventually fast-check an actor for the availability of a tag: + +```python +if your_actor.actor_has_tag('foo'): + ue.log('Success') +``` + +Finding all actors with a tag is unfortuntaley a slow operation (in C++, Blueprint and obviously python): + +```python +import unreal_engine as ue + +def find_all_actors_with_tag(world, tag): + for actor in world.all_actors(): + if actor.actor_has_tag(tag): + yield actor + + +world = ue.get_editor_world() + +for actor in find_all_actors_with_tag(world, 'foo'): + print(actor) +``` + +Eventually you can use the blueprint api: + +```python +import unreal_engine as ue +from unreal_engine.classes import GameplayStatics + +world = ue.get_editor_world() + +# blueprint ufunctions returns a tuple (as UFunctions can returns multiple values) +actors, = GameplayStatics.GetAllActorsWithTag(world, 'one') +for actor in actors: + print(actor) +``` + +## Tagging Components + +You can tag components too using the property 'ComponentTags': + +```python +your_component.ComponentTags = ['one', 'two', 'three'] +``` + +Fast-check of tag availability can be done with the component_has_tag() function: + +```python +if your_component.component_has_tag('one'): + print('yes') +``` + +While you can get the list of actor's component tagged with the specific value: + +```python +component_list = your_actor.get_components_by_tag('two') +``` + +The function can take an optional argument specifying which classes of ActorComponent must be taken into account: + +```python +from unreal_engine.classes import SceneComponent +# search all the components children of the class SceneComponent and tagged with 'two' +component_list = your_actor.get_components_by_tag('two', SceneComponent) +``` diff --git a/docs/android_packaging.png b/docs/android_packaging.png new file mode 100644 index 000000000..49f6e4009 Binary files /dev/null and b/docs/android_packaging.png differ diff --git a/docs/screenshots/slate_Nomad.png b/docs/screenshots/slate_Nomad.png new file mode 100644 index 000000000..8c6f8da11 Binary files /dev/null and b/docs/screenshots/slate_Nomad.png differ diff --git a/docs/screenshots/slate_OOP.png b/docs/screenshots/slate_OOP.png new file mode 100644 index 000000000..cac3dac26 Binary files /dev/null and b/docs/screenshots/slate_OOP.png differ diff --git a/docs/screenshots/slate_Padding.png b/docs/screenshots/slate_Padding.png new file mode 100644 index 000000000..fa097beb3 Binary files /dev/null and b/docs/screenshots/slate_Padding.png differ diff --git a/docs/screenshots/slate_Padding2.png b/docs/screenshots/slate_Padding2.png new file mode 100644 index 000000000..ab9fb4d58 Binary files /dev/null and b/docs/screenshots/slate_Padding2.png differ diff --git a/docs/screenshots/slate_Padding3.png b/docs/screenshots/slate_Padding3.png new file mode 100644 index 000000000..68f6b1b6d Binary files /dev/null and b/docs/screenshots/slate_Padding3.png differ diff --git a/docs/screenshots/slate_Padding4.png b/docs/screenshots/slate_Padding4.png new file mode 100644 index 000000000..b552e9bec Binary files /dev/null and b/docs/screenshots/slate_Padding4.png differ diff --git a/docs/screenshots/slate_SBorder.png b/docs/screenshots/slate_SBorder.png new file mode 100644 index 000000000..4503a8fee Binary files /dev/null and b/docs/screenshots/slate_SBorder.png differ diff --git a/docs/screenshots/slate_SButton.png b/docs/screenshots/slate_SButton.png new file mode 100644 index 000000000..b813bbb3f Binary files /dev/null and b/docs/screenshots/slate_SButton.png differ diff --git a/docs/screenshots/slate_SCheckBox.png b/docs/screenshots/slate_SCheckBox.png new file mode 100644 index 000000000..beff0cc36 Binary files /dev/null and b/docs/screenshots/slate_SCheckBox.png differ diff --git a/docs/screenshots/slate_SDetailView.png b/docs/screenshots/slate_SDetailView.png new file mode 100644 index 000000000..cbb6ac846 Binary files /dev/null and b/docs/screenshots/slate_SDetailView.png differ diff --git a/docs/screenshots/slate_SEditableTextBox.png b/docs/screenshots/slate_SEditableTextBox.png new file mode 100644 index 000000000..b5a617870 Binary files /dev/null and b/docs/screenshots/slate_SEditableTextBox.png differ diff --git a/docs/screenshots/slate_SGridPanel.png b/docs/screenshots/slate_SGridPanel.png new file mode 100644 index 000000000..1ed20ae0a Binary files /dev/null and b/docs/screenshots/slate_SGridPanel.png differ diff --git a/docs/screenshots/slate_SHorizontalBox.png b/docs/screenshots/slate_SHorizontalBox.png new file mode 100644 index 000000000..a82ec799c Binary files /dev/null and b/docs/screenshots/slate_SHorizontalBox.png differ diff --git a/docs/screenshots/slate_SHorizontalBox2.png b/docs/screenshots/slate_SHorizontalBox2.png new file mode 100644 index 000000000..95dc5c209 Binary files /dev/null and b/docs/screenshots/slate_SHorizontalBox2.png differ diff --git a/docs/screenshots/slate_SImage.png b/docs/screenshots/slate_SImage.png new file mode 100644 index 000000000..9d03b6450 Binary files /dev/null and b/docs/screenshots/slate_SImage.png differ diff --git a/docs/screenshots/slate_SObjectPropertyEntryBox.png b/docs/screenshots/slate_SObjectPropertyEntryBox.png new file mode 100644 index 000000000..b783f4e03 Binary files /dev/null and b/docs/screenshots/slate_SObjectPropertyEntryBox.png differ diff --git a/docs/screenshots/slate_SPythonEditorViewport.png b/docs/screenshots/slate_SPythonEditorViewport.png new file mode 100644 index 000000000..8de4d801f Binary files /dev/null and b/docs/screenshots/slate_SPythonEditorViewport.png differ diff --git a/docs/screenshots/slate_SScrollBox.png b/docs/screenshots/slate_SScrollBox.png new file mode 100644 index 000000000..a011a186f Binary files /dev/null and b/docs/screenshots/slate_SScrollBox.png differ diff --git a/docs/screenshots/slate_STextBlock.png b/docs/screenshots/slate_STextBlock.png new file mode 100644 index 000000000..81c87ebe3 Binary files /dev/null and b/docs/screenshots/slate_STextBlock.png differ diff --git a/docs/screenshots/slate_STextBlock_red.png b/docs/screenshots/slate_STextBlock_red.png new file mode 100644 index 000000000..062b1c4c5 Binary files /dev/null and b/docs/screenshots/slate_STextBlock_red.png differ diff --git a/docs/screenshots/slate_SVerticalBox.png b/docs/screenshots/slate_SVerticalBox.png new file mode 100644 index 000000000..e0b11f2b0 Binary files /dev/null and b/docs/screenshots/slate_SVerticalBox.png differ diff --git a/docs/screenshots/slate_SWindow.png b/docs/screenshots/slate_SWindow.png new file mode 100644 index 000000000..cc4977d44 Binary files /dev/null and b/docs/screenshots/slate_SWindow.png differ diff --git a/docs/screenshots/slate_Slot.png b/docs/screenshots/slate_Slot.png new file mode 100644 index 000000000..a7c473083 Binary files /dev/null and b/docs/screenshots/slate_Slot.png differ diff --git a/docs/uobject_API.md b/docs/uobject_API.md index 424ad1c5b..32c760920 100644 --- a/docs/uobject_API.md +++ b/docs/uobject_API.md @@ -200,14 +200,13 @@ return True if the actor has a component of the specified type --- ```py -yesno = uobject.get_actor_component_by_type(uclass) +component = uobject.get_actor_component_by_type(uclass) # alias -yesno = uobject.get_component_by_type(uclass) +component = uobject.get_component_by_type(uclass) ``` return the first component (of an actor) of the specified type -It has two shortcuts, it can retrieve the actor from a component, and can get a string (instead of the output of ue.find_class('name')) with the class of the component --- ```py diff --git a/examples/MaterialExpressionStaticSwitch.md b/examples/MaterialExpressionStaticSwitch.md new file mode 100644 index 000000000..91bd959af --- /dev/null +++ b/examples/MaterialExpressionStaticSwitch.md @@ -0,0 +1,75 @@ + +![MaterialExpressionStaticSwitch Screenshot](https://github.com/20tab/UnrealEnginePython/blob/master/examples/MaterialExpressionStaticSwitch.png) + +```python +import unreal_engine as ue +from unreal_engine.classes import MaterialFactoryNew +from unreal_engine.classes import MaterialExpressionStaticSwitch, MaterialExpressionStaticSwitchParameter, MaterialExpressionVectorParameter +from unreal_engine.structs import ColorMaterialInput, ExpressionInput +import time + +material_factory = MaterialFactoryNew() +material = material_factory.factory_create_new('/Game/Materials/Test' + str(int(time.time()))) + +material.modify() + +static_switch_node = MaterialExpressionStaticSwitch('', material) +static_switch_node.MaterialExpressionEditorX = -200 +static_switch_node.MaterialExpressionEditorY = 50 + +static_switch_parameter_node_true = MaterialExpressionStaticSwitchParameter('', material) +static_switch_parameter_node_true.MaterialExpressionEditorX = -400 +static_switch_parameter_node_true.MaterialExpressionEditorY = 0 +static_switch_parameter_node_true.ParameterName = 'True' + +static_switch_parameter_node_false = MaterialExpressionStaticSwitchParameter('', material) +static_switch_parameter_node_false.MaterialExpressionEditorX = -400 +static_switch_parameter_node_false.MaterialExpressionEditorY = 200 +static_switch_parameter_node_false.ParameterName = 'False' + +static_switch_node.A = ExpressionInput(Expression=static_switch_parameter_node_true) +static_switch_node.B = ExpressionInput(Expression=static_switch_parameter_node_false) + +vector_parameter_one = MaterialExpressionVectorParameter('', material) +vector_parameter_one.MaterialExpressionEditorX = -600 +vector_parameter_one.MaterialExpressionEditorY = -150 +vector_parameter_one.ParameterName = 'One' + +vector_parameter_two = MaterialExpressionVectorParameter('', material) +vector_parameter_two.MaterialExpressionEditorX = -800 +vector_parameter_two.MaterialExpressionEditorY = -50 +vector_parameter_two.ParameterName = 'Two' + +vector_parameter_three = MaterialExpressionVectorParameter('', material) +vector_parameter_three.MaterialExpressionEditorX = -600 +vector_parameter_three.MaterialExpressionEditorY = 150 +vector_parameter_three.ParameterName = 'Three' + +vector_parameter_four = MaterialExpressionVectorParameter('', material) +vector_parameter_four.MaterialExpressionEditorX = -800 +vector_parameter_four.MaterialExpressionEditorY = 250 +vector_parameter_four.ParameterName = 'Four' + + +static_switch_parameter_node_true.A = ExpressionInput(Expression=vector_parameter_one) +static_switch_parameter_node_true.B = ExpressionInput(Expression=vector_parameter_two) + +static_switch_parameter_node_false.A = ExpressionInput(Expression=vector_parameter_three) +static_switch_parameter_node_false.B = ExpressionInput(Expression=vector_parameter_four) + +material.BaseColor = ColorMaterialInput(Expression=static_switch_node) + +material.Expressions = [ + static_switch_node, + static_switch_parameter_node_true, + static_switch_parameter_node_false, + vector_parameter_one, + vector_parameter_two, + vector_parameter_three, + vector_parameter_four + ] + +material.post_edit_change() + +ue.open_editor_for_asset(material) +``` diff --git a/examples/MaterialExpressionStaticSwitch.png b/examples/MaterialExpressionStaticSwitch.png new file mode 100644 index 000000000..247a19eef Binary files /dev/null and b/examples/MaterialExpressionStaticSwitch.png differ diff --git a/examples/asset_editors.py b/examples/asset_editors.py new file mode 100644 index 000000000..3b7f1d037 --- /dev/null +++ b/examples/asset_editors.py @@ -0,0 +1,6 @@ +import unreal_engine as ue + +for _asset in ue.get_all_edited_assets(): + editor = ue.find_editor_for_asset(_asset) + print('{0} - {1}'.format(editor.get_editor_name(), editor.get_last_activation_time())) + editor.focus_window() \ No newline at end of file diff --git a/examples/asset_metadata_tag.py b/examples/asset_metadata_tag.py new file mode 100644 index 000000000..dfa036f36 --- /dev/null +++ b/examples/asset_metadata_tag.py @@ -0,0 +1,19 @@ +import unreal_engine as ue +from unreal_engine.classes import EditorAssetLibrary + +asset = ue.get_selected_assets()[0] + +# reflection-based api +EditorAssetLibrary.SetMetadataTag(asset, 'Foo', 'Bar') +for value in EditorAssetLibrary.GetMetadataTagValues(asset): + print(value) +print(EditorAssetLibrary.GetMetadataTag(asset, 'Foo')) + + +# native api +asset.set_metadata_tag('Test001', 'Text002') +asset.set_metadata_tag('Test003', 'Text004') +for key in asset.metadata_tags(): + print(key) +print(asset.has_metadata_tag('Foo')) # bool +print(asset.get_metadata_tag('Test001')) diff --git a/examples/blueprint_dynamic_cast.py b/examples/blueprint_dynamic_cast.py new file mode 100644 index 000000000..93e11f083 --- /dev/null +++ b/examples/blueprint_dynamic_cast.py @@ -0,0 +1,27 @@ +import unreal_engine as ue +from unreal_engine.classes import Blueprint, K2Node_DynamicCast, Actor, Object +from unreal_engine.structs import EdGraphPinType +from unreal_engine.enums import EEdGraphPinDirection + +bp_foo = ue.load_object(Blueprint, '/Game/Foo.Foo') +bp_bar = ue.load_object(Blueprint, '/Game/Bar.Bar') + +cast_node = K2Node_DynamicCast() +cast_node.TargetType = bp_bar.GeneratedClass + +graph = ue.blueprint_add_function(bp_foo, 'FooCaster') +func = graph.Nodes[0] + +pin_type = EdGraphPinType(PinCategory = 'object', PinSubCategoryObject=Actor) +pin = func.node_create_pin(EEdGraphPinDirection.EGPD_Input, pin_type, 'Arg001') + + +graph.graph_add_node(cast_node, 600, 0) + +cast_node.node_find_pin('Object').category = 'object' +cast_node.node_find_pin('Object').sub_category = Object + +pin.make_link_to(cast_node.node_find_pin('Object')) +func.node_find_pin('then').make_link_to(cast_node.node_find_pin('execute')) + +ue.compile_blueprint(bp_foo) \ No newline at end of file diff --git a/examples/blueprint_example_generator.py b/examples/blueprint_example_generator.py new file mode 100644 index 000000000..cfff157b8 --- /dev/null +++ b/examples/blueprint_example_generator.py @@ -0,0 +1,49 @@ +import unreal_engine as ue +from unreal_engine.classes import BlueprintFactory, DirectionalLightComponent, K2Node_Event + +import time + +# create new blueprint from factory +bpFactory = BlueprintFactory() +bp = bpFactory.factory_create_new('/Game/test' + str(int(time.time()))) + +# add intensity variable +intensity = ue.blueprint_add_member_variable(bp, 'intensity', 'float') +# set its visibility to True +ue.blueprint_set_variable_visibility(bp, 'intensity', True) + +# add directional light component +directLightComponent = ue.add_component_to_blueprint(bp,DirectionalLightComponent, "Directional_light") + +# add node variables (get) to the graph +intensity_node = bp.UberGraphPages[0].graph_add_node_variable_get('intensity', None, 200, 100) +directional_light_node = bp.UberGraphPages[0].graph_add_node_variable_get('Directional_light', None, 200, 0) + +# add the SetIntensity node (from DirectionalLightComponent) +directional_light_set_intensity = bp.UberGraphPages[0].graph_add_node_call_function(DirectionalLightComponent.SetIntensity, 400, 0) + +# link variables +intensity_node.node_find_pin('intensity').make_link_to(directional_light_set_intensity.node_find_pin('NewIntensity')) +directional_light_node.node_find_pin('Directional_light').make_link_to(directional_light_set_intensity.node_find_pin('self')) + +# a commodity function for finding an event node +def get_event_node(event_name): + for node in bp.UberGraphPages[0].Nodes: + if node.is_a(K2Node_Event): + if node.EventReference.MemberName == event_name: + return node + +# get the ReceiveBeginPlay event node +begin_play_node = get_event_node('ReceiveBeginPlay') + +# link BeginPlay to SetIntensity +begin_play_node.node_find_pin('then').make_link_to(directional_light_set_intensity.node_find_pin('execute')) + +# compile the blueprint +ue.compile_blueprint(bp) + +# open related editor +ue.open_editor_for_asset(bp) + +# spawn it +ue.get_editor_world().actor_spawn(bp.GeneratedClass) \ No newline at end of file diff --git a/examples/blueprint_variables.py b/examples/blueprint_variables.py new file mode 100644 index 000000000..642975f36 --- /dev/null +++ b/examples/blueprint_variables.py @@ -0,0 +1,28 @@ +import unreal_engine as ue + +from unreal_engine.classes import Material, BlueprintFactory, Blueprint, Actor, Texture2D, SkeletalMesh +from unreal_engine.structs import EdGraphPinType, Vector, Rotator, EdGraphTerminalType +from unreal_engine.enums import EPinContainerType + +import time + +bp = ue.create_blueprint(Actor, '/Game/FooActor' + str(int(time.time()))) + +pin = EdGraphPinType(PinCategory='object', PinSubCategoryObject=Material) +ue.blueprint_add_member_variable(bp, 'TestMat', pin, None, '/Engine/MapTemplates/Materials/BasicAsset03.BasicAsset03') + +pin = EdGraphPinType(PinCategory='class', PinSubCategoryObject=Texture2D) +ue.blueprint_add_member_variable(bp, 'TestTextureClass', pin) + +pin = EdGraphPinType(PinCategory='struct',PinSubCategoryObject=Vector) +ue.blueprint_add_member_variable(bp, 'TestVector', pin, None, '17,22,30') + +pin = EdGraphPinType(PinCategory='struct',PinSubCategoryObject=Rotator,ContainerType=EPinContainerType.Array) +ue.blueprint_add_member_variable(bp, 'TestRotator', pin, None, '((Pitch=0.000000,Yaw=3.000000,Roll=0.000000),(Pitch=1.000000,Yaw=0.000000,Roll=0.000000))') + +pin = EdGraphPinType(PinCategory='string',ContainerType=EPinContainerType.Map,PinValueType=EdGraphTerminalType(TerminalCategory='object',TerminalSubCategoryObject=SkeletalMesh)) +ue.blueprint_add_member_variable(bp, 'TestMap', pin, None, '(("firstKey", SkeletalMesh\'"/Game/Skel001"\'),("secondKey", SkeletalMesh\'"/Game/Skel002"\'))') + +ue.compile_blueprint(bp) + +ue.open_editor_for_asset(bp) diff --git a/examples/curve_generator.py b/examples/curve_generator.py new file mode 100644 index 000000000..034670af6 --- /dev/null +++ b/examples/curve_generator.py @@ -0,0 +1,42 @@ +import unreal_engine as ue +from unreal_engine.classes import CurveFloatFactory, CurveVectorFactory +from unreal_engine.structs import RichCurve, RichCurveKey +import time + +factory = CurveFloatFactory() + +curve = factory.factory_create_new('/Game/CustomFloatCurve' + str(int(time.time()))) + +keys = [] + +for i in range(0, 100): + keys.append(RichCurveKey(Time=i, Value=i)) + +curve.FloatCurve.Keys = keys + +curve.post_edit_change() + +ue.open_editor_for_asset(curve) + +factory = CurveVectorFactory() + +curve = factory.factory_create_new('/Game/CustomVectorCurve' + str(int(time.time()))) + +# one curve list for each axis +keys_x = [] +keys_y = [] +keys_z = [] + +for i in range(0, 100): + keys_x.append(RichCurveKey(Time=i * 0.1, Value=i * 0.1)) + keys_y.append(RichCurveKey(Time=i * 0.1, Value=i * 0.1)) + keys_z.append(RichCurveKey(Time=i * 0.1, Value=i * 0.1)) + +# FloatCurves is a native array, use property index (0=x, 1=y, 2=z) +curve.set_property('FloatCurves', RichCurve(Keys=keys_x), 0) +curve.set_property('FloatCurves', RichCurve(Keys=keys_y), 1) +curve.set_property('FloatCurves', RichCurve(Keys=keys_z), 2) + +curve.post_edit_change() + +ue.open_editor_for_asset(curve) diff --git a/examples/edit_level_blueprint.py b/examples/edit_level_blueprint.py new file mode 100644 index 000000000..a7ddd961c --- /dev/null +++ b/examples/edit_level_blueprint.py @@ -0,0 +1,8 @@ +import unreal_engine as ue +from unreal_engine.structs import EdGraphPinType + +world = ue.get_editor_world() +level_bp = world.CurrentLevel.get_level_script_blueprint() +pin = EdGraphPinType(PinCategory='string') +ue.blueprint_add_member_variable(level_bp, 'TestString', pin) +ue.open_editor_for_asset(level_bp) diff --git a/examples/get_windows.py b/examples/get_windows.py new file mode 100644 index 000000000..6b34d713b --- /dev/null +++ b/examples/get_windows.py @@ -0,0 +1,28 @@ +import unreal_engine as ue +from unreal_engine import FSlateApplication +from unreal_engine.classes import GameViewportClient + +def iterate_window(window): + print(window.get_title()) + for child in window.get_child_windows(): + iterate_window(child) + +# get the active top level window +top_window = FSlateApplication.get_active_top_level_window() +iterate_window(top_window) + +# get Game GameViewportClient +try: + iterate_window(ue.get_game_viewport_client().game_viewport_client_get_window()) +except: + pass + +# get PIE GameViewportClient +try: + iterate_window(ue.get_editor_pie_game_viewport_client().game_viewport_client_get_window()) +except: + pass + +# iterate all GameViewportClient uobject's +for game_viewport_client in ue.tobject_iterator(GameViewportClient): + iterate_window(game_viewport_client.game_viewport_client_get_window()) \ No newline at end of file diff --git a/examples/kdop.py b/examples/kdop.py new file mode 100644 index 000000000..c68facde6 --- /dev/null +++ b/examples/kdop.py @@ -0,0 +1,13 @@ +import unreal_engine as ue +from unreal_engine.structs import KAggregateGeom + + +mesh = ue.get_selected_assets()[0] + +mesh.BodySetup.AggGeom = KAggregateGeom() + +mesh.static_mesh_generate_kdop26() +mesh.static_mesh_generate_kdop18() +mesh.static_mesh_generate_kdop10x() +mesh.static_mesh_generate_kdop10y() +mesh.static_mesh_generate_kdop10z() diff --git a/examples/multi_in_editor_capture.py b/examples/multi_in_editor_capture.py new file mode 100644 index 000000000..a19680e11 --- /dev/null +++ b/examples/multi_in_editor_capture.py @@ -0,0 +1,19 @@ +import unreal_engine as ue +from unreal_engine.classes import AutomatedLevelSequenceCapture, World +from unreal_engine.structs import SoftObjectPath + +level_sequence_mappings = { + '/Game/SequenceForDefault001': '/Game/Default001', + '/Game/SequenceForVR001': '/Game/VR001' +} + +def setup_sequence(capture): + ue.open_editor_for_asset(ue.load_object(World, level_sequence_mappings[capture.LevelSequenceAsset.AssetPathName])) + +captures = [] +for sequence_asset in level_sequence_mappings: + capture = AutomatedLevelSequenceCapture() + capture.LevelSequenceAsset = SoftObjectPath(AssetPathName=sequence_asset) + captures.append(capture) + +ue.in_editor_capture(captures, setup_sequence) diff --git a/examples/register_new_native_component.py b/examples/register_new_native_component.py new file mode 100644 index 000000000..6b021b410 --- /dev/null +++ b/examples/register_new_native_component.py @@ -0,0 +1,15 @@ +import unreal_engine as ue +from unreal_engine.classes import ActorComponent + + +class FooComponent(ActorComponent): + def __init__(self): + ue.log('Ctor') + + def DoSomething(): + ue.print_string('TEST !!!') + +FooComponent.set_metadata('BlueprintType', 'true') +FooComponent.set_metadata('BlueprintSpawnableComponent', 'true') +FooComponent.set_metadata('IsBlueprintBase', 'true') +FooComponent.component_type_registry_invalidate_class() diff --git a/examples/rotate_texture.py b/examples/rotate_texture.py new file mode 100644 index 000000000..6d0de0834 --- /dev/null +++ b/examples/rotate_texture.py @@ -0,0 +1,21 @@ +from PIL import Image +import unreal_engine as ue +from unreal_engine.classes import Texture2D + +def rotate_selected_assets_data(degrees): + for asset in ue.get_selected_assets(): + if asset.is_a(Texture2D): + data = asset.texture_get_source_data() + + size = (asset.texture_get_width(), asset.texture_get_height()) + + img = Image.frombytes('RGBA', size, bytes(data)) + + out = img.rotate(degrees) + + asset.texture_set_source_data(out.tobytes()) + + + + +rotate_selected_assets_data(45) diff --git a/examples/sequencer_scripting.py b/examples/sequencer_scripting.py index ce73c1380..b1bc4d1c1 100644 --- a/examples/sequencer_scripting.py +++ b/examples/sequencer_scripting.py @@ -1,16 +1,22 @@ # the Sequencer API support has been sponsored by Matthew Whelan (http://www.mattwhelan.com/) import unreal_engine as ue -from unreal_engine.classes import MovieSceneAudioTrack, LevelSequenceFactoryNew, MovieSceneSkeletalAnimationTrack, Character, SkeletalMesh, MovieScene3DTransformTrack, CineCameraActor +from unreal_engine.classes import MovieSceneAudioTrack, LevelSequenceFactoryNew, MovieSceneSkeletalAnimationTrack, Character, SkeletalMesh, MovieScene3DTransformTrack, CineCameraActor, AnimSequence import time -from unreal_engine.structs import FloatRange, FloatRangeBound +from unreal_engine.structs import FloatRange, FloatRangeBound, MovieSceneObjectBindingID from unreal_engine import FTransform, FVector +from unreal_engine.enums import EMovieSceneObjectBindingSpace # create a new level sequence asset factory = LevelSequenceFactoryNew() seq = factory.factory_create_new('/Game/MovieMaster' + str(int(time.time()))) +if ue.ENGINE_MINOR_VERSION >= 20 + print(seq.MovieScene.TickResolution.Numerator) + +seq.sequencer_set_playback_range(0, 30) + # add an audio track (without sound section ;) to the sequence audio = seq.sequencer_add_master_track(MovieSceneAudioTrack) @@ -21,7 +27,7 @@ character = world.actor_spawn(Character) # notify modifications are about to happen... character.modify() -character.Mesh.SkeletalMesh = ue.load_object(SkeletalMesh, '/Game/InfinityBladeAdversaries/Enemy/Enemy_Bear/Enemy_Bear.Enemy_Bear') +character.Mesh.SkeletalMesh = ue.load_object(SkeletalMesh, '/Game/Mannequin/Character/Mesh/SK_Mannequin.SK_Mannequin') # finalize the actor character.post_edit_change() @@ -34,35 +40,28 @@ # create 3 animations sections (assign AnimSequence field to set the animation to play) anim_sequence = anim.sequencer_track_add_section() -anim_sequence.StartTime = 1 -anim_sequence.EndTime = 3 +anim_sequence.sequencer_set_section_range(1, 3) +anim_sequence.Params.Animation = ue.load_object(AnimSequence, '/Game/Mannequin/Animations/ThirdPersonRun.ThirdPersonRun') anim_sequence.RowIndex = 0 anim_sequence2 = anim.sequencer_track_add_section() anim_sequence2.RowIndex = 1 -anim_sequence2.StartTime = 2 -anim_sequence2.EndTime = 5 +anim_sequence2.sequencer_set_section_range(2, 5) anim_sequence3 = anim.sequencer_track_add_section() anim_sequence3.RowIndex = 1 anim_sequence3.SlotName = 'Hello' -anim_sequence3.StartTIme = 0 -anim_sequence3.EndTime = 30 +anim_sequence3.sequencer_set_section_range(0, 30) # add a transform track/section in one shot to the actor transform = seq.sequencer_add_track(MovieScene3DTransformTrack, guid).sequencer_track_add_section() -transform.StartTime = 0 -transform.EndTime = 5 +transform.sequencer_set_section_range(0, 50) -# add keyframes to the transform section -transform.sequencer_section_add_key(0, FTransform(FVector(0, 0, 17 * 100))) -transform.sequencer_section_add_key(1, FTransform(FVector(0, 0, 22 * 100))) -transform.sequencer_section_add_key(2, FTransform(FVector(0, 0, 26 * 100))) -transform.sequencer_section_add_key(2.5, FTransform(FVector(0, 0, 30 * 100))) - -# set playback range -float_range = FloatRange(LowerBound=FloatRangeBound(Value=0), UpperBound=FloatRangeBound(Value=10)) -seq.MovieScene.PlaybackRange = float_range +# add keyframes to the transform section (from 4.20 you can directly use teh reflection api, and the methods returns the frame numbers) +print(transform.sequencer_section_add_key(0, FTransform(FVector(0, 0, 17 * 100)))) +print(transform.sequencer_section_add_key(1.1, FTransform(FVector(0, 0, 22 * 100)))) +print(transform.sequencer_section_add_key(2.2, FTransform(FVector(0, 0, 26 * 100)))) +print(transform.sequencer_section_add_key(3.3, FTransform(FVector(0, 0, 30 * 100)))) # add camera cut track (can be only one) camera_cut_track = seq.sequencer_add_camera_cut_track() @@ -78,16 +77,13 @@ cine_camera2 = world.actor_spawn(CineCameraActor) camera2_guid = seq.sequencer_add_actor(cine_camera2) -# assign the two cameras to the camera cut sections (via guid) -camera1.CameraGuid = ue.string_to_guid(camera_guid) -camera2.CameraGuid = ue.string_to_guid(camera2_guid) - -# set cameras time slots -camera1.StartTime = 0 -camera1.EndTime = 3.5 +# assign the two cameras to the camera cut sections (via binding id) +camera1.CameraBindingID = MovieSceneObjectBindingID( Guid=ue.string_to_guid( camera_guid ), Space=EMovieSceneObjectBindingSpace.Local ) +camera2.CameraBindingID = MovieSceneObjectBindingID( Guid=ue.string_to_guid( camera2_guid ), Space=EMovieSceneObjectBindingSpace.Local ) -camera2.StartTime = 3.5 -camera2.EndTime = 5 +# set cameras ranges +camera1.sequencer_set_section_range(3.5, 5) +camera2.sequencer_set_section_range(0.5, 17) # notify the sequence editor that something heavily changed (True will focus to the sequence editor) seq.sequencer_changed(True) diff --git a/examples/slate_file_path_picker.py b/examples/slate_file_path_picker.py new file mode 100644 index 000000000..92674fed3 --- /dev/null +++ b/examples/slate_file_path_picker.py @@ -0,0 +1,18 @@ +import unreal_engine as ue +from unreal_engine import SFilePathPicker, SWindow, FLinearColor +from unreal_engine.structs import ButtonStyle, SlateBrush, SlateColor + +# a style is required for the file picker +style = ButtonStyle(Normal=SlateBrush(TintColor=SlateColor(SpecifiedColor=FLinearColor(1, 0, 0)))) + + +window = SWindow(client_size=(576,576), title='Hello', modal=True) + +def path_picked(path): + print(path) + window.request_destroy() + +picker = SFilePathPicker(browse_title='Hello', browse_button_style=style, on_path_picked=path_picked) +window.set_content(picker) + +window.add_modal() \ No newline at end of file diff --git a/examples/slow_task.py b/examples/slow_task.py new file mode 100644 index 000000000..f3f8f54b7 --- /dev/null +++ b/examples/slow_task.py @@ -0,0 +1,28 @@ +from unreal_engine import FSlowTask +import time + +# Create an FSlowTask object, defining the amount of work that +# will be done, and the initial message. +t = FSlowTask(10, "Doing Something") +t.initialize() + +# Make the dialog, and include a Cancel button (default is not to +# allow a cancel button). +t.make_dialog(True) + +time.sleep(1) + +for i in range(10) : + # Update the progress bar. Note that the first argument is the + # amount of work to be done this frame, not the overall work + # done so far. + t.enter_progress_frame(1, "Progress Position : {}".format(i)) + time.sleep(0.2) + + # If there was a cancel button included, we can check if it was + # pressed. + if t.received_user_cancel(): + print("Cancelled") + break + +t.destroy() diff --git a/examples/sub_menu.py b/examples/sub_menu.py new file mode 100644 index 000000000..9d7901f2f --- /dev/null +++ b/examples/sub_menu.py @@ -0,0 +1,30 @@ +import unreal_engine as ue + +def open_submenu001(builder): + builder.begin_section('submenu001', 'i am a tooltip') + builder.add_menu_entry('sub_one', 'tooltip', lambda: ue.log('hello from submenu001')) + builder.add_menu_entry('sub_one_2', 'tooltip 2', lambda: ue.log('hello again')) + builder.end_section() + +def open_sub_submenu(builder): + builder.begin_section('sub_submenu003', 'i am a tooltip for the submenu') + builder.add_menu_entry('sub_sub_three', 'tooltip', lambda: ue.log('hello from sub_submenu003')) + builder.end_section() + +def open_submenu002(builder): + builder.begin_section('submenu002', 'i am a tooltip') + builder.add_menu_entry('sub_two', 'tooltip', lambda: ue.log('hello from submenu002')) + builder.add_sub_menu('sub sub menu', 'tooltip !', open_sub_submenu) + builder.end_section() + + +def open_menu(builder): + builder.begin_section('test1', 'test2') + builder.add_menu_entry('one', 'two', lambda: ue.log('ciao 1')) + builder.add_sub_menu('i am a submenu', 'tooltip for the submenu', open_submenu001) + builder.add_menu_entry('three', 'four', lambda: ue.log('ciao 2')) + builder.add_sub_menu('i am another submenu', 'tooltip for the second submenu', open_submenu002) + builder.end_section() + + +ue.add_menu_bar_extension('SimpleMenuBarExtension', open_menu) \ No newline at end of file diff --git a/examples/widget_blueprint_generator.py b/examples/widget_blueprint_generator.py new file mode 100644 index 000000000..ec68c1b6d --- /dev/null +++ b/examples/widget_blueprint_generator.py @@ -0,0 +1,37 @@ +import unreal_engine as ue + +from unreal_engine.classes import Image, CanvasPanelSlot, TextBlock, WidgetBlueprintFactory +from unreal_engine.structs import AnchorData, Anchors, Vector2D, Margin + +import time + +widget = WidgetBlueprintFactory().factory_create_new( "/Game/W_MyWidgetBlueprint" + str(int(time.time())) ) + +widget.modify() + +widgetTree = widget.WidgetTree + + +slot = CanvasPanelSlot('', widgetTree) +image = Image('', widgetTree) + +slot.Content = image + +slot2 = CanvasPanelSlot('', widgetTree) +text_block = TextBlock('', widgetTree) +text_block.Text = 'Hello World' + +slot2.Content = text_block + +widgetTree.RootWidget.Slots = [slot, slot2] +widgetTree.AllWidgets = [ widgetTree.RootWidget, image, text_block ] + +slot.LayoutData = AnchorData(Offsets=Margin(Left=0, Top=0, Right=300, Bottom=300)) + +slot2.LayoutData = AnchorData(Anchors=Anchors(Minimum=Vector2D(X=0.5, Y=0.5), Maximum=Vector2D(X=1, Y=1))) + +widget.post_edit_change() + +ue.compile_blueprint(widget) + +ue.open_editor_for_asset(widget) \ No newline at end of file diff --git a/examples/world_folders_and_groups.py b/examples/world_folders_and_groups.py new file mode 100644 index 000000000..d4be586b6 --- /dev/null +++ b/examples/world_folders_and_groups.py @@ -0,0 +1,26 @@ +import unreal_engine as ue +from unreal_engine.classes import GroupActor + +import time + +world = ue.get_editor_world() +group_actor = world.actor_spawn(GroupActor) + +for folder in world.world_folders(): + print(folder) + +new_folder = 'FooBar_{}'.format(int(time.time())) + +world.world_create_folder(new_folder) + +world.world_rename_folder(new_folder, new_folder + '__hello') + +world.world_delete_folder(new_folder + '__hello') + +actor = ue.editor_get_selected_actors()[0] + +# folder tree will be automatically created +actor.set_folder_path('Test1/Test2/Test3') + +# assign actors to the group +group_actor.GroupActors = [actor] \ No newline at end of file diff --git a/tests/test_actor.py b/tests/test_actor.py index 3b0d0e7fe..b2ef6e832 100644 --- a/tests/test_actor.py +++ b/tests/test_actor.py @@ -58,3 +58,5 @@ def test_get_components(self): +if __name__ == '__main__': + unittest.main(exit=False) diff --git a/tests/test_blueprint.py b/tests/test_blueprint.py index 408996564..5f755848f 100644 --- a/tests/test_blueprint.py +++ b/tests/test_blueprint.py @@ -50,3 +50,6 @@ def test_event(self): new_actor.TestEvent() self.assertEqual(new_actor.get_actor_location(), FVector(17, 30, 22)) + +if __name__ == '__main__': + unittest.main(exit=False) diff --git a/tests/test_clipboard.py b/tests/test_clipboard.py index bdabedf73..3416ef31d 100644 --- a/tests/test_clipboard.py +++ b/tests/test_clipboard.py @@ -9,4 +9,7 @@ def test_copy_and_paste(self): def test_copy_and_paste_red_light(self): ue.clipboard_copy('Hello from red light test') - self.assertNotEqual(ue.clipboard_paste(), 'Hello from python unit test') \ No newline at end of file + self.assertNotEqual(ue.clipboard_paste(), 'Hello from python unit test') + +if __name__ == '__main__': + unittest.main(exit=False) diff --git a/tests/test_structs.py b/tests/test_structs.py index 9b6bb351f..d1d239dbb 100644 --- a/tests/test_structs.py +++ b/tests/test_structs.py @@ -40,11 +40,11 @@ def test_cmp(self): def test_ptr(self): source_model = StaticMeshSourceModel() - source_model.ref().BuildSettings.ref().bRecomputeNormals=False - source_model.ref().BuildSettings.ref().bRecomputeTangents=True - source_model.ref().BuildSettings.ref().bUseMikkTSpace=True - source_model.ref().BuildSettings.ref().bBuildAdjacencyBuffer=True - source_model.ref().BuildSettings.ref().bRemoveDegenerates=True + source_model.BuildSettings.bRecomputeNormals=False + source_model.BuildSettings.bRecomputeTangents=True + source_model.BuildSettings.bUseMikkTSpace=True + source_model.BuildSettings.bBuildAdjacencyBuffer=True + source_model.BuildSettings.bRemoveDegenerates=True source_model2 = source_model.clone() self.assertEqual(source_model2.BuildSettings.bRecomputeNormals, False) diff --git a/tools/build_mac.sh b/tools/build_mac.sh new file mode 100644 index 000000000..646fe368a --- /dev/null +++ b/tools/build_mac.sh @@ -0,0 +1 @@ +UEP_ENABLE_UNITY_BUILD=1 mono "/Users/Shared/Epic Games/UE_4.19/Engine/Binaries/DotNET/UnrealBuildTool.exe" PyTest418 Development Mac -project="/Users/roberto/Documents/Unreal Projects/PyTest418/PyTest418.uproject" -editorrecompile diff --git a/tools/generate_pyi_stubs.py b/tools/generate_pyi_stubs.py new file mode 100644 index 000000000..8afbac0e3 --- /dev/null +++ b/tools/generate_pyi_stubs.py @@ -0,0 +1,152 @@ +import re +import os +import sys +import unreal_engine as ue + + +# TODO: there are invalid names like 'IsInAir?' and 'EUserInterfaceActionType.None' +VALID_NAME_PATTERN = re.compile('^[_a-zA-Z][_a-zA-Z0-9]*$') +FILTERED_NAMES = { + '__new__', '__doc__', + '__str__', '__repr__', '__name__', + '__loader__', '__spec__', '__package__', + '__loader__', '__hash__', '__weakref__' +} + +# This list is kinda reliable for descriptors implemented in C, it's ugly to get their types +# https://docs.python.org/3/library/inspect.html#fetching-attributes-statically +DESCRIPTORS = {'getset_descriptor', 'member_descriptor'} + + +def is_valid_name(name): + return VALID_NAME_PATTERN.match(name) is not None and name not in FILTERED_NAMES + + +def filter_names(names): + return (name for name in names if is_valid_name(name)) + + +def filter_attributes(attributes): + return {name: value for name, value in attributes.items() if is_valid_name(name)} + + +def get_type_name(obj): + type_ = type(obj) + try: + return type_.__qualname__ + except AttributeError: + return type_.__name__ + + +def is_class(t): + return isinstance(t, type) + + +def is_callable(obj): + return hasattr(obj, '__call__') + + +def write_function(file, name, indent): + file.write(indent) + # TODO: ideally methods functions should be handled differently, like have self + # but we don't know arguments and if it's staticmethod or classmethod anyway + file.write("def {}(*args, **kwargs) -> 'typing.Any': ...\n".format(name)) + + +def write_variable(file, name, value, indent): + type_name = get_type_name(value) + file.write(indent) + + if isinstance(value, property) or value is None or type_name in DESCRIPTORS: + variable_type = 'typing.Any' + else: + variable_type = '{}'.format(type_name) + + file.write( + "{}: '{}'\n".format(name, variable_type) + ) + + +def write_class(file, name, value, indent): + file.write(indent) + file.write("class {}:\n".format(name)) + attributes = filter_attributes(vars(value)) + + if not attributes: + file.write(indent) + file.write(" pass\n") + else: + for attribute_name, attribute_value in attributes.items(): + write_object(file, attribute_name, attribute_value, indent + ' ') + + file.write('\n') + file.write('\n') + + +def write_object(file, name, value, indent): + # TODO: https://github.com/20tab/UnrealEnginePython/issues/394 ESlateEnums contains invalid attributes + if not is_valid_name(name): + return + + if is_class(value): + write_class(file, name, value, indent) + elif is_callable(value): + write_function(file, name, indent) + else: + write_variable(file, name, value, indent) + + +def write_ue_classes(file, classes): + for class_ in classes: + file.write("class {}:\n".format(class_.get_name())) + + attributes_count = 0 + + for property_ in filter_names(class_.properties()): + file.write(" ") + file.write("{}: 'typing.Any'\n".format(property_)) + attributes_count += 1 + + for function_ in filter_names(class_.functions()): + file.write(" ") + file.write("def {}(*args, **kwargs) -> 'typing.Any': pass\n".format(function_)) + attributes_count += 1 + + if attributes_count == 0: + file.write(" ") + file.write("pass\n") + + file.write("\n") + + +def generate_pyi_stubs(directory, include_reflection=False): + """ + Generates pyi file. Note include_reflection has not been implemented yet. + """ + # include_reflection is still WIP and bit unusable, because: + # * the result file is very large and PyCharm by default ignores such files + # * it contains some invalid identifiers ('IsInAir?') + if include_reflection: + raise NotImplementedError + + package_dir = os.path.join(directory, 'unreal_engine') + os.mkdir(package_dir) + + init_path = os.path.join(package_dir, '__init__.pyi') + with open(init_path, mode='w') as file: + file.write('import typing') + file.write('\n\n') + + ue_public = vars(ue) + for name, value in filter_attributes(ue_public).items(): + write_object(file, name, value, '') + file.write('\n') + + if include_reflection: + classes_path = os.path.join(package_dir, 'classes.pyi') + with open(classes_path, mode='w') as file: + write_ue_classes(file, ue.all_classes()) + + +if __name__ == '__main__': + generate_pyi_stubs(sys.argv[1]) diff --git a/tools/release_win64.py b/tools/release_win64.py index 3af62aabf..057800496 100644 --- a/tools/release_win64.py +++ b/tools/release_win64.py @@ -5,8 +5,11 @@ import shutil import zipfile -UE_VERSIONS = ['4.15', '4.16', '4.17', '4.18'] -PYTHON_VERSIONS = ["C:/Program Files/Python36", "C:/Program Files/Python35", "C:/Python27"] +UE_VERSIONS = ['4.20', '4.21', '4.22'] +PYTHON_VERSIONS = ["C:/Program Files/Python37", "C:/Program Files/Python36", "C:/Python27"] +MSBUILD = 'C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/MSBuild/15.0/Bin/MSBuild.exe' +UE_PATH = 'C:/Program Files/Epic Games' +PROJECTS_PATH = 'C:/Users/rober/Documents/Unreal Projects' RELEASE_DIR = sys.argv[1].rstrip('/') @@ -16,33 +19,31 @@ def zipdir(path, zh, base): filename = os.path.join(root, file) zh.write(filename, os.path.relpath(filename, base)) -def msbuild(project, python_version, variant): +def msbuild(project, python_version): base_environ = os.environ base_environ.update({'PYTHONHOME': python_version}) - if variant == 'threaded_': - base_environ.update({'UEP_ENABLE_THREADS': '1'}) - #vs = '"C:/Program Files (x86)/MSBuild/14.0/Bin/MSBuild.exe"' - vs = '"C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/MSBuild/15.0/Bin/MSBuild.exe"' - process = subprocess.Popen('{0} {1} /m /t:Rebuild /p:Configuration="Development Editor" /p:Platform=Win64'.format(vs, project), env=base_environ) + base_environ.update({'UEP_ENABLE_UNITY_BUILD': '1'}) + vs = '"{}"'.format(MSBUILD) + process = subprocess.Popen('{0} "{1}" /m /t:Rebuild /p:Configuration="Development Editor" /p:Platform=Win64'.format(vs, project), env=base_environ) while process.poll() is None: time.sleep(0.5) if process.returncode != 0: sys.exit(process.returncode) def commandlet(version, project): - ue_editor = os.path.join('D:/', 'UE_{0}'.format(version), 'Engine/Binaries/Win64/UE4Editor-Cmd.exe') - process = subprocess.Popen('{0} D:/{1}/{2}.uproject -run=PyCommandlet D:/{3}/Plugins/UnrealEnginePython/tools/release_check.py'.format(ue_editor, project, project, project)) + ue_editor = os.path.join(UE_PATH, 'UE_{0}'.format(version), 'Engine/Binaries/Win64/UE4Editor-Cmd.exe') + process = subprocess.Popen('{0} {1}/{2}/{3}.uproject -run=PyCommandlet {1}/{4}/Plugins/UnrealEnginePython/tools/release_check.py'.format(ue_editor, PROJECTS_PATH, project, project, project)) while process.poll() is None: time.sleep(0.5) # ignore return code, has too much different meanings for commandlets def git(project): - process = subprocess.Popen('git checkout master', cwd='D:/{0}/Plugins/UnrealEnginePython'.format(project)) + process = subprocess.Popen('git checkout master', cwd='{0}/{1}/Plugins/UnrealEnginePython'.format(PROJECTS_PATH, project)) while process.poll() is None: time.sleep(0.5) if process.returncode != 0: sys.exit(process.returncode) - process = subprocess.Popen('git pull', cwd='D:/{0}/Plugins/UnrealEnginePython'.format(project)) + process = subprocess.Popen('git pull', cwd='{0}/{1}/Plugins/UnrealEnginePython'.format(PROJECTS_PATH, project)) while process.poll() is None: time.sleep(0.5) if process.returncode != 0: @@ -52,31 +53,30 @@ def git(project): main_start = time.time() for ue_version in UE_VERSIONS: project = 'PyTest{0}'.format(ue_version.replace('.', '')) - sln = os.path.join('D:/', project, '{0}.sln'.format(project)) + sln = os.path.join(PROJECTS_PATH, project, '{0}.sln'.format(project)) git(project) for python_version in PYTHON_VERSIONS: - for variant in ('', 'threaded_'): - python_sanitized = os.path.basename(python_version).lower() - start = time.time() - print('\n\n***** building {0} for {1} ({2}) *****\n\n'.format(sln, python_version, variant)) - sys.stdout.flush() - msbuild(sln, python_version, variant) - commandlet(ue_version, project) - end = time.time() - for item in ('UE4Editor.modules', 'UE4Editor-UnrealEnginePython.dll', 'UE4Editor-PythonConsole.dll', 'UE4Editor-PythonEditor.dll'): - shutil.copyfile('D:/{0}/Plugins/UnrealEnginePython/Binaries/Win64/{1}'.format(project, item), '{0}/UnrealEnginePython/Binaries/Win64/{1}'.format(RELEASE_DIR, item)) - if python_sanitized == 'python36': - shutil.copyfile('D:/{0}/Plugins/UnrealEnginePython/Binaries/Win64/{1}'.format(project, item), '{0}/Embedded/UnrealEnginePython/Binaries/Win64/{1}'.format(RELEASE_DIR, item)) - filename = 'UnrealEnginePython_{0}_{1}_{2}_{3}win64.zip'.format(os.path.basename(RELEASE_DIR), ue_version.replace('.','_'), python_sanitized, variant) + python_sanitized = os.path.basename(python_version).lower() + start = time.time() + print('\n\n***** building {0} for {1} *****\n\n'.format(sln, python_version)) + sys.stdout.flush() + msbuild(sln, python_version) + commandlet(ue_version, project) + end = time.time() + for item in ('UE4Editor.modules', 'UE4Editor-UnrealEnginePython.dll', 'UE4Editor-PythonConsole.dll', 'UE4Editor-PythonEditor.dll', 'UE4Editor-PythonAutomation.dll'): + shutil.copyfile('{0}/{1}/Plugins/UnrealEnginePython/Binaries/Win64/{2}'.format(PROJECTS_PATH, project, item), '{0}/UnrealEnginePython/Binaries/Win64/{1}'.format(RELEASE_DIR, item)) + if python_sanitized == 'python36': + shutil.copyfile('{0}/{1}/Plugins/UnrealEnginePython/Binaries/Win64/{2}'.format(PROJECTS_PATH, project, item), '{0}/Embedded/UnrealEnginePython/Binaries/Win64/{1}'.format(RELEASE_DIR, item)) + filename = 'UnrealEnginePython_{0}_{1}_{2}_win64.zip'.format(os.path.basename(RELEASE_DIR), ue_version.replace('.','_'), python_sanitized) + zh = zipfile.ZipFile(os.path.join(RELEASE_DIR, filename), 'w', zipfile.ZIP_DEFLATED) + zipdir(os.path.join(RELEASE_DIR, 'UnrealEnginePython'), zh, RELEASE_DIR) + zh.close() + if python_sanitized == 'python36': + filename = 'UnrealEnginePython_{0}_{1}_{2}_embedded_win64.zip'.format(os.path.basename(RELEASE_DIR), ue_version.replace('.','_'), python_sanitized) zh = zipfile.ZipFile(os.path.join(RELEASE_DIR, filename), 'w', zipfile.ZIP_DEFLATED) - zipdir(os.path.join(RELEASE_DIR, 'UnrealEnginePython'), zh, RELEASE_DIR) + zipdir(os.path.join(RELEASE_DIR, 'Embedded/UnrealEnginePython'), zh, os.path.join(RELEASE_DIR, 'Embedded')) zh.close() - if python_sanitized == 'python36': - filename = 'UnrealEnginePython_{0}_{1}_{2}_{3}embedded_win64.zip'.format(os.path.basename(RELEASE_DIR), ue_version.replace('.','_'), python_sanitized, variant) - zh = zipfile.ZipFile(os.path.join(RELEASE_DIR, filename), 'w', zipfile.ZIP_DEFLATED) - zipdir(os.path.join(RELEASE_DIR, 'Embedded/UnrealEnginePython'), zh, os.path.join(RELEASE_DIR, 'Embedded')) - zh.close() - print('\n\n***** built {0} for {1} in {2} seconds [{3}]*****\n\n'.format(project, python_version, end-start, filename)) + print('\n\n***** built {0} for {1} in {2} seconds [{3}]*****\n\n'.format(project, python_version, end-start, filename)) main_end = time.time() print('release ready after {0} seconds'.format(main_end-main_start)) diff --git a/tutorials/AsyncIOAndUnrealEngine.md b/tutorials/AsyncIOAndUnrealEngine.md index d374b29bb..4bce75306 100644 --- a/tutorials/AsyncIOAndUnrealEngine.md +++ b/tutorials/AsyncIOAndUnrealEngine.md @@ -182,7 +182,7 @@ async def new_client_connected(reader, writer): # see below for more infos about exception management async def spawn_server(host, port): try: - coro = await asyncio.start_server(new_client_connected, host, port) + coro = await asyncio.start_server(new_client_connected, host, port, reuse_address=True) ue.log('tcp server spawned on {0}:{1}'.format(host, port)) await coro.wait_closed() finally: diff --git a/tutorials/FixingMixamoRootMotionWithPython.md b/tutorials/FixingMixamoRootMotionWithPython.md index 3abb1266d..6bea40e5a 100644 --- a/tutorials/FixingMixamoRootMotionWithPython.md +++ b/tutorials/FixingMixamoRootMotionWithPython.md @@ -16,7 +16,7 @@ Once our mixamo assets are imported we need to do the following steps: * Modify the SkeletalMesh bone influences as indexes will be shifted after the adding of a new bone -* Split the 'Hips' related animation curve in two other curves, one containing the root motion (translations, relative to local axis origin) that will be mapped to the 'root' track, and the other mapped to the 'Hips' track that will contain only rotations. +* Split the 'Hips' related animation curve in two other curves, one containing the root motion (translations, relative to local axis origin) that will be mapped to the 'root' track, and the other mapped to the 'Hips' track that will contain only rotations. The 'root' track must be the first one. To avoid damages, we will generate a copy of each asset, so you will be able to always use the original ones. @@ -326,16 +326,13 @@ class RootMotionFixer: new_anim.NumFrames = animation.NumFrames new_anim.SequenceLength = animation.SequenceLength - # iterate each track to copy/fix + # first step is generatin the 'root' track + # we need to do it before anything else, as the 'root' track must be the 0 one for index, name in enumerate(animation.AnimationTrackNames): - data = animation.get_raw_animation_track(index) if name == bone: + data = animation.get_raw_animation_track(index) # extract root motion - root_motion = [position - data.pos_keys[0] for position in data.pos_keys] - - # remove root motion from original track (but leave a single key for position, otherwise the track will break) - data.pos_keys = [data.pos_keys[0]] - new_anim.add_new_raw_track(name, data) + root_motion = [(position - data.pos_keys[0]) for position in data.pos_keys] # create a new track (the root motion one) root_data = FRawAnimSequenceTrack() @@ -343,14 +340,36 @@ class RootMotionFixer: # ensure empty rotations ! root_data.rot_keys = [FQuat()] - # add the track + # add the track new_anim.add_new_raw_track('root', root_data) + break + else: + raise DialogException('Unable to find bone {0}'.format(bone)) + + # now append the original tracks, but removes the position keys + # from the original root bone + for index, name in enumerate(animation.AnimationTrackNames): + data = animation.get_raw_animation_track(index) + if name == bone: + # remove root motion from original track + data.pos_keys = [data.pos_keys[0]] + new_anim.add_new_raw_track(name, data) else: new_anim.add_new_raw_track(name, data) new_anim.save_package() ``` +The two 'for loops' is where the fix happens. Take into account that some animation could require additional manipulation, +as an example you may want to remove z and x transformations for a running loop: + +```python +# extract root motion +root_motion = [((position - data.pos_keys[0]) * FVector(0, 1, 0)) for position in data.pos_keys] +``` + +And always remember that modifying the z axis in root motion, requires your Character to be in 'Flying' movement mode. + Now add support for AnimSequence in your final loop: ```python diff --git a/tutorials/FixingMixamoRootMotionWithPython_Assets/mixamo.py b/tutorials/FixingMixamoRootMotionWithPython_Assets/mixamo.py index 9445e3c1f..9e269f4c7 100644 --- a/tutorials/FixingMixamoRootMotionWithPython_Assets/mixamo.py +++ b/tutorials/FixingMixamoRootMotionWithPython_Assets/mixamo.py @@ -122,15 +122,13 @@ def split_hips(self, animation, bone='Hips'): new_anim.NumFrames = animation.NumFrames new_anim.SequenceLength = animation.SequenceLength + # first step is generatin the 'root' track + # we need to do it before anything else, as the 'root' track must be the 0 one for index, name in enumerate(animation.AnimationTrackNames): - data = animation.get_raw_animation_track(index) if name == bone: + data = animation.get_raw_animation_track(index) # extract root motion - root_motion = [position - data.pos_keys[0] for position in data.pos_keys] - - # remove root motion from original track - data.pos_keys = [data.pos_keys[0]] - new_anim.add_new_raw_track(name, data) + root_motion = [(position - data.pos_keys[0]) for position in data.pos_keys] # create a new track (the root motion one) root_data = FRawAnimSequenceTrack() @@ -138,8 +136,20 @@ def split_hips(self, animation, bone='Hips'): # ensure empty rotations ! root_data.rot_keys = [FQuat()] - # add the track + # add the track new_anim.add_new_raw_track('root', root_data) + break + else: + raise DialogException('Unable to find bone {0}'.format(bone)) + + # now append the original tracks, but removes the position keys + # from the original root bone + for index, name in enumerate(animation.AnimationTrackNames): + data = animation.get_raw_animation_track(index) + if name == bone: + # remove root motion from original track + data.pos_keys = [data.pos_keys[0]] + new_anim.add_new_raw_track(name, data) else: new_anim.add_new_raw_track(name, data) diff --git a/tutorials/PlottingGraphsWithMatplotlibAndUnrealEnginePython.md b/tutorials/PlottingGraphsWithMatplotlibAndUnrealEnginePython.md index 8ff7795c7..4d9c5246a 100644 --- a/tutorials/PlottingGraphsWithMatplotlibAndUnrealEnginePython.md +++ b/tutorials/PlottingGraphsWithMatplotlibAndUnrealEnginePython.md @@ -194,7 +194,7 @@ class PlotComponent: dpi = 72.0 self.texture = ue.create_transient_texture(width, height, EPixelFormat.PF_R8G8B8A8) - self.uobject.get_owner().StaticMesh.OverrideMaterials[0].set_material_texture_parameter('Graph', self.texture) + self.uobject.get_owner().StaticMeshComponent.OverrideMaterials[0].set_material_texture_parameter('Graph', self.texture) self.fig = plt.figure(1) self.fig.set_dpi(dpi) diff --git a/tutorials/PlottingGraphsWithMatplotlibAndUnrealEnginePython_Assets/plotter.py b/tutorials/PlottingGraphsWithMatplotlibAndUnrealEnginePython_Assets/plotter.py index e8e8418a4..6466adee2 100644 --- a/tutorials/PlottingGraphsWithMatplotlibAndUnrealEnginePython_Assets/plotter.py +++ b/tutorials/PlottingGraphsWithMatplotlibAndUnrealEnginePython_Assets/plotter.py @@ -14,7 +14,7 @@ def begin_play(self): dpi = 72.0 self.texture = ue.create_transient_texture(width, height, EPixelFormat.PF_R8G8B8A8) - self.uobject.get_owner().StaticMesh.OverrideMaterials[0].set_material_texture_parameter('Graph', self.texture) + self.uobject.get_owner().StaticMeshComponent.OverrideMaterials[0].set_material_texture_parameter('Graph', self.texture) self.fig = plt.figure(1) self.fig.set_dpi(dpi) diff --git a/tutorials/WritingAColladaFactoryWithPython.md b/tutorials/WritingAColladaFactoryWithPython.md index befd94c7d..3ea454911 100644 --- a/tutorials/WritingAColladaFactoryWithPython.md +++ b/tutorials/WritingAColladaFactoryWithPython.md @@ -94,7 +94,7 @@ obviously we still have not added data to our StaticMesh, so in our Content Brow ![Empty mesh](https://github.com/20tab/UnrealEnginePython/blob/master/tutorials/WritingAColladaFactoryWithPython_Assets/empty_mesh.png) -## Bulding the new mesh +## Building the new mesh The following part is a bit complex and requires heavy understanding of the UE4 internals. diff --git a/tutorials/YourFirstAutomatedPipeline.md b/tutorials/YourFirstAutomatedPipeline.md index c2a775127..f0cf00832 100644 --- a/tutorials/YourFirstAutomatedPipeline.md +++ b/tutorials/YourFirstAutomatedPipeline.md @@ -459,8 +459,6 @@ Its event graph manages the Speed variable for the blend space and the idle time ```python from unreal_engine.classes import AnimBlueprintFactory -anim_bp_factory = AnimBlueprintFactory() -anim_bp_factory.TargetSkeleton = slicer_mesh.Skeleton # ensure no blueprint with the same name exists # find_asset() returns None if the asset does not exist @@ -468,6 +466,9 @@ anim_bp = ue.find_asset('/Game/Kaiju/Slicer/slicer_AnimBP.slicer_AnimBP') if anim_bp: ue.delete_asset(anim_bp.get_path_name()) +anim_bp_factory = AnimBlueprintFactory() +anim_bp_factory.TargetSkeleton = slicer_mesh.Skeleton + anim_bp = anim_bp_factory.factory_create_new('/Game/Kaiju/Slicer/slicer_AnimBP') ```