void g_include( struct SEE_interpreter *interp, struct SEE_object *self, struct SEE_object *thisobj, int argc, struct SEE_value **argv, struct SEE_value *res) { struct SEE_value s; SEE_ToString(interp, argv[0], &s); char *filename = (char*)malloc(sizeof(char)*(s.u.string->length+1)); int i; for (i = 0; i < s.u.string->length; i++) { filename[i] = s.u.string->data[i]; } filename[s.u.string->length] = '\0'; evaluate_file(interp, res, filename); free(filename); SEE_SET_BOOLEAN(res, 1); }
void g_println( struct SEE_interpreter *interp, struct SEE_object *self, struct SEE_object *thisobj, int argc, struct SEE_value **argv, struct SEE_value *res) { struct SEE_value s; SEE_ToString(interp, argv[0], &s); int i; for (i = 0; i < s.u.string->length; i++) { fprintf(cgiOut, "%c", s.u.string->data[i]); } fprintf(cgiOut, "\n"); SEE_SET_BOOLEAN(res, 1); }
static void SeeLogErrorObj(SEE_interpreter* interpr_, SEE_value* errorValue) { // is the value an object? if( errorValue==NULL || SEE_VALUE_GET_TYPE(errorValue) != SEE_OBJECT ) return; // is the object an array? SEE_object* errorObj = errorValue->u.object; if( errorObj == NULL ) return; // get what to get ... wxString errorName, errorMsg, tempStr; long lineno = -1; // ... get the error name SEE_value tempVal; SEE_OBJECT_GET(interpr_, errorObj, str_name, &tempVal); if( SEE_VALUE_GET_TYPE(&tempVal) == SEE_STRING ) errorName = SeeValueToWxString(interpr_, &tempVal); errorName.Trim(true); errorName.Trim(false); if( errorName.IsEmpty() ) errorName = wxT("Error"); // ... get the error message, this is formatted as "<string>:<lineno>:msg" SEE_OBJECT_GET(interpr_, errorObj, str_message, &tempVal); if( SEE_VALUE_GET_TYPE(&tempVal) == SEE_STRING ) { errorMsg = SeeValueToWxString(interpr_, &tempVal); if( errorMsg.Find(wxT(":")) >= 0 ) { tempStr = errorMsg.BeforeFirst(wxT(':')); errorMsg = errorMsg.AfterFirst(wxT(':')); } if( errorMsg.Find(wxT(":")) >= 0 ) { tempStr = errorMsg.BeforeFirst(wxT(':')); if( !tempStr.ToLong(&lineno, 10) ) lineno = -1; errorMsg = errorMsg.AfterFirst(wxT(':')); } errorMsg.Trim(true); errorMsg.Trim(false); } if( errorMsg.IsEmpty() ) errorMsg = wxT("Unknown error"); // ... get the line number if( lineno >= 1 ) tempStr.Printf(wxT("%i"), (int)lineno); else tempStr = wxT("?"); // ... format the line wxLogError(wxT("Line %s: %s: %s [%s]"), tempStr.c_str(), errorName.c_str(), errorMsg.c_str(), HOST_DATA->m_executionScope.c_str() ); // old stuff #if 0 { SEE_value errorObjAsStr; SEE_ToString(interpr_, errorValue, &errorObjAsStr); wxString error = ::SeeValueToWxString(interpr_, &errorObjAsStr); if( error.IsEmpty() ) error = wxT("Unknown error."); wxLogError(wxT("%s [%s]"), error.c_str(), HOST_DATA->m_executionScope.c_str()); } #endif }