Skip to content

Commit 8b4b95f

Browse files
committed
More tweaks
1 parent ac919ba commit 8b4b95f

20 files changed

+244
-184
lines changed

modules/yup_core/native/yup_Threads_android.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,4 +464,13 @@ YUP_API void YUP_CALLTYPE Process::raisePrivilege() {}
464464

465465
YUP_API void YUP_CALLTYPE Process::lowerPrivilege() {}
466466

467+
YUP_API bool YUP_CALLTYPE Process::isForegroundProcess()
468+
{
469+
return true;
470+
}
471+
472+
YUP_API void YUP_CALLTYPE Process::makeForegroundProcess() {}
473+
474+
YUP_API void YUP_CALLTYPE Process::hide() {}
475+
467476
} // namespace yup

modules/yup_core/native/yup_Threads_linux.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,4 +107,16 @@ YUP_API void YUP_CALLTYPE Process::lowerPrivilege()
107107
swapUserAndEffectiveUser();
108108
}
109109

110+
//#if YUP_MODULE_AVAILABLE_yup_gui
111+
// TODO: This might require the GUI layer
112+
YUP_API bool YUP_CALLTYPE Process::isForegroundProcess()
113+
{
114+
return true;
115+
}
116+
117+
YUP_API void YUP_CALLTYPE Process::makeForegroundProcess() {}
118+
119+
YUP_API void YUP_CALLTYPE Process::hide() {}
120+
//#endif
121+
110122
} // namespace yup

modules/yup_core/native/yup_Threads_wasm.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,13 @@ YUP_API void YUP_CALLTYPE Process::lowerPrivilege()
8989
swapUserAndEffectiveUser();
9090
}
9191

92+
YUP_API bool YUP_CALLTYPE Process::isForegroundProcess()
93+
{
94+
return true;
95+
}
96+
97+
YUP_API void YUP_CALLTYPE Process::makeForegroundProcess() {}
98+
99+
YUP_API void YUP_CALLTYPE Process::hide() {}
100+
92101
} // namespace yup

modules/yup_python/bindings/yup_YupCore_bindings.h

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ namespace PYBIND11_NAMESPACE
4343
namespace detail
4444
{
4545

46-
// =================================================================================================
46+
//==============================================================================
4747

4848
template <>
4949
struct type_caster<yup::StringRef>
@@ -59,7 +59,7 @@ struct type_caster<yup::StringRef>
5959
bool load_raw (handle src);
6060
};
6161

62-
// =================================================================================================
62+
//==============================================================================
6363

6464
template <>
6565
struct type_caster<yup::String>
@@ -75,7 +75,7 @@ struct type_caster<yup::String>
7575
bool load_raw (handle src);
7676
};
7777

78-
// =================================================================================================
78+
//==============================================================================
7979

8080
template <>
8181
struct type_caster<yup::Identifier> : public type_caster_base<yup::Identifier>
@@ -93,7 +93,7 @@ struct type_caster<yup::Identifier> : public type_caster_base<yup::Identifier>
9393
bool load_raw (handle src);
9494
};
9595

96-
// =================================================================================================
96+
//==============================================================================
9797

9898
template <>
9999
struct type_caster<yup::var>
@@ -112,11 +112,11 @@ struct type_caster<yup::var>
112112
namespace yup::Bindings
113113
{
114114

115-
// =================================================================================================
115+
//==============================================================================
116116

117117
void registerYupCoreBindings (pybind11::module_& m);
118118

119-
// ============================================================================================
119+
//==============================================================================
120120

121121
template <class T, class = void>
122122
struct isEqualityComparable : std::false_type
@@ -128,7 +128,7 @@ struct isEqualityComparable<T, std::void_t<decltype (std::declval<T>() == std::d
128128
{
129129
};
130130

131-
// =================================================================================================
131+
//==============================================================================
132132

133133
template <class T>
134134
struct PyArrayElementComparator
@@ -150,7 +150,7 @@ struct PyArrayElementComparator
150150
}
151151
};
152152

153-
// ============================================================================================
153+
//==============================================================================
154154

155155
template <template <class, class, int> class Class, class... Types>
156156
void registerArray (pybind11::module_& m)
@@ -348,7 +348,7 @@ void registerArray (pybind11::module_& m)
348348
m.attr ("Array") = type;
349349
}
350350

351-
// =================================================================================================
351+
//==============================================================================
352352

353353
struct PyThreadID
354354
{
@@ -376,7 +376,7 @@ struct PyThreadID
376376
Thread::ThreadID value;
377377
};
378378

379-
// =================================================================================================
379+
//==============================================================================
380380

381381
template <class Base = InputStream>
382382
struct PyInputStream : Base
@@ -509,7 +509,7 @@ struct PyInputStream : Base
509509
}
510510
};
511511

512-
// =================================================================================================
512+
//==============================================================================
513513

514514
template <class Base = InputSource>
515515
struct PyInputSource : Base
@@ -532,7 +532,7 @@ struct PyInputSource : Base
532532
}
533533
};
534534

535-
// =================================================================================================
535+
//==============================================================================
536536

537537
template <class Base = OutputStream>
538538
struct PyOutputStream : Base
@@ -660,7 +660,7 @@ struct PyOutputStream : Base
660660
}
661661
};
662662

663-
// =================================================================================================
663+
//==============================================================================
664664

665665
template <class Base = FileFilter>
666666
struct PyFileFilter : Base
@@ -678,7 +678,7 @@ struct PyFileFilter : Base
678678
}
679679
};
680680

681-
// =================================================================================================
681+
//==============================================================================
682682

683683
struct YUP_API PyURLDownloadTaskListener : public URL::DownloadTaskListener
684684
{
@@ -693,7 +693,7 @@ struct YUP_API PyURLDownloadTaskListener : public URL::DownloadTaskListener
693693
}
694694
};
695695

696-
// =================================================================================================
696+
//==============================================================================
697697

698698
struct YUP_API PyXmlElementComparator
699699
{
@@ -739,7 +739,7 @@ struct YUP_API PyXmlElementCallableComparator
739739
pybind11::function fn;
740740
};
741741

742-
// =================================================================================================
742+
//==============================================================================
743743

744744
struct YUP_API PyHighResolutionTimer : public HighResolutionTimer
745745
{
@@ -749,7 +749,7 @@ struct YUP_API PyHighResolutionTimer : public HighResolutionTimer
749749
}
750750
};
751751

752-
// =================================================================================================
752+
//==============================================================================
753753

754754
template <class T>
755755
struct PyGenericScopedLock
@@ -858,7 +858,7 @@ struct PyGenericScopedTryLock
858858
bool acquireLockOnInitialisation;
859859
};
860860

861-
// =================================================================================================
861+
//==============================================================================
862862

863863
template <class Base = Thread>
864864
struct PyThread : Base
@@ -897,7 +897,7 @@ struct PyThread : Base
897897
}
898898
};
899899

900-
// =================================================================================================
900+
//==============================================================================
901901

902902
struct YUP_API PyThreadListener : Thread::Listener
903903
{
@@ -909,7 +909,7 @@ struct YUP_API PyThreadListener : Thread::Listener
909909
}
910910
};
911911

912-
// =================================================================================================
912+
//==============================================================================
913913

914914
struct YUP_API PyThreadPoolJob : ThreadPoolJob
915915
{
@@ -921,7 +921,7 @@ struct YUP_API PyThreadPoolJob : ThreadPoolJob
921921
}
922922
};
923923

924-
// =================================================================================================
924+
//==============================================================================
925925

926926
struct YUP_API PyThreadPoolJobSelector : ThreadPool::JobSelector
927927
{
@@ -933,7 +933,7 @@ struct YUP_API PyThreadPoolJobSelector : ThreadPool::JobSelector
933933
}
934934
};
935935

936-
// =================================================================================================
936+
//==============================================================================
937937

938938
struct YUP_API PyTimeSliceClient : TimeSliceClient
939939
{

modules/yup_python/modules/yup_YupMain_module.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
*/
2121

2222
#include "../utilities/yup_PyBind11Includes.h"
23-
2423
#include "../bindings/yup_YupCore_bindings.h"
2524

2625
#if YUP_MODULE_AVAILABLE_juce_events
@@ -64,7 +63,8 @@
6463
#include "ScriptJuceAudioUtilsBindings.h"
6564
#endif
6665

67-
// =================================================================================================
66+
//==============================================================================
67+
6868
#if YUP_PYTHON_EMBEDDED_INTERPRETER
6969
PYBIND11_EMBEDDED_MODULE (YUP_PYTHON_MODULE_NAME, m)
7070
#else

modules/yup_python/scripting/yup_ScriptBindings.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
namespace yup::Bindings {
3333

34-
// =================================================================================================
34+
//==============================================================================
3535

3636
ComponentTypeMap& getComponentTypeMap()
3737
{

modules/yup_python/scripting/yup_ScriptBindings.h

Lines changed: 44 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -34,83 +34,77 @@
3434
namespace yup
3535
{
3636

37-
// =================================================================================================
38-
39-
/**
40-
* @brief Define a type alias for a function that casts a YUP Component to a pointer of a specified type.
41-
*
42-
* This type alias defines a function pointer named `ComponentTypeCaster`. This function is designed to take a YUP Component
43-
* and a reference to a `std::type_info` object, and it returns a constant pointer to void. The purpose of this function is to enable
44-
* dynamic casting of a YUP Component to a specific derived class type. It can be used for tasks like type-safe downcasting of
45-
* components in a straw application when obtaining Components in scripts and it's used by pybind11.
46-
*
47-
* @warning Be cautious when using this function as it deals with low-level type information and dynamic casting.
48-
*
49-
* @param component A pointer to a YUP Component that you want to cast to a specific type.
50-
* @param typeInfo A reference to a `std::type_info` object representing the target type.
51-
*
52-
* @return A constant pointer to void that can be interpreted as a pointer to an instance of the target type
53-
* if the cast is successful. If the cast fails, it may return a null pointer.
37+
//==============================================================================
38+
39+
/** Define a type alias for a function that casts a YUP Component to a pointer of a specified type.
40+
41+
This type alias defines a function pointer named `ComponentTypeCaster`. This function is designed to take a YUP Component
42+
and a reference to a `std::type_info` object, and it returns a constant pointer to void. The purpose of this function is to enable
43+
dynamic casting of a YUP Component to a specific derived class type. It can be used for tasks like type-safe downcasting of
44+
components in a straw application when obtaining Components in scripts and it's used by pybind11.
45+
46+
@warning Be cautious when using this function as it deals with low-level type information and dynamic casting.
47+
48+
@param component A pointer to a YUP Component that you want to cast to a specific type.
49+
@param typeInfo A reference to a `std::type_info` object representing the target type.
50+
51+
@return A constant pointer to void that can be interpreted as a pointer to an instance of the target type
52+
if the cast is successful. If the cast fails, it may return a null pointer.
5453
*/
5554
using ComponentTypeCaster = std::function<const void*(const Component*, const std::type_info*&)>;
5655

57-
// =================================================================================================
56+
//==============================================================================
5857

5958
namespace Bindings
6059
{
6160

62-
/**
63-
* @brief A structure for managing component type mappings.
64-
*
65-
* This structure is used to store mappings between class names and ComponentTypeCaster functions, allowing for dynamic casting of
66-
* Component objects to their derived types.
61+
/** A structure for managing component type mappings.
62+
63+
This structure is used to store mappings between class names and ComponentTypeCaster functions, allowing for dynamic casting of
64+
Component objects to their derived types.
6765
*/
6866
struct YUP_API ComponentTypeMap
6967
{
7068
CriticalSection mutex;
7169
std::unordered_map<String, ComponentTypeCaster> typeMap;
7270
};
7371

74-
/**
75-
* @brief Get the global ComponentTypeMap instance.
76-
*
77-
* @return A reference to the global ComponentTypeMap instance.
72+
/** Get the global ComponentTypeMap instance.
73+
74+
@return A reference to the global ComponentTypeMap instance.
7875
*/
7976
ComponentTypeMap& getComponentTypeMap();
8077

81-
/**
82-
* @brief Register a component type caster for a specific class.
83-
*
84-
* This function registers a component type caster for the specified class name.
85-
*
86-
* @param className The name of the class to register the caster for.
87-
* @param classCaster The component type caster function for the class.
78+
/** Register a component type caster for a specific class.
79+
80+
This function registers a component type caster for the specified class name.
81+
82+
@param className The name of the class to register the caster for.
83+
@param classCaster The component type caster function for the class.
8884
*/
8985
void registerComponentType (StringRef className, ComponentTypeCaster classCaster);
9086

91-
/**
92-
* @brief Clear all registered component types.
93-
*
94-
* This function clears all the registered component type mappings in the ComponentTypeMap.
87+
/** Clear all registered component types.
88+
89+
This function clears all the registered component type mappings in the ComponentTypeMap.
9590
*/
9691
void clearComponentTypes();
9792

9893
} // namespace Bindings
9994

100-
// =================================================================================================
95+
//==============================================================================
96+
97+
/** Template function for casting a Component to a derived type.
98+
99+
This template function is used to cast a Component to a derived type. It performs a `dynamic_cast` and returns a pointer to the
100+
derived type if the cast is successful, or nullptr otherwise.
101+
102+
@tparam T The derived type to cast to.
101103
102-
/**
103-
* @brief Template function for casting a Component to a derived type.
104-
*
105-
* This template function is used to cast a Component to a derived type. It performs a `dynamic_cast` and returns a pointer to the
106-
* derived type if the cast is successful, or nullptr otherwise.
107-
*
108-
* @tparam T The derived type to cast to.
109-
*
110-
* @param src The source Component to cast.
111-
* @param type A pointer to a std::type_info object that will be set to the type of the derived class if the cast is successful.
104+
@param src The source Component to cast.
105+
@param type A pointer to a std::type_info object that will be set to the type of the derived class if the cast is successful.
112106
113-
* @return A pointer to the derived type if the cast is successful, or nullptr otherwise.
107+
@return A pointer to the derived type if the cast is successful, or nullptr otherwise.
114108
*/
115109
template <class T>
116110
const void* ComponentType (const Component* src, const std::type_info*& type)

0 commit comments

Comments
 (0)