2 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
25 #include <dali/integration-api/debug.h>
28 #include <object/property-value-wrapper.h>
29 #include <actors/actor-wrapper.h>
30 #include <object/handle-wrapper.h>
31 #include <image/image-wrapper.h>
32 #include <render-tasks/render-task-wrapper.h>
33 #include <object/property-value-wrapper.h>
37 * Similar to DALI_LOG_ERROR except the PRETTY_FUNCTION
38 * is removed because it makes no sense for scripting errors.
40 #define DALI_LOG_SCRIPT_ERROR(format, args...) Dali::Integration::Log::LogMessage(Dali::Integration::Log::DebugError, format, ## args)
51 void Log(const v8::FunctionCallbackInfo< v8::Value >& args)
53 v8::HandleScope handleScope( args.GetIsolate());
56 for (int i = 0; i < args.Length(); i++)
66 v8::String::Utf8Value utf8_value( args[i] );
67 std::cout << *utf8_value << "\n";
71 void LogError(const v8::FunctionCallbackInfo< v8::Value >& args)
73 v8::HandleScope handleScope( args.GetIsolate());
76 for (int i = 0; i < args.Length(); i++)
86 v8::String::Utf8Value utf8_value( args[i] );
87 output += *utf8_value;
90 DALI_LOG_ERROR_NOFN( "JavaScript: %s",output.c_str() );
93 void GetFileContents(const std::string &fileName, std::string& contents)
95 std::ifstream t(fileName.c_str());
96 contents = std::string((std::istreambuf_iterator<char>(t)), std::istreambuf_iterator<char>());
99 void GetFileDirectory( const std::string& fileName, std::string& directory )
103 // get the position of the last slash
104 size_t pos = fileName.find_last_of("\\/");
106 // if it doesn't exist, return nothing
107 if( (std::string::npos == pos ) )
113 // check an edge case where the string ends in a forward slash "mydir/"
114 if( (pos+1) < fileName.length() )
116 directory = fileName.substr(0, pos+1);
122 void GetFileName( const std::string& fullPathName, std::string& fileName )
124 // look for last slash
125 size_t pos = fullPathName.find_last_of("\\/");
127 if( std::string::npos == pos )
129 fileName = fullPathName;
133 fileName = fullPathName.substr(pos,fileName.length());
137 void GetModuleName( const std::string& fileName, std::string& moduleName )
139 std::string fileNameNoPath;
140 GetFileName( fileName , fileNameNoPath );
141 size_t pos = fileNameNoPath.find_last_of(".");
142 if( std::string::npos == pos )
144 moduleName = fileNameNoPath;
148 moduleName = fileName.substr(0, pos );
152 void ReportException( v8::Isolate* isolate, v8::TryCatch* tryCatch)
154 v8::HandleScope handleScope( isolate );
156 v8::String::Utf8Value exception(tryCatch->Exception());
157 v8::Handle<v8::Message> message = tryCatch->Message();
159 if (message.IsEmpty())
161 // V8 didn't provide any extra information about this error; just
162 // print the exception.
163 DALI_LOG_SCRIPT_ERROR("%s\n", *exception);
168 // Print (filename):(line number): (message).
169 v8::String::Utf8Value filename(message->GetScriptResourceName());
171 DALI_LOG_SCRIPT_ERROR("\n\n====== Error found in JavaScript: ========= \n");
174 int linenum = message->GetLineNumber();
175 DALI_LOG_SCRIPT_ERROR("File: %s\n", *filename, linenum, *exception);
177 DALI_LOG_SCRIPT_ERROR("Error: :%s\n", *exception );
178 DALI_LOG_SCRIPT_ERROR("Line: :%i\n", linenum );
180 // Print line of source code.
181 v8::String::Utf8Value sourceline(message->GetSourceLine());
183 DALI_LOG_SCRIPT_ERROR("Source: %s\n", *sourceline);
185 // Print wavy underline (GetUnderline is deprecated).
187 std::stringstream msg;
189 int start = message->GetStartColumn();
190 for (int i = 0; i < start; i++)
194 int end = message->GetEndColumn();
195 for (int i = start; i < end; i++)
200 DALI_LOG_SCRIPT_ERROR(" %s\n", msg.str().c_str());
202 v8::String::Utf8Value stack_trace(tryCatch->StackTrace());
203 if (stack_trace.length() > 0)
205 DALI_LOG_SCRIPT_ERROR("%s\n", *stack_trace);
207 DALI_LOG_SCRIPT_ERROR("\n=========================================== \n");
212 std::string GetJavaScriptFunctionName( const char* functionName )
214 // @todo if we are 100% decided on lower case, go through
215 // every api and manually change the function names to lower case first character
216 std::string name( functionName );
217 name[0]=tolower( functionName[0] );
221 void Version(const v8::FunctionCallbackInfo< v8::Value >& args)
223 v8::HandleScope handleScope( args.GetIsolate());
225 v8::Handle<v8::String> ver = v8::String::NewFromUtf8(args.GetIsolate(), v8::V8::GetVersion());
227 args.GetReturnValue().Set(ver);
231 std::string v8StringToStdString( const v8::Handle<v8::Value>& value )
233 v8::String::Utf8Value utf8(value);
234 return std::string(*utf8);
238 std::string PropertyNameToJavaScriptName(const std::string& hyphenatedName)
242 ret.reserve(hyphenatedName.size());
244 bool capitlizeNext = false ;
245 for(unsigned int i = 0; i < hyphenatedName.size(); ++i)
247 char c = hyphenatedName[i];
250 capitlizeNext = true;
256 ret.push_back(std::toupper(c));
257 capitlizeNext = false;
271 void ScriptError( const char* function, v8::Isolate* isolate, std::string errorString )
273 v8::EscapableHandleScope scope( isolate);
274 std::string errorMsg = std::string(function) + std::string("(), ") + errorString;
276 // log out to DALI_LOG_ERROR first, so we know something has gone wrong
277 DALI_LOG_ERROR("%s \n", errorMsg.c_str() );
279 // throw a V8 exception, DALi will keep running but we will get a print out
280 // of where the error occured in the JavaScript source
281 isolate->ThrowException( v8::String::NewFromUtf8( isolate, errorMsg.c_str()) );
284 bool IsBooleanPrimitiveOrObject( const v8::Local<v8::Value>& value )
286 return ( value->IsBoolean() || value->IsBooleanObject());
289 bool GetBooleanValue( v8::Isolate* isolate, const v8::Local<v8::Value>& value )
291 v8::EscapableHandleScope scope( isolate); // may not be required.
293 if( value->IsBoolean() )
295 return value->ToBoolean()->Value();
297 else if (value->IsBooleanObject() )
299 const v8::Local<v8::BooleanObject> object = v8::Local<v8::BooleanObject>::Cast(value);
300 return object->BooleanValue();
302 DALI_SCRIPT_EXCEPTION(isolate, "no bool found");
306 bool IsNumberPrimitiveOrObject( const v8::Local<v8::Value>& value )
308 return ( value->IsNumber() || value->IsNumberObject());
311 float GetNumberValue( v8::Isolate* isolate, const v8::Local<v8::Value>& value )
313 v8::EscapableHandleScope scope( isolate); // may not be required.
315 if( value->IsNumber() )
317 return value->ToNumber()->Value();
319 else if (value->IsNumberObject() )
321 const v8::Local<v8::NumberObject> object = v8::Local<v8::NumberObject>::Cast(value);
322 return object->ValueOf();
325 DALI_SCRIPT_EXCEPTION(isolate, "no number found?");
329 bool IsStringPrimitiveOrObject( const v8::Local<v8::Value>& value )
331 return ( value->IsString() || value->IsStringObject());
334 std::string GetStringValue( v8::Isolate* isolate, const v8::Local<v8::Value>& value )
336 v8::EscapableHandleScope scope( isolate); // may not be required.
338 if( value->IsString() )
340 return V8Utils::v8StringToStdString(value);
342 else if (value->IsStringObject() )
344 const v8::Local<v8::StringObject> object = v8::Local<v8::StringObject>::Cast(value);
345 return V8Utils::v8StringToStdString( object->ValueOf() );
348 DALI_SCRIPT_EXCEPTION(isolate, "no string found?");
353 Property::Value GetPropertyValueFromObject( bool& found, v8::Isolate* isolate, const v8::Local<v8::Value >& value )
355 v8::HandleScope handleScope( isolate);
357 Property::Value daliPropertyValue;// creates a property with Property::NONE
361 if( value->IsObject() )
363 v8::Local<v8::Object> object = v8::Handle<v8::Object>::Cast( value );
365 if( BaseWrappedObject::IsWrappedTypeAPropertyValue( object ) )
368 PropertyValueWrapper* propertyWrapper = PropertyValueWrapper::Unwrap( isolate, object );
369 return propertyWrapper->GetValue();
371 else if( value->IsArray() )
374 return PropertyValueWrapper::VectorOrMatrixFromV8Array( isolate, object);//todo check for V8 array / map?
377 else if( value->IsBoolean() )
380 v8::Local<v8::Boolean> v = value->ToBoolean();
381 return Dali::Property::Value(v->Value());
383 else if( value->IsNumber() )
386 v8::Local<v8::Number> v = value->ToNumber();
387 return Dali::Property::Value(static_cast<float>(v->Value()));
389 else if( value->IsInt32() || value->IsUint32() )
392 v8::Local<v8::Int32> v = value->ToInt32();
393 return Dali::Property::Value(static_cast<int>(v->Value()));
395 return daliPropertyValue;
399 Property::Map GetPropertyMapFromObject( v8::Isolate* isolate, const v8::Local<v8::Object>& object)
401 v8::Local<v8::Array> properties = object->GetPropertyNames();
402 Property::Map propertyMap; // empty map
404 for( unsigned int i = 0; i < properties->Length(); ++i)
407 v8::Local<v8::Value> key = properties->Get( i );
408 std::string keyString = v8StringToStdString( key );
411 v8::Local<v8::Value> value = object->Get( key );
413 if( value->IsBoolean() )
415 v8::Local<v8::Boolean> v = value->ToBoolean();
416 propertyMap[ keyString ] = v->Value();
418 else if( value->IsNumber() )
420 v8::Local<v8::Number> v = value->ToNumber();
421 propertyMap[ keyString ] = static_cast<float>(v->Value());
423 else if( value->IsInt32() || value->IsUint32() )
425 v8::Local<v8::Int32> v = value->ToInt32();
426 propertyMap[ keyString ] = static_cast<int>(v->Value());
428 else if( value->IsString() )
430 std::string valueString = V8Utils::v8StringToStdString( value );
431 propertyMap[ keyString ] = valueString.c_str();
433 else if( value->IsArray() )
435 propertyMap[ keyString ] = PropertyValueWrapper::VectorOrMatrixFromV8Array( isolate, value);
437 else if( value->IsObject() )
439 Dali::Property::Map map = V8Utils::GetPropertyMapFromObject(isolate, value->ToObject());
442 propertyMap[ keyString ] = Dali::Property::Value( map );
450 Actor GetActorFromObject( v8::Isolate* isolate, bool& found, v8::Local<v8::Object>& object)
452 v8::HandleScope handleScope( isolate);
455 if( BaseWrappedObject::IsWrappedType ( isolate, object, BaseWrappedObject::ACTOR ))
457 HandleWrapper* handleWrapper = HandleWrapper::Unwrap( isolate, object );
458 return Actor::DownCast( handleWrapper->mHandle );
464 int GetIntegerParameter( unsigned int index, bool& found, v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args, int defaultValue )
467 unsigned int length = args.Length();
468 if( index >= length )
472 if( args[ index ]->IsInt32() )
475 return args[ index ]->Int32Value();
483 float GetFloatParameter( unsigned int index, bool& found, v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args, float defaultValue )
486 unsigned int length = args.Length();
487 if( index >= length )
491 if( args[ index ]->IsNumber() )
494 return args[ index ]->NumberValue();
502 std::string GetStringParameter( unsigned int index, bool& found, v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args )
505 unsigned int length = args.Length();
507 if( index >= length )
509 return std::string();
511 if( args[ index ]->IsString() )
514 return v8StringToStdString( args[ index ]);
518 return std::string();
522 bool GetBooleanParameter( unsigned int index, bool& found, v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args )
524 v8::HandleScope handleScope( isolate);
527 unsigned int length = args.Length();
528 if( index >= length )
532 if( args[ index ]->IsBoolean() )
535 v8::Local<v8::Boolean> v = args[ index ]->ToBoolean();
544 void* GetArrayBufferViewParameter( unsigned int index, bool& found, v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args )
547 unsigned int length = args.Length();
548 if( index < length && args[index]->IsArrayBufferView() )
551 v8::ArrayBufferView* bufferView = v8::ArrayBufferView::Cast(*(args[index]));
552 v8::Handle<v8::ArrayBuffer> buffer = bufferView->Buffer();
553 v8::ArrayBuffer::Contents contents = buffer->Externalize();
554 return contents.Data();
562 Handle GetHandleParameter( unsigned int index, bool& found, v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args )
564 v8::HandleScope handleScope( isolate);
567 unsigned int length = args.Length();
568 if( index >= length )
573 if( args[ index ]->IsObject() )
575 v8::Local<v8::Object> object = args[ index ]->ToObject();
576 v8::Local<v8::External> field = v8::Local<v8::External>::Cast( object->GetInternalField(0) );
577 void* ptr = field->Value();
581 HandleWrapper* wrapper = static_cast< HandleWrapper *>(ptr);
582 return wrapper->GetHandle();
588 Vector2 GetVector2Parameter( unsigned int index, bool& found, v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args )
590 v8::HandleScope handleScope( isolate);
591 unsigned int length = args.Length();
597 if( args[ index ]->IsObject() )
599 Dali::Property::Value value;
600 value = PropertyValueWrapper::ExtractPropertyValue( isolate, args[index], Dali::Property::VECTOR2 );
601 if( value.GetType() == Dali::Property::VECTOR2)
608 DALI_SCRIPT_EXCEPTION(isolate, "Missing Vector2 parameter");
614 DALI_SCRIPT_EXCEPTION(isolate, "Missing Vector2 parameter");
620 Vector2 GetVector2ParameterFrom2Float( unsigned int index, bool& found, v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args )
622 Vector2 ret(0.0f,0.0f);
624 unsigned int argCount( args.Length() );
626 if( index+2 >= argCount )
628 DALI_SCRIPT_EXCEPTION(isolate, "Missing parameter");
632 ret.x = V8Utils::GetFloatParameter( index, bFound, isolate, args, 0.0f );
633 found = found && bFound;
634 ret.y = V8Utils::GetFloatParameter( index+1, bFound, isolate, args, 0.0f );
635 found = found && bFound;
640 Vector3 GetVector3Parameter( unsigned int index, bool& found, v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args)
642 v8::HandleScope handleScope( isolate);
643 unsigned int argCount( args.Length() );
646 if( index < argCount )
648 if( args[ index ]->IsObject() )
650 Dali::Property::Value value;
651 value = PropertyValueWrapper::ExtractPropertyValue( isolate, args[index], Dali::Property::VECTOR3 );
652 if( value.GetType() == Dali::Property::VECTOR3)
659 DALI_SCRIPT_EXCEPTION(isolate, "Missing Vector3 parameter");
665 DALI_SCRIPT_EXCEPTION(isolate, "Missing Vector3 parameter");
672 Vector4 GetVector4Parameter( unsigned int index, bool& found, v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args)
674 v8::HandleScope handleScope( isolate);
675 unsigned int argCount( args.Length() );
679 if( index < argCount )
681 if( args[ index ]->IsObject() )
683 Dali::Property::Value value;
684 value = PropertyValueWrapper::ExtractPropertyValue( isolate, args[index], Dali::Property::VECTOR4 );
685 if( value.GetType() == Dali::Property::VECTOR4)
692 DALI_SCRIPT_EXCEPTION(isolate, "Missing Vector4 parameter");
698 DALI_SCRIPT_EXCEPTION(isolate, "Missing Vector4 parameter");
705 Rect<int> GetRectIntParameter( unsigned int index, bool& found, v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args )
707 v8::HandleScope handleScope( isolate);
710 int length = args.Length() - index;
712 // if it's an array read the 2 numbers into a vector2
715 if( args[ 0 + index ]->IsInt32() &&
716 args[ 1 + index ]->IsInt32() &&
717 args[ 2 + index ]->IsInt32() &&
718 args[ 3 + index ]->IsInt32() )
721 Rect<int> rect( args[ 0 + index ]->Int32Value(),
722 args[ 1 + index ]->Int32Value(),
723 args[ 2 + index ]->Int32Value(),
724 args[ 3 + index ]->Int32Value() );
728 // this will extract a Vector4, if it is a Vector4 or a Javascript array object
729 if( args[ index ]->IsObject() )
731 Dali::Property::Value value;
732 value = PropertyValueWrapper::ExtractPropertyValue( isolate, args[index], Dali::Property::RECTANGLE );
733 if( value.GetType() == Dali::Property::RECTANGLE)
741 // @todo support vector4 as well?
746 Actor GetActorParameter( unsigned int index, bool& found, v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args )
748 BaseWrappedObject* wrapper = GetWrappedDaliObjectParameter( index, BaseWrappedObject::ACTOR, isolate, args);
749 ActorWrapper* actorWrapper = static_cast< ActorWrapper*>( wrapper );
753 return actorWrapper->GetActor();
761 Layer GetLayerParameter( unsigned int index, bool& found, v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args )
763 Actor actor = GetActorParameter( index, found, isolate, args );
764 return Layer::DownCast( actor );
767 Image GetImageParameter( unsigned int index, bool& found, v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args )
769 BaseWrappedObject* wrappedObject = V8Utils::GetWrappedDaliObjectParameter( index, BaseWrappedObject::IMAGE, isolate, args );
773 ImageWrapper* wrapper = static_cast< ImageWrapper *>(wrappedObject);
774 return wrapper->GetImage();
783 RenderTask GetRenderTaskParameter( unsigned int paramIndex, bool& found, v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args )
786 BaseWrappedObject* wrappedObject = V8Utils::GetWrappedDaliObjectParameter( paramIndex, BaseWrappedObject::RENDER_TASK, isolate, args );
790 RenderTaskWrapper* wrapper = static_cast< RenderTaskWrapper *>(wrappedObject);
791 return wrapper->GetRenderTask();
795 return RenderTask(); // empty handle
799 BaseWrappedObject* GetWrappedDaliObjectParameter( unsigned int index, BaseWrappedObject::Type type, v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args )
801 v8::HandleScope handleScope( isolate);
802 unsigned int length = args.Length();
804 if( index >= length )
809 if( !args[ index ]->IsObject() )
814 v8::Local<v8::Object> object = args[ index ]->ToObject();
816 if( BaseWrappedObject::IsWrappedType ( isolate, object, type ))
818 v8::Local<v8::External> field = v8::Local<v8::External>::Cast( object->GetInternalField(0) );
819 void* ptr = field->Value();
820 BaseWrappedObject* wrapper = static_cast< BaseWrappedObject *>(ptr);
827 Property::Value GetPropertyValueParameter( unsigned int index, bool& found, v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args )
829 v8::HandleScope handleScope( isolate);
831 Property::Value daliPropertyValue;// creates a property with Property::INVALID
834 unsigned int length = args.Length();
836 if( index >= length )
838 return daliPropertyValue;
840 v8::Local<v8::Value > value = args[ index ];
842 return GetPropertyValueFromObject( found, isolate, value);
845 Property::Map GetPropertyMapParameter( unsigned int index, bool& found, v8::Isolate* isolate, const v8::FunctionCallbackInfo< v8::Value >& args )
847 v8::HandleScope handleScope( isolate);
849 Property::Map propertyMap; // empty map
852 unsigned int length = args.Length();
854 if( index >= length )
859 if( !args[ index ]->IsObject() )
865 // go through each key value pair
866 v8::Local<v8::Object> obj = args[ index ]->ToObject();
868 return GetPropertyMapFromObject( isolate, obj );
872 void CreatePropertyMap( v8::Isolate* isolate, const Property::Map& map, v8::Local<v8::Object>& object )
874 v8::HandleScope handleScope( isolate);
876 // we're converting a dali property map in to a JavaScript property map
877 if( map.Count() == 0 )
882 for( unsigned int index = 0; index < map.Count() - 1; ++index )
884 const std::string& key = map.GetKey( index );
885 Property::Value& value = map.GetValue( index );
886 v8::Local<v8::Value> v8Value;
888 switch( value.GetType() )
890 case Dali::Property::FLOAT:
892 v8Value = v8::Number::New( isolate, value.Get<float>() );
895 case Dali::Property::BOOLEAN:
897 v8Value = v8::Boolean::New( isolate, value.Get<bool>());
900 case Dali::Property::INTEGER:
902 v8Value = v8::Integer::New( isolate, value.Get<int>());
905 case Dali::Property::STRING:
907 std::string string = value.Get< std::string >();
908 v8Value = v8::String::NewFromUtf8( isolate, string.c_str());
911 case Dali::Property::VECTOR2:
914 Vector2 vec = value.Get<Vector2>();
915 v8::Local<v8::Array> array= v8::Array::New( isolate, 2 );
916 array->Set( 0 , v8::Number::New(isolate, vec.x));
917 array->Set( 1 , v8::Number::New(isolate, vec.y));
921 case Dali::Property::VECTOR3:
924 Vector3 vec = value.Get<Vector3>();
925 v8::Local<v8::Array> array= v8::Array::New( isolate, 3 );
926 array->Set( 0 , v8::Number::New(isolate, vec.x));
927 array->Set( 1 , v8::Number::New(isolate, vec.y));
928 array->Set( 2 , v8::Number::New(isolate, vec.z));
932 case Dali::Property::VECTOR4:
935 Vector4 vec = value.Get<Vector4>();
936 v8::Local<v8::Array> array= v8::Array::New( isolate, 4 );
937 array->Set( 0 , v8::Number::New(isolate, vec.x));
938 array->Set( 1 , v8::Number::New(isolate, vec.y));
939 array->Set( 2 , v8::Number::New(isolate, vec.z));
940 array->Set( 3 , v8::Number::New(isolate, vec.w));
947 DALI_SCRIPT_EXCEPTION( isolate, "Primitive mismatch \n");
951 object->Set( v8::String::NewFromUtf8( isolate, key.c_str() ), v8Value );
955 void ReadFloatArguments( bool& foundAllArguments, float* data, unsigned int dataSize, const v8::FunctionCallbackInfo< v8::Value >& args, float defaultValue )
957 foundAllArguments = true;
958 unsigned int length = args.Length();
960 if( length < dataSize )
962 foundAllArguments = false;
965 for( unsigned int i = 0; i< dataSize ;i++ )
969 if( args[ i ]->IsNumber() )
971 data[i] = args[i]->NumberValue();
975 data[i] = defaultValue;
976 foundAllArguments = false; // bad argument
981 data[i] = defaultValue; // not enough arguments
987 void ReadIntegerArguments( bool& foundAllArguments, int* data, int dataSize, const v8::FunctionCallbackInfo< v8::Value >& args, int defaultValue )
989 foundAllArguments = true;
990 int length = args.Length();
991 if( length < dataSize )
993 foundAllArguments = false;
996 for( int i = 0; i< dataSize ;i++ )
1000 if( args[ i ]->IsInt32() )
1002 data[i] = args[i]->Int32Value();
1006 data[i] = defaultValue;
1007 foundAllArguments = false; // bad argument
1012 data[i] = defaultValue; // not enough arguments
1017 } // namespace V8Utils
1019 } // namespace V8Plugin