add object_create_ex

This commit is contained in:
lixianjing 2021-09-26 12:15:22 +08:00
parent ceb88998f1
commit 55debc5b0a
3 changed files with 35 additions and 1 deletions

View File

@ -1,5 +1,8 @@
# 最新动态
2021/09/25
* 增加object\_create\_ex
2021/09/24
* 完善文档[渐变色](gradient.md)(感谢雨欣提供补丁)

View File

@ -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);

View File

@ -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
*