Kalle Olavi Niemitalo
aa410301f1
Bug 846: {get,set}Property check JS_InstanceOf without asserting.
...
The getProperty and setProperty functions of a JSClass must not assume
that the obj parameter points to an instance of that class. It might
instead point to another object that merely has an instance of the
class in its prototype chain. Thus, do not assert that JS_InstanceOf
returns true there. Instead, run the check even with CONFIG_FASTMEM,
and just return JS_FALSE if it fails.
2006-12-03 11:17:48 +02:00
Kalle Olavi Niemitalo
39e97921f7
smjs_action_fn_callback: Assert the type of the correct object.
...
We're calling JS_GetPrivate(ctx, fn_obj), so the JS_InstanceOf assertion
must also use fn_obj, rather than obj.
Reported by Miciah.
2006-12-02 01:15:07 +02:00
Kalle Olavi Niemitalo
d9604331b8
SMJS: keymap_get_property: fix build error
...
Fix an error in the order of variable initialisation that was introduced
in commit bbf0d478e9
.
2006-11-26 15:37:24 +02:00
Miciah Dashiel Butler Masters
8617d69872
SMJS: keymap_set_property: fix build error
...
Fix an error in the order of variable initialisation that was introduced
in commit bbf0d478e9
.
2006-11-26 12:43:45 +00:00
Kalle Olavi Niemitalo
15ea2b9b50
Bug 846: Add two more comments about how SMJS calls functions.
...
They should have been in commit 670ad939c3
.
The corresponding commit fcebd6d111
in the
elinks-0.11 branch does include them.
2006-11-25 23:25:52 +02:00
Kalle Olavi Niemitalo
47dce0922b
Bug 846: Add plenty of JS_InstanceOf assertions and checks.
2006-11-25 16:09:38 +02:00
Kalle Olavi Niemitalo
bbf0d478e9
Bug 846: Separate JS_GetParent & JS_GetPrivate calls from initializations.
...
This will allow the types of objects to be checked before those calls.
2006-11-25 15:55:25 +02:00
Kalle Olavi Niemitalo
356678dd80
Bug 846: Document the JSClass assumed in each JS_{Set,Get}Private call.
2006-11-25 14:52:58 +02:00
Kalle Olavi Niemitalo
670ad939c3
Bug 846: Comments on the relations between JSClasses and functions.
2006-11-25 13:36:28 +02:00
Kalle Olavi Niemitalo
d6ea143f36
Bug 846: Document the private data in each SMJS class.
2006-11-25 13:19:35 +02:00
Kalle Olavi Niemitalo
c33d195ff4
Garbage-collect SMJS objects before flushing caches.
2006-09-25 23:43:32 +03:00
Kalle Olavi Niemitalo
2eeb14f95c
Key name strings are const in read_key() and in its (indirect) callers.
2006-08-13 14:44:01 +03:00
Witold Filipczyk
d1e5e0b7d2
Introduced STRING_DIR_SEP for better portability
2006-07-02 08:44:52 +02:00
Miciah Dashiel Butler Masters
52bd1ea01b
SMJS: Fix crash with elinks.vs and no document loaded
...
Make sure that there really is a view_state before creating a wrapper
object with a bad pointer for it.
2006-06-11 02:33:41 +00:00
Miciah Dashiel Butler Masters
5899c281ce
SMJS: bookmark_folder_get_property: Reflow some code.
2006-06-11 00:37:31 +00:00
Miciah Dashiel Butler Masters
1a3b718f98
SMJS: bookmark_folder_get_property: Reflow some code.
...
Set the return value to JSVAL_NULL up front instead of in every error
handling block.
2006-06-11 00:33:19 +00:00
Miciah Dashiel Butler Masters
ec1ab9fbe9
SMJS: Better handle when the C code tries to call a badly defined method
...
Before, when one assigned a value other than a function to
elinks.preformat_html, elinks.goto_url_hook, or elinks.follow_url_hook,
an assertion failure was triggered (and probably worse happened in
non-DEBUG builds). Now just fail silently.
2006-06-10 18:11:37 +00:00
Miciah Dashiel Butler Masters
355cbebaad
SMJS: Add elinks.vs
...
E.g., elinks.vs.plain = 0; elinks.action.rerender(); forces ELinks to
rerender the current document as HTML.
2006-06-10 18:11:37 +00:00
Miciah Dashiel Butler Masters
1df39d5068
SMJS: Add elinks.action
...
E.g., elinks.action.link_follow(20) follows the twentieth link.
The argument is optional.
2006-06-10 18:11:37 +00:00
Jonas Fonseca
4433438f92
SMJS: Add execute method to the elinks object
...
It is similar to lua's execute and let's you run a command line in
'non-blocking' mode. Example:
elinks.keymaps.main["F"] = function () {
elinks.execute("firefox " + elinks.location);
};
2006-06-06 16:30:24 +02:00
Miciah Dashiel Butler Masters
6ab4eee456
SMJS: Introduce elinks.globhist.
...
Items can be accessed via elinks.globhist["http://www.foo.net/ "]. The
resulting object has title, url, and last_visit properties. last_visit
is the seconds since the epoch. See comments in the code for why I don't
provide a nicer interface for last_visit.
2006-05-03 13:52:58 +00:00
Miciah Dashiel Butler Masters
e27596c5dc
SMJS: Add the elinks.load_uri(uri, callback) interface.
...
|callback| will be applied to the cache object when the download of
|uri| completes.
2006-04-30 04:22:11 +00:00
Miciah Dashiel Butler Masters
8ce8740359
SMJS: Return JS_FALSE if one specifies an invalid type of action for
...
a keybinding.
2006-02-12 21:20:36 +00:00
Miciah Dashiel Butler Masters
3bd14d8392
SMJS: elinks.alert: drop the extra 'error' text
...
Use info_box directly instead of via report_scripting_error by way of
alert_smjs_error, thereby avoiding the addition of extra text saying
that an error has occurred.
2006-02-12 21:05:35 +00:00
Miciah Dashiel Butler Masters
d5fe12b5f4
Merge script_hook_goto_url and script_hook_follow_url
...
Combine the two into the new script_hook_url and use the hook data field
to store the name of the appropriate ECMAScript routine.
2006-02-12 20:55:25 +00:00
Miciah Dashiel Butler Masters
495fb2805b
SMJS: Give user scripts access to the view_state
...
Introduce the view_state object to ECMAScript with properties .uri and
.plain and pass the current view_state to preformat hooks.
2006-01-28 03:27:45 +00:00
Jonas Fonseca
ba45514339
Change the SMJS scripting module name to Spidermonkey ECMAScript
2006-01-19 00:14:50 +01:00
Miciah Dashiel Butler Masters
97b5b9cfe1
Check for hooks.js before trying to load it.
...
Check file_exists(path) before calling smjs_do_file(path)
in smjs_load_hooks to fix an error message when there is no hooks.js,
reported by zas.
2006-01-02 18:53:13 +00:00
Laurent MONIN
54997c506f
Drop trailing whitespaces.
2006-01-02 00:15:20 +01:00
Miciah Dashiel Butler Masters
6a44d5192d
Fix a typo in an error message in cache_entry_set_property: s/get/set/
2005-12-29 22:31:25 +00:00
Miciah Dashiel Butler Masters
7f1711471f
Drop an extra object_lock in bookmark_folder_get_property:
...
smjs_get_bookmark_object will lock the bookmark for us.
2005-12-29 22:19:19 +00:00
Miciah Dashiel Butler Masters
9e06b709d4
Return NULL when a script tries to get a bookmark that does not exist
...
in the given folder. (What was I thinking before?)
2005-12-29 22:18:45 +00:00
Miciah Dashiel Butler Masters
684bac3b22
Define do_file before loading hooks.js in case hooks.js wants to use
...
do_file immediately.
2005-12-29 14:24:00 +00:00
Miciah Dashiel Butler Masters
ae42c586f8
Add elinks.home property.
2005-12-29 14:19:09 +00:00
Miciah Dashiel Butler Masters
a4be153703
Generalise the error message from smjs_do_file by dropping 'default'
...
from 'error loading default script file'.
2005-12-29 13:54:26 +00:00
Miciah Dashiel Butler Masters
b52a29f8c0
Let smjs_do_file return 0 to indicate failure and 1 to indicate
...
success. Add smjs_do_file_wrapper and let ECMAScript load files with
do_file(path).
2005-12-29 13:48:02 +00:00
Miciah Dashiel Butler Masters
cb506ea412
Factor smjs_do_file out of smjs_load_hooks.
2005-12-29 13:27:12 +00:00
Miciah Dashiel Butler Masters
9d4893e384
Mark smjs_load_hooks static.
2005-12-29 13:26:38 +00:00
Miciah Dashiel Butler Masters
79cf499cf9
Use JS_PropertyStub instead of NULL where applicable in JSClass
...
definitions.
2005-12-29 07:25:04 +00:00
Miciah Dashiel Butler Masters
46b1db47a2
Check JS_TRUE == ... instead of JS_FALSE != ... in smjs_get_keymap_object.
2005-12-29 07:20:33 +00:00
Miciah Dashiel Butler Masters
1ba2b6931a
Don't check CACHE_ENTRY_LENGTH in cache_entry_set_property since, as
...
Jonas pointed out, .length is read-only, so SpiderMonkey will never
pass the setter CACHE_ENTRY_LENGTH. Anyway, .uri is also read-only and
is not handled in the setter.
2005-12-29 07:19:15 +00:00
Miciah Dashiel Butler Masters
17b7ffc7df
Add elinks.bookmarks interface for reading bookmarks.
2005-12-29 07:05:31 +00:00
Miciah Dashiel Butler Masters
81be17108b
Understand a boolean true from elinks.goto_url_hook and
...
elinks.follow_url_hook to mean that the URI should be unchanged and that
further hooks should be permitted to run.
2005-12-28 07:12:09 +00:00
Miciah Dashiel Butler Masters
76d9b9de91
Add elinks.follow_url_hook.
2005-12-28 07:07:21 +00:00
Miciah Dashiel Butler Masters
d7c7736008
Add elinks.goto_url_hook.
2005-12-28 07:06:42 +00:00
Miciah Dashiel Butler Masters
c0fd25b368
Add a read-only .uri property to the cache_entry class.
2005-12-28 06:37:00 +00:00
Miciah Dashiel Butler Masters
1602bd5d29
Factor intdup out of smjs_get_keymap_object.
2005-12-26 11:07:15 +00:00
Miciah Dashiel Butler Masters
309f3d26f3
In smjs_get_keymap_object, free the private data JS_SetPrivate fails,
...
per fonseca's suggestion.
2005-12-24 18:07:55 +00:00
Miciah Dashiel Butler Masters
f46cdd8f03
Add elinks.location property to get and set the current URL.
2005-12-24 18:05:32 +00:00
Miciah Dashiel Butler Masters
d44a24050c
Undo in favour of a nicer API...
2005-12-24 07:17:36 +00:00
Miciah Dashiel Butler Masters
054fb15ff0
Add an elinks.goto_url method.
2005-12-24 07:14:51 +00:00
Miciah Dashiel Butler Masters
330cd6b7ce
Assign the given ses to smjs_ses while the ECMAScript callback runs in
...
smjs_keybinding_action_callback.
2005-12-24 07:01:17 +00:00
Miciah Dashiel Butler Masters
80a5467b8d
Introduce get_action_from_keystroke and get_action_name_from_keystroke.
...
Introduce smjs_init_keybinding_interface, which creates elinks.keymaps.<map>
for <map> in "main", "edit", and "menu". elinks.keymaps.<map> is a hash
indexed by string representations of keystrokes, and can be used to get the
current action for a key and to set the action either to an internal ELinks
action or to an ECMAScript function.
2005-12-24 06:54:01 +00:00
Miciah Dashiel Butler Masters
92da153e13
Lock the struct cache_entry when creating the corresponding ECMAScript
...
object in smjs_get_cache_entry_object and unlock it in the new finalizer
cache_entry_finalize.
2005-12-24 04:07:32 +00:00
Miciah Dashiel Butler Masters
f8de70b8f6
Comment smjs_elinks_object.
2005-12-24 03:49:06 +00:00
Miciah Dashiel Butler Masters
9b645f9b66
Move smjs_elinks_object to elinks_object.h.
2005-12-24 03:48:57 +00:00
Miciah Dashiel Butler Masters
8743ec74d8
Factor the initialisation of smjs_elinks_global out of init_smjs and
...
into the new smjs_init_elinks_object.
2005-12-24 03:47:34 +00:00
Miciah Dashiel Butler Masters
60dd7515f9
Change smjs_get_elinks_object to use smjs_global_object instead of
...
an argument.
2005-12-24 03:43:53 +00:00
Miciah Dashiel Butler Masters
d6ecf895ce
Make global_object a global with the new name smjs_global_object and
...
create smjs_init_global_object to initialise the global.
2005-12-24 03:40:59 +00:00
Miciah Dashiel Butler Masters
3174c533b0
Factor smjs_get_global_object out of init_smjs.
2005-12-24 03:39:24 +00:00
Miciah Dashiel Butler Masters
2a0653a9f2
Fix the comment heading to say ECMAScript instead of Ruby.
2005-12-22 23:45:12 +00:00
Miciah Dashiel Butler Masters
f6ce6c84f7
Rename get_cache_entry_object to smjs_get_cache_entry_object for great
...
consistency.
2005-12-20 22:13:29 +00:00
Miciah Dashiel Butler Masters
9e15d09340
NULL-terminate cache_entry_props. This and the last change resolves
...
crashes with GCC 2.x and 3.x reported by zas.
2005-12-20 22:10:59 +00:00
Miciah Dashiel Butler Masters
bb4f08172b
In init_smjs, mark global_class static.
2005-12-20 22:09:56 +00:00
Miciah Dashiel Butler Masters
be76bed022
Check the return values of JS_SetPrivate and JS_DefineProperties in
...
get_cache_entry_object.
2005-12-20 10:44:51 +00:00
Miciah Dashiel Butler Masters
71fb9a1db7
Move smjs_invoke_elinks_object_method from hooks.c to elinks_object.c.
2005-12-20 05:26:55 +00:00
Miciah Dashiel Butler Masters
3302baca35
Rename call_script_hook to smjs_invoke_elinks_object_method and rename
...
its hook parameter to method.
2005-12-20 05:25:36 +00:00
Miciah Dashiel Butler Masters
f5b102cfea
Assert smjs_ctx in get_cache_entry_object.
2005-12-19 21:33:10 +00:00
Miciah Dashiel Butler Masters
2e0907ff8d
In script_hook_pre_format_html, check whether get_cache_entry_object
...
returns NULL.
2005-12-19 21:28:52 +00:00
Miciah Dashiel Butler Masters
2b6ef067be
In init_smjs, destroy the runtime if JS_NewContext returns NULL.
2005-12-19 21:26:05 +00:00
Miciah Dashiel Butler Masters
fcd13e35cb
Do nothing in cleanup_smjs is smjs_ctx is NULL.
2005-12-19 21:24:54 +00:00
Miciah Dashiel Butler Masters
11c90e7205
Add some assertions.
2005-12-19 21:24:27 +00:00
Miciah Dashiel Butler Masters
5ca5381fbc
Rework smjs_load_hooks not to free path until it is done and to always
...
call done_string on the script string, even when add_file_to_string fails.
2005-12-19 19:08:34 +00:00
Jonas Fonseca
fa124d0988
Merge with git+ssh://pasky.or.cz/srv/git/elinks.git
2005-12-18 23:49:15 +01:00
Miciah Dashiel Butler Masters
2fef4bd531
In cache_entry_get_property and cache_entry_set_property, use
...
cache_entry_is_valid to check that the reference to the struct cache_entry
is still valid. Thanks to fonseca for the reminder.
2005-12-18 22:47:58 +00:00
Jonas Fonseca
8ea7f202b1
#include "src/scripting/smjs/cache_object.h"
2005-12-18 22:17:48 +01:00
Jonas Fonseca
838e2ea0c9
Make all global variables exported by src/scripting/smjs/core.h extern
2005-12-18 19:57:03 +01:00
Miciah Dashiel Butler Masters
51322649fe
Load the default script.
2005-12-18 18:02:32 +00:00
Miciah Dashiel Butler Masters
e3fed7e19e
Add a pre-format-html hook.
2005-12-18 17:58:42 +00:00
Miciah Dashiel Butler Masters
30ccbaaf21
Add the elinks.alert method.
2005-12-18 17:49:21 +00:00
Miciah Dashiel Butler Masters
6e0d4374c1
Add the "elinks" object.
2005-12-18 17:47:54 +00:00
Miciah Dashiel Butler Masters
acb2bb80be
Create a global object.
2005-12-18 17:40:13 +00:00
Miciah Dashiel Butler Masters
60d40b7f50
Initial skeleton for SpiderMonkey scripting backend.
2005-12-18 17:40:00 +00:00