Example #1
0
DaoValue* DaoObject_GetField( DaoObject *self, const char *name )
{
	DaoValue *res = NULL;
	DString str = DString_WrapChars( name );
	DaoObject_GetData( self, & str, & res, self );
	return res;
}
Example #2
0
static void DaoStream_ReadLines( DaoStream *self, DaoList *list, DaoProcess *proc, int count, int chop )
{
	DaoValue *res;
	DaoString *line;
	DaoVmCode *sect = DaoProcess_InitCodeSection( proc, 1 );
	daoint i = 0;

	if( sect == NULL ){
		line = DaoString_New();
		while( (count == 0 || (i++) < count) && DaoStream_ReadLine( self, line->value ) ){
			if( line->value->size == 0 && self->AtEnd != NULL && self->AtEnd( self ) ) break;
			if( chop ) DString_Chop( line->value, 0 );
			DaoList_Append( list, (DaoValue*) line );
		}
		DaoString_Delete( line );
	}else{
		ushort_t entry = proc->topFrame->entry;
		if( sect->b ){
			DaoString tmp = {DAO_STRING,0,0,0,1,NULL};
			DString tmp2 = DString_WrapChars( "" );
			tmp.value = & tmp2;
			line = (DaoString*) DaoProcess_SetValue( proc, sect->a, (DaoValue*)(void*) &tmp );
		}
		while( (count == 0 || (i++) < count) && DaoStream_ReadLine( self, line->value ) ){
			if( line->value->size == 0 && self->AtEnd != NULL && self->AtEnd( self ) ) break;
			if( chop ) DString_Chop( line->value, 0 );
			proc->topFrame->entry = entry;
			DaoProcess_Execute( proc );
			if( proc->status == DAO_PROCESS_ABORTED ) break;
			res = proc->stackValues[0];
			if( res && res->type != DAO_NONE ) DaoList_Append( list, res );
		}
		DaoProcess_PopFrame( proc );
	}
}
Example #3
0
DaoRoutine* DaoObject_GetMethod( DaoObject *self, const char *name )
{
	DaoValue *V;
	DString str = DString_WrapChars( name );
	int id = DaoClass_FindConst( self->defClass, & str );
	if( id < 0 ) return NULL;
	V = DaoClass_GetConst( self->defClass, id );
	if( V == NULL || V->type != DAO_ROUTINE ) return NULL;
	return (DaoRoutine*) V;
}
Example #4
0
FILE* Dao_OpenFile( const char *file, const char *mode )
{
#if _WIN32
	DString file2 = DString_WrapChars( file );
	DString mode2 = DString_WrapChars( mode );
	DArray *file3 = DArray_New( sizeof(wchar_t) );
	DArray *mode3 = DArray_New( sizeof(wchar_t) );
	int ret1 = DString_DecodeUTF8( & file2, file3 );
	int ret2 = DString_DecodeUTF8( & mode2, mode3 );
	if( ret1 && ret2 ){
		FILE *pfile = _wfopen( file3->data.wchars, mode3->data.wchars );
		DArray_Delete( file3 );
		DArray_Delete( mode3 );
		return pfile;
	}
	DArray_Delete( file3 );
	DArray_Delete( mode3 );
#endif
	return fopen( file, mode );
}
Example #5
0
void DaoxShader_AddShader( DaoxShader *self, int type, const char *codes )
{
	DString source = DString_WrapChars( codes );
	switch( type ){
	case GL_VERTEX_SHADER :
		DArray_Append( self->vertexSources, & source );
		break;
	case GL_FRAGMENT_SHADER :
		DArray_Append( self->fragmentSources, & source );
		break;
	}
}
Example #6
0
int Dao_FileStat( const char *path, struct stat *buf )
{
#if _WIN32
	DString path2 = DString_WrapChars( path );
	DArray *path3 = DArray_New( sizeof(wchar_t) );
	if( DString_DecodeUTF8( & path2, path3 ) ){
		int ret = _wstat( path3->data.wchars, buf );
		DArray_Delete( path3 );
		return ret;
	}
	DArray_Delete( path3 );
#endif
	return stat( path, buf );
}
Example #7
0
DaoXmlNode* DaoXmlNode_GetChildMBS( DaoXmlNode *self, const char *name )
{
	DString name2 = DString_WrapChars( name );
	return DaoXmlNode_GetChild( self, & name2 );
}
Example #8
0
DaoXmlNode* DaoXmlNode_GetAncestorMBS( DaoXmlNode *self, const char *name, int level )
{
	DString name2 = DString_WrapChars( name );
	return DaoXmlNode_GetAncestor( self, & name2, level );
}
Example #9
0
DString* DaoXmlNode_GetAttributeMBS( DaoXmlNode *self, const char *name )
{
	DString name2 = DString_WrapChars( name );
	return DaoXmlNode_GetAttribute( self, & name2 );
}
Example #10
0
DaoXmlNode* DaoXmlNode_GetChildByAttributeMBS( DaoXmlNode *self, const char *key, const char *value )
{
	DString key2 = DString_WrapChars( key );
	DString value2 = DString_WrapChars( value );
	return DaoXmlNode_GetChildByAttribute( self, & key2, & value2 );
}
Example #11
0
int DaoRegex_CheckSizeChars( const char *src )
{
	DString str = DString_WrapChars( src );
	return DaoRegex_CheckSize( & str );
}