Skip to content

Commit

Permalink
* Add minimal mappings for std::chrono from C++11 (pull bytedeco#766)
Browse files Browse the repository at this point in the history
  • Loading branch information
HGuillemet authored Aug 4, 2024
1 parent a506820 commit 2fd35c6
Show file tree
Hide file tree
Showing 25 changed files with 491 additions and 6 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/javacpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ jobs:
steps:
- uses: bytedeco/javacpp-presets/.github/actions/deploy-ubuntu@actions
ios-arm64:
runs-on: macos-11
runs-on: macos-14
steps:
- uses: bytedeco/javacpp-presets/.github/actions/deploy-macosx@actions
ios-x86_64:
runs-on: macos-11
runs-on: macos-12
steps:
- uses: bytedeco/javacpp-presets/.github/actions/deploy-macosx@actions
# linux-armhf:
Expand All @@ -56,11 +56,11 @@ jobs:
steps:
- uses: bytedeco/javacpp-presets/.github/actions/deploy-ubuntu@actions
macosx-arm64:
runs-on: macos-11
runs-on: macos-14
steps:
- uses: bytedeco/javacpp-presets/.github/actions/deploy-macosx@actions
macosx-x86_64:
runs-on: macos-11
runs-on: macos-12
env:
CI_DEPLOY_OPTIONS: "" # to not skip tests
steps:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

* Add minimal mappings for `std::chrono` from C++11 ([pull #766](https://github.com/bytedeco/javacpp/pull/766))
* Let `Parser` annotate Java constructors with `@Deprecated` when appropriate ([pull #757](https://github.com/bytedeco/javacpp/pull/757))
* Add to `InfoMap.defaults` more names that are reserved in Java, but not in C++ ([pull #757](https://github.com/bytedeco/javacpp/pull/757))
* Bundle `libomp` from Visual Studio to fix presets using OpenMP on Windows ([pull #755](https://github.com/bytedeco/javacpp/pull/755))
Expand Down
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ Import-Package: \
<argument>-Dplatform.compiler=${javacpp.platform.compiler}</argument>
<argument>org.bytedeco.javacpp.Pointer</argument>
<argument>org.bytedeco.javacpp.presets.javacpp</argument>
<argument>org.bytedeco.javacpp.chrono.*</argument>
<argument>-mod</argument>
<argument>${project.build.directory}/generated-sources/java9/module-info.java</argument>
</arguments>
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/org/bytedeco/javacpp/chrono/HighResolutionClock.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.bytedeco.javacpp.chrono;

import org.bytedeco.javacpp.Pointer;
import org.bytedeco.javacpp.annotation.ByVal;
import org.bytedeco.javacpp.annotation.MemberGetter;
import org.bytedeco.javacpp.annotation.Name;
import org.bytedeco.javacpp.annotation.Properties;

@Name("std::chrono::high_resolution_clock") @Properties(inherit = org.bytedeco.javacpp.presets.chrono.class)
public class HighResolutionClock extends Pointer {
static public native @ByVal HighResolutionTime now();
static public native @MemberGetter boolean is_steady();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package org.bytedeco.javacpp.chrono;

import org.bytedeco.javacpp.Pointer;
import org.bytedeco.javacpp.annotation.*;

@Name("std::chrono::high_resolution_clock::duration") @Properties(inherit = org.bytedeco.javacpp.presets.chrono.class)
public class HighResolutionDuration extends Pointer {
public HighResolutionDuration() { allocate(); }
private native void allocate();
public HighResolutionDuration(long r) { allocate(r); }
private native void allocate(long r);

public native @Name("operator=") @ByRef HighResolutionDuration put(@Const @ByRef HighResolutionDuration other);
public native @Name("operator-") @ByVal HighResolutionDuration negate();
public native @Name("operator++") @ByRef HighResolutionDuration increment();
public native @Name("operator--") @ByRef HighResolutionDuration decrement();
public native @Name("operator+=") @ByRef HighResolutionDuration addPut(@Const @ByRef HighResolutionDuration d);
public native @Name("operator-=") @ByRef HighResolutionDuration subtractPut(@Const @ByRef HighResolutionDuration d);
public native @Name("operator*=") @ByRef HighResolutionDuration multiplyPut(@Const @ByRef long rhs);
public native @Name("operator%=") @ByRef HighResolutionDuration modPut(@Const @ByRef long rhs);
public native @Name("operator%=") @ByRef HighResolutionDuration modPut(@Const @ByRef HighResolutionDuration rhs);

public native long count();
static public native @ByVal @Name("zero") HighResolutionDuration zero_();
static public native @ByVal HighResolutionDuration min();
static public native @ByVal HighResolutionDuration max();
}
20 changes: 20 additions & 0 deletions src/main/java/org/bytedeco/javacpp/chrono/HighResolutionTime.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.bytedeco.javacpp.chrono;

import org.bytedeco.javacpp.Pointer;
import org.bytedeco.javacpp.annotation.*;

@Name("std::chrono::time_point<std::chrono::high_resolution_clock>") @Properties(inherit = org.bytedeco.javacpp.presets.chrono.class)
public class HighResolutionTime extends Pointer {
public HighResolutionTime() { allocate(); }
private native void allocate();

public HighResolutionTime(HighResolutionDuration d) { allocate(d); }
private native void allocate(@Const @ByRef HighResolutionDuration d);

public native @ByVal HighResolutionTime time_since_epoch();

public native @Name("operator +=") @ByRef HighResolutionTime addPut(@Const @ByRef HighResolutionDuration d);
public native @Name("operator -=") @ByRef HighResolutionTime subtractPut(@Const @ByRef HighResolutionDuration d);
static public native @ByVal HighResolutionTime min();
static public native @ByVal HighResolutionTime max();
}
27 changes: 27 additions & 0 deletions src/main/java/org/bytedeco/javacpp/chrono/Hours.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package org.bytedeco.javacpp.chrono;

import org.bytedeco.javacpp.Pointer;
import org.bytedeco.javacpp.annotation.*;

@Name("std::chrono::hours") @Properties(inherit = org.bytedeco.javacpp.presets.chrono.class)
public class Hours extends Pointer {
public Hours() { allocate(); }
private native void allocate();
public Hours(long r) { allocate(r); }
private native void allocate(long r);

public native @Name("operator=") @ByRef Hours put(@Const @ByRef Hours other);
public native @Name("operator-") @ByVal Hours negate();
public native @Name("operator++") @ByRef Hours increment();
public native @Name("operator--") @ByRef Hours decrement();
public native @Name("operator+=") @ByRef Hours addPut(@Const @ByRef Hours d);
public native @Name("operator-=") @ByRef Hours subtractPut(@Const @ByRef Hours d);
public native @Name("operator*=") @ByRef Hours multiplyPut(@Const @ByRef int rhs);
public native @Name("operator%=") @ByRef Hours modPut(@Const @ByRef int rhs);
public native @Name("operator%=") @ByRef Hours modPut(@Const @ByRef Hours rhs);

public native int count();
static public native @ByVal @Name("zero") Hours zero_();
static public native @ByVal Hours min();
static public native @ByVal Hours max();
}
36 changes: 36 additions & 0 deletions src/main/java/org/bytedeco/javacpp/chrono/Microseconds.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package org.bytedeco.javacpp.chrono;

import org.bytedeco.javacpp.Pointer;
import org.bytedeco.javacpp.annotation.*;

@Name("std::chrono::microseconds") @Properties(inherit = org.bytedeco.javacpp.presets.chrono.class)
public class Microseconds extends Pointer {
public Microseconds() { allocate(); }
private native void allocate();
public Microseconds(long r) { allocate(r); }
private native void allocate(long r);

public Microseconds(Milliseconds d) { allocate(d); }
private native void allocate(@Const @ByRef Milliseconds d);
public Microseconds(Seconds d) { allocate(d); }
private native void allocate(@Const @ByRef Seconds d);
public Microseconds(Minutes d) { allocate(d); }
private native void allocate(@Const @ByRef Minutes d);
public Microseconds(Hours d) { allocate(d); }
private native void allocate(@Const @ByRef Hours d);

public native @Name("operator=") @ByRef Microseconds put(@Const @ByRef Microseconds other);
public native @Name("operator-") @ByVal Microseconds negate();
public native @Name("operator++") @ByRef Microseconds increment();
public native @Name("operator--") @ByRef Microseconds decrement();
public native @Name("operator+=") @ByRef Microseconds addPut(@Const @ByRef Microseconds d);
public native @Name("operator-=") @ByRef Microseconds subtractPut(@Const @ByRef Microseconds d);
public native @Name("operator*=") @ByRef Microseconds multiplyPut(@Const @ByRef long rhs);
public native @Name("operator%=") @ByRef Microseconds modPut(@Const @ByRef long rhs);
public native @Name("operator%=") @ByRef Microseconds modPut(@Const @ByRef Microseconds rhs);

public native long count();
static public native @ByVal @Name("zero") Microseconds zero_();
static public native @ByVal Microseconds min();
static public native @ByVal Microseconds max();
}
33 changes: 33 additions & 0 deletions src/main/java/org/bytedeco/javacpp/chrono/Milliseconds.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package org.bytedeco.javacpp.chrono;

import org.bytedeco.javacpp.Pointer;
import org.bytedeco.javacpp.annotation.*;

@Name("std::chrono::milliseconds") @Properties(inherit = org.bytedeco.javacpp.presets.chrono.class)
public class Milliseconds extends Pointer {
public Milliseconds() { allocate(); }
private native void allocate();
public Milliseconds(long r) { allocate(r); }
private native void allocate(long r);
public Milliseconds(Seconds d) { allocate(d); }
private native void allocate(@Const @ByRef Seconds d);
public Milliseconds(Minutes d) { allocate(d); }
private native void allocate(@Const @ByRef Minutes d);
public Milliseconds(Hours d) { allocate(d); }
private native void allocate(@Const @ByRef Hours d);

public native @Name("operator=") @ByRef Milliseconds put(@Const @ByRef Milliseconds other);
public native @Name("operator-") @ByVal Milliseconds negate();
public native @Name("operator++") @ByRef Milliseconds increment();
public native @Name("operator--") @ByRef Milliseconds decrement();
public native @Name("operator+=") @ByRef Milliseconds addPut(@Const @ByRef Milliseconds d);
public native @Name("operator-=") @ByRef Milliseconds subtractPut(@Const @ByRef Milliseconds d);
public native @Name("operator*=") @ByRef Milliseconds multiplyPut(@Const @ByRef long rhs);
public native @Name("operator%=") @ByRef Milliseconds modPut(@Const @ByRef long rhs);
public native @Name("operator%=") @ByRef Milliseconds modPut(@Const @ByRef Milliseconds rhs);

public native long count();
static public native @ByVal @Name("zero") Milliseconds zero_();
static public native @ByVal Milliseconds min();
static public native @ByVal Milliseconds max();
}
29 changes: 29 additions & 0 deletions src/main/java/org/bytedeco/javacpp/chrono/Minutes.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.bytedeco.javacpp.chrono;

import org.bytedeco.javacpp.Pointer;
import org.bytedeco.javacpp.annotation.*;

@Name("std::chrono::minutes") @Properties(inherit = org.bytedeco.javacpp.presets.chrono.class)
public class Minutes extends Pointer {
public Minutes() { allocate(); }
private native void allocate();
public Minutes(long r) { allocate(r); }
private native void allocate(long r);
public Minutes(Hours d) { allocate(d); }
private native void allocate(@Const @ByRef Hours d);

public native @Name("operator=") @ByRef Minutes put(@Const @ByRef Minutes other);
public native @Name("operator-") @ByVal Minutes negate();
public native @Name("operator++") @ByRef Minutes increment();
public native @Name("operator--") @ByRef Minutes decrement();
public native @Name("operator+=") @ByRef Minutes addPut(@Const @ByRef Minutes d);
public native @Name("operator-=") @ByRef Minutes subtractPut(@Const @ByRef Minutes d);
public native @Name("operator*=") @ByRef Minutes multiplyPut(@Const @ByRef int rhs);
public native @Name("operator%=") @ByRef Minutes modPut(@Const @ByRef int rhs);
public native @Name("operator%=") @ByRef Minutes modPut(@Const @ByRef Minutes rhs);

public native int count();
static public native @ByVal @Name("zero") Minutes zero_();
static public native @ByVal Minutes min();
static public native @ByVal Minutes max();
}
43 changes: 43 additions & 0 deletions src/main/java/org/bytedeco/javacpp/chrono/Nanoseconds.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package org.bytedeco.javacpp.chrono;

import org.bytedeco.javacpp.Pointer;
import org.bytedeco.javacpp.annotation.*;

@Name("std::chrono::nanoseconds") @Properties(inherit = org.bytedeco.javacpp.presets.chrono.class)
public class Nanoseconds extends Pointer {
public Nanoseconds() { allocate(); }
private native void allocate();
public Nanoseconds(long r) { allocate(r); }
private native void allocate(long r);
public Nanoseconds(Microseconds d) { allocate(d); }
private native void allocate(@Const @ByRef Microseconds d);
public Nanoseconds(Milliseconds d) { allocate(d); }
private native void allocate(@Const @ByRef Milliseconds d);
public Nanoseconds(Seconds d) { allocate(d); }
private native void allocate(@Const @ByRef Seconds d);
public Nanoseconds(Minutes d) { allocate(d); }
private native void allocate(@Const @ByRef Minutes d);
public Nanoseconds(Hours d) { allocate(d); }
private native void allocate(@Const @ByRef Hours d);
public Nanoseconds(SystemDuration d) { super((Pointer)null); allocate(d); };
private native void allocate(@Const @ByRef SystemDuration d);
public Nanoseconds(HighResolutionDuration d) { super((Pointer)null); allocate(d); };
private native void allocate(@Const @ByRef HighResolutionDuration d);
public Nanoseconds(SteadyDuration d) { super((Pointer)null); allocate(d); };
private native void allocate(@Const @ByRef SteadyDuration d);

public native @Name("operator=") @ByRef Nanoseconds put(@Const @ByRef Nanoseconds other);
public native @Name("operator-") @ByVal Nanoseconds negate();
public native @Name("operator++") @ByRef Nanoseconds increment();
public native @Name("operator--") @ByRef Nanoseconds decrement();
public native @Name("operator+=") @ByRef Nanoseconds addPut(@Const @ByRef Nanoseconds d);
public native @Name("operator-=") @ByRef Nanoseconds subtractPut(@Const @ByRef Nanoseconds d);
public native @Name("operator*=") @ByRef Nanoseconds multiplyPut(@Const @ByRef long rhs);
public native @Name("operator%=") @ByRef Nanoseconds modPut(@Const @ByRef long rhs);
public native @Name("operator%=") @ByRef Nanoseconds modPut(@Const @ByRef Nanoseconds rhs);

public native long count();
static public native @ByVal @Name("zero") Nanoseconds zero_();
static public native @ByVal Nanoseconds min();
static public native @ByVal Nanoseconds max();
}
31 changes: 31 additions & 0 deletions src/main/java/org/bytedeco/javacpp/chrono/Seconds.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.bytedeco.javacpp.chrono;

import org.bytedeco.javacpp.Pointer;
import org.bytedeco.javacpp.annotation.*;

@Name("std::chrono::seconds") @Properties(inherit = org.bytedeco.javacpp.presets.chrono.class)
public class Seconds extends Pointer {
public Seconds() { allocate(); }
private native void allocate();
public Seconds(long r) { allocate(r); }
private native void allocate(long r);
public Seconds(Minutes d) { allocate(d); }
private native void allocate(@Const @ByRef Minutes d);
public Seconds(Hours d) { allocate(d); }
private native void allocate(@Const @ByRef Hours d);

public native @Name("operator=") @ByRef Seconds put(@Const @ByRef Seconds other);
public native @Name("operator-") @ByVal Seconds negate();
public native @Name("operator++") @ByRef Seconds increment();
public native @Name("operator--") @ByRef Seconds decrement();
public native @Name("operator+=") @ByRef Seconds addPut(@Const @ByRef Seconds d);
public native @Name("operator-=") @ByRef Seconds subtractPut(@Const @ByRef Seconds d);
public native @Name("operator*=") @ByRef Seconds multiplyPut(@Const @ByRef long rhs);
public native @Name("operator%=") @ByRef Seconds modPut(@Const @ByRef long rhs);
public native @Name("operator%=") @ByRef Seconds modPut(@Const @ByRef Seconds rhs);

public native long count();
static public native @ByVal @Name("zero") Seconds zero_();
static public native @ByVal Seconds min();
static public native @ByVal Seconds max();
}
29 changes: 29 additions & 0 deletions src/main/java/org/bytedeco/javacpp/chrono/SecondsDouble.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.bytedeco.javacpp.chrono;

import org.bytedeco.javacpp.Pointer;
import org.bytedeco.javacpp.annotation.*;

@Name("std::chrono::duration<double>") @Properties(inherit = org.bytedeco.javacpp.presets.chrono.class)
public class SecondsDouble extends Pointer {
public SecondsDouble() { allocate(); }
private native void allocate();
public SecondsDouble(double r) { allocate(r); }
private native void allocate(double r);
public SecondsDouble(Nanoseconds d) { allocate(d); }
private native void allocate(@Const @ByRef Nanoseconds d);
public SecondsDouble(Seconds d) { allocate(d); }
private native void allocate(@Const @ByRef Seconds d);

public native @Name("operator=") @ByRef SecondsDouble put(@Const @ByRef SecondsDouble other);
public native @Name("operator-") @ByVal SecondsDouble negate();
public native @Name("operator++") @ByRef SecondsDouble increment();
public native @Name("operator--") @ByRef SecondsDouble decrement();
public native @Name("operator+=") @ByRef SecondsDouble addPut(@Const @ByRef SecondsDouble d);
public native @Name("operator-=") @ByRef SecondsDouble subtractPut(@Const @ByRef SecondsDouble d);
public native @Name("operator*=") @ByRef SecondsDouble multiplyPut(@Const @ByRef double rhs);

public native double count();
static public native @ByVal @Name("zero") SecondsDouble zero_();
static public native @ByVal SecondsDouble min();
static public native @ByVal SecondsDouble max();
}
29 changes: 29 additions & 0 deletions src/main/java/org/bytedeco/javacpp/chrono/SecondsFloat.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.bytedeco.javacpp.chrono;

import org.bytedeco.javacpp.Pointer;
import org.bytedeco.javacpp.annotation.*;

@Name("std::chrono::duration<float>") @Properties(inherit = org.bytedeco.javacpp.presets.chrono.class)
public class SecondsFloat extends Pointer {
public SecondsFloat() { allocate(); }
private native void allocate();
public SecondsFloat(float r) { allocate(r); }
private native void allocate(float r);
public SecondsFloat(Nanoseconds d) { allocate(d); }
private native void allocate(@Const @ByRef Nanoseconds d);
public SecondsFloat(Seconds d) { allocate(d); }
private native void allocate(@Const @ByRef Seconds d);

public native @Name("operator=") @ByRef SecondsFloat put(@Const @ByRef SecondsFloat other);
public native @Name("operator-") @ByVal SecondsFloat negate();
public native @Name("operator++") @ByRef SecondsFloat increment();
public native @Name("operator--") @ByRef SecondsFloat decrement();
public native @Name("operator+=") @ByRef SecondsFloat addPut(@Const @ByRef SecondsFloat d);
public native @Name("operator-=") @ByRef SecondsFloat subtractPut(@Const @ByRef SecondsFloat d);
public native @Name("operator*=") @ByRef SecondsFloat multiplyPut(@Const @ByRef float rhs);

public native float count();
static public native @ByVal @Name("zero") SecondsFloat zero_();
static public native @ByVal SecondsFloat min();
static public native @ByVal SecondsFloat max();
}
11 changes: 11 additions & 0 deletions src/main/java/org/bytedeco/javacpp/chrono/SteadyClock.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.bytedeco.javacpp.chrono;

import org.bytedeco.javacpp.Pointer;
import org.bytedeco.javacpp.annotation.ByVal;
import org.bytedeco.javacpp.annotation.Name;
import org.bytedeco.javacpp.annotation.Properties;

@Name("std::chrono::steady_clock") @Properties(inherit = org.bytedeco.javacpp.presets.chrono.class)
public class SteadyClock extends Pointer {
static public native @ByVal SteadyTime now();
}
Loading

0 comments on commit 2fd35c6

Please sign in to comment.