예제 #1
0
파일: outline.c 프로젝트: GNOME/dia
/*! Factory function - create default object */
static DiaObject *
outline_create (Point *startpoint,
		void *user_data,
		Handle **handle1,
		Handle **handle2)
{
  Outline *outline;
  DiaObject *obj;

  outline = g_new0 (Outline,1);
  obj = &outline->object;
  obj->type = &outline_type;
  obj->ops = &outline_ops;

  object_init (obj, NUM_HANDLES, 0);
  obj->position = *startpoint;

  outline_init_handles (outline);

  attributes_get_default_font (&outline->font, &outline->font_height);

  outline->line_width = 0; /* Not: attributes_get_default_linewidth(); it looks ugly */
  outline->line_color = attributes_get_foreground();
  outline->fill_color = attributes_get_background();
  outline->show_background = FALSE;
  outline->name = g_strdup ("?");
  outline->rotation = 0;

  *handle1 = outline->object.handles[0];
  *handle2 = outline->object.handles[1];

  outline_update_data (outline);

  return obj;
}
예제 #2
0
파일: mcall.zep.c 프로젝트: cluo/zephir
PHP_METHOD(Test_Mcall, testMethod7) {


	object_init(return_value);
	return;

}
예제 #3
0
파일: exec.c 프로젝트: flijten/saffire
static int do_exec(void) {
    char *source_file = saffire_getopt_string(0);

    setlocale(LC_ALL,"");
    context_init();
    object_init();
    module_init();

    t_ast_element *ast = ast_generate_from_file(source_file);

    if (dot_file) {
        dot_generate(ast, dot_file);
    }

    int ret = interpreter(ast);

    // Release memory of ast root
    if (ast != NULL) {
        ast_free_node(ast);
    }

    module_fini();
    object_fini();
    context_fini();

    return ret;
}
예제 #4
0
파일: queue.c 프로젝트: ccl2of4/C-Utilities
void
queue_init (queue_ref _self) {
	struct queue *self = _self;
	object_init (self);
	((struct object *)self)->object_dealloc = _object_dealloc__queue;
	self->list = list_create ();
}
예제 #5
0
void
polyconn_init(PolyConn *poly)
{
  Object *obj;

  obj = &poly->object;

  object_init(obj, 2, 0);
  
  poly->numpoints = 2;

  poly->points = g_malloc(2*sizeof(Point));

  poly->object.handles[0] = g_malloc(sizeof(Handle));
  poly->object.handles[1] = g_malloc(sizeof(Handle));

  obj->handles[0]->connect_type = HANDLE_CONNECTABLE;
  obj->handles[0]->connected_to = NULL;
  obj->handles[0]->type = HANDLE_MAJOR_CONTROL;
  obj->handles[0]->id = HANDLE_MOVE_STARTPOINT;
  
  obj->handles[1]->connect_type = HANDLE_CONNECTABLE;
  obj->handles[1]->connected_to = NULL;
  obj->handles[1]->type = HANDLE_MAJOR_CONTROL;
  obj->handles[1]->id = HANDLE_MOVE_ENDPOINT;

  polyconn_update_data(poly);
}
예제 #6
0
파일: light.c 프로젝트: tallendev/Raytracer
/*
 * Initializes an obj_t struct, and then a light_t struct to store inside of
 * the private data of the obj_t.
 *
 * Param: in   The stream to read in struct information from.
 * Param: objtype   The type of the object being created.
 *
 * Return: obj   The object that was just constructed and initialized.
 */
obj_t* light_init(FILE* in, int objtype)
{
    char buff[BUFF_SIZE];
    obj_t* obj = NULL;
    int pcount = 0;
    obj = object_init(in, objtype);
    light_t* light = Malloc(sizeof(light_t));
    pcount += fscanf(in, "%lf %lf %lf",
                     &(light->emissivity[X]),
                     &(light->emissivity[Y]),
                     &(light->emissivity[Z]));
    fgets(buff, BUFF_SIZE, in);
    pcount += fscanf(in, "%lf %lf %lf",
                     &(light->location[X]),
                     &(light->location[Y]),
                     &(light->location[Z]));
    fgets(buff, BUFF_SIZE, in);
    if (pcount != LIGHT_OBJS || obj == NULL)
    {
        fprintf(stderr, "Error found in light_init...");
        obj = NULL;
    }
    else
    {
        obj->priv = (void*)light;
        light->getemiss = default_getemiss;
        light->illum_check = NULL;
    }
    return obj;
}
예제 #7
0
파일: world.c 프로젝트: kaye64/gem
/**
 * Initializes a sector from a sector_t
 */
world_sector_t* sector_create(sector_t sector)
{
	world_sector_t* world_sector = (world_sector_t*)malloc(sizeof(world_sector_t));
	world_sector->sector = sector;
	object_init(list, &world_sector->players);
	return world_sector;
}
예제 #8
0
파일: poly_conn.c 프로젝트: AmiGanguli/dia
void
polyconn_init(PolyConn *poly, int num_points)
{
  DiaObject *obj;
  int i;

  obj = &poly->object;

  object_init(obj, num_points, 0);
  
  poly->numpoints = num_points;

  poly->points = g_malloc(num_points*sizeof(Point));

  for (i=0;i<num_points;i++) {
    obj->handles[i] = g_malloc(sizeof(Handle));
    if (0 == i)
      setup_handle(obj->handles[i], PC_HANDLE_START);
    else if (i == num_points-1)
      setup_handle(obj->handles[i], PC_HANDLE_END);
    else
      setup_handle(obj->handles[i], PC_HANDLE_CORNER);
  }

  polyconn_update_data(poly);
}
예제 #9
0
/**
 * @brief This function assigns a new client container
 * @return New http_client_t container pointer
 */
http_client_t * initClientContainer()
{
    http_client_t *client_container;
    client_container = object_init(sizeof(http_client_t));
    client_container->addr = object_ninit(sizeof(struct sockaddr_in));
    client_container->sockfd = 0;
    return client_container;
}
예제 #10
0
파일: buffer.c 프로젝트: kaye64/gem
/**
 * Initializes a new buffer
 */
static void buffer_init(buffer_t* buffer)
{
	buffer->data = (unsigned char*)malloc(sizeof(unsigned char)*DEFAULT_BUFFER_SIZE);
	buffer->real_size = DEFAULT_BUFFER_SIZE;
	buffer->read_ptr = 0;
	buffer->read_avail = 0;
	object_init(int_stack, &buffer->ptr_stack);
}
예제 #11
0
파일: oper.c 프로젝트: gerrit-rws/shalture
void _modinit(module_t *m)
{
	MODULE_TRY_REQUEST_SYMBOL(m, exttarget_tree, "exttarget/main", "exttarget_tree");

	mowgli_patricia_add(*exttarget_tree, "oper", oper_validate_f);

	object_init(object(&dummy_entity), "$oper", NULL);
}
예제 #12
0
파일: server.c 프로젝트: kaye64/gem
/**
 * Initializes a new server
 */
static void server_init(server_t* server)
{
	server->fd = -1;
	server->buf_size = DEFAULT_BUFFER_SIZE;
	server->io_loop = 0;
	server->buffer = NULL;
	object_init(list, &server->client_list);
}
예제 #13
0
파일: server.c 프로젝트: kaye64/gem
/**
 * Initializes a client
 *  - fd: The file descriptor of the client
 *  - addr: The address of the client
 */
client_t* server_client_init(server_t* server, int fd, struct in_addr addr)
{
	client_t* client = server->accept_cb(fd, addr, server);
	if (client == NULL) {
		return NULL;
	}
	client->fd = fd;
	client->addr = addr;
	client->server = server;
	client->handshake_stage = HANDSHAKE_PENDING;
	client->client_drop = false;
	object_init(buffer, &client->read_buffer);
	object_init(buffer, &client->write_buffer);
	buffer_realloc(&client->read_buffer, server->buf_size);
	buffer_realloc(&client->write_buffer, server->buf_size);
	return client;
}
예제 #14
0
/**
 * Initialize an infinite plane.
 * Initializes the underlying object structure and calculates the transformed
 * bounding box.
 */
void plane_init(struct object *o, const struct transform *t){
	object_init(o, t);

	get_bounding_box(t, &(o->boundingBox));

	o->get_intersection = get_intersection;
	o->get_normal = get_normal;
}
예제 #15
0
/** Create a new semaphore.
 * @param name		Optional name for the semaphore, for debugging purposes.
 * @param count		Initial count of the semaphore.
 * @param security	Security attributes for the ACL. If NULL, default
 *			attributes will be constructed which grant full access
 *			to the semaphore to the calling process' user.
 * @param rights	Access rights for the handle.
 * @param handlep	Where to store handle to the semaphore.
 * @return		Status code describing result of the operation. */
status_t kern_semaphore_create(const char *name, size_t count,
	const object_security_t *security, object_rights_t rights,
	handle_t *handlep)
{
	object_security_t ksecurity = { -1, -1, NULL };
	user_semaphore_t *sem;
	status_t ret;

	if(!handlep)
		return STATUS_INVALID_ARG;

	if(security) {
		ret = object_security_from_user(&ksecurity, security, true);
		if(ret != STATUS_SUCCESS)
			return ret;
	}

	/* Construct a default ACL if required. */
	if(!ksecurity.acl) {
		ksecurity.acl = kmalloc(sizeof(*ksecurity.acl), MM_WAIT);
		object_acl_init(ksecurity.acl);
		object_acl_add_entry(ksecurity.acl, ACL_ENTRY_USER, -1, SEMAPHORE_RIGHT_USAGE);
	}

	sem = kmalloc(sizeof(user_semaphore_t), MM_WAIT);
	sem->id = id_allocator_alloc(&semaphore_id_allocator);
	if(sem->id < 0) {
		kfree(sem);
		object_security_destroy(&ksecurity);
		return STATUS_NO_SEMAPHORES;
	}
	if(name) {
		ret = strndup_from_user(name, SEMAPHORE_NAME_MAX, &sem->name);
		if(ret != STATUS_SUCCESS) {
			id_allocator_free(&semaphore_id_allocator, sem->id);
			kfree(sem);
			object_security_destroy(&ksecurity);
			return ret;
		}
	} else {
		sem->name = NULL;
	}

	object_init(&sem->obj, &semaphore_object_type, &ksecurity, NULL);
	object_security_destroy(&ksecurity);
	semaphore_init(&sem->sem, (sem->name) ? sem->name : "user_semaphore", count);
	refcount_set(&sem->count, 1);

	rwlock_write_lock(&semaphore_tree_lock);
	avl_tree_insert(&semaphore_tree, &sem->tree_link, sem->id, sem);
	rwlock_unlock(&semaphore_tree_lock);

	ret = object_handle_create(&sem->obj, NULL, rights, NULL, 0, NULL, NULL, handlep);
	if(ret != STATUS_SUCCESS)
		user_semaphore_release(sem);

	return ret;
}
예제 #16
0
void generic_trans_init(GenericTrans_ptr self, const TransType trans_type)
{
  object_init(OBJECT(self));

  self->_type = trans_type;

  OVERRIDE(Object, finalize)   = generic_trans_finalize;
  OVERRIDE(Object, copy)       = generic_trans_copy;
}
예제 #17
0
PHP_METHOD(Test_UseTest, createInstance) {

	ZEPHIR_INIT_THIS();


	object_init(return_value);
	return;

}
예제 #18
0
파일: pool.c 프로젝트: rcpsec/cphalcon
/**
 * Sets the default descriptor for database connections.
 *
 *
 *
 * @param array $options
 * @return boolean
 */
PHP_METHOD(Phalcon_Db_Pool, setDefaultDescriptor){

	zval *options = NULL, *descriptor = NULL, *value = NULL, *key = NULL;
	zval *i0 = NULL;
	HashTable *ah0;
	HashPosition hp0;
	zval **hd;
	char *hash_index;
	uint hash_index_len;
	ulong hash_num;
	int hash_type;

	PHALCON_MM_GROW();
	
	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &options) == FAILURE) {
		PHALCON_MM_RESTORE();
		RETURN_NULL();
	}

	if (Z_TYPE_P(options) != IS_ARRAY) { 
		if (Z_TYPE_P(options) != IS_OBJECT) {
			PHALCON_THROW_EXCEPTION_STR(phalcon_db_exception_ce, "The parameter 'options' must be an Array or Object");
			return;
		}
	}
	if (Z_TYPE_P(options) == IS_ARRAY) { 
		PHALCON_ALLOC_ZVAL_MM(i0);
		object_init(i0);
		PHALCON_CPY_WRT(descriptor, i0);
		if (phalcon_valid_foreach(options TSRMLS_CC)) {
			ah0 = Z_ARRVAL_P(options);
			zend_hash_internal_pointer_reset_ex(ah0, &hp0);
			fes_162f_0:
			if(zend_hash_get_current_data_ex(ah0, (void**) &hd, &hp0) != SUCCESS){
				goto fee_162f_0;
			} else {
				PHALCON_INIT_VAR(key);
				PHALCON_GET_FOREACH_KEY(key, ah0, hp0);
			}
			PHALCON_INIT_VAR(value);
			ZVAL_ZVAL(value, *hd, 1, 0);
			phalcon_update_property_zval_zval(descriptor, key, value TSRMLS_CC);
			zend_hash_move_forward_ex(ah0, &hp0);
			goto fes_162f_0;
			fee_162f_0:
			if(0){}
		} else {
			return;
		}
	} else {
		PHALCON_CPY_WRT(descriptor, options);
	}
	
	phalcon_update_static_property(SL("Phalcon_Db_Pool"), SL("_defaultDescriptor"), descriptor TSRMLS_CC);
	
	PHALCON_MM_RESTORE();
}
예제 #19
0
Object *object_create_as_int(int init_value, heap_info *heap) {
	Object *obj = object_create(heap);
	int *new_int = (int*)heap_alloc(heap, sizeof(int));
	*new_int = init_value;

	object_init(obj, &Class_Int, new_int, heap, true);

	return obj;
}
예제 #20
0
파일: imap_circle.c 프로젝트: Minoos/gimp
Object_t*
create_circle(gint x, gint y, gint r)
{
   Circle_t *circle = g_new(Circle_t, 1);
   circle->x = x;
   circle->y = y;
   circle->r = r;
   return object_init(&circle->obj, &circle_class);
}
예제 #21
0
파일: textobj.c 프로젝트: jbohren-forks/dia
static DiaObject *
textobj_load(ObjectNode obj_node, int version, DiaContext *ctx)
{
  Textobj *textobj;
  DiaObject *obj;
  AttributeNode attr;
  Point startpoint = {0.0, 0.0};

  textobj = g_malloc0(sizeof(Textobj));
  obj = &textobj->object;
  
  obj->type = &textobj_type;
  obj->ops = &textobj_ops;

  object_load(obj, obj_node, ctx);

  attr = object_find_attribute(obj_node, "text");
  if (attr != NULL) {
    textobj->text = data_text(attribute_first_data(attr), ctx);
  } else {
    DiaFont* font = dia_font_new_from_style(DIA_FONT_MONOSPACE,1.0);
    textobj->text = new_text("", font, 1.0,
			     &startpoint, &color_black, ALIGN_CENTER);
    dia_font_unref(font);
  }

  attr = object_find_attribute(obj_node, "valign");
  if (attr != NULL)
    textobj->vert_align = data_enum(attribute_first_data(attr), ctx);
  else if (version == 0) {
    textobj->vert_align = VALIGN_FIRST_LINE;
  }

  /* default visibility must be off to keep compatibility */
  textobj->fill_color = attributes_get_background();
  attr = object_find_attribute(obj_node, "fill_color");
  if (attr)
    data_color(attribute_first_data(attr), &textobj->fill_color, ctx);
  attr = object_find_attribute(obj_node, "show_background");
  if (attr)
    textobj->show_background = data_boolean(attribute_first_data(attr), ctx);
  else
    textobj->show_background = FALSE;

  object_init(obj, 1, 0);

  obj->handles[0] = &textobj->text_handle;
  textobj->text_handle.id = HANDLE_TEXT;
  textobj->text_handle.type = HANDLE_MAJOR_CONTROL;
  textobj->text_handle.connect_type = HANDLE_CONNECTABLE;
  textobj->text_handle.connected_to = NULL;

  textobj_update_data(textobj);

  return &textobj->object;
}
예제 #22
0
Object_t*
create_rectangle(gint x, gint y, gint width, gint height)
{
   Rectangle_t *rectangle = g_new(Rectangle_t, 1);
   rectangle->x = x;
   rectangle->y = y;
   rectangle->width = width;
   rectangle->height = height;
   return object_init(&rectangle->obj, &rectangle_class);
}
예제 #23
0
파일: main.c 프로젝트: AdamRLukaitis/prex
/*
 * Initialization code.
 *
 * Called from kernel_start() routine that is
 * implemented in HAL.
 * We assume that the following machine state has
 * been already set before this routine.
 *	- Kernel BSS section is filled with 0.
 *	- Kernel stack is configured.
 *	- All interrupts are disabled.
 *	- Minimum page table is set. (MMU systems only)
 */
int
main(void)
{

	sched_lock();
	diag_init();
	DPRINTF((BANNER));

	/*
	 * Initialize memory managers.
	 */
	page_init();
	kmem_init();

	/*
	 * Do machine-dependent
	 * initialization.
	 */
	machine_startup();

	/*
	 * Initialize kernel core.
	 */
	vm_init();
	task_init();
	thread_init();
	sched_init();
	exception_init();
	timer_init();
	object_init();
	msg_init();

	/*
	 * Enable interrupt and
	 * initialize devices.
	 */
	irq_init();
	clock_init();
	device_init();

	/*
	 * Set up boot tasks.
	 */
	task_bootstrap();

	/*
	 * Start scheduler and
	 * enter idle loop.
	 */
	sched_unlock();
	thread_idle();

	/* NOTREACHED */
	return 0;
}
예제 #24
0
PHP_METHOD(Test_Oo, testInstance1) {

	zval *o;

	ZEPHIR_MM_GROW();

	ZEPHIR_INIT_VAR(o);
	object_init(o);
	RETURN_CCTOR(o);

}
예제 #25
0
파일: server.c 프로젝트: kaye64/gem
/**
 * Configures a server
 */
void server_config(server_t* server, const char* addr, int port, uint8_t flags)
{
	strcpy(server->addr, addr);
	server->port = port;
	server->fd = -1;
	server->buf_size = DEFAULT_BUFFER_SIZE;
	server->buffer = (unsigned char*)malloc(server->buf_size);
	server->io_loop = 0;
	server->flags = flags;
	object_init(list, &server->client_list);
}
예제 #26
0
PHP_METHOD(Test_Instanceoff, testInstanceOf1) {

	zval *a;

	ZEPHIR_MM_GROW();

	ZEPHIR_INIT_VAR(a);
	object_init(a);
	RETURN_MM_BOOL(zephir_instance_of_ev(a, zend_standard_class_def TSRMLS_CC));

}
예제 #27
0
PHP_METHOD(Test_Instanceoff, testInstanceOf3) {

	zval *a;

	ZEPHIR_MM_GROW();

	ZEPHIR_INIT_VAR(a);
	object_init(a);
	RETURN_MM_BOOL(zephir_instance_of_ev(a, test_unknownclass_ce TSRMLS_CC));

}
예제 #28
0
static void
SWIG_ZTS_SetPointerZval(zval *z, void *ptr, swig_type_info *type, int newobject TSRMLS_DC) {
  swig_object_wrapper *value=NULL;
  /*
   * First test for Null pointers.  Return those as PHP native NULL
   */
  if (!ptr ) {
    ZVAL_NULL(z);
    return;
  }
  if (type->clientdata) {
    if (! (*(int *)(type->clientdata)))
      zend_error(E_ERROR, "Type: %s failed to register with zend",type->name);
    value=(swig_object_wrapper *)emalloc(sizeof(swig_object_wrapper));
    value->ptr=ptr;
    value->newobject=newobject;
    if (newobject <= 1) {
      /* Just register the pointer as a resource. */
      ZEND_REGISTER_RESOURCE(z, value, *(int *)(type->clientdata));
    } else {
      /*
       * Wrap the resource in an object, the resource will be accessible
       * via the "_cPtr" member. This is currently only used by
       * directorin typemaps.
       */
      value->newobject = 0;
      zval *resource;
      MAKE_STD_ZVAL(resource);
      ZEND_REGISTER_RESOURCE(resource, value, *(int *)(type->clientdata));
      zend_class_entry **ce = NULL;
      zval *classname;
      MAKE_STD_ZVAL(classname);
      /* _p_Foo -> Foo */
      ZVAL_STRING(classname, (char*)type->name+3, 1);
      /* class names are stored in lowercase */
      php_strtolower(Z_STRVAL_PP(&classname), Z_STRLEN_PP(&classname));
      if (zend_lookup_class(Z_STRVAL_P(classname), Z_STRLEN_P(classname), &ce TSRMLS_CC) != SUCCESS) {
        /* class does not exist */
        object_init(z);
      } else {
        object_init_ex(z, *ce);
      }
      Z_SET_REFCOUNT_P(z, 1);
      Z_SET_ISREF_P(z);
      zend_hash_update(HASH_OF(z), (char*)"_cPtr", sizeof("_cPtr"), (void*)&resource, sizeof(zval), NULL);
      FREE_ZVAL(classname);
    }
    return;
  }
  zend_error(E_ERROR, "Type: %s not registered with zend",type->name);
}
예제 #29
0
파일: textobj.c 프로젝트: GNOME/dia
static DiaObject *
textobj_create(Point *startpoint,
	       void *user_data,
	       Handle **handle1,
	       Handle **handle2)
{
  Textobj *textobj;
  DiaObject *obj;
  Color col;
  DiaFont *font = NULL;
  real font_height;

  textobj = g_malloc0(sizeof(Textobj));
  obj = &textobj->object;
  obj->enclosing_box = g_new0 (Rectangle, 1);

  obj->type = &textobj_type;

  obj->ops = &textobj_ops;

  col = attributes_get_foreground();
  attributes_get_default_font(&font, &font_height);
  textobj->text = new_text("", font, font_height,
			   startpoint, &col, default_properties.alignment );
  /* need to initialize to object.position as well, it is used update data */
  obj->position = *startpoint;

  dia_font_unref(font);
  textobj->vert_align = default_properties.vert_align;

  /* default visibility must be off to keep compatibility */
  textobj->fill_color = attributes_get_background();
  textobj->show_background = FALSE;

  object_init(obj, 1, 0);

  obj->handles[0] = &textobj->text_handle;
  textobj->text_handle.id = HANDLE_TEXT;
  textobj->text_handle.type = HANDLE_MAJOR_CONTROL;
  textobj->text_handle.connect_type = HANDLE_CONNECTABLE;
  textobj->text_handle.connected_to = NULL;
  /* no margin till Dia 0.98 */
  textobj->margin = 0.0;

  textobj_update_data(textobj);

  *handle1 = NULL;
  *handle2 = obj->handles[0];
  return &textobj->object;
}
예제 #30
0
파일: compound.c 프로젝트: brunetton/dia
static DiaObject *
compound_create (Point * start_point, void * user_data,
                 Handle **handle1, Handle **handle2)
{
  Compound * comp;
  DiaObject * obj;
  Handle * handle;
  gint num_handles;
  gint i;

  comp = g_new0 (Compound, 1);
  obj = &comp->object;

  obj->type = &compound_type;
  obj->ops = &compound_ops;

  comp->num_arms = DEFAULT_NUMARMS;
  comp->line_width = attributes_get_default_linewidth ();
  comp->line_color = attributes_get_foreground ();
  /* init our mount-point */
  setup_mount_point (&comp->mount_point, obj, start_point);

  num_handles = comp->num_arms + 1;
  /* init the inherited object */
  object_init (obj, num_handles, 1);
  obj->connections[0] = &comp->mount_point;

  comp->handles = g_new0 (Handle, num_handles);
  /* init the handle on the mount-point */
  obj->handles[0] = &comp->handles[0];
  setup_handle (obj->handles[0], HANDLE_MOUNT_POINT,
                HANDLE_MAJOR_CONTROL, HANDLE_NONCONNECTABLE);
  /* now init the rest of the handles */
  for (i = 1; i < num_handles; i++)
    {
      handle = &comp->handles[i];
      obj->handles[i] = handle;
      setup_handle (handle, HANDLE_ARM,
                    HANDLE_MINOR_CONTROL, HANDLE_CONNECTABLE_NOBREAK);
    }
  init_default_handle_positions (comp);

  compound_update_data (comp);
  compound_sanity_check (comp, "Created");

  *handle1 = &comp->handles[0];
  *handle2 = &comp->handles[1];

  return &comp->object;
}