mirror of
https://github.com/weechat/weechat.git
synced 2026-06-27 13:26:38 +02:00
script: expose theme_register to python, perl, ruby, lua, tcl, javascript, php, guile
Add weechat.theme_register (name, overrides) to all eight script
languages. Each binding is a mechanical translation of the same
signature:
- name: string
- overrides: language-native dict / hash / associative array of
full_option_name -> value strings
- returns: pointer-as-string of the registered t_theme (empty
string on failure)
Each binding converts the dict to a struct t_hashtable using the
existing per-language helper (weechat_python_dict_to_hashtable,
weechat_perl_hash_to_hashtable, weechat_ruby_hash_to_hashtable,
weechat_lua_tohashtable, weechat_tcl_dict_to_hashtable,
weechat_js_object_to_hashtable, weechat_php_array_to_hashtable,
weechat_guile_alist_to_hashtable), calls weechat_theme_register,
frees the temporary hashtable, and returns the result. The new
function is registered right after the config_* functions so the API
listing stays grouped by topic.
PHP also receives a new arginfo entry (string, array -> string) in
both weechat-php_arginfo.h and weechat-php_legacy_arginfo.h.
This is plumbing only - the underlying theme_register function is
already covered by tests/unit/core/test-core-theme.cpp
(TEST(CoreTheme, Register)). No script-side tests are added here.
This commit is contained in:
@@ -2175,6 +2175,33 @@ API_FUNC(config_unset_plugin)
|
||||
API_RETURN_INT(result);
|
||||
}
|
||||
|
||||
API_FUNC(theme_register)
|
||||
{
|
||||
zend_string *z_name;
|
||||
zval *z_overrides;
|
||||
char *name;
|
||||
struct t_hashtable *overrides;
|
||||
const char *result;
|
||||
|
||||
API_INIT_FUNC(1, "theme_register", API_RETURN_EMPTY);
|
||||
if (zend_parse_parameters (ZEND_NUM_ARGS(), "Sa", &z_name,
|
||||
&z_overrides) == FAILURE)
|
||||
API_WRONG_ARGS(API_RETURN_EMPTY);
|
||||
|
||||
name = ZSTR_VAL(z_name);
|
||||
overrides = weechat_php_array_to_hashtable (z_overrides,
|
||||
WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
WEECHAT_HASHTABLE_STRING);
|
||||
|
||||
result = API_PTR2STR(weechat_theme_register ((const char *)name,
|
||||
overrides));
|
||||
|
||||
weechat_hashtable_free (overrides);
|
||||
|
||||
API_RETURN_STRING(result);
|
||||
}
|
||||
|
||||
API_FUNC(key_bind)
|
||||
{
|
||||
zend_string *z_context;
|
||||
|
||||
@@ -132,6 +132,7 @@ PHP_FUNCTION(weechat_config_is_set_plugin);
|
||||
PHP_FUNCTION(weechat_config_set_plugin);
|
||||
PHP_FUNCTION(weechat_config_set_desc_plugin);
|
||||
PHP_FUNCTION(weechat_config_unset_plugin);
|
||||
PHP_FUNCTION(weechat_theme_register);
|
||||
PHP_FUNCTION(weechat_key_bind);
|
||||
PHP_FUNCTION(weechat_key_unbind);
|
||||
PHP_FUNCTION(weechat_prefix);
|
||||
|
||||
@@ -190,6 +190,7 @@ const zend_function_entry weechat_functions[] = {
|
||||
PHP_FE(weechat_config_set_plugin, arginfo_weechat_config_set_plugin)
|
||||
PHP_FE(weechat_config_set_desc_plugin, arginfo_weechat_config_set_desc_plugin)
|
||||
PHP_FE(weechat_config_unset_plugin, arginfo_weechat_config_unset_plugin)
|
||||
PHP_FE(weechat_theme_register, arginfo_weechat_theme_register)
|
||||
PHP_FE(weechat_key_bind, arginfo_weechat_key_bind)
|
||||
PHP_FE(weechat_key_unbind, arginfo_weechat_key_unbind)
|
||||
PHP_FE(weechat_prefix, arginfo_weechat_prefix)
|
||||
|
||||
@@ -233,6 +233,11 @@ ZEND_END_ARG_INFO()
|
||||
|
||||
#define arginfo_weechat_config_unset_plugin arginfo_weechat_charset_set
|
||||
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_weechat_theme_register, 0, 2, IS_STRING, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, p0, IS_STRING, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, p1, IS_ARRAY, 0)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_weechat_key_bind, 0, 2, IS_LONG, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, p0, IS_STRING, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, p1, IS_ARRAY, 0)
|
||||
|
||||
@@ -194,6 +194,8 @@ ZEND_END_ARG_INFO()
|
||||
|
||||
#define arginfo_weechat_config_unset_plugin arginfo_weechat_plugin_get_name
|
||||
|
||||
#define arginfo_weechat_theme_register arginfo_weechat_iconv_to_internal
|
||||
|
||||
#define arginfo_weechat_key_bind arginfo_weechat_iconv_to_internal
|
||||
|
||||
#define arginfo_weechat_key_unbind arginfo_weechat_iconv_to_internal
|
||||
|
||||
Reference in New Issue
Block a user