From 77954bb3dd830c43e18d3585639f06782baaf6fa Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Thu, 6 Aug 2020 21:37:38 -0700 Subject: [PATCH] [wpiutil] Add JNI wrapper for wpi::Now() (#2632) --- .../java/edu/wpi/first/wpiutil/WPIUtilJNI.java | 4 +++- wpiutil/src/main/native/cpp/jni/WPIUtilJNI.cpp | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/wpiutil/src/main/java/edu/wpi/first/wpiutil/WPIUtilJNI.java b/wpiutil/src/main/java/edu/wpi/first/wpiutil/WPIUtilJNI.java index 941e691d78..3a22c7b9aa 100644 --- a/wpiutil/src/main/java/edu/wpi/first/wpiutil/WPIUtilJNI.java +++ b/wpiutil/src/main/java/edu/wpi/first/wpiutil/WPIUtilJNI.java @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -51,6 +51,8 @@ public final class WPIUtilJNI { libraryLoaded = true; } + public static native long now(); + public static native void addPortForwarder(int port, String remoteHost, int remotePort); public static native void removePortForwarder(int port); } diff --git a/wpiutil/src/main/native/cpp/jni/WPIUtilJNI.cpp b/wpiutil/src/main/native/cpp/jni/WPIUtilJNI.cpp index c14b3f4c94..fcf99e1c37 100644 --- a/wpiutil/src/main/native/cpp/jni/WPIUtilJNI.cpp +++ b/wpiutil/src/main/native/cpp/jni/WPIUtilJNI.cpp @@ -1,5 +1,5 @@ /*----------------------------------------------------------------------------*/ -/* Copyright (c) 2019 FIRST. All Rights Reserved. */ +/* Copyright (c) 2019-2020 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ @@ -10,6 +10,7 @@ #include "edu_wpi_first_wpiutil_WPIUtilJNI.h" #include "wpi/PortForwarder.h" #include "wpi/jni_util.h" +#include "wpi/timestamp.h" using namespace wpi::java; @@ -25,6 +26,18 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved) { JNIEXPORT void JNICALL JNI_OnUnload(JavaVM* vm, void* reserved) {} +/* + * Class: edu_wpi_first_networktables_NetworkTablesJNI + * Method: now + * Signature: ()J + */ +JNIEXPORT jlong JNICALL +Java_edu_wpi_first_networktables_NetworkTablesJNI_now + (JNIEnv*, jclass) +{ + return wpi::Now(); +} + /* * Class: edu_wpi_first_wpiutil_WPIUtilJNI * Method: addPortForwarder