Object.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /* vim: set expandtab ts=4 sw=4: */
  2. /*
  3. * You may redistribute this program and/or modify it under the terms of
  4. * the GNU General Public License as published by the Free Software Foundation,
  5. * either version 3 of the License, or (at your option) any later version.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. *
  12. * You should have received a copy of the GNU General Public License
  13. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  14. */
  15. #ifndef Object_H
  16. #define Object_H
  17. #include <stdint.h>
  18. // Dictionaries and lists are pointers to the head entry so that the head can change.
  19. typedef struct Dict_Entry* Dict;
  20. typedef struct List_Item* List;
  21. typedef struct String_s {
  22. uintptr_t len;
  23. char* bytes;
  24. } String;
  25. typedef String String_t;
  26. typedef Dict Dict_t;
  27. typedef List List_t;
  28. enum Object_Type {
  29. Object_INTEGER,
  30. Object_STRING,
  31. Object_LIST,
  32. Object_DICT,
  33. Object_UNPARSABLE
  34. };
  35. typedef struct {
  36. enum Object_Type type;
  37. union {
  38. int64_t number;
  39. String_t* string;
  40. List_t* list;
  41. Dict_t* dictionary;
  42. } as;
  43. } Object;
  44. typedef Object Object_t;
  45. #endif