mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-12-02 03:58:33 +08:00
add object_create_ex
This commit is contained in:
parent
ceb88998f1
commit
55debc5b0a
@ -1,5 +1,8 @@
|
||||
# 最新动态
|
||||
|
||||
2021/09/25
|
||||
* 增加object\_create\_ex
|
||||
|
||||
2021/09/24
|
||||
* 完善文档[渐变色](gradient.md)(感谢雨欣提供补丁)
|
||||
|
||||
|
@ -54,6 +54,24 @@ static ret_t object_destroy(object_t* obj) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
object_t* object_create_ex(const object_vtable_t* vt, uint32_t extra_data_size) {
|
||||
uint32_t size = 0;
|
||||
object_t* obj = NULL;
|
||||
return_value_if_fail(vt != NULL && vt->size >= sizeof(object_t), NULL);
|
||||
|
||||
size = vt->size + extra_data_size;
|
||||
obj = (object_t*)TKMEM_ALLOC(size);
|
||||
return_value_if_fail(obj != NULL, NULL);
|
||||
|
||||
memset(obj, 0x00, size);
|
||||
|
||||
obj->vt = vt;
|
||||
obj->ref_count = 1;
|
||||
emitter_init((emitter_t*)obj);
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
object_t* object_create(const object_vtable_t* vt) {
|
||||
object_t* obj = NULL;
|
||||
return_value_if_fail(vt != NULL && vt->size >= sizeof(object_t), NULL);
|
||||
|
@ -130,10 +130,23 @@ object_t* object_clone(object_t* obj);
|
||||
*
|
||||
* @param {const object_vtable_t*} vt 虚函数表。
|
||||
*
|
||||
* @return {ret_t} 返回object对象。
|
||||
* @return {object_t*} 返回object对象。
|
||||
*/
|
||||
object_t* object_create(const object_vtable_t* vt);
|
||||
|
||||
/**
|
||||
* @method object_create_ex
|
||||
* 创建对象。
|
||||
*
|
||||
* > 仅供子类调用。
|
||||
*
|
||||
* @param {const object_vtable_t*} vt 虚函数表。
|
||||
* @param {uint32_t} extra_data_size 额外的内存大小。
|
||||
*
|
||||
* @return {object_t*} 返回object对象。
|
||||
*/
|
||||
object_t* object_create_ex(const object_vtable_t* vt, uint32_t extra_data_size);
|
||||
|
||||
/**
|
||||
* @method object_get_type
|
||||
* 获取对象的类型名称。
|
||||
|
Loading…
Reference in New Issue
Block a user