rubydex 0.4.2 → 0.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/THIRD_PARTY_LICENSES.html +6 -408
- data/ext/rubydex/declaration.c +2 -6
- data/ext/rubydex/definition.c +2 -3
- data/ext/rubydex/extconf.rb +1 -0
- data/ext/rubydex/graph.c +2 -1
- data/ext/rubydex/query.c +3 -1
- data/ext/rubydex/reference.c +3 -3
- data/ext/rubydex/utils.c +13 -0
- data/ext/rubydex/utils.h +5 -0
- data/lib/rubydex/version.rb +1 -1
- data/rust/Cargo.lock +6 -6
- data/rust/Cargo.toml +3 -2
- data/rust/rubydex/Cargo.toml +2 -2
- data/rust/rubydex-sys/Cargo.toml +6 -3
- data/rust/rubydex-sys/build.rs +1 -2
- data/rust/rubydex-sys/src/cypher_api.rs +8 -8
- data/rust/rubydex-sys/src/declaration_api.rs +11 -19
- data/rust/rubydex-sys/src/definition_api.rs +10 -17
- data/rust/rubydex-sys/src/diagnostic_api.rs +5 -7
- data/rust/rubydex-sys/src/reference_api.rs +7 -10
- data/rust/rubydex-sys/src/utils.rs +49 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 196878527af0452d4afb518e0520ed26ccf7370fc6755954d70038afa6e0f66e
|
|
4
|
+
data.tar.gz: 864a4ac367601c64a465946115b732da341971b2a7c9d06f96ce8b3fae983354
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 30ef223c97026abc1cb3f1a8c84048f87889dbb96aa01fc81fe37a9db52109cbb774ba492635ec09067050ab7a33dbd2b7f40aac5512dc81367d7f0009c036ee
|
|
7
|
+
data.tar.gz: 20e4b61e4790603a8589419404d85011ef0f9342b4e0cc65f056b19fdadc5a6d881a37f3e49cd9328c072bc64cc6e988350e0372da32243632d5ae2a1de2fcbf
|
data/THIRD_PARTY_LICENSES.html
CHANGED
|
@@ -50,14 +50,13 @@
|
|
|
50
50
|
|
|
51
51
|
<h2>Overview of licenses:</h2>
|
|
52
52
|
<ul class="licenses-overview">
|
|
53
|
-
<li><a href="#Apache-2.0">Apache License 2.0</a> (
|
|
53
|
+
<li><a href="#Apache-2.0">Apache License 2.0</a> (115)</li>
|
|
54
54
|
<li><a href="#Unicode-3.0">Unicode License v3</a> (19)</li>
|
|
55
|
-
<li><a href="#MIT">MIT License</a> (
|
|
55
|
+
<li><a href="#MIT">MIT License</a> (16)</li>
|
|
56
56
|
<li><a href="#BSD-2-Clause">BSD 2-Clause "Simplified" License</a> (2)</li>
|
|
57
57
|
<li><a href="#BSD-3-Clause">BSD 3-Clause "New" or "Revised" License</a> (1)</li>
|
|
58
58
|
<li><a href="#BSL-1.0">Boost Software License 1.0</a> (1)</li>
|
|
59
59
|
<li><a href="#ISC">ISC License</a> (1)</li>
|
|
60
|
-
<li><a href="#MPL-2.0">Mozilla Public License 2.0</a> (1)</li>
|
|
61
60
|
<li><a href="#mingw-w64-toolchain">MinGW-w64 toolchain and related libraries for Windows precompiled
|
|
62
61
|
builds</a></li>
|
|
63
62
|
</ul>
|
|
@@ -1264,36 +1263,21 @@ Software.
|
|
|
1264
1263
|
<li><a
|
|
1265
1264
|
href=" https://github.com/polyfill-rs/once_cell_polyfill ">once_cell_polyfill
|
|
1266
1265
|
1.70.1</a></li>
|
|
1267
|
-
<li><a
|
|
1268
|
-
href=" https://github.com/toml-rs/toml ">serde_spanned
|
|
1269
|
-
0.6.9</a></li>
|
|
1270
1266
|
<li><a
|
|
1271
1267
|
href=" https://github.com/toml-rs/toml ">serde_spanned
|
|
1272
1268
|
1.1.1</a></li>
|
|
1273
1269
|
<li><a
|
|
1274
1270
|
href=" https://github.com/tikv/jemallocator ">tikv-jemalloc-ctl
|
|
1275
1271
|
0.7.0</a></li>
|
|
1276
|
-
<li><a
|
|
1277
|
-
href=" https://github.com/toml-rs/toml ">toml
|
|
1278
|
-
0.8.23</a></li>
|
|
1279
1272
|
<li><a
|
|
1280
1273
|
href=" https://github.com/toml-rs/toml ">toml
|
|
1281
1274
|
1.1.2+spec-1.1.0</a></li>
|
|
1282
|
-
<li><a
|
|
1283
|
-
href=" https://github.com/toml-rs/toml ">toml_datetime
|
|
1284
|
-
0.6.11</a></li>
|
|
1285
1275
|
<li><a
|
|
1286
1276
|
href=" https://github.com/toml-rs/toml ">toml_datetime
|
|
1287
1277
|
1.1.1+spec-1.1.0</a></li>
|
|
1288
|
-
<li><a
|
|
1289
|
-
href=" https://github.com/toml-rs/toml ">toml_edit
|
|
1290
|
-
0.22.27</a></li>
|
|
1291
1278
|
<li><a
|
|
1292
1279
|
href=" https://github.com/toml-rs/toml ">toml_parser
|
|
1293
1280
|
1.1.2+spec-1.1.0</a></li>
|
|
1294
|
-
<li><a
|
|
1295
|
-
href=" https://github.com/toml-rs/toml ">toml_write
|
|
1296
|
-
0.1.2</a></li>
|
|
1297
1281
|
<li><a
|
|
1298
1282
|
href=" https://github.com/toml-rs/toml ">toml_writer
|
|
1299
1283
|
1.1.1+spec-1.1.0</a></li>
|
|
@@ -2864,19 +2848,19 @@ SOFTWARE.
|
|
|
2864
2848
|
<ul class="license-used-by">
|
|
2865
2849
|
<li><a
|
|
2866
2850
|
href=" https://github.com/Shopify/rubydex ">rubydex
|
|
2867
|
-
0.4.
|
|
2851
|
+
0.4.4</a></li>
|
|
2868
2852
|
<li><a
|
|
2869
2853
|
href=" https://github.com/Shopify/rubydex ">rubydex-sys
|
|
2870
|
-
0.4.
|
|
2854
|
+
0.4.4</a></li>
|
|
2871
2855
|
<li><a
|
|
2872
2856
|
href=" https://github.com/DimaKudosh/difflib ">difflib
|
|
2873
2857
|
0.4.0</a></li>
|
|
2874
2858
|
<li><a
|
|
2875
2859
|
href=" https://github.com/ruby/prism ">ruby-prism-sys
|
|
2876
|
-
2.0.0
|
|
2860
|
+
2.0.0</a></li>
|
|
2877
2861
|
<li><a
|
|
2878
2862
|
href=" https://github.com/ruby/prism ">ruby-prism
|
|
2879
|
-
2.0.0
|
|
2863
|
+
2.0.0</a></li>
|
|
2880
2864
|
</ul>
|
|
2881
2865
|
<pre class="license-text">MIT License
|
|
2882
2866
|
|
|
@@ -2935,9 +2919,6 @@ DEALINGS IN THE SOFTWARE.
|
|
|
2935
2919
|
<h3 id="MIT">MIT License</h3>
|
|
2936
2920
|
<h4>Used by:</h4>
|
|
2937
2921
|
<ul class="license-used-by">
|
|
2938
|
-
<li><a
|
|
2939
|
-
href=" https://github.com/winnow-rs/winnow ">winnow
|
|
2940
|
-
0.7.12</a></li>
|
|
2941
2922
|
<li><a
|
|
2942
2923
|
href=" https://github.com/winnow-rs/winnow ">winnow
|
|
2943
2924
|
1.0.3</a></li>
|
|
@@ -3060,389 +3041,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
3060
3041
|
THE SOFTWARE.
|
|
3061
3042
|
|
|
3062
3043
|
See the generated THIRD_PARTY_LICENSES.html file for third party licenses.
|
|
3063
|
-
</pre>
|
|
3064
|
-
</li>
|
|
3065
|
-
<li class="license">
|
|
3066
|
-
<h3 id="MPL-2.0">Mozilla Public License 2.0</h3>
|
|
3067
|
-
<h4>Used by:</h4>
|
|
3068
|
-
<ul class="license-used-by">
|
|
3069
|
-
<li><a
|
|
3070
|
-
href=" https://github.com/mozilla/cbindgen ">cbindgen
|
|
3071
|
-
0.29.0</a></li>
|
|
3072
|
-
</ul>
|
|
3073
|
-
<pre class="license-text">Mozilla Public License Version 2.0
|
|
3074
|
-
==================================
|
|
3075
|
-
|
|
3076
|
-
1. Definitions
|
|
3077
|
-
--------------
|
|
3078
|
-
|
|
3079
|
-
1.1. "Contributor"
|
|
3080
|
-
means each individual or legal entity that creates, contributes to
|
|
3081
|
-
the creation of, or owns Covered Software.
|
|
3082
|
-
|
|
3083
|
-
1.2. "Contributor Version"
|
|
3084
|
-
means the combination of the Contributions of others (if any) used
|
|
3085
|
-
by a Contributor and that particular Contributor's Contribution.
|
|
3086
|
-
|
|
3087
|
-
1.3. "Contribution"
|
|
3088
|
-
means Covered Software of a particular Contributor.
|
|
3089
|
-
|
|
3090
|
-
1.4. "Covered Software"
|
|
3091
|
-
means Source Code Form to which the initial Contributor has attached
|
|
3092
|
-
the notice in Exhibit A, the Executable Form of such Source Code
|
|
3093
|
-
Form, and Modifications of such Source Code Form, in each case
|
|
3094
|
-
including portions thereof.
|
|
3095
|
-
|
|
3096
|
-
1.5. "Incompatible With Secondary Licenses"
|
|
3097
|
-
means
|
|
3098
|
-
|
|
3099
|
-
(a) that the initial Contributor has attached the notice described
|
|
3100
|
-
in Exhibit B to the Covered Software; or
|
|
3101
|
-
|
|
3102
|
-
(b) that the Covered Software was made available under the terms of
|
|
3103
|
-
version 1.1 or earlier of the License, but not also under the
|
|
3104
|
-
terms of a Secondary License.
|
|
3105
|
-
|
|
3106
|
-
1.6. "Executable Form"
|
|
3107
|
-
means any form of the work other than Source Code Form.
|
|
3108
|
-
|
|
3109
|
-
1.7. "Larger Work"
|
|
3110
|
-
means a work that combines Covered Software with other material, in
|
|
3111
|
-
a separate file or files, that is not Covered Software.
|
|
3112
|
-
|
|
3113
|
-
1.8. "License"
|
|
3114
|
-
means this document.
|
|
3115
|
-
|
|
3116
|
-
1.9. "Licensable"
|
|
3117
|
-
means having the right to grant, to the maximum extent possible,
|
|
3118
|
-
whether at the time of the initial grant or subsequently, any and
|
|
3119
|
-
all of the rights conveyed by this License.
|
|
3120
|
-
|
|
3121
|
-
1.10. "Modifications"
|
|
3122
|
-
means any of the following:
|
|
3123
|
-
|
|
3124
|
-
(a) any file in Source Code Form that results from an addition to,
|
|
3125
|
-
deletion from, or modification of the contents of Covered
|
|
3126
|
-
Software; or
|
|
3127
|
-
|
|
3128
|
-
(b) any new file in Source Code Form that contains any Covered
|
|
3129
|
-
Software.
|
|
3130
|
-
|
|
3131
|
-
1.11. "Patent Claims" of a Contributor
|
|
3132
|
-
means any patent claim(s), including without limitation, method,
|
|
3133
|
-
process, and apparatus claims, in any patent Licensable by such
|
|
3134
|
-
Contributor that would be infringed, but for the grant of the
|
|
3135
|
-
License, by the making, using, selling, offering for sale, having
|
|
3136
|
-
made, import, or transfer of either its Contributions or its
|
|
3137
|
-
Contributor Version.
|
|
3138
|
-
|
|
3139
|
-
1.12. "Secondary License"
|
|
3140
|
-
means either the GNU General Public License, Version 2.0, the GNU
|
|
3141
|
-
Lesser General Public License, Version 2.1, the GNU Affero General
|
|
3142
|
-
Public License, Version 3.0, or any later versions of those
|
|
3143
|
-
licenses.
|
|
3144
|
-
|
|
3145
|
-
1.13. "Source Code Form"
|
|
3146
|
-
means the form of the work preferred for making modifications.
|
|
3147
|
-
|
|
3148
|
-
1.14. "You" (or "Your")
|
|
3149
|
-
means an individual or a legal entity exercising rights under this
|
|
3150
|
-
License. For legal entities, "You" includes any entity that
|
|
3151
|
-
controls, is controlled by, or is under common control with You. For
|
|
3152
|
-
purposes of this definition, "control" means (a) the power, direct
|
|
3153
|
-
or indirect, to cause the direction or management of such entity,
|
|
3154
|
-
whether by contract or otherwise, or (b) ownership of more than
|
|
3155
|
-
fifty percent (50%) of the outstanding shares or beneficial
|
|
3156
|
-
ownership of such entity.
|
|
3157
|
-
|
|
3158
|
-
2. License Grants and Conditions
|
|
3159
|
-
--------------------------------
|
|
3160
|
-
|
|
3161
|
-
2.1. Grants
|
|
3162
|
-
|
|
3163
|
-
Each Contributor hereby grants You a world-wide, royalty-free,
|
|
3164
|
-
non-exclusive license:
|
|
3165
|
-
|
|
3166
|
-
(a) under intellectual property rights (other than patent or trademark)
|
|
3167
|
-
Licensable by such Contributor to use, reproduce, make available,
|
|
3168
|
-
modify, display, perform, distribute, and otherwise exploit its
|
|
3169
|
-
Contributions, either on an unmodified basis, with Modifications, or
|
|
3170
|
-
as part of a Larger Work; and
|
|
3171
|
-
|
|
3172
|
-
(b) under Patent Claims of such Contributor to make, use, sell, offer
|
|
3173
|
-
for sale, have made, import, and otherwise transfer either its
|
|
3174
|
-
Contributions or its Contributor Version.
|
|
3175
|
-
|
|
3176
|
-
2.2. Effective Date
|
|
3177
|
-
|
|
3178
|
-
The licenses granted in Section 2.1 with respect to any Contribution
|
|
3179
|
-
become effective for each Contribution on the date the Contributor first
|
|
3180
|
-
distributes such Contribution.
|
|
3181
|
-
|
|
3182
|
-
2.3. Limitations on Grant Scope
|
|
3183
|
-
|
|
3184
|
-
The licenses granted in this Section 2 are the only rights granted under
|
|
3185
|
-
this License. No additional rights or licenses will be implied from the
|
|
3186
|
-
distribution or licensing of Covered Software under this License.
|
|
3187
|
-
Notwithstanding Section 2.1(b) above, no patent license is granted by a
|
|
3188
|
-
Contributor:
|
|
3189
|
-
|
|
3190
|
-
(a) for any code that a Contributor has removed from Covered Software;
|
|
3191
|
-
or
|
|
3192
|
-
|
|
3193
|
-
(b) for infringements caused by: (i) Your and any other third party's
|
|
3194
|
-
modifications of Covered Software, or (ii) the combination of its
|
|
3195
|
-
Contributions with other software (except as part of its Contributor
|
|
3196
|
-
Version); or
|
|
3197
|
-
|
|
3198
|
-
(c) under Patent Claims infringed by Covered Software in the absence of
|
|
3199
|
-
its Contributions.
|
|
3200
|
-
|
|
3201
|
-
This License does not grant any rights in the trademarks, service marks,
|
|
3202
|
-
or logos of any Contributor (except as may be necessary to comply with
|
|
3203
|
-
the notice requirements in Section 3.4).
|
|
3204
|
-
|
|
3205
|
-
2.4. Subsequent Licenses
|
|
3206
|
-
|
|
3207
|
-
No Contributor makes additional grants as a result of Your choice to
|
|
3208
|
-
distribute the Covered Software under a subsequent version of this
|
|
3209
|
-
License (see Section 10.2) or under the terms of a Secondary License (if
|
|
3210
|
-
permitted under the terms of Section 3.3).
|
|
3211
|
-
|
|
3212
|
-
2.5. Representation
|
|
3213
|
-
|
|
3214
|
-
Each Contributor represents that the Contributor believes its
|
|
3215
|
-
Contributions are its original creation(s) or it has sufficient rights
|
|
3216
|
-
to grant the rights to its Contributions conveyed by this License.
|
|
3217
|
-
|
|
3218
|
-
2.6. Fair Use
|
|
3219
|
-
|
|
3220
|
-
This License is not intended to limit any rights You have under
|
|
3221
|
-
applicable copyright doctrines of fair use, fair dealing, or other
|
|
3222
|
-
equivalents.
|
|
3223
|
-
|
|
3224
|
-
2.7. Conditions
|
|
3225
|
-
|
|
3226
|
-
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
|
|
3227
|
-
in Section 2.1.
|
|
3228
|
-
|
|
3229
|
-
3. Responsibilities
|
|
3230
|
-
-------------------
|
|
3231
|
-
|
|
3232
|
-
3.1. Distribution of Source Form
|
|
3233
|
-
|
|
3234
|
-
All distribution of Covered Software in Source Code Form, including any
|
|
3235
|
-
Modifications that You create or to which You contribute, must be under
|
|
3236
|
-
the terms of this License. You must inform recipients that the Source
|
|
3237
|
-
Code Form of the Covered Software is governed by the terms of this
|
|
3238
|
-
License, and how they can obtain a copy of this License. You may not
|
|
3239
|
-
attempt to alter or restrict the recipients' rights in the Source Code
|
|
3240
|
-
Form.
|
|
3241
|
-
|
|
3242
|
-
3.2. Distribution of Executable Form
|
|
3243
|
-
|
|
3244
|
-
If You distribute Covered Software in Executable Form then:
|
|
3245
|
-
|
|
3246
|
-
(a) such Covered Software must also be made available in Source Code
|
|
3247
|
-
Form, as described in Section 3.1, and You must inform recipients of
|
|
3248
|
-
the Executable Form how they can obtain a copy of such Source Code
|
|
3249
|
-
Form by reasonable means in a timely manner, at a charge no more
|
|
3250
|
-
than the cost of distribution to the recipient; and
|
|
3251
|
-
|
|
3252
|
-
(b) You may distribute such Executable Form under the terms of this
|
|
3253
|
-
License, or sublicense it under different terms, provided that the
|
|
3254
|
-
license for the Executable Form does not attempt to limit or alter
|
|
3255
|
-
the recipients' rights in the Source Code Form under this License.
|
|
3256
|
-
|
|
3257
|
-
3.3. Distribution of a Larger Work
|
|
3258
|
-
|
|
3259
|
-
You may create and distribute a Larger Work under terms of Your choice,
|
|
3260
|
-
provided that You also comply with the requirements of this License for
|
|
3261
|
-
the Covered Software. If the Larger Work is a combination of Covered
|
|
3262
|
-
Software with a work governed by one or more Secondary Licenses, and the
|
|
3263
|
-
Covered Software is not Incompatible With Secondary Licenses, this
|
|
3264
|
-
License permits You to additionally distribute such Covered Software
|
|
3265
|
-
under the terms of such Secondary License(s), so that the recipient of
|
|
3266
|
-
the Larger Work may, at their option, further distribute the Covered
|
|
3267
|
-
Software under the terms of either this License or such Secondary
|
|
3268
|
-
License(s).
|
|
3269
|
-
|
|
3270
|
-
3.4. Notices
|
|
3271
|
-
|
|
3272
|
-
You may not remove or alter the substance of any license notices
|
|
3273
|
-
(including copyright notices, patent notices, disclaimers of warranty,
|
|
3274
|
-
or limitations of liability) contained within the Source Code Form of
|
|
3275
|
-
the Covered Software, except that You may alter any license notices to
|
|
3276
|
-
the extent required to remedy known factual inaccuracies.
|
|
3277
|
-
|
|
3278
|
-
3.5. Application of Additional Terms
|
|
3279
|
-
|
|
3280
|
-
You may choose to offer, and to charge a fee for, warranty, support,
|
|
3281
|
-
indemnity or liability obligations to one or more recipients of Covered
|
|
3282
|
-
Software. However, You may do so only on Your own behalf, and not on
|
|
3283
|
-
behalf of any Contributor. You must make it absolutely clear that any
|
|
3284
|
-
such warranty, support, indemnity, or liability obligation is offered by
|
|
3285
|
-
You alone, and You hereby agree to indemnify every Contributor for any
|
|
3286
|
-
liability incurred by such Contributor as a result of warranty, support,
|
|
3287
|
-
indemnity or liability terms You offer. You may include additional
|
|
3288
|
-
disclaimers of warranty and limitations of liability specific to any
|
|
3289
|
-
jurisdiction.
|
|
3290
|
-
|
|
3291
|
-
4. Inability to Comply Due to Statute or Regulation
|
|
3292
|
-
---------------------------------------------------
|
|
3293
|
-
|
|
3294
|
-
If it is impossible for You to comply with any of the terms of this
|
|
3295
|
-
License with respect to some or all of the Covered Software due to
|
|
3296
|
-
statute, judicial order, or regulation then You must: (a) comply with
|
|
3297
|
-
the terms of this License to the maximum extent possible; and (b)
|
|
3298
|
-
describe the limitations and the code they affect. Such description must
|
|
3299
|
-
be placed in a text file included with all distributions of the Covered
|
|
3300
|
-
Software under this License. Except to the extent prohibited by statute
|
|
3301
|
-
or regulation, such description must be sufficiently detailed for a
|
|
3302
|
-
recipient of ordinary skill to be able to understand it.
|
|
3303
|
-
|
|
3304
|
-
5. Termination
|
|
3305
|
-
--------------
|
|
3306
|
-
|
|
3307
|
-
5.1. The rights granted under this License will terminate automatically
|
|
3308
|
-
if You fail to comply with any of its terms. However, if You become
|
|
3309
|
-
compliant, then the rights granted under this License from a particular
|
|
3310
|
-
Contributor are reinstated (a) provisionally, unless and until such
|
|
3311
|
-
Contributor explicitly and finally terminates Your grants, and (b) on an
|
|
3312
|
-
ongoing basis, if such Contributor fails to notify You of the
|
|
3313
|
-
non-compliance by some reasonable means prior to 60 days after You have
|
|
3314
|
-
come back into compliance. Moreover, Your grants from a particular
|
|
3315
|
-
Contributor are reinstated on an ongoing basis if such Contributor
|
|
3316
|
-
notifies You of the non-compliance by some reasonable means, this is the
|
|
3317
|
-
first time You have received notice of non-compliance with this License
|
|
3318
|
-
from such Contributor, and You become compliant prior to 30 days after
|
|
3319
|
-
Your receipt of the notice.
|
|
3320
|
-
|
|
3321
|
-
5.2. If You initiate litigation against any entity by asserting a patent
|
|
3322
|
-
infringement claim (excluding declaratory judgment actions,
|
|
3323
|
-
counter-claims, and cross-claims) alleging that a Contributor Version
|
|
3324
|
-
directly or indirectly infringes any patent, then the rights granted to
|
|
3325
|
-
You by any and all Contributors for the Covered Software under Section
|
|
3326
|
-
2.1 of this License shall terminate.
|
|
3327
|
-
|
|
3328
|
-
5.3. In the event of termination under Sections 5.1 or 5.2 above, all
|
|
3329
|
-
end user license agreements (excluding distributors and resellers) which
|
|
3330
|
-
have been validly granted by You or Your distributors under this License
|
|
3331
|
-
prior to termination shall survive termination.
|
|
3332
|
-
|
|
3333
|
-
************************************************************************
|
|
3334
|
-
* *
|
|
3335
|
-
* 6. Disclaimer of Warranty *
|
|
3336
|
-
* ------------------------- *
|
|
3337
|
-
* *
|
|
3338
|
-
* Covered Software is provided under this License on an "as is" *
|
|
3339
|
-
* basis, without warranty of any kind, either expressed, implied, or *
|
|
3340
|
-
* statutory, including, without limitation, warranties that the *
|
|
3341
|
-
* Covered Software is free of defects, merchantable, fit for a *
|
|
3342
|
-
* particular purpose or non-infringing. The entire risk as to the *
|
|
3343
|
-
* quality and performance of the Covered Software is with You. *
|
|
3344
|
-
* Should any Covered Software prove defective in any respect, You *
|
|
3345
|
-
* (not any Contributor) assume the cost of any necessary servicing, *
|
|
3346
|
-
* repair, or correction. This disclaimer of warranty constitutes an *
|
|
3347
|
-
* essential part of this License. No use of any Covered Software is *
|
|
3348
|
-
* authorized under this License except under this disclaimer. *
|
|
3349
|
-
* *
|
|
3350
|
-
************************************************************************
|
|
3351
|
-
|
|
3352
|
-
************************************************************************
|
|
3353
|
-
* *
|
|
3354
|
-
* 7. Limitation of Liability *
|
|
3355
|
-
* -------------------------- *
|
|
3356
|
-
* *
|
|
3357
|
-
* Under no circumstances and under no legal theory, whether tort *
|
|
3358
|
-
* (including negligence), contract, or otherwise, shall any *
|
|
3359
|
-
* Contributor, or anyone who distributes Covered Software as *
|
|
3360
|
-
* permitted above, be liable to You for any direct, indirect, *
|
|
3361
|
-
* special, incidental, or consequential damages of any character *
|
|
3362
|
-
* including, without limitation, damages for lost profits, loss of *
|
|
3363
|
-
* goodwill, work stoppage, computer failure or malfunction, or any *
|
|
3364
|
-
* and all other commercial damages or losses, even if such party *
|
|
3365
|
-
* shall have been informed of the possibility of such damages. This *
|
|
3366
|
-
* limitation of liability shall not apply to liability for death or *
|
|
3367
|
-
* personal injury resulting from such party's negligence to the *
|
|
3368
|
-
* extent applicable law prohibits such limitation. Some *
|
|
3369
|
-
* jurisdictions do not allow the exclusion or limitation of *
|
|
3370
|
-
* incidental or consequential damages, so this exclusion and *
|
|
3371
|
-
* limitation may not apply to You. *
|
|
3372
|
-
* *
|
|
3373
|
-
************************************************************************
|
|
3374
|
-
|
|
3375
|
-
8. Litigation
|
|
3376
|
-
-------------
|
|
3377
|
-
|
|
3378
|
-
Any litigation relating to this License may be brought only in the
|
|
3379
|
-
courts of a jurisdiction where the defendant maintains its principal
|
|
3380
|
-
place of business and such litigation shall be governed by laws of that
|
|
3381
|
-
jurisdiction, without reference to its conflict-of-law provisions.
|
|
3382
|
-
Nothing in this Section shall prevent a party's ability to bring
|
|
3383
|
-
cross-claims or counter-claims.
|
|
3384
|
-
|
|
3385
|
-
9. Miscellaneous
|
|
3386
|
-
----------------
|
|
3387
|
-
|
|
3388
|
-
This License represents the complete agreement concerning the subject
|
|
3389
|
-
matter hereof. If any provision of this License is held to be
|
|
3390
|
-
unenforceable, such provision shall be reformed only to the extent
|
|
3391
|
-
necessary to make it enforceable. Any law or regulation which provides
|
|
3392
|
-
that the language of a contract shall be construed against the drafter
|
|
3393
|
-
shall not be used to construe this License against a Contributor.
|
|
3394
|
-
|
|
3395
|
-
10. Versions of the License
|
|
3396
|
-
---------------------------
|
|
3397
|
-
|
|
3398
|
-
10.1. New Versions
|
|
3399
|
-
|
|
3400
|
-
Mozilla Foundation is the license steward. Except as provided in Section
|
|
3401
|
-
10.3, no one other than the license steward has the right to modify or
|
|
3402
|
-
publish new versions of this License. Each version will be given a
|
|
3403
|
-
distinguishing version number.
|
|
3404
|
-
|
|
3405
|
-
10.2. Effect of New Versions
|
|
3406
|
-
|
|
3407
|
-
You may distribute the Covered Software under the terms of the version
|
|
3408
|
-
of the License under which You originally received the Covered Software,
|
|
3409
|
-
or under the terms of any subsequent version published by the license
|
|
3410
|
-
steward.
|
|
3411
|
-
|
|
3412
|
-
10.3. Modified Versions
|
|
3413
|
-
|
|
3414
|
-
If you create software not governed by this License, and you want to
|
|
3415
|
-
create a new license for such software, you may create and use a
|
|
3416
|
-
modified version of this License if you rename the license and remove
|
|
3417
|
-
any references to the name of the license steward (except to note that
|
|
3418
|
-
such modified license differs from this License).
|
|
3419
|
-
|
|
3420
|
-
10.4. Distributing Source Code Form that is Incompatible With Secondary
|
|
3421
|
-
Licenses
|
|
3422
|
-
|
|
3423
|
-
If You choose to distribute Source Code Form that is Incompatible With
|
|
3424
|
-
Secondary Licenses under the terms of this version of the License, the
|
|
3425
|
-
notice described in Exhibit B of this License must be attached.
|
|
3426
|
-
|
|
3427
|
-
Exhibit A - Source Code Form License Notice
|
|
3428
|
-
-------------------------------------------
|
|
3429
|
-
|
|
3430
|
-
This Source Code Form is subject to the terms of the Mozilla Public
|
|
3431
|
-
License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3432
|
-
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
3433
|
-
|
|
3434
|
-
If it is not possible or desirable to put the notice in a particular
|
|
3435
|
-
file, then You may include the notice in a location (such as a LICENSE
|
|
3436
|
-
file in a relevant directory) where a recipient would be likely to look
|
|
3437
|
-
for such a notice.
|
|
3438
|
-
|
|
3439
|
-
You may add additional accurate notices of copyright ownership.
|
|
3440
|
-
|
|
3441
|
-
Exhibit B - "Incompatible With Secondary Licenses" Notice
|
|
3442
|
-
---------------------------------------------------------
|
|
3443
|
-
|
|
3444
|
-
This Source Code Form is "Incompatible With Secondary Licenses", as
|
|
3445
|
-
defined by the Mozilla Public License, v. 2.0.
|
|
3446
3044
|
</pre>
|
|
3447
3045
|
</li>
|
|
3448
3046
|
<li class="license">
|
data/ext/rubydex/declaration.c
CHANGED
|
@@ -60,9 +60,7 @@ VALUE rdxi_declaration_class_for_kind(CDeclarationKind kind) {
|
|
|
60
60
|
static VALUE rdxr_declaration_name(VALUE self) {
|
|
61
61
|
HandleData *data;
|
|
62
62
|
void *graph = rdxi_graph_from_handle(self, &data);
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
return rdxi_owned_c_string_to_ruby(name);
|
|
63
|
+
return rdxi_owned_string_to_ruby(rdx_declaration_name(graph, data->id));
|
|
66
64
|
}
|
|
67
65
|
|
|
68
66
|
/*
|
|
@@ -74,9 +72,7 @@ static VALUE rdxr_declaration_name(VALUE self) {
|
|
|
74
72
|
static VALUE rdxr_declaration_unqualified_name(VALUE self) {
|
|
75
73
|
HandleData *data;
|
|
76
74
|
void *graph = rdxi_graph_from_handle(self, &data);
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
return rdxi_owned_c_string_to_ruby(name);
|
|
75
|
+
return rdxi_owned_string_to_ruby(rdx_declaration_unqualified_name(graph, data->id));
|
|
80
76
|
}
|
|
81
77
|
|
|
82
78
|
// Body function for rb_ensure in Declaration#definitions
|
data/ext/rubydex/definition.c
CHANGED
|
@@ -132,7 +132,7 @@ static VALUE rdxr_definition_comments(VALUE self) {
|
|
|
132
132
|
for (size_t i = 0; i < arr->len; i++) {
|
|
133
133
|
CommentEntry entry = arr->items[i];
|
|
134
134
|
|
|
135
|
-
VALUE string =
|
|
135
|
+
VALUE string = rb_utf8_str_new(entry.string.data, (long)entry.string.length);
|
|
136
136
|
|
|
137
137
|
Location *loc = entry.location;
|
|
138
138
|
VALUE location = rdxi_build_location_value(loc);
|
|
@@ -160,8 +160,7 @@ static VALUE rdxr_definition_name(VALUE self) {
|
|
|
160
160
|
HandleData *data;
|
|
161
161
|
void *graph = rdxi_graph_from_handle(self, &data);
|
|
162
162
|
|
|
163
|
-
|
|
164
|
-
return rdxi_owned_c_string_to_ruby(name);
|
|
163
|
+
return rdxi_owned_string_to_ruby(rdx_definition_name(graph, data->id));
|
|
165
164
|
}
|
|
166
165
|
|
|
167
166
|
/*
|
data/ext/rubydex/extconf.rb
CHANGED
|
@@ -29,6 +29,7 @@ bindings_path = root_dir.join("rubydex-sys").join("rustbindings.h")
|
|
|
29
29
|
|
|
30
30
|
cargo_args = ["--manifest-path #{root_dir.join("Cargo.toml")}"]
|
|
31
31
|
cargo_args << "$(CARGO_PROFILE_FLAG)"
|
|
32
|
+
cargo_args << "--features rubydex-sys/generate_bindings"
|
|
32
33
|
|
|
33
34
|
if Gem.win_platform?
|
|
34
35
|
cargo_args << "--target x86_64-pc-windows-gnu"
|
data/ext/rubydex/graph.c
CHANGED
|
@@ -679,7 +679,8 @@ static VALUE rdxr_graph_diagnostics(VALUE self) {
|
|
|
679
679
|
VALUE diagnostics = rb_ary_new_capa((long)array->len);
|
|
680
680
|
for (size_t i = 0; i < array->len; i++) {
|
|
681
681
|
DiagnosticEntry entry = array->items[i];
|
|
682
|
-
VALUE message =
|
|
682
|
+
VALUE message =
|
|
683
|
+
entry.message.data == NULL ? Qnil : rb_utf8_str_new(entry.message.data, (long)entry.message.length);
|
|
683
684
|
VALUE rule = rdxi_rule_class_from_name(entry.rule.name, entry.rule.name_length);
|
|
684
685
|
VALUE location = rdxi_build_location_value(entry.location);
|
|
685
686
|
|
data/ext/rubydex/query.c
CHANGED
|
@@ -188,7 +188,9 @@ static VALUE cypher_cell_to_value(VALUE graph_obj, const struct CCell *cell) {
|
|
|
188
188
|
case CCellTag_Int:
|
|
189
189
|
return LL2NUM(cell->payload.int_val);
|
|
190
190
|
case CCellTag_Str:
|
|
191
|
-
return cell->payload.str_val == NULL
|
|
191
|
+
return cell->payload.str_val.data == NULL
|
|
192
|
+
? Qnil
|
|
193
|
+
: rb_utf8_str_new(cell->payload.str_val.data, (long)cell->payload.str_val.length);
|
|
192
194
|
case CCellTag_List: {
|
|
193
195
|
VALUE array = rb_ary_new_capa((long)cell->payload.list.len);
|
|
194
196
|
for (size_t i = 0; i < cell->payload.list.len; i++) {
|
data/ext/rubydex/reference.c
CHANGED
|
@@ -86,11 +86,11 @@ static VALUE rdxr_method_reference_name(VALUE self) {
|
|
|
86
86
|
HandleData *data;
|
|
87
87
|
void *graph = rdxi_graph_from_handle(self, &data);
|
|
88
88
|
|
|
89
|
-
|
|
90
|
-
if (name == NULL) {
|
|
89
|
+
OwnedString name = rdx_method_reference_name(graph, data->id);
|
|
90
|
+
if (name.data == NULL) {
|
|
91
91
|
rb_raise(rb_eRuntimeError, "Method reference must exist for a valid id");
|
|
92
92
|
}
|
|
93
|
-
return
|
|
93
|
+
return rdxi_owned_string_to_ruby(name);
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
/*
|
data/ext/rubydex/utils.c
CHANGED
|
@@ -59,6 +59,19 @@ VALUE rdxi_owned_c_string_to_ruby(const char *string) {
|
|
|
59
59
|
return value;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
// Convert a Rust-owned string with an explicit length to a Ruby string and release it with free_owned_string.
|
|
63
|
+
// Returns nil when the Rust side returned a null string.
|
|
64
|
+
VALUE rdxi_owned_string_to_ruby(OwnedString string) {
|
|
65
|
+
if (string.data == NULL) {
|
|
66
|
+
return Qnil;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
VALUE value = rb_utf8_str_new(string.data, (long)string.length);
|
|
70
|
+
free_owned_string(string);
|
|
71
|
+
|
|
72
|
+
return value;
|
|
73
|
+
}
|
|
74
|
+
|
|
62
75
|
// Coerce an optional String, Symbol, or nil to a C string, defaulting to `default_value` for nil.
|
|
63
76
|
const char *rdxi_symbol_or_string_cstr(VALUE value, const char *default_value) {
|
|
64
77
|
if (NIL_P(value)) {
|
data/ext/rubydex/utils.h
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
#define RUBYDEX_UTILS_H
|
|
3
3
|
|
|
4
4
|
#include "ruby.h"
|
|
5
|
+
#include "rustbindings.h"
|
|
5
6
|
|
|
6
7
|
// Convert a Ruby array of strings into a double char pointer so that we can pass that to Rust.
|
|
7
8
|
// This copies the data so it must be freed with rdxi_free_str_array
|
|
@@ -17,6 +18,10 @@ void rdxi_check_array_of_strings(VALUE array);
|
|
|
17
18
|
// Returns nil when the Rust side returned NULL.
|
|
18
19
|
VALUE rdxi_owned_c_string_to_ruby(const char *string);
|
|
19
20
|
|
|
21
|
+
// Convert a Rust-owned string with an explicit length to a Ruby string and release it with free_owned_string. Unlike
|
|
22
|
+
// a C string, it may contain NUL bytes. Returns nil when the Rust side returned a null string.
|
|
23
|
+
VALUE rdxi_owned_string_to_ruby(OwnedString string);
|
|
24
|
+
|
|
20
25
|
// Coerce an optional String, Symbol, or nil to a C string, returning `default_value` when the value
|
|
21
26
|
// is nil. A non-nil value must be a String or Symbol, otherwise a `TypeError` is raised. The
|
|
22
27
|
// returned pointer is owned by the Ruby VALUE and is only valid while it stays live.
|
data/lib/rubydex/version.rb
CHANGED
data/rust/Cargo.lock
CHANGED
|
@@ -718,9 +718,9 @@ checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
|
|
|
718
718
|
|
|
719
719
|
[[package]]
|
|
720
720
|
name = "ruby-prism"
|
|
721
|
-
version = "2.0.0
|
|
721
|
+
version = "2.0.0"
|
|
722
722
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
723
|
-
checksum = "
|
|
723
|
+
checksum = "e292a6139b28657899a18778d281cd4829d5e46ccc060edc1d0cdcd6b1fae774"
|
|
724
724
|
dependencies = [
|
|
725
725
|
"ruby-prism-sys",
|
|
726
726
|
"serde",
|
|
@@ -729,9 +729,9 @@ dependencies = [
|
|
|
729
729
|
|
|
730
730
|
[[package]]
|
|
731
731
|
name = "ruby-prism-sys"
|
|
732
|
-
version = "2.0.0
|
|
732
|
+
version = "2.0.0"
|
|
733
733
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
734
|
-
checksum = "
|
|
734
|
+
checksum = "0080aa6a022c43438c9f33533e2da926407776e96583be67d7864c4037fb84b3"
|
|
735
735
|
dependencies = [
|
|
736
736
|
"cc",
|
|
737
737
|
"shlex 2.0.1",
|
|
@@ -760,7 +760,7 @@ dependencies = [
|
|
|
760
760
|
|
|
761
761
|
[[package]]
|
|
762
762
|
name = "rubydex"
|
|
763
|
-
version = "0.4.
|
|
763
|
+
version = "0.4.4"
|
|
764
764
|
dependencies = [
|
|
765
765
|
"assert_cmd",
|
|
766
766
|
"bitflags",
|
|
@@ -789,7 +789,7 @@ dependencies = [
|
|
|
789
789
|
|
|
790
790
|
[[package]]
|
|
791
791
|
name = "rubydex-sys"
|
|
792
|
-
version = "0.4.
|
|
792
|
+
version = "0.4.4"
|
|
793
793
|
dependencies = [
|
|
794
794
|
"cbindgen",
|
|
795
795
|
"libc",
|
data/rust/Cargo.toml
CHANGED
|
@@ -7,7 +7,8 @@ members = [
|
|
|
7
7
|
resolver = "3"
|
|
8
8
|
|
|
9
9
|
[workspace.package]
|
|
10
|
-
version = "0.4.
|
|
10
|
+
version = "0.4.4"
|
|
11
|
+
rust-version = "1.99.1"
|
|
11
12
|
|
|
12
13
|
[profile.release]
|
|
13
14
|
lto = true
|
|
@@ -28,4 +29,4 @@ complexity = "deny"
|
|
|
28
29
|
style = "deny"
|
|
29
30
|
pedantic = "warn"
|
|
30
31
|
|
|
31
|
-
|
|
32
|
+
ptr_as_ptr = { level = "deny", priority = 1 }
|
data/rust/rubydex/Cargo.toml
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name = "rubydex"
|
|
3
3
|
version.workspace = true
|
|
4
4
|
edition = "2024"
|
|
5
|
-
rust-version =
|
|
5
|
+
rust-version.workspace = true
|
|
6
6
|
license = "MIT"
|
|
7
7
|
description = "High-performance Ruby code indexing and static analysis library."
|
|
8
8
|
homepage = "https://github.com/Shopify/rubydex"
|
|
@@ -32,7 +32,7 @@ test_utils = ["dep:tempfile"]
|
|
|
32
32
|
|
|
33
33
|
[dependencies]
|
|
34
34
|
cypher-parser = "0.8.1"
|
|
35
|
-
ruby-prism = "2.0.0
|
|
35
|
+
ruby-prism = "2.0.0"
|
|
36
36
|
ruby-rbs = "0.3"
|
|
37
37
|
url = "2.5.4"
|
|
38
38
|
xxhash-rust = { version = "0.8.15", features = ["xxh3"] }
|
data/rust/rubydex-sys/Cargo.toml
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name = "rubydex-sys"
|
|
3
3
|
version.workspace = true
|
|
4
4
|
edition = "2024"
|
|
5
|
-
rust-version =
|
|
5
|
+
rust-version.workspace = true
|
|
6
6
|
license = "MIT"
|
|
7
7
|
description = "C FFI bindings for the Rubydex Ruby code indexing engine."
|
|
8
8
|
homepage = "https://github.com/Shopify/rubydex"
|
|
@@ -15,13 +15,16 @@ categories = ["development-tools", "external-ffi-bindings"]
|
|
|
15
15
|
crate-type = ["cdylib", "staticlib"]
|
|
16
16
|
|
|
17
17
|
[dependencies]
|
|
18
|
-
rubydex = { version = "=0.4.
|
|
18
|
+
rubydex = { version = "=0.4.4", path = "../rubydex" }
|
|
19
19
|
libc = "0.2.174"
|
|
20
20
|
url = "2.5.4"
|
|
21
21
|
line-index = "0.1.2"
|
|
22
22
|
|
|
23
|
+
[features]
|
|
24
|
+
generate_bindings = ["dep:cbindgen"]
|
|
25
|
+
|
|
23
26
|
[build-dependencies]
|
|
24
|
-
cbindgen = "0.29"
|
|
27
|
+
cbindgen = { version = "0.29", optional = true }
|
|
25
28
|
|
|
26
29
|
[lints]
|
|
27
30
|
workspace = true
|
data/rust/rubydex-sys/build.rs
CHANGED
|
@@ -5,11 +5,13 @@ use crate::declaration_api::CDeclaration;
|
|
|
5
5
|
use crate::definition_api::map_definition_to_kind;
|
|
6
6
|
use crate::graph_api::{GraphPointer, with_graph};
|
|
7
7
|
use crate::utils;
|
|
8
|
+
use crate::utils::OwnedString;
|
|
8
9
|
use libc::{c_char, c_void};
|
|
9
10
|
use rubydex::model::graph::Graph;
|
|
10
11
|
use rubydex::query::cypher::schema::NodeRef;
|
|
11
12
|
use rubydex::query::cypher::{self, CypherValue, OutputFormat};
|
|
12
13
|
use std::ffi::CString;
|
|
14
|
+
use std::mem::ManuallyDrop;
|
|
13
15
|
use std::ptr;
|
|
14
16
|
|
|
15
17
|
/// Which layer of the Cypher pipeline rejected a call, so callers can raise a matching error class.
|
|
@@ -201,14 +203,13 @@ pub struct CMap {
|
|
|
201
203
|
/// Payload of a `CCell`. The active field is selected by the cell's `tag`; reading any other field
|
|
202
204
|
/// is undefined. `Null` carries no payload.
|
|
203
205
|
#[repr(C)]
|
|
204
|
-
#[derive(Clone, Copy)]
|
|
205
206
|
pub union CCellPayload {
|
|
206
207
|
/// `Bool`.
|
|
207
208
|
pub bool_val: bool,
|
|
208
209
|
/// `Int`.
|
|
209
210
|
pub int_val: i64,
|
|
210
|
-
/// `Str`: owned
|
|
211
|
-
pub str_val:
|
|
211
|
+
/// `Str`: owned string (freed by `rdx_rows_iter_free`). A union never drops its fields, so `free_cell` drops it.
|
|
212
|
+
pub str_val: ManuallyDrop<OwnedString>,
|
|
212
213
|
/// `Node`.
|
|
213
214
|
pub node: CNode,
|
|
214
215
|
/// `List`.
|
|
@@ -306,7 +307,7 @@ fn build_cell(graph: &Graph, value: &CypherValue) -> Result<CCell, String> {
|
|
|
306
307
|
CypherValue::Str(s) => Ok(CCell::new(
|
|
307
308
|
CCellTag::Str,
|
|
308
309
|
CCellPayload {
|
|
309
|
-
str_val:
|
|
310
|
+
str_val: ManuallyDrop::new(OwnedString::new(s)),
|
|
310
311
|
},
|
|
311
312
|
)),
|
|
312
313
|
CypherValue::List(items) => {
|
|
@@ -715,10 +716,9 @@ unsafe fn free_cell(cell: &CCell) {
|
|
|
715
716
|
match cell.tag {
|
|
716
717
|
// SAFETY: the tag selects the active union field.
|
|
717
718
|
CCellTag::Str => {
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
}
|
|
719
|
+
// The cell is not used after this, so moving the string out of it is sound
|
|
720
|
+
let string = unsafe { ptr::read(&raw const cell.payload.str_val) };
|
|
721
|
+
drop(ManuallyDrop::into_inner(string));
|
|
722
722
|
}
|
|
723
723
|
// SAFETY: the tag selects the active union field.
|
|
724
724
|
CCellTag::List => {
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
use libc::c_char;
|
|
4
4
|
use rubydex::model::declaration::{Ancestor, Declaration, Namespace};
|
|
5
|
-
use std::ffi::CString;
|
|
6
5
|
use std::ptr;
|
|
7
6
|
|
|
8
7
|
use crate::definition_api::{DefinitionsIter, rdx_definitions_iter_new_from_ids};
|
|
9
8
|
use crate::graph_api::{GraphPointer, with_graph};
|
|
10
9
|
use crate::reference_api::{CConstantReference, CMethodReference, ConstantReferencesIter, MethodReferencesIter};
|
|
11
10
|
use crate::utils;
|
|
11
|
+
use crate::utils::OwnedString;
|
|
12
12
|
use rubydex::model::ids::{DeclarationId, StringId, declaration_id_from_lookup_name};
|
|
13
13
|
|
|
14
14
|
#[repr(C)]
|
|
@@ -119,24 +119,20 @@ pub unsafe extern "C" fn rdx_graph_declarations_iter_free(iter: *mut Declaration
|
|
|
119
119
|
unsafe { DeclarationsIter::free(iter) }
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
/// Returns the UTF-8 name string for a declaration id.
|
|
123
|
-
/// Caller must free with `
|
|
122
|
+
/// Returns the UTF-8 name string for a declaration id, or a null string if the declaration cannot be found.
|
|
123
|
+
/// Caller must free with `free_owned_string`.
|
|
124
124
|
///
|
|
125
125
|
/// # Safety
|
|
126
126
|
///
|
|
127
127
|
/// Assumes pointer is valid.
|
|
128
|
-
///
|
|
129
|
-
/// # Panics
|
|
130
|
-
///
|
|
131
|
-
/// This function will panic if the name pointer is invalid.
|
|
132
128
|
#[unsafe(no_mangle)]
|
|
133
|
-
pub unsafe extern "C" fn rdx_declaration_name(pointer: GraphPointer, name_id: u64) ->
|
|
129
|
+
pub unsafe extern "C" fn rdx_declaration_name(pointer: GraphPointer, name_id: u64) -> OwnedString {
|
|
134
130
|
with_graph(pointer, |graph| {
|
|
135
131
|
let name_id = DeclarationId::new(name_id);
|
|
136
132
|
if let Some(decl) = graph.declarations().get(&name_id) {
|
|
137
|
-
|
|
133
|
+
OwnedString::new(decl.name())
|
|
138
134
|
} else {
|
|
139
|
-
|
|
135
|
+
OwnedString::null()
|
|
140
136
|
}
|
|
141
137
|
})
|
|
142
138
|
}
|
|
@@ -213,24 +209,20 @@ pub unsafe extern "C" fn rdx_declaration_find_member(
|
|
|
213
209
|
})
|
|
214
210
|
}
|
|
215
211
|
|
|
216
|
-
/// Returns the UTF-8 unqualified name string for a declaration id
|
|
217
|
-
/// Caller must free with `
|
|
212
|
+
/// Returns the UTF-8 unqualified name string for a declaration id, or a null string if the declaration cannot be
|
|
213
|
+
/// found. Caller must free with `free_owned_string`.
|
|
218
214
|
///
|
|
219
215
|
/// # Safety
|
|
220
216
|
///
|
|
221
217
|
/// Assumes pointer is valid.
|
|
222
|
-
///
|
|
223
|
-
/// # Panics
|
|
224
|
-
///
|
|
225
|
-
/// This function will panic if the name pointer is invalid.
|
|
226
218
|
#[unsafe(no_mangle)]
|
|
227
|
-
pub unsafe extern "C" fn rdx_declaration_unqualified_name(pointer: GraphPointer, name_id: u64) ->
|
|
219
|
+
pub unsafe extern "C" fn rdx_declaration_unqualified_name(pointer: GraphPointer, name_id: u64) -> OwnedString {
|
|
228
220
|
with_graph(pointer, |graph| {
|
|
229
221
|
let name_id = DeclarationId::new(name_id);
|
|
230
222
|
if let Some(decl) = graph.declarations().get(&name_id) {
|
|
231
|
-
|
|
223
|
+
OwnedString::new(&decl.unqualified_name())
|
|
232
224
|
} else {
|
|
233
|
-
|
|
225
|
+
OwnedString::null()
|
|
234
226
|
}
|
|
235
227
|
})
|
|
236
228
|
}
|
|
@@ -4,6 +4,7 @@ use crate::declaration_api::CDeclaration;
|
|
|
4
4
|
use crate::graph_api::{GraphPointer, with_graph};
|
|
5
5
|
use crate::location_api::{Location, create_location_for_uri_and_offset};
|
|
6
6
|
use crate::reference_api::CConstantReference;
|
|
7
|
+
use crate::utils::OwnedString;
|
|
7
8
|
use libc::c_char;
|
|
8
9
|
use rubydex::model::definitions::{Definition, Mixin};
|
|
9
10
|
use rubydex::model::graph::Graph;
|
|
@@ -84,30 +85,26 @@ pub unsafe extern "C" fn rdx_definition_kind(pointer: GraphPointer, definition_i
|
|
|
84
85
|
})
|
|
85
86
|
}
|
|
86
87
|
|
|
87
|
-
/// Returns the UTF-8 unqualified name string for a definition id.
|
|
88
|
-
/// Caller must free with `
|
|
88
|
+
/// Returns the UTF-8 unqualified name string for a definition id, or a null string if the definition cannot be found.
|
|
89
|
+
/// Caller must free with `free_owned_string`.
|
|
89
90
|
///
|
|
90
91
|
/// # Safety
|
|
91
92
|
///
|
|
92
93
|
/// Assumes pointer is valid.
|
|
93
|
-
///
|
|
94
|
-
/// # Panics
|
|
95
|
-
///
|
|
96
|
-
/// This function will panic if the definition cannot be found.
|
|
97
94
|
#[unsafe(no_mangle)]
|
|
98
|
-
pub unsafe extern "C" fn rdx_definition_name(pointer: GraphPointer, definition_id: u64) ->
|
|
95
|
+
pub unsafe extern "C" fn rdx_definition_name(pointer: GraphPointer, definition_id: u64) -> OwnedString {
|
|
99
96
|
with_graph(pointer, |graph| {
|
|
100
97
|
let def_id = DefinitionId::new(definition_id);
|
|
101
98
|
if let Some(defn) = graph.definitions().get(&def_id) {
|
|
102
99
|
let string_id = graph.definition_string_id(defn);
|
|
103
100
|
|
|
104
101
|
if let Some(name) = graph.strings().get(&string_id) {
|
|
105
|
-
|
|
102
|
+
OwnedString::new(name.as_str())
|
|
106
103
|
} else {
|
|
107
|
-
|
|
104
|
+
OwnedString::null()
|
|
108
105
|
}
|
|
109
106
|
} else {
|
|
110
|
-
|
|
107
|
+
OwnedString::null()
|
|
111
108
|
}
|
|
112
109
|
})
|
|
113
110
|
}
|
|
@@ -212,7 +209,7 @@ pub unsafe extern "C" fn rdx_definitions_iter_free(iter: *mut DefinitionsIter) {
|
|
|
212
209
|
/// C-compatible struct representing a single comment with its string and location
|
|
213
210
|
#[repr(C)]
|
|
214
211
|
pub struct CommentEntry {
|
|
215
|
-
pub string:
|
|
212
|
+
pub string: OwnedString,
|
|
216
213
|
pub location: *mut Location,
|
|
217
214
|
}
|
|
218
215
|
|
|
@@ -248,7 +245,7 @@ pub unsafe extern "C" fn rdx_definition_comments(pointer: GraphPointer, definiti
|
|
|
248
245
|
.comments()
|
|
249
246
|
.iter()
|
|
250
247
|
.map(|c| CommentEntry {
|
|
251
|
-
string:
|
|
248
|
+
string: OwnedString::new(c.string()),
|
|
252
249
|
location: create_location_for_uri_and_offset(graph, document, c.offset()),
|
|
253
250
|
})
|
|
254
251
|
.collect::<Vec<CommentEntry>>()
|
|
@@ -282,17 +279,13 @@ pub unsafe extern "C" fn rdx_definition_comments_free(ptr: *mut CommentArray) {
|
|
|
282
279
|
let mut boxed_slice: Box<[CommentEntry]> = unsafe { Box::from_raw(slice_ptr) };
|
|
283
280
|
|
|
284
281
|
for item in &mut boxed_slice {
|
|
285
|
-
if !item.string.is_null() {
|
|
286
|
-
// Free the CString allocated for the comment string
|
|
287
|
-
let _ = unsafe { CString::from_raw(item.string.cast_mut()) };
|
|
288
|
-
}
|
|
289
282
|
if !item.location.is_null() {
|
|
290
283
|
unsafe { crate::location_api::rdx_location_free(item.location) };
|
|
291
284
|
item.location = ptr::null_mut();
|
|
292
285
|
}
|
|
293
286
|
}
|
|
294
287
|
|
|
295
|
-
// boxed_slice is dropped here, freeing the items buffer
|
|
288
|
+
// boxed_slice is dropped here, freeing the items buffer and each item's string
|
|
296
289
|
}
|
|
297
290
|
// arr is dropped here
|
|
298
291
|
}
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
use crate::graph_api::{GraphPointer, with_graph};
|
|
4
4
|
use crate::location_api::{Location, create_location_for_uri_and_offset};
|
|
5
|
+
use crate::utils::OwnedString;
|
|
5
6
|
use libc::c_char;
|
|
6
7
|
use rubydex::diagnostic::{Rule, Severity};
|
|
7
|
-
use std::{
|
|
8
|
+
use std::{mem, ptr};
|
|
8
9
|
|
|
9
10
|
/// C-compatible enum representing diagnostic severity levels.
|
|
10
11
|
#[repr(C)]
|
|
@@ -49,7 +50,7 @@ impl From<Rule> for CRule {
|
|
|
49
50
|
#[repr(C)]
|
|
50
51
|
pub struct DiagnosticEntry {
|
|
51
52
|
pub rule: CRule,
|
|
52
|
-
pub message:
|
|
53
|
+
pub message: OwnedString,
|
|
53
54
|
pub location: *mut Location,
|
|
54
55
|
}
|
|
55
56
|
|
|
@@ -91,7 +92,7 @@ pub unsafe extern "C" fn rdx_graph_diagnostics(pointer: GraphPointer) -> *mut Di
|
|
|
91
92
|
|
|
92
93
|
DiagnosticEntry {
|
|
93
94
|
rule: CRule::from(*diagnostic.rule()),
|
|
94
|
-
message:
|
|
95
|
+
message: OwnedString::new(diagnostic.message()),
|
|
95
96
|
location,
|
|
96
97
|
}
|
|
97
98
|
})
|
|
@@ -119,15 +120,12 @@ pub unsafe extern "C" fn rdx_diagnostics_free(ptr: *mut DiagnosticArray) {
|
|
|
119
120
|
let mut boxed_slice: Box<[DiagnosticEntry]> = unsafe { Box::from_raw(slice_ptr) };
|
|
120
121
|
|
|
121
122
|
for entry in &mut *boxed_slice {
|
|
122
|
-
if !entry.message.is_null() {
|
|
123
|
-
let _ = unsafe { CString::from_raw(entry.message.cast_mut()) };
|
|
124
|
-
}
|
|
125
123
|
if !entry.location.is_null() {
|
|
126
124
|
unsafe { crate::location_api::rdx_location_free(entry.location) };
|
|
127
125
|
entry.location = ptr::null_mut();
|
|
128
126
|
}
|
|
129
127
|
}
|
|
130
|
-
// boxed_slice drops here, releasing the buffer
|
|
128
|
+
// boxed_slice drops here, releasing the buffer and each entry's message
|
|
131
129
|
}
|
|
132
130
|
// array drops here
|
|
133
131
|
}
|
|
@@ -6,6 +6,7 @@ use std::ptr;
|
|
|
6
6
|
use crate::declaration_api::CDeclaration;
|
|
7
7
|
use crate::graph_api::{GraphPointer, with_graph};
|
|
8
8
|
use crate::location_api::{Location, create_location_for_uri_and_offset};
|
|
9
|
+
use crate::utils::OwnedString;
|
|
9
10
|
use libc::c_char;
|
|
10
11
|
use rubydex::model::graph::Graph;
|
|
11
12
|
use rubydex::model::ids::{ConstantReferenceId, MethodReferenceId};
|
|
@@ -148,8 +149,8 @@ pub unsafe extern "C" fn rdx_constant_reference_name(pointer: GraphPointer, refe
|
|
|
148
149
|
})
|
|
149
150
|
}
|
|
150
151
|
|
|
151
|
-
/// Returns the UTF-8 name string for a method reference id, or
|
|
152
|
-
/// Caller must free with `
|
|
152
|
+
/// Returns the UTF-8 name string for a method reference id, or a null string if the reference cannot be found.
|
|
153
|
+
/// Caller must free with `free_owned_string`.
|
|
153
154
|
///
|
|
154
155
|
/// # Safety
|
|
155
156
|
///
|
|
@@ -159,18 +160,14 @@ pub unsafe extern "C" fn rdx_constant_reference_name(pointer: GraphPointer, refe
|
|
|
159
160
|
///
|
|
160
161
|
/// This function will panic if the reference's name cannot be found.
|
|
161
162
|
#[unsafe(no_mangle)]
|
|
162
|
-
pub unsafe extern "C" fn rdx_method_reference_name(pointer: GraphPointer, reference_id: u64) ->
|
|
163
|
+
pub unsafe extern "C" fn rdx_method_reference_name(pointer: GraphPointer, reference_id: u64) -> OwnedString {
|
|
163
164
|
with_graph(pointer, |graph| {
|
|
164
165
|
let ref_id = MethodReferenceId::new(reference_id);
|
|
165
166
|
let Some(reference) = graph.method_references().get(&ref_id) else {
|
|
166
|
-
return
|
|
167
|
+
return OwnedString::null();
|
|
167
168
|
};
|
|
168
|
-
let name = graph
|
|
169
|
-
|
|
170
|
-
.get(reference.str())
|
|
171
|
-
.expect("Name ID should exist")
|
|
172
|
-
.to_string();
|
|
173
|
-
CString::new(name).unwrap().into_raw().cast_const()
|
|
169
|
+
let name = graph.strings().get(reference.str()).expect("Name ID should exist");
|
|
170
|
+
OwnedString::new(name.as_str())
|
|
174
171
|
})
|
|
175
172
|
}
|
|
176
173
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
use libc::{c_char, size_t};
|
|
2
2
|
use std::ffi::{CStr, CString};
|
|
3
3
|
use std::path::Path;
|
|
4
|
+
use std::ptr;
|
|
4
5
|
use std::slice;
|
|
5
6
|
use std::str::Utf8Error;
|
|
6
7
|
|
|
@@ -42,6 +43,54 @@ pub extern "C" fn free_c_string(ptr: *const c_char) {
|
|
|
42
43
|
}
|
|
43
44
|
}
|
|
44
45
|
|
|
46
|
+
/// C-compatible owned UTF-8 string with an explicit length. Unlike a C string, it is not NUL-terminated and may
|
|
47
|
+
/// contain NUL bytes, which source code can put into names, comments and diagnostic messages. A null `data` means
|
|
48
|
+
/// there is no string. Dropping it frees the bytes
|
|
49
|
+
#[repr(C)]
|
|
50
|
+
pub struct OwnedString {
|
|
51
|
+
pub data: *const c_char,
|
|
52
|
+
pub length: usize,
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
impl OwnedString {
|
|
56
|
+
#[must_use]
|
|
57
|
+
pub fn new(value: &str) -> Self {
|
|
58
|
+
let bytes: Box<[u8]> = value.as_bytes().into();
|
|
59
|
+
Self {
|
|
60
|
+
length: bytes.len(),
|
|
61
|
+
data: Box::into_raw(bytes).cast::<c_char>().cast_const(),
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
#[must_use]
|
|
66
|
+
pub fn null() -> Self {
|
|
67
|
+
Self {
|
|
68
|
+
data: ptr::null(),
|
|
69
|
+
length: 0,
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
impl Drop for OwnedString {
|
|
75
|
+
fn drop(&mut self) {
|
|
76
|
+
if !self.data.is_null() {
|
|
77
|
+
let bytes = ptr::slice_from_raw_parts_mut(self.data.cast_mut().cast::<u8>(), self.length);
|
|
78
|
+
// SAFETY: a non-null `data` always comes from `Box::into_raw` in `OwnedString::new`, with `length` bytes
|
|
79
|
+
let _ = unsafe { Box::from_raw(bytes) };
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/// Frees an `OwnedString` allocated on the Rust side
|
|
85
|
+
///
|
|
86
|
+
/// # Safety
|
|
87
|
+
///
|
|
88
|
+
/// - `string` must have been returned by a rubydex function and must not be used after being freed
|
|
89
|
+
#[unsafe(no_mangle)]
|
|
90
|
+
pub unsafe extern "C" fn free_owned_string(string: OwnedString) {
|
|
91
|
+
drop(string);
|
|
92
|
+
}
|
|
93
|
+
|
|
45
94
|
/// Frees a boxed u64 allocated on the Rust side
|
|
46
95
|
#[unsafe(no_mangle)]
|
|
47
96
|
pub extern "C" fn free_u64(ptr: *const u64) {
|