Integrating latest 47acbe8
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/EBus/EBus.h>
|
||||
#include <AzCore/Interface/Interface.h>
|
||||
#include <AzCore/RTTI/BehaviorContext.h>
|
||||
|
||||
// forward declare the C typedef of a PyObject*
|
||||
struct _object;
|
||||
using PyObject = _object;
|
||||
|
||||
namespace EditorPythonBindings
|
||||
{
|
||||
//! A team can define custom generic types to be created for a TypeId
|
||||
//! The handler will need to allocate, deallocate, and convert behavior data to Python values
|
||||
//! NOTE: if the TypeId is registered with the Behavior Context then that will be used instead of this custom binding
|
||||
class CustomTypeBindingNotifications
|
||||
: public AZ::EBusTraits
|
||||
{
|
||||
public:
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// EBusTraits overrides
|
||||
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Multiple;
|
||||
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::ById;
|
||||
using BusIdType = AZ::TypeId;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//! This handle is used to identify the allocations an external module used to prepare the value
|
||||
//! After the EPB gem is done with the conversion, this handle will be sent back via the CleanUpValue() notification
|
||||
//! to indicate that the module should clean up the allocations for that value conversion
|
||||
using ValueHandle = std::intptr_t;
|
||||
|
||||
//! Allocate a default value for the supplied type
|
||||
using AllocationHandle = AZStd::optional<AZStd::pair<ValueHandle, AZ::BehaviorObject>>;
|
||||
virtual AllocationHandle AllocateDefault() = 0;
|
||||
|
||||
//! This method converts an incoming Python value into a behavior value; it should fill out the outValue fields
|
||||
virtual AZStd::optional<ValueHandle> PythonToBehavior(
|
||||
PyObject* pyObj,
|
||||
AZ::BehaviorParameter::Traits traits,
|
||||
AZ::BehaviorValueParameter& outValue) = 0;
|
||||
|
||||
//! This method convert an incoming behavior value into a Python value; it should fill out the outPyObj pointer
|
||||
virtual AZStd::optional<ValueHandle> BehaviorToPython(
|
||||
const AZ::BehaviorValueParameter& behaviorValue,
|
||||
PyObject*& outPyObj) = 0;
|
||||
|
||||
//! This method is used to determine that the behavior value can be processed using the Python object type as input
|
||||
//! NOTE: it should not actually do the conversion only detect IF it can be done with the supplied Python type
|
||||
virtual bool CanConvertPythonToBehavior(
|
||||
AZ::BehaviorParameter::Traits traits,
|
||||
PyObject* pyObj) const = 0;
|
||||
|
||||
//! This is used to deallocate the value used by the PythonToBehavior() or BehaviorToPython() methods
|
||||
//! The notification module is responsible for mapping the handle to the value's allocation(s)
|
||||
virtual void CleanUpValue(ValueHandle handle) = 0;
|
||||
};
|
||||
using CustomTypeBindingNotificationBus = AZ::EBus<CustomTypeBindingNotifications>;
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/EBus/EBus.h>
|
||||
|
||||
// forward declare the C typedef of a PyObject*
|
||||
struct _object;
|
||||
using PyObject = _object;
|
||||
|
||||
namespace EditorPythonBindings
|
||||
{
|
||||
/**
|
||||
* Python notifications during interpreter operations
|
||||
*/
|
||||
class EditorPythonBindingsNotifications
|
||||
: public AZ::EBusTraits
|
||||
{
|
||||
public:
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// EBusTraits overrides
|
||||
static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Multiple;
|
||||
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single;
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//! Sent when the Python VM is about to start
|
||||
virtual void OnPreInitialize() {}
|
||||
|
||||
//! Sent when the Python VM has started
|
||||
virtual void OnPostInitialize() {}
|
||||
|
||||
//! Sent when the Python VM is about to shutdown
|
||||
virtual void OnPreFinalize() {}
|
||||
|
||||
//! Sent when the Python VM has shutdown
|
||||
virtual void OnPostFinalize() {}
|
||||
|
||||
//! Sent when any module is being installed from Python script code (normally from an import statement in a script)
|
||||
virtual void OnImportModule(PyObject* module) { AZ_UNUSED(module); }
|
||||
};
|
||||
using EditorPythonBindingsNotificationBus = AZ::EBus<EditorPythonBindingsNotifications>;
|
||||
|
||||
} // namespace EditorPythonBindings
|
||||
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <AzCore/Math/Crc.h>
|
||||
|
||||
namespace EditorPythonBindings
|
||||
{
|
||||
// components
|
||||
constexpr const char PythonMarshalComponentTypeId[] = "{C733E1AD-9FDD-484E-A8D9-3EAB944B7841}";
|
||||
constexpr const char PythonReflectionComponentTypeId[] = "{CBF32BE1-292C-4988-9E64-25127A8525A7}";
|
||||
constexpr const char PythonSystemComponentTypeId[] = "{97F88B0F-CF68-4623-9541-549E59EE5F0C}";
|
||||
|
||||
// services
|
||||
constexpr AZ::Crc32 PythonMarshalingService = AZ_CRC_CE("PythonMarshalingService");
|
||||
constexpr AZ::Crc32 PythonReflectionService = AZ_CRC_CE("PythonReflectionService");
|
||||
constexpr AZ::Crc32 PythonEmbeddedService = AZ_CRC_CE("PythonEmbeddedService");
|
||||
}
|
||||
Reference in New Issue
Block a user