1
0
Fork 0
Commit graph

32 commits

Author SHA1 Message Date
Emmanuele Bassi
21eb49098a script: Fix the memory management
Currently, the memory management in ClutterScript is overly complicated.
The basic design tenet should be:

  - ClutterScript owns a reference on every object it creates

This allows the Script instance to reliably handle the lifetime of the
instances from creation to disposal.

In case of unmerge, the Script instance should destroy any Actor
instance, except for the Stage, and release the reference it owns. The
Stage is special because it's really owned by Clutter itself, and it
should be destroyed explicitly.

When disposing the Script itself, it should just release the reference;
any parented actor, or any InitiallyUnowned instance, will then be
managed by the parent object, as they should, while every GObject
instance will go away, as documented.

This commit is based on a patch by:

  Henrik Hedberg <hhedberg@innologies.fi>

http://bugzilla.clutter-project.org/show_bug.cgi?id=2316
2010-10-19 01:42:19 +01:00
Owen W. Taylor
f1c44a27a1 introspection: Add missing (out) annotations
Comprehensively add (out) annotations to functions parameters
returning int/float/double.

Not handled here: structure out returns like ClutterColor or
ClutterPerspective or GValue that should get (out caller-allocates).

Not handled here: Cogl

http://bugzilla.clutter-project.org/show_bug.cgi?id=2302
2010-09-08 15:43:07 +01:00
Bastian Winkler
cb58f1f68c script-parser: Apply child and layout properties to the right actor
http://bugzilla.clutter-project.org/show_bug.cgi?id=2285

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>
2010-08-25 16:18:25 +01:00
Emmanuele Bassi
b7f99ddd3c script: Let ClutterActor parse behaviours
Up until now, the "behaviours" member of an actor definition was parsed
by the ClutterScript parser itself - even though it's not strictly
necessary.

In an effort to minimize the ad hoc code in the Script parser, we should
let ClutterActor handle all the special cases that involve
actor-specific members.
2010-07-09 14:59:32 +01:00
Emmanuele Bassi
a4dbcf0c32 script-parser: Expose extracting the id from a node
The get_id_from_node() internal function should be exposed inside
Clutter (as a private function) because it can be useful to other
custom parsing code. The code is pretty trivial, but it would be
pointless to re-implement it.
2010-06-17 16:41:44 +01:00
Emmanuele Bassi
4c22f122e1 script: Support layout manager properties
Layout properties work similarly to child properties, with the added
headache that they require the 3-tuple:

  ( layout manager, container, actor )

to be valid in order to be inspected, parsed and applied. This means
using the newly added back-pointer from the container to the layout
manager and then rejigging a bit how the ScriptParser handles the
unresolved properties.

Similarly to the child properties, which use the "child::" prefix, the
layout manager properties use the "layout::" prefix and are defined with
the child of a container holding a layout manager.
2010-06-07 22:45:34 +01:00
Damien Lespiau
52a78a7220 analysis: FALSE/0 used in pointer context
While this is totally fine (0 in the pointer context will be converted
in the right internal NULL representation, which could be a value with
some bits to 1), I believe it's clearer to use NULL in the pointer
context.

It seems that, in most case, it's more an overlook than a deliberate
choice to use FALSE/0 as NULL, eg. copying a _COGL_GET_CONTEXT (ctx, 0)
or a g_return_val_if_fail (cond, 0) from a function returning a
gboolean.
2010-06-01 12:08:18 +01:00
Emmanuele Bassi
a8595aec13 script: Add more comments and annotations
Detail why we are adding a fake id, and under which circumstances that
happens. Also be more verbose with the debug annotations.
2010-03-18 20:20:09 +00:00
Emmanuele Bassi
203847d03c script: Skip empty nodes
If we get an empty node then we should skip it; this is really a
workaround for something that is broken in JSON-GLib or in our use
of JSON-GLib.
2010-03-18 17:44:14 +00:00
Emmanuele Bassi
79acb088e7 Remove mentions of the FSF address
Since using addresses that might change is something that finally
the FSF acknowledge as a plausible scenario (after changing address
twice), the license blurb in the source files should use the URI
for getting the license in case the library did not come with it.

Not that URIs cannot possibly change, but at least it's easier to
set up a redirection at the same place.

As a side note: this commit closes the oldes bug in Clutter's bug
report tool.

http://bugzilla.openedhand.com/show_bug.cgi?id=521
2010-03-01 12:56:10 +00:00
Emmanuele Bassi
d3d05261e6 script-parser: Remove top-level types list
The top-level types list was comically out of date, and it was only
determining whether the type we were constructing was initially unowned
or a full object. We can safely replace it with a simple type check.
2010-02-25 14:22:08 +00:00
Emmanuele Bassi
c0be19eff6 script-parser: Be more strict with "children" members
The "children" member for Container definitions should only reference
actors, and warn about any other type.
2010-02-25 14:20:05 +00:00
Emmanuele Bassi
136e8c1acb analysis: ClutterScriptParser
We parse a JSON value depending on the initial state of an uninitialized
variable. Ouch.
2010-02-12 14:50:11 +00:00
Emmanuele Bassi
09f91ff6ea script: Use a node when resolving an animation mode
Instead of taking a string and duplicating the "is it a string or an
integer" check in both Alpha and Animation, the function in
ClutterScript that resolves the animation mode values should take a
JsonNode and do all the checks it needs.
2010-02-08 15:45:43 +00:00
Emmanuele Bassi
2aa9d7bdc7 script: Copy the JSON node in PropertyInfo
PropertyInfo should store a copy of the JsonNodes it references, so
that property_info_free() can safely dispose them, and we can reference
values across different UI definition data.

The implicit timeline parsing code is not copying the JsonNode; this
leads to a double free in some cases, which is masked by the GSlice
allocator and produces a heap corruption later on.
2010-01-05 10:55:28 +00:00
Emmanuele Bassi
d54f4e944c Whitespace fixes 2009-11-13 15:01:17 +00:00
Emmanuele Bassi
30bc36082e Do not pass flags to g_module_open(NULL)
The flags are ignored when opening the main module, so we
should pass 0 to avoid confusion when reading the source.
2009-11-06 14:06:18 +00:00
Emmanuele Bassi
cb60c038ac behaviour: Implement the implicit alpha parsing
ClutterBehaviour should implement the Scriptable interface
and parse ClutterAlpha when implicitly defined, instead of
having this ad hoc code inside ClutterScriptParser itself.

After all, only ClutterBehaviour supports Alpha defined
implicitly.
2009-11-06 11:39:30 +00:00
Emmanuele Bassi
7279afd28c script: Generic assignment of properties requiring objects
The ClutterScriptParser should do most of the heavy-lifting for
parsing a JSON object member defining another JSON object into
a GObject property defined using a GParamSpecObject.
2009-11-06 11:39:30 +00:00
Emmanuele Bassi
f9581ca5ce script: Apply properties when constructing implicit timelines
The object construction is done in two passes, now, so we must do both
passes when parsing implicit timelines from a fake ObjectInfo.
2009-11-06 11:39:30 +00:00
Emmanuele Bassi
95d78acb4c script: Allow parsing child properties
The ClutterScript parser needs to be extended to parse child properties
and apply them after an actor has been added to a container. In order to
distinguish child properties from regular GObject properties we can use
the "child::" prefix, e.g.:

  {
    "type" : "ClutterRectangle",
    "id" : "child-01",
    "child::has-focus" : true,
    ...
  }

Parsing child properties can be deferred to the ClutterScriptable
interface, just like regular properties.
2009-11-04 16:50:35 +00:00
Emmanuele Bassi
8ba13d6495 script: Clean up Color parsing rules
All the ClutterColor parsing rules should be coalesced inside
clutter_script_parse_color(): object, array and string notations
are the canonical ways of defining a ClutterColor inside a
ClutterScript definition. Having a single function in charge of
the parsing cleans up the code.
2009-11-04 15:21:03 +00:00
Emmanuele Bassi
3e815de32b script: Simplify boxed types parsing
We should use the typed accessors for complex JSON types, and
be more liberal in what we accept.
2009-11-04 15:20:12 +00:00
Emmanuele Bassi
4df59d330c script: Separate construction from properties application
Currently, ClutterScriptParser will construct the object (using the
construct-only and construct parameters), apply the properties from
the ClutterScript definition, and eventuall will add children and
behaviours.

The construction phase should be more compartimentalized: the objects
should be constructed first and eventual children and behaviours
added. Then, once an object is requested or when the parsing process
has terminated, all the properties should be applied.

This change allows us to set up the actors before setting their
non-construct properties.
2009-11-04 14:18:43 +00:00
Emmanuele Bassi
31e5dadb68 script: Move all parser code inside ClutterScriptParser
ClutterScript is currently a mix of parser-related code and
the ClutterScript object. All the parser-related code should
be moved inside a private class, ClutterScriptParser, inheriting
from JsonParser.
2009-11-04 13:32:26 +00:00
Emmanuele Bassi
8c49e22753 Add copyright and license notice
The clutter-script-parser.c does not have a copyright and license
notices; even though the LGPL is a per-project license and not a
per-file license, having those notices in every source file is a
good idea.
2009-08-12 10:30:11 +01:00
Emmanuele Bassi
fbe225d179 2008-08-04 Emmanuele Bassi <ebassi@openedhand.com>
* clutter/clutter-script-parser.c:
	* clutter/clutter-script-private.h: Clean up the code; add a
	conversion function for reading a ClutterColor out of a
	JSON object or array definition.

	* clutter/clutter-script.c: Clean up the code; document properly
	how we translate from type name to type function.
2008-08-04 16:21:27 +00:00
Neil Roberts
6409b1adeb Merged clutter-ivan branch into trunk.
svn merge \
 https://svn.o-hand.com/repos/clutter/trunk/clutter@2509 \
 https://svn.o-hand.com/repos/clutter/branches/clutter-ivan@HEAD
2008-04-25 13:37:36 +00:00
Emmanuele Bassi
6b4a9c4df5 2008-02-07 Emmanuele Bassi <ebassi@openedhand.com>
* clutter/clutter-script-parser.c:
	(clutter_script_get_type_from_symbol),
	(clutter_script_get_type_from_class): Use BIND_LAZY flag
	when looking at the symbols, so we don't load them all up.

	* clutter/clutter-script.c (resolve_alpha_func): Ditto as above.
2008-02-07 14:17:53 +00:00
Emmanuele Bassi
4976be12ca 2007-11-28 Emmanuele Bassi <ebassi@openedhand.com>
Remove the layout containers: they will be moved to a
	high-level library.

	* clutter/clutter.h:
	* clutter/Makefile.am: Remove layout and boxes from the
	build.

	* clutter/clutter-layout.[ch]: Remove the ClutterLayout
	interface.
	
	* clutter/clutter-box.[ch]:
	* clutter/clutter-hbox.[ch]:
	* clutter/clutter-vbox.[ch]: Remove ClutterBox and its
	subclasses.
	
	* clutter/clutter-label.c: Remove ClutterLayout implementation

	* clutter/clutter-script-private.h:
	* clutter/clutter-script-parser.c:
	* clutter/clutter-script.c:
	(clutter_script_parse_node): Remove special parsing for
	ClutterMargin and ClutterPadding.

	* clutter/clutter-types.h: Remove ClutterPadding and ClutterMargin.

	* tests/Makefile.am:
	* tests/test-boxes.c: Remove the boxes test case.
2007-11-28 13:50:24 +00:00
Emmanuele Bassi
5a260b7ac3 2007-10-25 Emmanuele Bassi <ebassi@openedhand.com>
* clutter/clutter-script-parser.c: Unset the GValue when
	getting a ClutterUnit from a JSON node.
2007-10-25 15:14:06 +00:00
Emmanuele Bassi
6c01499abf 2007-10-25 Emmanuele Bassi <ebassi@openedhand.com>
* clutter/Makefile.am:
	* clutter/clutter.h:
	* clutter/clutter-scriptable.[ch]: Add the ClutterScriptable
	interface; by implementing this interface, a class can
	override the UI definition parsing and transform complex data
	types into GObject properties, or allow custom properties.

	* clutter/clutter-script.c:
	* clutter/clutter-script-parser.c:
	* clutter/clutter-script-private.h: Rearrange the code and
	use the ClutterScriptable interface to parse and build the
	custom properties. This cleans up the code and also it makes
	it more reliable (the complex type parsing is now done using
	the target type and not just the name of the property).
2007-10-25 14:34:54 +00:00