36static JSBool
SoundSourceSetProperty(JSContext *context, JSObject *
this, jsid propID, JSBool strict, jsval *value);
40static JSBool
SoundSourcePlay(JSContext *context, uintN argc, jsval *vp);
41static JSBool
SoundSourceStop(JSContext *context, uintN argc, jsval *vp);
58 JSCLASS_NO_OPTIONAL_MEMBERS
117 if (
EXPECT_NOT(!JS_IsConstructing(context, vp)))
119 OOJSReportError(context,
@"SoundSource() cannot be called as a function, it must be used as a constructor (as in new SoundSource()).");
133 if (!JSID_IS_INT(propID))
return YES;
139 if (!JSSoundSourceGetSoundSource(context,
this, &soundSource))
return NO;
141 switch (JSID_TO_INT(propID))
156 *value = INT_TO_JSVAL([soundSource repeatCount]);
167 return JS_NewNumberValue(context, [soundSource gain], value);
181 if (!JSID_IS_INT(propID))
return YES;
191 if (!JSSoundSourceGetSoundSource(context,
this, &soundSource))
return NO;
193 switch (JSID_TO_INT(propID))
196 [soundSource
setSound:SoundFromJSValue(context, *value)];
201 if (JS_ValueToBoolean(context, *value, &bValue))
209 if (JS_ValueToInt32(context, *value, &iValue))
211 if (iValue > 100) iValue = 100;
212 if (100 < 1) iValue = 1;
228 if (JS_ValueToBoolean(context, *value, &bValue))
236 if (JS_ValueToNumber(context, *value, &fValue))
238 fValue = OOClamp_0_max_d(fValue, 1);
327@implementation OOSoundSource (OOJavaScriptExtentions)
329- (jsval) oo_jsValueInContext:(JSContext *)context
331 JSObject *jsSelf = NULL;
332 jsval result = JSVAL_NULL;
337 if (!JS_SetPrivate(context, jsSelf, [
self retain])) jsSelf = NULL;
339 if (jsSelf != NULL) result = OBJECT_TO_JSVAL(jsSelf);
347 return @"SoundSource";
#define OOJS_END_FULL_NATIVE
#define OOJS_BEGIN_FULL_NATIVE(context)
#define OOJS_NATIVE_ENTER(cx)
static JSBool SoundSourceConstruct(JSContext *context, uintN argc, jsval *vp)
void InitOOJSSoundSource(JSContext *context, JSObject *global)
static JSBool SoundSourcePlay(JSContext *context, uintN argc, jsval *vp)
static JSClass sSoundSourceClass
static JSBool SoundSourcePlayOrRepeat(JSContext *context, uintN argc, jsval *vp)
static JSBool SoundSourceGetProperty(JSContext *context, JSObject *this, jsid propID, jsval *value)
static JSBool SoundSourceSetProperty(JSContext *context, JSObject *this, jsid propID, JSBool strict, jsval *value)
static JSBool SoundSourceStop(JSContext *context, uintN argc, jsval *vp)
@ kSoundSource_positional
@ kSoundSource_repeatCount
static JSFunctionSpec sSoundSourceMethods[]
static JSObject * sSoundSourcePrototype
static JSPropertySpec sSoundSourceProperties[]
BOOL JSValueToVector(JSContext *context, jsval value, Vector *outVector) NONNULL_FUNC
BOOL VectorToJSValue(JSContext *context, Vector vector, jsval *outValue) NONNULL_FUNC
JSBool OOJSObjectWrapperToString(JSContext *context, uintN argc, jsval *vp)
#define OOJS_PROP_READWRITE_CB
void OOJSRegisterObjectConverter(JSClass *theClass, OOJSClassConverterCallback converter)
OOINLINE jsval OOJSValueFromNativeObject(JSContext *context, id object)
#define DEFINE_JS_OBJECT_GETTER(NAME, JSCLASS, JSPROTO, OBJCCLASSNAME)
void OOJSObjectWrapperFinalize(JSContext *context, JSObject *this)
#define OOJS_RETURN_OBJECT(o)
void OOJSReportBadPropertySelector(JSContext *context, JSObject *thisObj, jsid propID, JSPropertySpec *propertySpec)
void OOJSReportError(JSContext *context, NSString *format,...)
OOINLINE jsval OOJSValueFromBOOL(int b) INLINE_CONST_FUNC
void OOJSReportBadPropertyValue(JSContext *context, JSObject *thisObj, jsid propID, JSPropertySpec *propertySpec, jsval value)
id OOJSBasicPrivateObjectConverter(JSContext *context, JSObject *object)
void OOJSReportBadArguments(JSContext *context, NSString *scriptClass, NSString *function, uintN argc, jsval *argv, NSString *message, NSString *expectedArgsDescription)
#define OOJS_PROP_READONLY_CB
NSString * oo_jsClassName()
void setPositional:(BOOL inPositional)
void setLoop:(BOOL inLoop)
void setRepeatCount:(uint8_t inCount)
void setGain:(float gain)
void setPosition:(Vector inPosition)
void setSound:(OOSound *inSound)