Beispiel #1
0
static void engine_update(RenderEngine *engine, Main *bmain, Scene *scene)
{
	extern FunctionRNA rna_RenderEngine_update_func;
	PointerRNA ptr;
	ParameterList list;
	FunctionRNA *func;

	RNA_pointer_create(NULL, engine->type->ext.srna, engine, &ptr);
	func= &rna_RenderEngine_update_func;

	RNA_parameter_list_create(&list, &ptr, func);
	RNA_parameter_set_lookup(&list, "data", &bmain);
	RNA_parameter_set_lookup(&list, "scene", &scene);
	engine->type->ext.call(NULL, &ptr, func, &list);

	RNA_parameter_list_free(&list);
}
Beispiel #2
0
static void engine_update_script_node(RenderEngine *engine, struct bNodeTree *ntree, struct bNode *node)
{
	extern FunctionRNA rna_RenderEngine_update_script_node_func;
	PointerRNA ptr, nodeptr;
	ParameterList list;
	FunctionRNA *func;

	RNA_pointer_create(NULL, engine->type->ext.srna, engine, &ptr);
	RNA_pointer_create((ID *)ntree, &RNA_Node, node, &nodeptr);
	func = &rna_RenderEngine_update_script_node_func;

	RNA_parameter_list_create(&list, &ptr, func);
	RNA_parameter_set_lookup(&list, "node", &nodeptr);
	engine->type->ext.call(NULL, &ptr, func, &list);

	RNA_parameter_list_free(&list);
}
Beispiel #3
0
static void menu_draw(const bContext *C, Menu *hdr)
{
	extern FunctionRNA rna_Menu_draw_func;

	PointerRNA mtr;
	ParameterList list;
	FunctionRNA *func;

	RNA_pointer_create(&CTX_wm_screen(C)->id, hdr->type->ext.srna, hdr, &mtr);
	func = &rna_Menu_draw_func; /* RNA_struct_find_function(&mtr, "draw"); */

	RNA_parameter_list_create(&list, &mtr, func);
	RNA_parameter_set_lookup(&list, "context", &C);
	hdr->type->ext.call((bContext *)C, &mtr, func, &list);

	RNA_parameter_list_free(&list);
}
Beispiel #4
0
static void panel_draw_header(const bContext *C, Panel *pnl)
{
	extern FunctionRNA rna_Panel_draw_header_func;

	PointerRNA ptr;
	ParameterList list;
	FunctionRNA *func;

	RNA_pointer_create(&CTX_wm_screen(C)->id, pnl->type->ext.srna, pnl, &ptr);
	func = &rna_Panel_draw_header_func; /* RNA_struct_find_function(&ptr, "draw_header"); */

	RNA_parameter_list_create(&list, &ptr, func);
	RNA_parameter_set_lookup(&list, "context", &C);
	pnl->type->ext.call((bContext *)C, &ptr, func, &list);

	RNA_parameter_list_free(&list);
}
Beispiel #5
0
static void uilist_draw_filter(uiList *ui_list, bContext *C, uiLayout *layout)
{
	extern FunctionRNA rna_UIList_draw_filter_func;

	PointerRNA ul_ptr;
	ParameterList list;
	FunctionRNA *func;

	RNA_pointer_create(&CTX_wm_screen(C)->id, ui_list->type->ext.srna, ui_list, &ul_ptr);
	func = &rna_UIList_draw_filter_func; /* RNA_struct_find_function(&ul_ptr, "draw_filter"); */

	RNA_parameter_list_create(&list, &ul_ptr, func);
	RNA_parameter_set_lookup(&list, "context", &C);
	RNA_parameter_set_lookup(&list, "layout", &layout);
	ui_list->type->ext.call((bContext *)C, &ul_ptr, func, &list);

	RNA_parameter_list_free(&list);
}
Beispiel #6
0
/* wrapper for iterator callback */
static void RKS_ITER_rna_internal(KeyingSetInfo *ksi, bContext *C, KeyingSet *ks)
{
	extern FunctionRNA rna_KeyingSetInfo_iterator_func;

	PointerRNA ptr;
	ParameterList list;
	FunctionRNA *func;

	RNA_pointer_create(NULL, ksi->ext.srna, ksi, &ptr);
	func = &rna_KeyingSetInfo_iterator_func; /* RNA_struct_find_function(&ptr, "poll"); */

	RNA_parameter_list_create(&list, &ptr, func);
		/* hook up arguments */
		RNA_parameter_set_lookup(&list, "ksi", &ksi);
		RNA_parameter_set_lookup(&list, "context", &C);
		RNA_parameter_set_lookup(&list, "ks", &ks);
		
		/* execute the function */
		ksi->ext.call(C, &ptr, func, &list);
	RNA_parameter_list_free(&list);
}
Beispiel #7
0
static int panel_poll(const bContext *C, PanelType *pt)
{
    PointerRNA ptr;
    ParameterList list;
    FunctionRNA *func;
    void *ret;
    int visible;

    RNA_pointer_create(NULL, pt->ext.srna, NULL, &ptr); /* dummy */
    func= RNA_struct_find_function(&ptr, "poll");

    RNA_parameter_list_create(&list, &ptr, func);
    RNA_parameter_set_lookup(&list, "context", &C);
    pt->ext.call((bContext *)C, &ptr, func, &list);

    RNA_parameter_get_lookup(&list, "visible", &ret);
    visible= *(int*)ret;

    RNA_parameter_list_free(&list);

    return visible;
}
Beispiel #8
0
static bool menu_poll(const bContext *C, MenuType *pt)
{
	extern FunctionRNA rna_Menu_poll_func;

	PointerRNA ptr;
	ParameterList list;
	FunctionRNA *func;
	void *ret;
	bool visible;

	RNA_pointer_create(NULL, pt->ext.srna, NULL, &ptr); /* dummy */
	func = &rna_Menu_poll_func; /* RNA_struct_find_function(&ptr, "poll"); */

	RNA_parameter_list_create(&list, &ptr, func);
	RNA_parameter_set_lookup(&list, "context", &C);
	pt->ext.call((bContext *)C, &ptr, func, &list);

	RNA_parameter_get_lookup(&list, "visible", &ret);
	visible = *(bool *)ret;

	RNA_parameter_list_free(&list);

	return visible;
}
Beispiel #9
0
static void uilist_filter_items(uiList *ui_list, bContext *C, PointerRNA *dataptr, const char *propname)
{
	extern FunctionRNA rna_UIList_filter_items_func;

	PointerRNA ul_ptr;
	ParameterList list;
	FunctionRNA *func;
	PropertyRNA *parm;

	uiListDyn *flt_data = ui_list->dyn_data;
	int *filter_flags, *filter_neworder;
	void *ret1, *ret2;
	int ret_len;
	int len = flt_data->items_len = RNA_collection_length(dataptr, propname);

	RNA_pointer_create(&CTX_wm_screen(C)->id, ui_list->type->ext.srna, ui_list, &ul_ptr);
	func = &rna_UIList_filter_items_func; /* RNA_struct_find_function(&ul_ptr, "filter_items"); */

	RNA_parameter_list_create(&list, &ul_ptr, func);
	RNA_parameter_set_lookup(&list, "context", &C);
	RNA_parameter_set_lookup(&list, "data", dataptr);
	RNA_parameter_set_lookup(&list, "property", &propname);

	ui_list->type->ext.call((bContext *)C, &ul_ptr, func, &list);

	parm = RNA_function_find_parameter(NULL, func, "filter_flags");
	ret_len = RNA_parameter_dynamic_length_get(&list, parm);
	if (ret_len != len && ret_len != 0) {
		printf("%s: Error, py func returned %d items in %s, %d or none were expected.\n", __func__,
		       RNA_parameter_dynamic_length_get(&list, parm), "filter_flags", len);
		/* Note: we cannot return here, we would let flt_data in inconsistent state... see T38356. */
		filter_flags = NULL;
	}
	else {
		RNA_parameter_get(&list, parm, &ret1);
		filter_flags = (int *)ret1;
	}

	parm = RNA_function_find_parameter(NULL, func, "filter_neworder");
	ret_len = RNA_parameter_dynamic_length_get(&list, parm);
	if (ret_len != len && ret_len != 0) {
		printf("%s: Error, py func returned %d items in %s, %d or none were expected.\n", __func__,
		       RNA_parameter_dynamic_length_get(&list, parm), "filter_neworder", len);
		/* Note: we cannot return here, we would let flt_data in inconsistent state... see T38356. */
		filter_neworder = NULL;
	}
	else {
		RNA_parameter_get(&list, parm, &ret2);
		filter_neworder = (int *)ret2;
	}

	/* We have to do some final checks and transforms... */
	{
		int i, filter_exclude = ui_list->filter_flag & UILST_FLT_EXCLUDE;
		if (filter_flags) {
			flt_data->items_filter_flags = MEM_mallocN(sizeof(int) * len, __func__);
			memcpy(flt_data->items_filter_flags, filter_flags, sizeof(int) * len);

			if (filter_neworder) {
				/* For sake of simplicity, py filtering is expected to filter all items, but we actually only want
				 * reordering data for shown items!
				 */
				int items_shown, shown_idx;
				int t_idx, t_ni, prev_ni;
				flt_data->items_shown = 0;
				for (i = 0, shown_idx = 0; i < len; i++) {
					if ((filter_flags[i] & UILST_FLT_ITEM) ^ filter_exclude) {
						filter_neworder[shown_idx++] = filter_neworder[i];
					}
				}
				items_shown = flt_data->items_shown = shown_idx;
				flt_data->items_filter_neworder = MEM_mallocN(sizeof(int) * items_shown, __func__);
				/* And now, bring back new indices into the [0, items_shown[ range!
				 * XXX This is O(N²)... :/
				 */
				for (shown_idx = 0, prev_ni = -1; shown_idx < items_shown; shown_idx++) {
					for (i = 0, t_ni = len, t_idx = -1; i < items_shown; i++) {
						int ni = filter_neworder[i];
						if (ni > prev_ni && ni < t_ni) {
							t_idx = i;
							t_ni = ni;
						}
					}
					if (t_idx >= 0) {
						prev_ni = t_ni;
						flt_data->items_filter_neworder[t_idx] = shown_idx;
					}
				}
			}
			else {
				/* we still have to set flt_data->items_shown... */
				flt_data->items_shown = 0;
				for (i = 0; i < len; i++) {
					if ((filter_flags[i] & UILST_FLT_ITEM) ^ filter_exclude) {
						flt_data->items_shown++;
					}
				}
			}
		}
		else {
			flt_data->items_shown = len;

			if (filter_neworder) {
				flt_data->items_filter_neworder = MEM_mallocN(sizeof(int) * len, __func__);
				memcpy(flt_data->items_filter_neworder, filter_neworder, sizeof(int) * len);
			}
		}
	}

	RNA_parameter_list_free(&list);
}