mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-03 03:01:44 +00:00
[wpiutil] Rename CreateEvent and CreateSemaphore to Make (#8710)
CreateEvent and CreateSemaphore are macros in Windows.h, which causes a ton of trouble. Just rename the functions. Closes #7303 Replaces #7336
This commit is contained in:
@@ -112,7 +112,7 @@ public class WPIUtilJNI {
|
||||
* @param initialState true to make the event initially in signaled state
|
||||
* @return Event handle
|
||||
*/
|
||||
public static native int createEvent(boolean manualReset, boolean initialState);
|
||||
public static native int makeEvent(boolean manualReset, boolean initialState);
|
||||
|
||||
/**
|
||||
* Destroys an event. Destruction wakes up any waiters.
|
||||
@@ -145,7 +145,7 @@ public class WPIUtilJNI {
|
||||
* @param maximumCount maximum value for the semaphore's internal counter
|
||||
* @return Semaphore handle
|
||||
*/
|
||||
public static native int createSemaphore(int initialCount, int maximumCount);
|
||||
public static native int makeSemaphore(int initialCount, int maximumCount);
|
||||
|
||||
/**
|
||||
* Destroys a semaphore. Destruction wakes up any waiters.
|
||||
|
||||
@@ -22,7 +22,7 @@ public final class Event implements AutoCloseable {
|
||||
* @param initialState true to make the event initially in signaled state
|
||||
*/
|
||||
public Event(boolean manualReset, boolean initialState) {
|
||||
m_handle = WPIUtilJNI.createEvent(manualReset, initialState);
|
||||
m_handle = WPIUtilJNI.makeEvent(manualReset, initialState);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,7 +21,7 @@ public final class Semaphore implements AutoCloseable {
|
||||
* @param maximumCount maximum value for the semaphore's internal counter
|
||||
*/
|
||||
public Semaphore(int initialCount, int maximumCount) {
|
||||
m_handle = WPIUtilJNI.createSemaphore(initialCount, maximumCount);
|
||||
m_handle = WPIUtilJNI.makeSemaphore(initialCount, maximumCount);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -97,7 +97,7 @@ class ManagerGuard {
|
||||
|
||||
} // namespace
|
||||
|
||||
WPI_EventHandle wpi::util::CreateEvent(bool manualReset, bool initialState) {
|
||||
WPI_EventHandle wpi::util::MakeEvent(bool manualReset, bool initialState) {
|
||||
ManagerGuard guard;
|
||||
if (!guard) {
|
||||
return {};
|
||||
@@ -147,8 +147,8 @@ void wpi::util::ResetEvent(WPI_EventHandle handle) {
|
||||
ResetSignalObject(handle);
|
||||
}
|
||||
|
||||
WPI_SemaphoreHandle wpi::util::CreateSemaphore(int initialCount,
|
||||
int maximumCount) {
|
||||
WPI_SemaphoreHandle wpi::util::MakeSemaphore(int initialCount,
|
||||
int maximumCount) {
|
||||
ManagerGuard guard;
|
||||
if (!guard) {
|
||||
return {};
|
||||
@@ -406,8 +406,8 @@ void wpi::util::DestroySignalObject(WPI_Handle handle) {
|
||||
|
||||
extern "C" {
|
||||
|
||||
WPI_EventHandle WPI_CreateEvent(int manual_reset, int initial_state) {
|
||||
return wpi::util::CreateEvent(manual_reset != 0, initial_state != 0);
|
||||
WPI_EventHandle WPI_MakeEvent(int manual_reset, int initial_state) {
|
||||
return wpi::util::MakeEvent(manual_reset != 0, initial_state != 0);
|
||||
}
|
||||
|
||||
void WPI_DestroyEvent(WPI_EventHandle handle) {
|
||||
@@ -422,8 +422,8 @@ void WPI_ResetEvent(WPI_EventHandle handle) {
|
||||
wpi::util::ResetEvent(handle);
|
||||
}
|
||||
|
||||
WPI_SemaphoreHandle WPI_CreateSemaphore(int initial_count, int maximum_count) {
|
||||
return wpi::util::CreateSemaphore(initial_count, maximum_count);
|
||||
WPI_SemaphoreHandle WPI_MakeSemaphore(int initial_count, int maximum_count) {
|
||||
return wpi::util::MakeSemaphore(initial_count, maximum_count);
|
||||
}
|
||||
|
||||
void WPI_DestroySemaphore(WPI_SemaphoreHandle handle) {
|
||||
|
||||
@@ -194,14 +194,14 @@ Java_org_wpilib_util_WPIUtilJNI_getSystemTime
|
||||
|
||||
/*
|
||||
* Class: org_wpilib_util_WPIUtilJNI
|
||||
* Method: createEvent
|
||||
* Method: makeEvent
|
||||
* Signature: (ZZ)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_wpilib_util_WPIUtilJNI_createEvent
|
||||
Java_org_wpilib_util_WPIUtilJNI_makeEvent
|
||||
(JNIEnv*, jclass, jboolean manualReset, jboolean initialState)
|
||||
{
|
||||
return wpi::util::CreateEvent(manualReset, initialState);
|
||||
return wpi::util::MakeEvent(manualReset, initialState);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -242,14 +242,14 @@ Java_org_wpilib_util_WPIUtilJNI_resetEvent
|
||||
|
||||
/*
|
||||
* Class: org_wpilib_util_WPIUtilJNI
|
||||
* Method: createSemaphore
|
||||
* Method: makeSemaphore
|
||||
* Signature: (II)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_org_wpilib_util_WPIUtilJNI_createSemaphore
|
||||
Java_org_wpilib_util_WPIUtilJNI_makeSemaphore
|
||||
(JNIEnv*, jclass, jint initialCount, jint maximumCount)
|
||||
{
|
||||
return wpi::util::CreateSemaphore(initialCount, maximumCount);
|
||||
return wpi::util::MakeSemaphore(initialCount, maximumCount);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -36,7 +36,7 @@ extern "C" {
|
||||
* @param initial_state true to make the event initially in signaled state
|
||||
* @return Event handle
|
||||
*/
|
||||
WPI_EventHandle WPI_CreateEvent(int manual_reset, int initial_state);
|
||||
WPI_EventHandle WPI_MakeEvent(int manual_reset, int initial_state);
|
||||
|
||||
/**
|
||||
* Destroys an event. Destruction wakes up any waiters.
|
||||
@@ -70,7 +70,7 @@ void WPI_ResetEvent(WPI_EventHandle handle);
|
||||
* @param maximum_count maximum value for the semaphore's internal counter
|
||||
* @return Semaphore handle
|
||||
*/
|
||||
WPI_SemaphoreHandle WPI_CreateSemaphore(int initial_count, int maximum_count);
|
||||
WPI_SemaphoreHandle WPI_MakeSemaphore(int initial_count, int maximum_count);
|
||||
|
||||
/**
|
||||
* Destroys a semaphore. Destruction wakes up any waiters.
|
||||
|
||||
@@ -39,8 +39,7 @@ constexpr int HANDLE_TYPE_USER_BASE = 80;
|
||||
* @param initialState true to make the event initially in signaled state
|
||||
* @return Event handle
|
||||
*/
|
||||
WPI_EventHandle CreateEvent(bool manualReset = false,
|
||||
bool initialState = false);
|
||||
WPI_EventHandle MakeEvent(bool manualReset = false, bool initialState = false);
|
||||
|
||||
/**
|
||||
* Destroys an event. Destruction wakes up any waiters.
|
||||
@@ -74,8 +73,8 @@ void ResetEvent(WPI_EventHandle handle);
|
||||
* @param maximumCount maximum value for the semaphore's internal counter
|
||||
* @return Semaphore handle
|
||||
*/
|
||||
WPI_SemaphoreHandle CreateSemaphore(int initialCount = 0,
|
||||
int maximumCount = INT_MAX);
|
||||
WPI_SemaphoreHandle MakeSemaphore(int initialCount = 0,
|
||||
int maximumCount = INT_MAX);
|
||||
|
||||
/**
|
||||
* Destroys a semaphore. Destruction wakes up any waiters.
|
||||
@@ -237,7 +236,7 @@ class Event final {
|
||||
* @param initialState true to make the event initially in signaled state
|
||||
*/
|
||||
explicit Event(bool manualReset = false, bool initialState = false)
|
||||
: m_handle{CreateEvent(manualReset, initialState)} {}
|
||||
: m_handle{MakeEvent(manualReset, initialState)} {}
|
||||
~Event() {
|
||||
if (m_handle != 0) {
|
||||
DestroyEvent(m_handle);
|
||||
@@ -302,7 +301,7 @@ class Semaphore final {
|
||||
* @param maximumCount maximum value for the semaphore's internal counter
|
||||
*/
|
||||
explicit Semaphore(int initialCount = 0, int maximumCount = INT_MAX)
|
||||
: m_handle{CreateSemaphore(initialCount, maximumCount)} {}
|
||||
: m_handle{MakeSemaphore(initialCount, maximumCount)} {}
|
||||
~Semaphore() {
|
||||
if (m_handle != 0) {
|
||||
DestroySemaphore(m_handle);
|
||||
|
||||
@@ -6,11 +6,11 @@ extra_includes:
|
||||
- pybind11/stl.h
|
||||
|
||||
functions:
|
||||
CreateEvent:
|
||||
MakeEvent:
|
||||
DestroyEvent:
|
||||
SetEvent:
|
||||
ResetEvent:
|
||||
CreateSemaphore:
|
||||
MakeSemaphore:
|
||||
DestroySemaphore:
|
||||
ReleaseSemaphore:
|
||||
param_override:
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# autogenerated by 'semiwrap create-imports wpiutil.sync wpiutil._wpiutil.sync'
|
||||
from .._wpiutil.sync import (
|
||||
createEvent,
|
||||
createSemaphore,
|
||||
makeEvent,
|
||||
makeSemaphore,
|
||||
createSignalObject,
|
||||
destroyEvent,
|
||||
destroySemaphore,
|
||||
@@ -16,8 +16,8 @@ from .._wpiutil.sync import (
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
"createEvent",
|
||||
"createSemaphore",
|
||||
"makeEvent",
|
||||
"makeSemaphore",
|
||||
"createSignalObject",
|
||||
"destroyEvent",
|
||||
"destroySemaphore",
|
||||
|
||||
Reference in New Issue
Block a user