PageRenderTime 20ms CodeModel.GetById 19ms app.highlight 1ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/rel-1-3-25/SWIG/Examples/pike/template/runme.pike

#
Unknown | 33 lines | 26 code | 7 blank | 0 comment | 0 complexity | 62439f11e0d312771bab333bdcee477e MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
 1int main()
 2{
 3    // Call some templated functions
 4    write(sprintf("%d\n", .example.maxint(3, 7)));
 5    write(sprintf("%f\n", .example.maxdouble(3.14, 2.18)));
 6    
 7    // Create some objects
 8    .example.vecint iv = .example.vecint(100);
 9    .example.vecdouble dv = .example.vecdouble(1000);
10    
11    for (int i = 0; i < 100; i++) {
12        iv->setitem(i, 2*i);
13    }
14
15    for (int i = 0; i < 1000; i++) {
16        dv->setitem(i, 1.0/(i+1));
17    }
18    
19    int isum = 0;
20    for (int i = 0; i < 100; i++) {
21        isum += iv->getitem(i);
22    }
23    
24    write(sprintf("%d\n", isum));
25    
26    float fsum = 0.0;
27    for (int i = 0; i < 1000; i++) {
28        fsum += dv->getitem(i);
29    }
30    write(sprintf("%f\n", fsum));
31    
32    return 0;
33}