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 <inttypes.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 {
  23. uintptr_t len;
  24. char* bytes;
  25. } String;
  26. enum Object_Type {
  27. Object_INTEGER,
  28. Object_STRING,
  29. Object_LIST,
  30. Object_DICT,
  31. Object_UNPARSABLE
  32. };
  33. typedef struct {
  34. enum Object_Type type;
  35. union {
  36. int64_t number;
  37. String* string;
  38. List* list;
  39. Dict* dictionary;
  40. } as;
  41. } Object;
  42. //#include "benc/List.h"
  43. //#include "benc/Dict.h"
  44. #endif