1
0

Object.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. #include "memory/Allocator.h"
  19. // Dictionaries and lists are pointers to the head entry so that the head can change.
  20. typedef struct Dict_Entry* Dict;
  21. typedef struct List_Item* List;
  22. typedef struct String_s {
  23. uintptr_t len;
  24. char* bytes;
  25. } String;
  26. typedef String String_t;
  27. enum Object_Type {
  28. Object_INTEGER,
  29. Object_STRING,
  30. Object_LIST,
  31. Object_DICT,
  32. Object_UNPARSABLE
  33. };
  34. typedef struct {
  35. enum Object_Type type;
  36. union {
  37. int64_t number;
  38. String* string;
  39. List* list;
  40. Dict* dictionary;
  41. } as;
  42. } Object;
  43. //#include "benc/List.h"
  44. //#include "benc/Dict.h"
  45. #endif