sljit-sys 0.4.0

System crate for sljit using bindgen and ast-grep
Documentation
rule:
  any:
  - pattern: |
      pub fn $FUNC(compiler: *mut sljit_compiler) -> *mut sljit_const;
  - pattern: |
      pub fn $FUNC(compiler: *mut sljit_compiler, $$$ARGS) -> *mut sljit_const;
transform:
  NAME:
    replace:
      source: $FUNC
      replace: "sljit_(.*)"
      by: "$1"
  PARAMS:
    replace:
      source: $$$ARGS
      replace: "(.*?): .*"
      by: "$1,"
fix: '#[inline(always)] pub fn $NAME(&mut self, $$$ARGS) -> Constant { unsafe { $FUNC(self.0, $PARAMS) }.into() }'
id: rewrite-with-return-type-constant
language: rust
---
rule:
  any:
  - pattern: |
      pub fn $FUNC(compiler: *mut sljit_compiler) -> *mut sljit_label;
  - pattern: |
      pub fn $FUNC(compiler: *mut sljit_compiler, $$$ARGS) -> *mut sljit_label;
transform:
  NAME:
    replace:
      source: $FUNC
      replace: "sljit_(.*)"
      by: "$1"
  PARAMS:
    replace:
      source: $$$ARGS
      replace: "(.*?): .*"
      by: "$1,"
fix: '#[inline(always)] pub fn $NAME(&mut self, $$$ARGS) -> Label { unsafe { $FUNC(self.0, $PARAMS) }.into() }'
id: rewrite-with-return-type-label
language: rust
---
rule:
  any:
  - pattern: |
      pub fn $FUNC(compiler: *mut sljit_compiler) -> *mut sljit_put_label;
  - pattern: |
      pub fn $FUNC(compiler: *mut sljit_compiler, $$$ARGS) -> *mut sljit_put_label;
transform:
  NAME:
    replace:
      source: $FUNC
      replace: "sljit_(.*)"
      by: "$1"
  PARAMS:
    replace:
      source: $$$ARGS
      replace: "(.*?): .*"
      by: "$1,"
fix: '#[inline(always)] pub fn $NAME(&mut self, $$$ARGS) -> PutLabel { unsafe { $FUNC(self.0, $PARAMS) }.into() }'
id: rewrite-with-return-type-put-label
language: rust
---
rule:
  any:
  - pattern: |
      pub fn $FUNC(compiler: *mut sljit_compiler) -> *mut sljit_jump;
  - pattern: |
      pub fn $FUNC(compiler: *mut sljit_compiler, $$$ARGS) -> *mut sljit_jump;
transform:
  NAME:
    replace:
      source: $FUNC
      replace: "sljit_(.*)"
      by: "$1"
  PARAMS:
    replace:
      source: $$$ARGS
      replace: "(.*?): .*"
      by: "$1,"
fix: '#[inline(always)] pub fn $NAME(&mut self, $$$ARGS) -> Jump { unsafe { $FUNC(self.0, $PARAMS) }.into() }'
id: rewrite-with-return-type-jump
language: rust
---
rule:
  all:
  - any:
    - pattern: |
        pub fn $FUNC(compiler: *mut sljit_compiler) -> $RET;
    - pattern: |
        pub fn $FUNC(compiler: *mut sljit_compiler, $$$ARGS) -> $RET;
  - not:
      any:
      - pattern: |
          pub fn sljit_generate_code(compiler: *mut sljit_compiler, $$$ARGS) -> $RET;
      - pattern: |
          pub fn $FUNC(compiler: *mut sljit_compiler) -> *mut sljit_const;
      - pattern: |
          pub fn $FUNC(compiler: *mut sljit_compiler, $$$ARGS) -> *mut sljit_const;
      - pattern: |
          pub fn $FUNC(compiler: *mut sljit_compiler) -> *mut sljit_label;
      - pattern: |
          pub fn $FUNC(compiler: *mut sljit_compiler, $$$ARGS) -> *mut sljit_label;
      - pattern: |
          pub fn $FUNC(compiler: *mut sljit_compiler) -> *mut sljit_put_label;
      - pattern: |
          pub fn $FUNC(compiler: *mut sljit_compiler, $$$ARGS) -> *mut sljit_put_label;
      - pattern: |
          pub fn $FUNC(compiler: *mut sljit_compiler) -> *mut sljit_jump;
      - pattern: |
          pub fn $FUNC(compiler: *mut sljit_compiler, $$$ARGS) -> *mut sljit_jump;

transform:
  NAME:
    replace:
      source: $FUNC
      replace: "sljit_(.*)"
      by: "$1"

  PARAMS:
    replace:
      source: $$$ARGS
      replace: "(.*?): .*"
      by: "$1,"
fix: '#[inline(always)] pub fn $NAME(&mut self, $$$ARGS) -> $RET { unsafe { $FUNC(self.0, $PARAMS) } }'
id: rewrite-with-return-type
language: rust
---
rule:
  all:
  - any:
    - pattern: |
        pub fn $FUNC(compiler: *mut sljit_compiler);
    - pattern: |
        pub fn $FUNC(compiler: *mut sljit_compiler, $$$ARGS);
  - not:
      any:
      - pattern: |
          pub fn sljit_free_compiler(compiler: *mut sljit_compiler);
transform:
  NAME:
    replace:
      source: $FUNC
      replace: "sljit_(.*)"
      by: "$1"
  PARAMS:
    replace:
      source: $$$ARGS
      replace: "(.*?): .*"
      by: "$1,"
fix: '#[inline(always)] pub fn $NAME(&mut self, $$$ARGS) { unsafe { $FUNC(self.0, $PARAMS) } }'
id: rewrite-without-return-type
language: rust