RNA
* Disable editable pointers for now, difficult to support well. * Swap parameters in RNA_access.h functions to make it more consistent. * Rename rna members for operators to wmOperatorType.srna, and wmOperator.ptr, to make the distincton a bit clearer. • Removed the RNA_int_default and similar functions, they're too confusing. RNA_property_is_set can still be used to achieve the same goal. * Add functions to create RNA pointers. Some example code for RNA data access and operator properties: http://wiki.blender.org/index.php/BlenderDev/Blender2.5/RNAExampleCode
This commit is contained in:
@@ -62,8 +62,8 @@ void wm_operator_free(wmOperator *op)
|
||||
op->properties= NULL;
|
||||
}
|
||||
|
||||
if(op->rna)
|
||||
MEM_freeN(op->rna);
|
||||
if(op->ptr)
|
||||
MEM_freeN(op->ptr);
|
||||
|
||||
MEM_freeN(op);
|
||||
}
|
||||
@@ -74,9 +74,9 @@ void wm_operator_register(wmWindowManager *wm, wmOperator *op)
|
||||
{
|
||||
int tot;
|
||||
|
||||
if(op->rna) {
|
||||
MEM_freeN(op->rna);
|
||||
op->rna= NULL;
|
||||
if(op->ptr) {
|
||||
MEM_freeN(op->ptr);
|
||||
op->ptr= NULL;
|
||||
}
|
||||
|
||||
BLI_addtail(&wm->operators, op);
|
||||
|
||||
@@ -299,9 +299,8 @@ int WM_operator_invoke(bContext *C, wmOperatorType *ot, wmEvent *event)
|
||||
|
||||
op->type= ot;
|
||||
|
||||
op->rna= MEM_callocN(sizeof(PointerRNA), "wmOperatorPtrRNA");
|
||||
op->rna->type= op->type->rna;
|
||||
op->rna->data= op;
|
||||
op->ptr= MEM_callocN(sizeof(PointerRNA), "wmOperatorPtrRNA");
|
||||
RNA_pointer_create(&RNA_WindowManager, &C->wm->id, ot->srna, op, op->ptr);
|
||||
|
||||
if(op->type->invoke)
|
||||
retval= (*op->type->invoke)(C, op, event);
|
||||
|
||||
@@ -74,9 +74,9 @@ void WM_operatortype_append(void (*opfunc)(wmOperatorType*))
|
||||
wmOperatorType *ot;
|
||||
|
||||
ot= MEM_callocN(sizeof(wmOperatorType), "operatortype");
|
||||
ot->rna= RNA_def_struct(&BLENDER_RNA, "", "Operator", "");
|
||||
ot->srna= RNA_def_struct(&BLENDER_RNA, "", "Operator", "");
|
||||
opfunc(ot);
|
||||
RNA_def_struct_identifier(ot->rna, ot->idname, ot->name);
|
||||
RNA_def_struct_identifier(ot->srna, ot->idname, ot->name);
|
||||
BLI_addtail(&global_ops, ot);
|
||||
}
|
||||
|
||||
@@ -159,12 +159,12 @@ static void border_select_apply(bContext *C, wmOperator *op, int event_type)
|
||||
rcti *rect= gesture->customdata;
|
||||
|
||||
/* operator arguments and storage. */
|
||||
RNA_int_default(op->rna, "xmin", rect->xmin);
|
||||
RNA_int_default(op->rna, "ymin", rect->ymin);
|
||||
RNA_int_default(op->rna, "xmax", rect->xmax);
|
||||
RNA_int_default(op->rna, "ymax", rect->ymax);
|
||||
RNA_int_set(op->ptr, "xmin", rect->xmin);
|
||||
RNA_int_set(op->ptr, "ymin", rect->ymin);
|
||||
RNA_int_set(op->ptr, "xmax", rect->xmax);
|
||||
RNA_int_set(op->ptr, "ymax", rect->ymax);
|
||||
|
||||
RNA_int_default(op->rna, "event_type", event_type);
|
||||
RNA_int_set(op->ptr, "event_type", event_type);
|
||||
|
||||
op->type->exec(C, op);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user