Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

asdl.h 1.2 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
  1. #ifndef Py_ASDL_H
  2. #define Py_ASDL_H
  3. typedef PyObject * identifier;
  4. typedef PyObject * string;
  5. typedef PyObject * bytes;
  6. typedef PyObject * object;
  7. typedef PyObject * singleton;
  8. typedef PyObject * constant;
  9. /* It would be nice if the code generated by asdl_c.py was completely
  10. independent of Python, but it is a goal the requires too much work
  11. at this stage. So, for example, I'll represent identifiers as
  12. interned Python strings.
  13. */
  14. /* XXX A sequence should be typed so that its use can be typechecked. */
  15. typedef struct {
  16. Py_ssize_t size;
  17. void *elements[1];
  18. } asdl_seq;
  19. typedef struct {
  20. Py_ssize_t size;
  21. int elements[1];
  22. } asdl_int_seq;
  23. asdl_seq *_Py_asdl_seq_new(Py_ssize_t size, PyArena *arena);
  24. asdl_int_seq *_Py_asdl_int_seq_new(Py_ssize_t size, PyArena *arena);
  25. #define asdl_seq_GET(S, I) (S)->elements[(I)]
  26. #define asdl_seq_LEN(S) ((S) == NULL ? 0 : (S)->size)
  27. #ifdef Py_DEBUG
  28. #define asdl_seq_SET(S, I, V) \
  29. do { \
  30. Py_ssize_t _asdl_i = (I); \
  31. assert((S) != NULL); \
  32. assert(_asdl_i < (S)->size); \
  33. (S)->elements[_asdl_i] = (V); \
  34. } while (0)
  35. #else
  36. #define asdl_seq_SET(S, I, V) (S)->elements[I] = (V)
  37. #endif
  38. #endif /* !Py_ASDL_H */
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...