⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 g_array.c

📁 c语言是面向过程的程序语言
💻 C
字号:
/* ****************************** * Object Oriented Programming in C * * Author: Laurent Deniau, Laurent.Deniau@cern.ch * * For more information, please see the paper: * http://home.cern.ch/ldeniau/html/oopc/oopc.html * ****************************** *//*----------------------------------*//*   Generic array implementation   *//*      inherit from memBlock       *//*----------------------------------*/#define IMPLEMENTATION#include <g_array.h>/* simplify reading */#define  MEMBLOCK  GENERIC(memBlock)#define _MEMBLOCK  GENERIC_DTOR(memBlock)/*  Object implementation*/gType1methodDecl(*getData){  return this->m.data;}voidmethodDecl_(startAt) int i __{  this->m.data = MEMBLOCK.base(super(this,MEMBLOCK)) - i;}voidmethodDecl_(set) size_t i, gType1 x __{  /* should throw an exception 'out of range' if we store the size */  this->m.data[i] = x;}gType1constMethodDecl_(get) size_t i __{  /* should throw an exception 'out of range' if we store the size */  return this->m.data[i];}OBJECT_IMPLEMENTATION  SUPERCLASS(MEMBLOCK),  methodName(getData),  methodName(startAt),  methodName(set),  methodName(get)ENDOF_IMPLEMENTATION/*  Class implementation*/initClassDecl() /* required */{  initSuper(MEMBLOCK);}dtorDecl() /* required */{  MEMBLOCK._MEMBLOCK(super(this,MEMBLOCK));  this->m.data = NULL;}t_OBJECTclassMethodDecl_(*const new) size_t n __{  t_OBJECT *const this = OBJECT.alloc();  if (this) OBJECT.init(this, n);  return this;}t_OBJECTclassMethodDecl_(*const newRef) gType1 *const t __{  t_OBJECT *const this = OBJECT.alloc();  if (this) OBJECT.initRef(this, t);  return this;}voidmethodDecl_(init) size_t n __{  MEMBLOCK.init(super(this,MEMBLOCK), n);  this->m.data = MEMBLOCK.base(super(this,MEMBLOCK));}voidmethodDecl_(initRef) gType1 *const t __{  MEMBLOCK.initRef(super(this,MEMBLOCK), t);  this->m.data = MEMBLOCK.base(super(this,MEMBLOCK));}CLASS_IMPLEMENTATION  methodName(new),  methodName(newRef),  methodName(init),  methodName(initRef),ENDOF_IMPLEMENTATION

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -