Beispiel #1
0
    Dart_Handle Isolate::New(const char* typeName, int argc, Dart_Handle* args)
    {
        // entering and leaving the scope here causes us to invalidate the instance handle!
//        Dart_EnterScope();
        
        // Get type
        Dart_Handle type = Dart_GetType(library_, NewString(typeName), 0, NULL);
        if(Dart_IsError(type)) {
            LOG_E(Dart_GetError(type));
        }
        
        // Invoke the unnamed constructor.
        Dart_Handle instance = Dart_New(type, Dart_Null(), argc, args);
        
        if (Dart_IsError(instance)) {
            //            Dart_NewApiError
            LOG_E(Dart_GetError(instance) << " while instantiating '"<< type <<"'")
        }

//        Dart_ExitScope();
        return instance;
    }
Beispiel #2
0
void VM::loadCinderDartLib()
{
	string script = getCinderDartScript();
	Dart_Handle source = toDart( script );
	CIDART_CHECK( source );

	Dart_Handle cinderDartLib = Dart_LoadLibrary( toDart( "cinder.dart" ), source, 0, 0 );
	if( Dart_IsError( cinderDartLib ) ) {
		throw DartException( string( "failed to load cinder.dart, error message: " ) + Dart_GetError( cinderDartLib ) );
	}

	CIDART_CHECK( Dart_SetNativeResolver( cinderDartLib, Script::resolveNameHandler, NULL ) );

	// finalize any scripts loaded, needs to be done before the libs can be looked up and modified below
	CIDART_CHECK( Dart_FinalizeLoading( false ) );

	// swap in custom _printClosure to enable print() in dart
	Dart_Handle internalLib = Dart_LookupLibrary( toDart( "dart:_internal" ) );
	CIDART_CHECK( internalLib );
	Dart_Handle print = Dart_GetField( cinderDartLib, toDart( "_printClosure" ) );
	CIDART_CHECK( print );
	CIDART_CHECK( Dart_SetField( internalLib, toDart( "_printClosure" ), print ) );
}
Beispiel #3
0
// static
void VM::unhandledExceptionCallback( Dart_Handle error )
{
	 CI_LOG_E( Dart_GetError( error ) );
}
Beispiel #4
0
void throwIfError( Dart_Handle handle, const std::string &description )
{
	if( Dart_IsError( handle ) ) {
		throwException( description + ", description: " + Dart_GetError( handle ) );
	}
}