Exemple #1
0
static void resume(WrenValue* method)
{
  WrenInterpretResult result = wrenCall(getVM(), method);
  
  // If a runtime error occurs in response to an async operation and nothing
  // catches the error in the fiber, then exit the CLI.
  if (result == WREN_RESULT_RUNTIME_ERROR)
  {
    uv_stop(getLoop());
    setExitCode(70); // EX_SOFTWARE.
  }
}
Exemple #2
0
static void callResume(WrenValue* resumeMethod, WrenValue* fiber,
                       const char* argTypes, ...)
{
  va_list args;
  va_start(args, argTypes);
  WrenInterpretResult result = wrenCallVarArgs(getVM(), resumeMethod, NULL,
                                               argTypes, args);
  va_end(args);
  
  wrenReleaseValue(getVM(), fiber);
  
  // If a runtime error occurs in response to an async operation and nothing
  // catches the error in the fiber, then exit the CLI.
  if (result == WREN_RESULT_RUNTIME_ERROR)
  {
    uv_stop(getLoop());
    setExitCode(70); // EX_SOFTWARE.
  }
}
void ExternalCommand::onFinished(int exitCode)
{
	setExitCode(exitCode);
}
Exemple #4
0
static BOOL parseCreateBlock (char *line, CtnrBlock *block, char **freeSymbolMap, int idxBlock) {

	int ret;
	char *cursor;
 	unsigned long lStartTime, lEndTime;
	EnumAction blockAction;
	BOOL inLabel;
	
	ret = TRUE;  // TODO: set ret = 0 if there's not even a single time or no '-'  
	
	block->idxFirstAction = -1;
	block->idxNextStart = MASK_IDX_NEXT_START;
	block->idxNextEnd = -1;

	cursor = strchr(line,DELIMITER);
	cursor++; //either number or whitespace immediately following DELIMITER
	
	while (*cursor && isspace(*cursor))
		cursor++;
	
	//check for block-start action (of type EnumAction)
	//todo: don't get tricked into seeing digits in [labels]
	while (*cursor && !isdigit(*cursor) && *cursor != '-') {
		if (!isspace(*cursor)) {
			blockAction = getActionEnumFromChar(cursor);
			if (blockAction >= 0)
				setStartCode(&block->actionStartEnd,blockAction);
			//todo:else exception and log
		}
		cursor++;
	}

	if (*cursor == '-')	
		lStartTime = 0; //nothing before '-' means block begins at beginning of file
	else
		lStartTime = strToLong(cursor);
	//reduce the precision to convert long to int ans space space
	block->startTime = compressTime(lStartTime, context.package->timePrecision);
		
	cursor = strchr(cursor,'-');
	do //either number or whitespace immediately following '-'
		cursor++; 
	while (*cursor && isspace(*cursor));
	
	if (isdigit(*cursor))
		lEndTime = strToLong(cursor);
	else 
		lEndTime = 0xFFFFFFFF; // nothing after '-' means block runs to end of file
	//reduce the precision to convert long to int ans space space
	block->endTime = compressTime(lEndTime, context.package->timePrecision);

	if (block->startTime > block->endTime)
		ret = FALSE; //todo:log this problem
	
	while (*cursor && (isspace(*cursor) || isdigit(*cursor)))
		cursor++;
	
	//check for block-end action (of type EnumAction)
	while (*cursor && *cursor != '[' && *cursor != '/') {
		if (!isspace(*cursor)) {
			blockAction = getActionEnumFromChar(cursor);
			if (blockAction != -1)
				setEndCode(&block->actionStartEnd,blockAction);
		}
		cursor++;
	}
	
	// check if block is hyperlinked
	inLabel = FALSE;
	for (cursor=line;*cursor;cursor++) {
		if (*cursor == '[')
			inLabel = TRUE;
		else if (*cursor == ']')
			inLabel = FALSE;
		if (!inLabel && *cursor == '?') {
			setBlockHyperlinked(block);
			break;
		}
	}					

	// check if block has enter/exit events
	cursor = strchr(line,'/');
	if (cursor != NULL) {
		// go backwards to beginning of legit enter/exit codes
		do {
			cursor--;
			if (*cursor != '+' && *cursor != '-')
				blockAction = getEnterExitEnumFromChar(cursor); 
		} while (blockAction != -1 || *cursor == '+' || *cursor == '-' || *cursor == 'N');
		//read in enter codes
		for (cursor++;*cursor != '/';cursor++) {
			if (*cursor != '-' && *cursor != '+' && *cursor != 'N') {
				blockAction = getEnterExitEnumFromChar(cursor);
				setEnterCode(block,blockAction);
			}
		}
		// must be back to '/'; now read in exit codes
		do {
			cursor++;
			if (*cursor && *cursor != '-' && *cursor != '+' && *cursor != 'N') {
				blockAction = getEnterExitEnumFromChar(cursor);
				if (blockAction != -1)
					setExitCode(block,blockAction);
			}
		} while (*cursor && (blockAction != -1 || *cursor == '+' || *cursor == '-' || *cursor == 'N'));
	}
			
	cursor = strchr(line,']');
	// a block does not need a symbol if nothing refers to it
	if (cursor != NULL) {
		//set null marker before ] but also before any whitespace
		while (isspace(*(cursor-1)))
			cursor--;
		*cursor = '\0';
		cursor = strchr(line,'[');
		// todo: error if there is a ] but no [
		do
			cursor++;
		while (isspace(*cursor));
		cursor = strcpy(*freeSymbolMap,cursor);
		cursor = strchr(cursor,'\0');
		*(cursor + 1) = idxBlock;
		*freeSymbolMap = cursor + 2;
	}
	return ret;
}