/* Copyright (C) 2007 The cluttermm Development Team
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include <glibmm/interface.h>
#include <glibmm/ustring.h>
#include <cluttermm/script.h>
#include <clutter/clutter.h>
 
_DEFS(cluttermm,clutter)
_PINCLUDE(glibmm/private/interface_p.h)


namespace Clutter
{

class Scriptable : public Glib::Interface
{
  _CLASS_INTERFACE(Scriptable, ClutterScriptable, CLUTTER_SCRIPTABLE, ClutterScriptableIface)

public:
  _WRAP_METHOD(void set_id(const std::string& id), clutter_scriptable_set_id)
  _WRAP_METHOD(std::string get_id() const, clutter_scriptable_get_id)

  // TODO: Wrap glib-json?
#m4  _CONVERSION(`const Glib::RefPtr<Script>&', `ClutterScript*', `Glib::unwrap($3)')
  _WRAP_METHOD(bool parse_custom_node(const Glib::RefPtr<Script>& script, Glib::ValueBase& value, const Glib::ustring& name, JsonNode* node), clutter_scriptable_parse_custom_node)
  _WRAP_METHOD(void set_custom_property(const Glib::RefPtr<Script>& script, const Glib::ustring& name, const Glib::ValueBase& value), clutter_scriptable_set_custom_property)

protected:

  _WRAP_VFUNC(void set_id(const std::string& id), set_id)

  // Note: We cannot return a std::string here since the C API expects a
  // const gchar* as return value. const gchar* however means that the returned
  // value is not supposed to be freed by the caller. If we would want to return
  // std::string here, what should we pass to the underlying C API then?
  // string.c_str() doesn't work since the string destroys the data upon
  // destruction (which means, we would effectively return an invalid pointer).
  // We also can't copy the string's content since we would leak that copy
  // otherwise.
  _WRAP_VFUNC(const char* get_id() const, get_id)

#m4  _CONVERSION(`ClutterScript*', `const Glib::RefPtr<Script>&', `Glib::wrap(($3), true)')
  _WRAP_VFUNC(void set_custom_property(const Glib::RefPtr<Script>& script, const Glib::ustring& name, const Glib::ValueBase& value), set_custom_property)

  // TODO: parse_custom_node vfunc
};

} // namespace Clutter
//vim: ts=2,sw=2
