basicclass.m 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #include <stdio.h>
  2. #include <objc/Object.h>
  3. @interface BasicClass: Object
  4. {
  5. id object;
  6. }
  7. + newWithArg: arg;
  8. - doIt;
  9. - takeArg: arg;
  10. - printHi;
  11. - (int) printNumber: (int)number;
  12. - (const char *) myDescription;
  13. @end
  14. @interface BasicClass (Private)
  15. - hiddenMethod;
  16. @end
  17. @implementation BasicClass
  18. + newWithArg: arg
  19. {
  20. id obj = [self new];
  21. [obj takeArg: arg];
  22. return obj;
  23. }
  24. - doIt
  25. {
  26. return self;
  27. }
  28. - takeArg: arg
  29. {
  30. object = arg;
  31. [self hiddenMethod];
  32. return self;
  33. }
  34. - printHi
  35. {
  36. printf("Hi\n");
  37. return self;
  38. }
  39. - (int) printNumber: (int)number
  40. {
  41. printf("%d\n", number);
  42. return number+1;
  43. }
  44. - (const char *) myDescription
  45. {
  46. return "BasicClass gdb test object";
  47. }
  48. @end
  49. @implementation BasicClass (Private)
  50. - hiddenMethod
  51. {
  52. return self;
  53. }
  54. @end
  55. int main (int argc, const char *argv[])
  56. {
  57. id obj;
  58. obj = [BasicClass new];
  59. [obj takeArg: obj];
  60. return 0;
  61. }
  62. const char *_NSPrintForDebugger(id object)
  63. {
  64. /* This is not really what _NSPrintForDebugger should do, but it
  65. is a simple test if gdb can call this function */
  66. if (object && [object respondsTo: @selector(myDescription)])
  67. return [object myDescription];
  68. return NULL;
  69. }