BFObject.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #include <bf/BFObject.h>
  2. /* Beoran's Objects, Objective-C/Smalltalk/Javascript-ish */
  3. struct BObject_;
  4. typedef struct BFObject_ BFObject;
  5. /* A Class is simply an object too. */
  6. typedef struct BFObject_ BFClass;
  7. typedef struct BMethod_ BFMethod;
  8. typedef struct BFMethodTable_ BFMethodTable;
  9. typedef struct BFInstanceVariable_ BFInstanceVariable;
  10. typedef struct BFInstanceVariableTable_ BFInstanceVariableTable;
  11. typedef BFObject * BMethodFunction(BFObject * self, int argc, BFObject * argv[]);
  12. union BFValue_ {
  13. BFObject * bobject;
  14. int integer;
  15. double number;
  16. void * pointer;
  17. char * cstr;
  18. };
  19. struct BFMethod_ {
  20. char * name;
  21. BMethodFunction * action;
  22. };
  23. struct BFInstanceVariable_ {
  24. char * name;
  25. void * value;
  26. };
  27. struct BFMethodTable_ {
  28. BFMethod * last;
  29. BFMethod * methods;
  30. int size;
  31. };
  32. struct BFInstanceVariableTable_ {
  33. BFInstanceVariable * last;
  34. BFMethodTable * variables;
  35. int size;
  36. };
  37. struct BFObject_ {
  38. BFMethodTable methods_;
  39. BFObject * prototype_;
  40. };
  41. BFObject * bfobject_init(BFObject * self) {
  42. return self;
  43. }