henesyinit from p9f47575dc5 years agoHistory
180 lines · 3.5 KB · C
RawDownload
#include <u.h>#include <libc.h>#include "system.h"#ifdef Plan9#include <libg.h>#endif# include "stdio.h"# include "defines.h"# include "object.h"# include "dict.h"#include "njerq.h"#include "cache.h" struct	objectmakestring(int length){	struct	object	object ; 	object.type = OB_STRING ;	object.xattr = XA_LITERAL ;	if ( length < 0 )		pserror("rangecheck", "makestring size<0") ;	if ( length > STRING_LIMIT ){		fprintf(stderr,"length=%d\n",length);		pserror("rangecheck", "makestring too long") ;	}	object.value.v_string.access = AC_UNLIMITED ;	object.value.v_string.length = length ;	object.value.v_string.chars = (unsigned char *)vm_alloc(length) ;	return(object) ;} struct	objectmakereal(double real){	struct	object	object ; 	object.type = OB_REAL ;	object.xattr = XA_LITERAL ;	object.value.v_real = real ;	return(object) ;} struct	objectmakeint(int integer){	struct	object	object ; 	object.type = OB_INT ;	object.xattr = XA_LITERAL ;	object.value.v_int = integer ;	return(object) ;} struct	objectmakepointer(char *p){	struct	object	object ; 	object.type = OB_NONE ;	object.xattr = XA_LITERAL ;	object.value.v_pointer = p ;	return(object) ;} struct	objectmakesave(int level, struct namelist *namelist, char *cur_mem){	struct	object	object ; 	object.type = OB_SAVE ;	object.xattr = XA_LITERAL ;	object.value.v_save = (struct save *)vm_alloc(sizeof(*object.value.v_save)) ;	object.value.v_save->level = level ;	object.value.v_save->namelist = namelist ;	object.value.v_save->cur_mem = cur_mem ;	return(object) ;} struct	objectmakebool(enum bool bool){	struct	object	object ; 	object.type = OB_BOOLEAN ;	object.xattr = XA_LITERAL ;	object.value.v_boolean = bool ;	return(object) ;} struct	objectmakenull(void){	struct	object	object ; 	object.type = OB_NULL ;	object.xattr = XA_LITERAL ;	return(object) ;}  struct	objectmakenone(void){	struct	object	object ; 	object.type = OB_NONE ;	object.xattr = XA_LITERAL ;	return(object) ;} struct	objectmakearray(int length, enum xattr xattr){	struct	object	array ; 	array.type = OB_ARRAY ;	array.xattr = xattr ;	if ( length < 0 )		pserror("rangecheck", "makearray <0") ;	if ( length > ARRAY_LIMIT )		pserror("rangecheck", "makearray too big") ;	array.value.v_array.access = AC_UNLIMITED ;	array.value.v_array.length = length ;	array.value.v_array.object = (struct object *)vm_alloc(length*sizeof(*array.value.v_array.object)) ;	return(array) ;} struct	objectmakedict(int max){	struct	object	dict ; 	dict.type = OB_DICTIONARY ;	dict.xattr = XA_LITERAL ;	if ( max < 0 )		pserror("rangecheck", "makedict <0") ;	if ( max > DICTIONARY_LIMIT )		pserror("rangecheck", "makedict too big") ;	dict.value.v_dict = (struct dict *)vm_alloc(sizeof(*dict.value.v_dict)) ;	dict.value.v_dict->access = AC_UNLIMITED ;	dict.value.v_dict->cur = 0 ;	dict.value.v_dict->max = max ;	dict.value.v_dict->dictent = (struct dictent *)vm_alloc(max*sizeof(*dict.value.v_dict->dictent)) ;	return(dict) ;} struct	objectmakefile(FILE *fp, enum access access, enum xattr xattr){	struct	object	object ; 	object.type = OB_FILE ;	object.xattr = xattr ;	object.value.v_file.access = access ;	object.value.v_file.fp = fp ;	return(object) ;} struct	objectmakeoperator(void (*op)(void)){	struct	object	object ; 	object.type = OB_OPERATOR ;	object.xattr = XA_EXECUTABLE ;	object.value.v_operator = op ;	return(object) ;} struct	objectmakefid(void){	struct	object	object ; 	object.type = OB_FONTID ;	object.xattr = XA_LITERAL ;	object.value.v_fontid.fontno = Fonts++;	return(object) ;}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t