Hello,
i want to add custom javascript function to V8,i see
that:[https://v8project.blogspot.co.id/2016/02/v8-extras.html]
Vec2.js
(function(global, binding, v8) {
'use strict';
const Object = global.Object;
const x = v8.createPrivateSymbol('x');
const y = v8.createPrivateSymbol('y');
class Vec2 {
constructor(theX, theY) {
this[x] = theX;
this[y] = theY;
}
norm() {
return binding.computeNorm(this[x], this[y]);
}
}
Object.defineProperty(global, 'Vec2', {
value: Vec2,
enumerable: false,
configurable: true,
writable: true
});
binding.Vec2 = Vec2;
});
i cp Vec2.js to $chromium_src_dir/v8/src/js/
and edit $chromium_src_dir/v8/src/v8.gyp ,add the line
'v8_extra_library_files':
['js/Vec2.js',],like below:
{
'variables': {
'v8_code': 1,
'v8_random_seed%': 314159265,
'v8_vector_stores%': 0,
'embed_script%': "",
'warmup_script%': "",
'v8_extra_library_files': ['js/Vec2.js',],
'v8_experimental_extra_library_files%': [],
'v8_enable_inspector%': 1,
'mksnapshot_exec':
'<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)mksnapshot<(EXECUTABLE_SUFFIX)',
'mkpeephole_exec':
'<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)mkpeephole<(EXECUTABLE_SUFFIX)',
'v8_os_page_size%': 0,
},
}
then,i built the chrome_public.apk ,run the test javascript page ,
<html>
<head>
<title>test</title>
</head>
<body>
<script text='javascript'>document.write(typeof(Vec2));</script>
</body>
</html>
it's show undefined.it's no work ,Does anyone know why?
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups
"v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.