File: tobjc20.pp

package info (click to toggle)
fpc 2.6.4%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 178,760 kB
  • ctags: 83,946
  • sloc: pascal: 2,000,374; xml: 138,807; ansic: 9,617; asm: 7,843; yacc: 3,747; php: 3,271; sh: 2,626; makefile: 2,610; lex: 2,537; sql: 267; cpp: 145; sed: 132; perl: 126; csh: 34; tcl: 7
file content (99 lines) | stat: -rw-r--r-- 1,770 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
{ %target=darwin }
{ %cpu=powerpc,powerpc64,i386,x86_64,arm }

{ Written by Jonas Maebe in 2009, released into the public domain }

program project1;

{$mode objfpc}{$H+}
{$modeswitch objectivec1}
type
  tr = record
    s: shortstring;
  end;

 MyObject = objcclass(NSObject)
   fss: shortstring;
   fsingle: single;
   fdouble: double;
   fbool: boolean;

   function getss: shortstring ; message 'getss';
   function getsspara(l1,l2: longint): shortstring ; message 'getss:l1:';
   function getsingle(l1,l2: longint): single; message 'getsingle:l1:';
   function getdouble(l1,l2: longint; d: double): double; message 'getdouble:l1:l2:';

   function getbool: boolean; message 'getbool';
 end;

function MyObject.getss: shortstring;
begin
  result:=fss;
end;


function MyObject.getsspara(l1,l2: longint): shortstring;
begin
  if (l1<>1) or
     (l2<>2) then
    halt(1);
  result:=fss;
end;


function MyObject.getsingle(l1,l2: longint): single;
begin
  if (l1<>1) or
     (l2<>2) then
    halt(2);
  result:=fsingle;
end;


function MyObject.getdouble(l1,l2: longint; d: double): double;
begin
  writeln(d);
  if (l1<>1) or
     (l2<>2) or
     (d<>1.5) then
    halt(3);
  result:=fdouble;
end;

function MyObject.getbool: boolean;
begin
  result:=fbool;
end;

var
  m: MyObject;
  b: boolean;
begin
 m := MyObject.alloc;
 m:=m.init;
 m.fss:='hello!';
 m.fsingle:=123.625;
 m.fdouble:=9876.0625;

 if m.getss<>'hello!' then
   halt(4);
 m.fss:='gij ook';
 if m.getsspara(1,2)<>'gij ook' then
   halt(5);
 if m.getsingle(1,2)<>123.625 then
   halt(6);
 if m.getdouble(1,2,1.5)<>9876.0625 then
   halt(7);

 m.fbool:=true;
 b:=m.getbool;
 if ord(b)<>ord(true) then
   halt(8);

 m.fbool:=false;
 b:=m.getbool;
 if ord(b)<>ord(false) then
   halt(9);

 m.release;
end.