Merge pull request #10 from gunyarakun/fix-invalid-return
[cocotron.git] / Onyx2D / O2Function.h
blobc484cc076fbe05ec1ed46c60c47caa2d1d27c46c
1 /* Copyright (c) 2007 Christopher J. W. Lloyd
3 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
9 #import <Foundation/NSObject.h>
10 #import <Onyx2D/O2Geometry.h>
12 @class O2Function;
13 typedef O2Function *O2FunctionRef;
15 typedef struct {
16 unsigned version;
17 void (*evaluate)(void *, const float *, float *);
18 void (*releaseInfo)(void *);
19 } O2FunctionCallbacks;
21 @interface O2Function : NSObject {
22 void *_info;
23 unsigned _domainCount;
24 float *_domain;
25 unsigned _rangeCount;
26 float *_range;
27 O2FunctionCallbacks _callbacks;
30 O2FunctionRef O2FunctionCreate(void *info, size_t domainDimension, const O2Float *domain, size_t rangeDimension, const O2Float *range, const O2FunctionCallbacks *callbacks);
32 O2FunctionRef O2FunctionRetain(O2FunctionRef self);
33 void O2FunctionRelease(O2FunctionRef self);
35 // FIX, only works for one input value
36 void O2FunctionEvaluate(O2FunctionRef self, O2Float in, O2Float *out);
38 - (unsigned)domainCount;
39 - (const float *)domain;
40 - (unsigned)rangeCount;
41 - (const float *)range;
43 - (BOOL)isLinear;
45 @end