Discussion:
[dart-misc] Dart_LookupLibrary() fails with imported library?
Rich Eakin
2015-06-14 07:25:20 UTC
Permalink
I'm trying to get the following routine to construct a (dart)
vector_math:Vector3 from a (c++) glm::vec3 so I can pass it into my dart
script, but I can't seem to get the vector_math::Vector3 type.


Dart_Handle toDart( const glm::vec3 &value )
{
Dart_Handle vecArgs[3] = { Dart_NewDouble( value.x ), Dart_NewDouble(
value.y ), Dart_NewDouble( value.z ) };

Dart_Handle vectorMathLib = Dart_LookupLibrary( toDart( "vector_math" ) );
CIDART_CHECK( vectorMathLib ); // *<-- error: "library 'vector_math' not
found."*

Dart_Handle typeHandle = Dart_GetType( vectorMathLib, toDart( "Vector3" ),
3, vecArgs );
CIDART_CHECK( typeHandle );

Dart_Handle result = Dart_New( typeHandle, Dart_Null(), 3, vecArgs );
CIDART_CHECK( result );

return result;
}

The current script / isolate being run has already imported vector_math
with the line:

import 'package:vector_math/vector_math.dart';

Does anyone know how I can make this work? Do I need to Dart_LoadLibrary()
on vector_math for a second time? I'm missing something, just not sure
what.

Thanks for any help,
Rich
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new

To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
'Ivan Posva' via Dart Misc
2015-06-16 16:14:19 UTC
Permalink
Rich,

Dart_LookupLibrary expects the fully resolved URI from which the
library was loaded, which in your case looks like should be
"package:vector_math/vector_math.dart" instead of just "vector_math".

Hope this helps,
-Ivan
Post by Rich Eakin
I'm trying to get the following routine to construct a (dart)
vector_math:Vector3 from a (c++) glm::vec3 so I can pass it into my dart
script, but I can't seem to get the vector_math::Vector3 type.
Dart_Handle toDart( const glm::vec3 &value )
{
Dart_Handle vecArgs[3] = { Dart_NewDouble( value.x ), Dart_NewDouble(
value.y ), Dart_NewDouble( value.z ) };
Dart_Handle vectorMathLib = Dart_LookupLibrary( toDart( "vector_math" ) );
CIDART_CHECK( vectorMathLib ); // <-- error: "library 'vector_math' not
found."
Dart_Handle typeHandle = Dart_GetType( vectorMathLib, toDart( "Vector3" ),
3, vecArgs );
CIDART_CHECK( typeHandle );
Dart_Handle result = Dart_New( typeHandle, Dart_Null(), 3, vecArgs );
CIDART_CHECK( result );
return result;
}
The current script / isolate being run has already imported vector_math with
import 'package:vector_math/vector_math.dart';
Does anyone know how I can make this work? Do I need to Dart_LoadLibrary()
on vector_math for a second time? I'm missing something, just not sure
what.
Thanks for any help,
Rich
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
To unsubscribe from this group and stop receiving emails from it, send an
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new

To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Rich Eakin
2015-06-17 04:30:30 UTC
Permalink
On Tue, Jun 16, 2015 at 12:14 PM, 'Ivan Posva' via Dart VM Developers <vm-
Post by 'Ivan Posva' via Dart Misc
Rich,
Dart_LookupLibrary expects the fully resolved URI from which the
library was loaded, which in your case looks like should be
"package:vector_math/vector_math.dart" instead of just "vector_math".
Hope this helps,
-Ivan
Ah, great, using the full url indeed works for me. I suppose I expected it
to be match whatever the name was using the 'library' keyword, though I do
see now that Dart_LookupLibrary()'s argument is called 'url' so I should
have tried that. Thanks for getting me back on track..

cheers,
Rich
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new

To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Loading...