[Git][java-team/jruby-joni][master] 10 commits: Add a CI action

Hideki Yamane (@henrich) gitlab at salsa.debian.org
Tue Mar 7 13:50:43 GMT 2023



Hideki Yamane pushed to branch master at Debian Java Maintainers / jruby-joni


Commits:
6925301e by Charles Oliver Nutter at 2023-02-04T11:25:48-06:00
Add a CI action
- - - - -
ad492d4c by Charles Oliver Nutter at 2023-02-04T12:26:19-05:00
Encapsulate fields of Region

There are optimizations we could make here if the beg and end
fields were encapsulated that are impossible with them public. The
other fields should just be encapsulated as good practice.

- - - - -
a826018e by Charles Oliver Nutter at 2023-02-04T13:52:04-05:00
Merge pull request #58 from headius/encapsulate_region

Encapsulate fields of Region
- - - - -
f9e3936c by Charles Oliver Nutter at 2023-02-04T13:19:47-06:00
[maven-release-plugin] prepare release joni-2.1.47

- - - - -
43adfb96 by Charles Oliver Nutter at 2023-02-04T13:19:49-06:00
[maven-release-plugin] prepare for next development iteration

- - - - -
0afc3069 by Charles Oliver Nutter at 2023-02-05T08:33:01+01:00
Move to a factory method for Region instances

In order to specialize Region based on width, we need consumers to
stop instantiating it directly. This commit deprecates the two
Region constructors, replacing them with newRegion factory methods
we can use in the future to construct specialized Region shapes.

This feature will have to be in the wild for some time to allow
JRuby and libraries like strscan to move to the updated API. At
some point in the future, we can major rev joni and remove the
deprecated constructors and public fields.

- - - - -
9a702c66 by Charles Oliver Nutter at 2023-02-05T02:35:46-05:00
Merge pull request #60 from headius/region_factory

Move to a factory method for Region instances
- - - - -
aee63322 by Charles Oliver Nutter at 2023-02-06T08:54:13-06:00
[maven-release-plugin] prepare release joni-2.1.48

- - - - -
b5e66dd0 by Charles Oliver Nutter at 2023-02-06T08:54:15-06:00
[maven-release-plugin] prepare for next development iteration

- - - - -
92292ed3 by Charles Oliver Nutter at 2023-03-01T10:23:59-06:00
Add properties for debug configs

- - - - -


9 changed files:

- + .github/workflows/maven.yml
- pom.xml
- src/org/joni/ByteCodeMachine.java
- src/org/joni/Config.java
- + src/org/joni/ConfigSupport.java
- src/org/joni/Matcher.java
- src/org/joni/Regex.java
- src/org/joni/Region.java
- test/org/joni/test/Test.java


Changes:

=====================================
.github/workflows/maven.yml
=====================================
@@ -0,0 +1,31 @@
+# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
+# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven
+
+# This workflow uses actions that are not certified by GitHub.
+# They are provided by a third-party and are governed by
+# separate terms of service, privacy policy, and support
+# documentation.
+
+name: Java CI with Maven
+
+on:
+  push:
+    branches: [ "master" ]
+  pull_request:
+    branches: [ "master" ]
+
+jobs:
+  build:
+
+    runs-on: ubuntu-latest
+
+    steps:
+    - uses: actions/checkout at v3
+    - name: Set up JDK 11
+      uses: actions/setup-java at v3
+      with:
+        java-version: '11'
+        distribution: 'temurin'
+        cache: maven
+    - name: Build with Maven
+      run: mvn -B package --file pom.xml


=====================================
pom.xml
=====================================
@@ -4,7 +4,7 @@
   <groupId>org.jruby.joni</groupId>
   <artifactId>joni</artifactId>
   <packaging>jar</packaging>
-  <version>2.1.47-SNAPSHOT</version>
+  <version>2.1.49-SNAPSHOT</version>
   <name>Joni</name>
   <description>
     Java port of Oniguruma: http://www.geocities.jp/kosako3/oniguruma


=====================================
src/org/joni/ByteCodeMachine.java
=====================================
@@ -98,10 +98,10 @@ class ByteCodeMachine extends StackMachine {
 
     private void checkCaptureHistory(Region region) {
         CaptureTreeNode node;
-        if (region.historyRoot == null) {
-            node = region.historyRoot = new CaptureTreeNode();
+        if (region.getCaptureTree() == null) {
+            node = region.setCaptureTree(new CaptureTreeNode());
         } else {
-            node = region.historyRoot;
+            node = region.getCaptureTree();
             node.clear();
         }
 
@@ -111,7 +111,7 @@ class ByteCodeMachine extends StackMachine {
         node.end = s      - str;
 
         stkp = 0;
-        makeCaptureHistoryTree(region.historyRoot);
+        makeCaptureHistoryTree(region.getCaptureTree());
     }
 
     private byte[]cfbuf;
@@ -470,16 +470,17 @@ class ByteCodeMachine extends StackMachine {
             final Region region = msaRegion;
             if (region != null) {
                 // USE_POSIX_REGION_OPTION ... else ...
-                region.beg[0] = msaBegin = ((pkeep > s) ? s : pkeep) - str;
-                region.end[0] = msaEnd   = s      - str;
+                region.setBeg(0, msaBegin = ((pkeep > s) ? s : pkeep) - str);
+                region.setEnd(0, msaEnd   = s      - str);
                 for (int i = 1; i <= regex.numMem; i++) {
                     int me = repeatStk[memEndStk + i];
                     if (me != INVALID_INDEX) {
                         int ms = repeatStk[memStartStk + i];
-                        region.beg[i] = (bsAt(regex.btMemStart, i) ? stack[ms].getMemPStr() : ms) - str;
-                        region.end[i] = (bsAt(regex.btMemEnd, i) ? stack[me].getMemPStr() : me) - str;
+                        region.setBeg(i, (bsAt(regex.btMemStart, i) ? stack[ms].getMemPStr() : ms) - str);
+                        region.setEnd(i, (bsAt(regex.btMemEnd, i) ? stack[me].getMemPStr() : me) - str);
                     } else {
-                        region.beg[i] = region.end[i] = Region.REGION_NOTPOS;
+                        region.setBeg(i, Region.REGION_NOTPOS);
+                        region.setEnd(i, Region.REGION_NOTPOS);
                     }
                 }
 


=====================================
src/org/joni/Config.java
=====================================
@@ -74,13 +74,13 @@ public interface Config extends org.jcodings.Config {
     final PrintStream log = System.out;
     final PrintStream err = System.err;
 
-    final boolean DEBUG_ALL                         = false;
-
-    final boolean DEBUG                             = DEBUG_ALL;
-    final boolean DEBUG_PARSE_TREE                  = DEBUG_ALL;
-    final boolean DEBUG_PARSE_TREE_RAW              = true;
-    final boolean DEBUG_COMPILE                     = DEBUG_ALL;
-    final boolean DEBUG_COMPILE_BYTE_CODE_INFO      = DEBUG_ALL;
-    final boolean DEBUG_SEARCH                      = DEBUG_ALL;
-    final boolean DEBUG_MATCH                       = DEBUG_ALL;
+    final boolean DEBUG_ALL                         = ConfigSupport.getBoolean("joni.debug.all", false);
+
+    final boolean DEBUG                             = ConfigSupport.getBoolean("joni.debug", false) || DEBUG_ALL;
+    final boolean DEBUG_PARSE_TREE                  = ConfigSupport.getBoolean("joni.debug.parse.tree", false) || DEBUG_ALL;
+    final boolean DEBUG_PARSE_TREE_RAW              = ConfigSupport.getBoolean("joni.debug.parse.tree.raw", true) || DEBUG_ALL;
+    final boolean DEBUG_COMPILE                     = ConfigSupport.getBoolean("joni.debug.compile", false) || DEBUG_ALL;
+    final boolean DEBUG_COMPILE_BYTE_CODE_INFO      = ConfigSupport.getBoolean("joni.debug.compile.bytecode.info", false) || DEBUG_ALL;
+    final boolean DEBUG_SEARCH                      = ConfigSupport.getBoolean("joni.debug.search", false) || DEBUG_ALL;
+    final boolean DEBUG_MATCH                       = ConfigSupport.getBoolean("joni.debug.match", false) || DEBUG_ALL;
 }


=====================================
src/org/joni/ConfigSupport.java
=====================================
@@ -0,0 +1,8 @@
+package org.joni;
+
+public class ConfigSupport {
+    static boolean getBoolean(String property, boolean def) {
+        String value = System.getProperty(property, def ? "true" : "false");
+        return !value.equals("false");
+    }
+}


=====================================
src/org/joni/Matcher.java
=====================================
@@ -71,7 +71,7 @@ public abstract class Matcher extends IntHolder {
     }
 
     public final Region getEagerRegion() {
-        return msaRegion != null ? msaRegion : new Region(msaBegin, msaEnd);
+        return msaRegion != null ? msaRegion : Region.newRegion(msaBegin, msaEnd);
     }
 
     public final int getBegin() {


=====================================
src/org/joni/Regex.java
=====================================
@@ -164,7 +164,7 @@ public final class Regex {
     }
 
     public Matcher matcher(byte[]bytes, int p, int end) {
-        return factory.create(this, numMem == 0 ? null : new Region(numMem + 1), bytes, p, end);
+        return factory.create(this, numMem == 0 ? null : Region.newRegion(numMem + 1), bytes, p, end);
     }
 
     public Matcher matcherNoRegion(byte[]bytes, int p, int end) {
@@ -244,7 +244,7 @@ public final class Regex {
         default:
             if (region != null) {
                 for (int i = e.backNum - 1; i >= 0; i--) {
-                    if (region.beg[e.backRefs[i]] != Region.REGION_NOTPOS) return e.backRefs[i];
+                    if (region.getBeg(e.backRefs[i]) != Region.REGION_NOTPOS) return e.backRefs[i];
                 }
             }
             return e.backRefs[e.backNum - 1];


=====================================
src/org/joni/Region.java
=====================================
@@ -22,23 +22,42 @@ package org.joni;
 public final class Region {
     static final int REGION_NOTPOS = -1;
 
+    @Deprecated
     public final int numRegs;
-    public final int[]beg;
-    public final int[]end;
+    @Deprecated
+    public final int[] beg;
+    @Deprecated
+    public final int[] end;
+    @Deprecated
     public CaptureTreeNode historyRoot;
 
+    @SuppressWarnings("deprecation")
+    public static Region newRegion(int num) {
+        return new Region(num);
+    }
+
+    @SuppressWarnings("deprecation")
+    public static Region newRegion(int begin, int end) {
+        return new Region(begin, end);
+    }
+
+    @Deprecated
+    @SuppressWarnings("deprecation")
     public Region(int num) {
         this.numRegs = num;
         this.beg = new int[num];
         this.end = new int[num];
     }
 
+    @Deprecated
+    @SuppressWarnings("deprecation")
     public Region(int begin, int end) {
         this.numRegs = 1;
         this.beg = new int[]{begin};
         this.end = new int[]{end};
     }
 
+    @SuppressWarnings("deprecation")
     public Region clone() {
         Region region = new Region(numRegs);
         System.arraycopy(beg, 0, region.beg, 0, beg.length);
@@ -47,6 +66,32 @@ public final class Region {
         return region;
     }
 
+    @SuppressWarnings("deprecation")
+    public int getNumRegs() {
+        return numRegs;
+    }
+
+    @SuppressWarnings("deprecation")
+    public int getBeg(int index) {
+        return beg[index];
+    }
+
+    @SuppressWarnings("deprecation")
+    public int setBeg(int index, int value) {
+        return beg[index] = value;
+    }
+
+    @SuppressWarnings("deprecation")
+    public int getEnd(int index) {
+        return end[index];
+    }
+
+    @SuppressWarnings("deprecation")
+    public int setEnd(int index, int value) {
+        return end[index] = value;
+    }
+
+    @SuppressWarnings("deprecation")
     public String toString() {
         StringBuilder sb = new StringBuilder();
         sb.append("Region: \n");
@@ -54,10 +99,17 @@ public final class Region {
         return sb.toString();
     }
 
+    @SuppressWarnings("deprecation")
     CaptureTreeNode getCaptureTree() {
         return historyRoot;
     }
 
+    @SuppressWarnings("deprecation")
+    CaptureTreeNode setCaptureTree(CaptureTreeNode ctn) {
+        return this.historyRoot = ctn;
+    }
+
+    @SuppressWarnings("deprecation")
     void clear() {
         for (int i=0; i<beg.length; i++) {
             beg[i] = end[i] = REGION_NOTPOS;


=====================================
test/org/joni/test/Test.java
=====================================
@@ -177,13 +177,13 @@ public abstract class Test {
                 Config.log.println("FAIL(NOT): " + reprTest(pattern, str, option));
                 nfail++;
             } else {
-                if (region.beg[mem] == from && region.end[mem] == to) {
+                if (region.getBeg(mem) == from && region.getEnd(mem) == to) {
                     if (VERBOSE) Config.log.println("OK: " + reprTest(pattern, str, option));
                     nsucc++;
                 } else {
                     Config.log.println("FAIL: " + reprTest(pattern, str, option) + " GPOS: " + gpos + " Start: "
-                            + searchStart + " Groups: [Exp " + from + "-" + to + ", Act " + region.beg[mem] + "-"
-                            + region.end[mem] + "]");
+                            + searchStart + " Groups: [Exp " + from + "-" + to + ", Act " + region.getBeg(mem) + "-"
+                            + region.getEnd(mem) + "]");
                     nfail++;
                 }
             }



View it on GitLab: https://salsa.debian.org/java-team/jruby-joni/-/compare/99ea1930ad6f2403b3ae649000769e8a727c7427...92292ed34f66500b87504c43babd8cb4a72a54c1

-- 
View it on GitLab: https://salsa.debian.org/java-team/jruby-joni/-/compare/99ea1930ad6f2403b3ae649000769e8a727c7427...92292ed34f66500b87504c43babd8cb4a72a54c1
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20230307/4e880bc8/attachment.htm>


More information about the pkg-java-commits mailing list