snippet: Add a 'replace' string

If present, the 'replace' string will be used instead of whatever code
would normally be invoked for that hook point. It will also replace
any previous snippets.

Reviewed-by: Robert Bragg <robert@linux.intel.com>
This commit is contained in:
Neil Roberts
2011-11-25 14:36:31 +00:00
committed by Robert Bragg
parent 0fdd5690c6
commit 717e96b304
7 changed files with 110 additions and 4 deletions

View File

@ -108,6 +108,27 @@ cogl_snippet_get_pre (CoglSnippet *snippet)
return snippet->pre;
}
void
cogl_snippet_set_replace (CoglSnippet *snippet,
const char *replace)
{
_COGL_RETURN_IF_FAIL (cogl_is_snippet (snippet));
if (!_cogl_snippet_modify (snippet))
return;
g_free (snippet->replace);
snippet->replace = replace ? g_strdup (replace) : NULL;
}
const char *
cogl_snippet_get_replace (CoglSnippet *snippet)
{
_COGL_RETURN_VAL_IF_FAIL (cogl_is_snippet (snippet), NULL);
return snippet->replace;
}
void
cogl_snippet_set_post (CoglSnippet *snippet,
const char *post)
@ -140,6 +161,7 @@ _cogl_snippet_free (CoglSnippet *snippet)
{
g_free (snippet->declarations);
g_free (snippet->pre);
g_free (snippet->replace);
g_free (snippet->post);
g_slice_free (CoglSnippet, snippet);
}