summaryrefslogtreecommitdiff
path: root/modules
Commit message (Collapse)AuthorAgeFilesLines
* Rework typechecking and private data accessGiovanni Campagna2012-08-081-1/+4
| | | | | | | | | | | | | | | | | | Previously, all type safety checks were inside priv_from_js, which returned NULL if the object was of the wrong class. Except that a lot of code was not checking for NULL, causing potential crashes. Also, we were only checking the JSClass, not the actual type of object, so for example a function accepting a boxed would take in any boxed instance, not just the right one (and then that could crash JS code). Rework this by splitting typechecking and private data access. Internal API for typechecking is provided by all object classes (object, boxed, union, param, gerror) and it takes the necessary amount of information (GType, GIBaseInfo) to ensure type safety. priv_from_js becomes unsafe, and thus ok to call in dangerous data paths such as tracing and finalization. https://bugzilla.gnome.org/show_bug.cgi?id=679688
* GLib: Don't pass extra arguments to constructorsJasper St. Pierre2012-08-071-4/+4
| | | | https://bugzilla.gnome.org/show_bug.cgi?id=680215
* Trace signal closures from the object instead of the context keep-aliveGiovanni Campagna2012-06-202-9/+10
| | | | | | | | | | | | Implement tracing for GObjects and use it so that signal handlers are rooted to the objects they're connected, and not the global object. This means that if the object goes away and the only thing referring to it is the handler function, it is recognized as a cycle by the GC and collected, reducing memory leaks. Other closures, as well as callback trampolines and vfuncs, are still rooted in the usual way. https://bugzilla.gnome.org/show_bug.cgi?id=678504
* Gio: modernize DBus bindingsGiovanni Campagna2012-06-201-153/+153
| | | | | | | Remove tabs, use modern GError bindings, remove comments that are no longer relevant. https://bugzilla.gnome.org/show_bug.cgi?id=669350
* Gio: split GDBus implementation into helpersGiovanni Campagna2012-06-201-51/+63
| | | | | | | Soon new API wrappers will be introduced, and this will help reusing code. https://bugzilla.gnome.org/show_bug.cgi?id=669350
* Introduce special marshalling for GErrorsGiovanni Campagna2012-06-071-0/+5
| | | | | | | | | | Previously GErrors were transformed into plain Error with a custom message, which removed the code and domain metadata. This commit introduces a new class hierarchy (derived from GLib.Error) for each enumeration representing an error domain, and modifies existing code to throw instances of that when a function fails. https://bugzilla.gnome.org/show_bug.cgi?id=591480
* Fix various memory leaksJasper St. Pierre2012-05-251-1/+1
| | | | | | Found with make valgrind-check. We should run it more often. https://bugzilla.gnome.org/show_bug.cgi?id=676843
* foreign: Remove type_info from foreign APIsJasper St. Pierre2012-05-251-3/+0
| | | | | | | | If we don't require a type_info in a foreign API, this will make it easier to use the foreign API from another place in the code. Swap out the use of type_info with the interface info that the type info contains. https://bugzilla.gnome.org/show_bug.cgi?id=671687
* system: Add a debugger function to retrieve the refcount of a GObjectJasper St. Pierre2012-05-251-0/+30
|
* modules: Import a new "format" moduleJasper St. Pierre2012-05-243-0/+177
| | | | | | | Imported from gnome-shell, this provides printf-like formatting to JavaScript. https://bugzilla.gnome.org/show_bug.cgi?id=675479
* Rename GjsDBus to GjsPrivateGiovanni Campagna2012-05-231-3/+3
| | | | | | | | | | GjsDBus is likely to be present in system directories too, if an older version of gjs is installed, and this can cause symbol conflicts between system libgjs-gdbus.so and libgjs.so. Also, it could be that some day we want to do something else with it. https://bugzilla.gnome.org/show_bug.cgi?id=675018
* system: add getpid(), getuid(), getgid()Giovanni Campagna2012-04-291-0/+64
| | | | | | | | These functions are useful sometimes (for example when building a PolkitSubject), and have no equivalent in GLib, therefore it's appropriate to place them in the system module. https://bugzilla.gnome.org/show_bug.cgi?id=646187
* GDBus: fix NotImplementedError messageGiovanni Campagna2012-04-291-1/+1
| | | | | | | Single quotes must be used, or the method_name concatenation is not recognized. https://bugzilla.gnome.org/show_bug.cgi?id=675018
* Show a debug message when DBus introspection failsJames Willcox2012-03-151-0/+1
| | | | https://bugzilla.gnome.org/show_bug.cgi?id=607589
* Fix comparisons with JSVAL_VOID and JSVAL_NULLPierre Lejeune2012-03-015-29/+29
|
* Improve GType detection for unconstrained GValuesGiovanni Campagna2012-02-131-0/+2
| | | | | | | | | | In ebc84492, we added a way to get a GType for a constructor. Let's expand this to objects (by way of the JavaScript 'constructor' property), and then use this mechanism to improve GType detection in GValues. This can be used with APIs like GtkListStore that force the user to create a GValue and expect the right type. https://bugzilla.gnome.org/show_bug.cgi?id=669848
* object: Make custom types have a custom JSClassGiovanni Campagna2012-02-031-19/+55
| | | | | Use gjs_define_object_class to create a dynamic JSClass for the newly registered gtype, which doesn't have any introspection info.
* object: Add support for interfacesGiovanni Campagna2012-02-031-0/+7
| | | | | | | Introduces a new Gi.add_interface internal method, that wraps g_type_add_interface(). Introduces support for interface vfuncs when hooking them, and for retrieving their C implementation from prototypes.
* object: Introduce support for signalsGiovanni Campagna2012-02-031-2/+38
| | | | | | | | Introduce Gi.signal_new, which is a thin wrapper over g_signal_newv, and then make GObject.Class read a map of signal descriptions as parameters to the class. Also, use g_signal_override_class_closure to connect "on_foo" to the respective signals.
* object: Support glib propertiesJasper St. Pierre2012-02-031-0/+7
| | | | | | | | | | | | | To support installing custom properties, we must be able to have JS context and JS object in set_property before even g_object_newv() returns. This is achieved by using other internal construct properties that are set if the object is of a custom type. Use this so that we can implement a sane default implementation of do_get_property/do_set_property that simply sets the corresponding field on the JS object. Implementations that need more complex behavior can either use ES5 or Mozilla getters/setters, or implement their own override of do_get_property and do_set_property.
* object: Allow GObject subclasses to override parent vfuncsJasper St. Pierre2012-02-031-0/+7
| | | | | | | | | | Allow GObject subclasses to override parent vfuncs. We automatically hook up such vfuncs if the name of the function is prefixed with "vfunc_". Some of the code here related to finding the vfunc's implementor struct was stolen from pygobject. Maybe it should go in libgirepository instead. https://bugzilla.gnome.org/show_bug.cgi?id=663492
* object: Implement gobject inheritanceJasper St. Pierre2012-02-032-0/+44
| | | | https://bugzilla.gnome.org/show_bug.cgi?id=663492
* lang: Introduce meta classesGiovanni Campagna2012-02-031-20/+86
| | | | | | | | Classes created with new Lang.Class are now first class objects themselves, and Lang.Class is itself a Lang.Class (to the extent permitted by JS). It is therefore possible to inherit from Lang.Class and create custom python-like metaclasses, instances of which are actual instantiable classes.
* Fix system moduleJasper St. Pierre2012-02-031-3/+6
|
* Add "system" moduleJasper St. Pierre2012-02-032-0/+140
| | | | | | | | | | | | | | | | | | There are three functions in here: * addressOf: Extremely useful when debugging a gjs process with a native code debugger like GDB. Add "print(imports.system.addressOf(foo))" for an object, then take the number it prints "12345" and paste into gdb like: p (JSObject*) 12345 * breakpoint: Wrapper for G_BREAKPOINT(). Insert a SIGTRAP which, if the process is under a debugger, causes a breakpoint. Combines nicely with the above. * gc: Forces a full garbage collection. Based on a patch by Colin Walters <walters@verbum.org> https://bugzilla.gnome.org/show_bug.cgi?id=630412
* drop JS_LOCALETOUNICODE_NEEDS_CONST_CHAR check and silence warningsMarc-Antoine Perennou2012-01-041-2/+0
| | | | | | | | | Since we now require mozjs185, it always needs a const char* Silence btw warnings about argv sometimes not being used https://bugzilla.gnome.org/show_bug.cgi?id=666331 Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
* Add a new "GObject" override module to aid us in creating ParamSpecsJasper St. Pierre2011-12-151-0/+120
| | | | https://bugzilla.gnome.org/show_bug.cgi?id=665432
* Remove JSFUN_FAST_NATIVEJasper St. Pierre2011-11-2813-129/+129
| | | | https://bugzilla.gnome.org/show_bug.cgi?id=664360
* Strip compat.h #define hellJasper St. Pierre2011-11-282-17/+0
| | | | https://bugzilla.gnome.org/show_bug.cgi?id=664360
* lang: Fix up an error messageJasper St. Pierre2011-11-281-1/+1
| | | | https://bugzilla.gnome.org/show_bug.cgi?id=663490
* Class: fix for reentrant callsGiovanni Campagna2011-11-211-3/+4
| | | | | | | | Uponing entering a method from another on the same object, the function wrapper must save the previous value of __caller__, or susbsequents calls to parent() would fail. https://bugzilla.gnome.org/show_bug.cgi?id=664437
* Class: introduce abstract classesGiovanni Campagna2011-11-211-8/+15
| | | | | | | | | By setting Abstract: true in the class parameters, you can now obtain a class that will throw upon instantiation. The class can still have an _init (that derived class can call) and otherwise works like all other classes. https://bugzilla.gnome.org/show_bug.cgi?id=664437
* Class: improve prototype property descriptorsGiovanni Campagna2011-11-211-9/+19
| | | | | | | | | | Use ES5 reflection methods to obtain and manipulate property descriptors, instead of copying the property values with for-in. This allows for non-enumerable properties, prevents Object.prototype properties from being iterated, allows setting .configurable, and most important allows accessor properties with the usual syntax. https://bugzilla.gnome.org/show_bug.cgi?id=664437
* overrides/Gio: Ignore replies that we don't care aboutColin Walters2011-11-101-3/+0
| | | | | It should be OK to call a DBus function asynchronously and ignore the result.
* overrides/Gio.js: Fix property setterColin Walters2011-11-101-9/+9
| | | | This code was obviously never tested or run.
* overrides/GLib.js: Add missing trailing newlineColin Walters2011-11-101-1/+1
|
* lang: Add new "Class" framework adapted from MooToolsJasper St. Pierre2011-10-271-0/+80
| | | | | | | | | | | The current strategy of using __proto__ and _init to implement prototype chains is non-standard and error-prone. Use something a bit more automatic to help us along. Additionally, when patches come for inheriting from gi objects, we can use the existing framework to hoist ourselves without too much effort. https://bugzilla.gnome.org/show_bug.cgi?id=662582
* Add some missing Cairo.OperatorMarc-André Lureau2011-08-061-1/+16
| | | | https://bugzilla.gnome.org/show_bug.cgi?id=656074
* cairo: bind image_surface_get_{format,width,height,stride}Marc-André Lureau2011-08-061-4/+100
| | | | | | Add some missing cairo_image_surface getters bindings. https://bugzilla.gnome.org/show_bug.cgi?id=655447
* Complete porting to GDBusGiovanni Campagna2011-07-251-16/+204
| | | | | | | | | | Introduces a new introspected library, libgjs-gdbus, which hosts GjsDBusImplementation, a standalone, signal-driven GDBusInterfaceSkeleton. This is exposed, thanks to overrides, as Gio.DBusExportedObject, where it gains some JS code to expose normal JS objects on the bus and some glue to use E4X in place of XML strings for introspection. https://bugzilla.gnome.org/show_bug.cgi?id=622921
* Remove All Rights Reserved. for code originating from LitlJohan Dahlin2011-07-2527-27/+27
|
* Lang.js: Add defineAccessorPropertyGiovanni Campagna2011-06-301-0/+14
| | | | | This is a wrapper for Object.defineProperty() but with a fallback for older versions of spidermonkey.
* Lang.bind: Use Function.bind() if we're not curryingGiovanni Campagna2011-06-301-3/+6
| | | | | The standard Function.bind() works, but doesn't support passing additional arguments.
* dbus: Add conversion rule for 'q' to JSEmmanuele Bassi2011-06-241-0/+14
| | | | | | | The int16/uint16 type (signature: 'q') is lacking the conversion rule from DBus value to JavaScript. Easy enough to add. https://bugzilla.gnome.org/show_bug.cgi?id=653332
* Merge gi.so into gjs.soColin Walters2011-06-212-86/+0
| | | | | | | | No consumer of gjs is interested in gjs without gi, let's stop pretending it's an addon module. All of the other modules link to it anyways, and in reality to integrate things well, we need to be able to cross call between gjs core -> gi and the reverse.
* Gio.js: Quiet a compiler warningColin Walters2011-06-211-6/+6
|
* Add a JS GDBus convenience layerGiovanni Campagna2011-06-211-1/+201
| | | | | | | | This only covers the proxy (client) side, for the skeleton (server) side we still need glue code (but it is easy to generate it using gdbus-binding-tool, for example) https://bugzilla.gnome.org/show_bug.cgi?id=622921
* GVariant: add JS wrappers for packing and unpackingGiovanni Campagna2011-06-201-0/+261
| | | | | | | Using JS overrides, adds glue code that packs and unpacks GVariants into JS objects (hash maps, arrays and primitive types) https://bugzilla.gnome.org/show_bug.cgi?id=622344
* Parse input as UTF-8, not ISO-8859-1Colin Walters2011-06-061-2/+15
| | | | | | | Implement this by assuming input is UTF-8, convert it to UTF-16, and pass it to the "UC" variants of the JSAPI. https://bugzilla.gnome.org/show_bug.cgi?id=581028
* Introduce infrastructure for override modulesGiovanni Campagna2011-05-191-0/+2
| | | | | | | Override modules are JS modules that can subsume or replace native modules from GObject Introspection. https://bugzilla.gnome.org/show_bug.cgi?id=646633