Skip to content

Commit d243357

Browse files
committed
Move strings api table
1 parent c6d938e commit d243357

3 files changed

Lines changed: 28 additions & 1 deletion

File tree

mypyc/lib-rt/static_data.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define STATIC_DATA
33

44
#include "static_data.h"
5+
#include "strings/librt_strings.h"
56

67
// Adopted from numpy 2.4.0: numpy/_core/src/multiarry/npy_static_data.c
78

@@ -72,4 +73,10 @@ intern_strings(void) {
7273
return 0;
7374
}
7475

76+
#ifdef MYPYC_EXPERIMENTAL
77+
78+
void *LibRTStrings_API[LIBRT_STRINGS_API_LEN] = {0};
79+
80+
#endif // MYPYC_EXPERIMENTAL
81+
7582
#endif

mypyc/lib-rt/strings/librt_strings.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import_librt_strings(void)
3030
// LIBRT_STRINGS_API_VERSION.
3131
#define LIBRT_STRINGS_API_LEN 14
3232

33-
static void *LibRTStrings_API[LIBRT_STRINGS_API_LEN];
33+
extern void *LibRTStrings_API[LIBRT_STRINGS_API_LEN];
3434

3535
typedef struct {
3636
PyObject_HEAD

mypyc/test-data/run-multimodule.test

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1390,3 +1390,23 @@ class Parent:
13901390
[file driver.py]
13911391
from native import test
13921392
test()
1393+
1394+
[case testExtraOpsFunction_experimental_librt]
1395+
from librt.strings import BytesWriter
1396+
1397+
def call_write(b: bytes) -> bytes:
1398+
w = BytesWriter()
1399+
w.write(b) # calls CPyBytesWriter_Write defined in byteswriter_extra_ops.c
1400+
return w.getvalue()
1401+
1402+
[file other.py]
1403+
from native import call_write
1404+
1405+
def test(b: bytes) -> bytes:
1406+
return call_write(b)
1407+
1408+
[file driver.py]
1409+
from other import test
1410+
1411+
input = b'x' * 512
1412+
assert test(input) == input

0 commit comments

Comments
 (0)