TITANIUM_FUNCTION(File, write) { const auto js_context = this_object.get_context(); if (arguments.size() < 1) { return js_context.CreateUndefined(); } const auto _0 = arguments.at(0); const auto _1 = arguments.size() < 2 ? js_context.CreateBoolean(false) : arguments.at(1); TITANIUM_ASSERT(_1.IsBoolean()); const auto append = static_cast<bool>(_1); if (_0.IsString()) { return js_context.CreateBoolean(write(static_cast<std::string>(arguments.at(0)), append)); } else if (_0.IsObject()) { const auto js_object = static_cast<JSObject>(_0); const auto blob = js_object.GetPrivate<Titanium::Blob>(); const auto file = js_object.GetPrivate<File>(); if (blob != nullptr) { return js_context.CreateBoolean(write(blob, append)); } else if (file != nullptr) { return js_context.CreateBoolean(write(file, append)); } } return js_context.CreateNull(); }
ExpressionType GetType() const { if (IsTensor()) return ExpressionType::TENSOR; else if (IsScalar()) return ExpressionType::SCALAR; else if (IsIndices()) return ExpressionType::INDICES; else if (IsBoolean()) return ExpressionType::BOOLEAN; else if (IsSubstitution()) return ExpressionType::SUBSTITUTION; else if (IsVoid()) return ExpressionType::VOID_TYPE; return ExpressionType::UNKNOWN; }
bool LuaStack::Peek(bool& o_val, int i_index) { if (IsBoolean(i_index)) { o_val = lua_toboolean(state, i_index) != 0; return true; } return false; }
int GetBoolean() { if (!IsBoolean(Look)) { Expected("Boolean Literal"); } int ret = uppercase(Look) == 'T'; GetChar(); return ret; }
TITANIUM_FUNCTION(File, deleteDirectory) { bool recursive = false; if (arguments.size() > 0) { const auto _0 = arguments.at(0); TITANIUM_ASSERT(_0.IsBoolean()); recursive = static_cast<bool>(_0); } return get_context().CreateBoolean(deleteDirectory(recursive)); }
void BoolFactor() { if (IsBoolean(Look)) { if (GetBoolean()) { EmitLn("movl $-1, %eax"); } else { EmitLn("xor %eax, %eax"); } } else { Relation(); } }
TITANIUM_FUNCTION(WebView, stopLoading) { if (arguments.size() < 1) { return get_context().CreateUndefined(); } else if (arguments.size() >= 1) { const auto _0 = arguments.at(0); TITANIUM_ASSERT(_0.IsBoolean()); const bool hardStop = static_cast<bool>(_0); stopLoading(hardStop); } stopLoading(false); return get_context().CreateUndefined(); }
TITANIUM_FUNCTION(TableView, setFilterCaseInsensitive) { TITANIUM_LOG_WARN("TableView.setFilterCaseInsensitive is not implemented yet"); if (arguments.empty()) { return get_context().CreateUndefined(); } else if (arguments.size() >= 1) { const auto _0 = arguments.at(0); TITANIUM_ASSERT(_0.IsBoolean()); const bool filterCaseInsensitive = static_cast<bool>(_0); // setFilterCaseInsensitive(filterCaseInsensitive); } return get_context().CreateUndefined(); }
void BoolFactor() { if(IsBoolean(Look)) { if(GetBoolean()) { EmitLn("mov rax, -1"); } else { EmitLn("xor rax, rax"); } } else { Relation(); } }
bool JObject::GetBoolean() { IOTJS_ASSERT(IsBoolean()); return JVAL_TO_BOOLEAN(&_obj_val); }
const CPDF_Boolean* CPDF_Object::AsBoolean() const { return IsBoolean() ? static_cast<const CPDF_Boolean*>(this) : nullptr; }
bool PluginPreference::IsString() { return !IsBoolean() && !IsInteger() && !IsDouble(); }
// function that tokenizes the input, using a structure of conscell's, where each conscell has a car and a cdr, // each car has two values, the type and the actual value. ConsCell* tokenize(char *expression) { ConsCell *current =malloc(sizeof(ConsCell)); ConsCell *Head = current; int i = 0; for (int i = 0; expression[i]; i++) { if (expression[i]==' ') continue; else if (expression[i] == '\n'){ continue; } if (expression[i]== '\t'){ continue; } Value *carVar = malloc(sizeof(Value)); Value *cdrVar = malloc(sizeof(Value)); if (expression[i]=='(') { carVar->type = 6; carVar->openValue = '('; } else if (expression[i]==')') { carVar->type=7; carVar->closeValue = ')'; } else { if (IsAnInt(expression, i)) { carVar->type=2; carVar->intValue=GiveInt(expression, i); i = getNextTerminal(expression, i); i -=1; } else if(IsSymbol(expression, i)) { int symbolLength=returnSymbolLength(expression, i); carVar->type=5; carVar->symbolValue=returnSymbol(expression, i, symbolLength); if (IsId(carVar->symbolValue)){ carVar->type = 9; carVar->idValue = carVar->symbolValue; } else if (IsPrimitive(carVar->symbolValue)) { carVar->type = 13; carVar->primValue = carVar->symbolValue; } i+=symbolLength; } else if(IsString(expression, i)) { carVar->type=4; carVar->stringValue=returnString(expression, i); int lengthOfString = findLengthOfString(carVar->stringValue); i+=lengthOfString; } else if(IsBoolean(expression,i)){ carVar->type = 1; carVar->boolValue=returnBoolean(expression,i); i +=1; } else if(IsFloat(expression, i)) { carVar->type=3; carVar->floatValue=GiveFloat(expression, i); i = getNextTerminal(expression, i); i -=1; } else if(expression[i] == ';') { free(carVar); free(cdrVar); break; } else { free(carVar); free(cdrVar); printf("Error: Bad syntax.\n"); ConsCell *emptyCons =malloc(sizeof(ConsCell)); Value *Val = malloc(sizeof(Value)); Val->type = 0; Val->intValue= 1; emptyCons->car = Val; Value *cdrVal = malloc(sizeof(Value)); cdrVal->type = 0; cdrVal->intValue = 0; current->car = cdrVal; cleanupCCLL(Head); return emptyCons; break; } } ConsCell *newCell = malloc(sizeof(ConsCell)); cdrVar->type = 8; cdrVar->cons = newCell; current = insertCC(current, carVar, cdrVar); current = newCell; } Value *cdrVal = malloc(sizeof(Value)); cdrVal->type = 0; cdrVal->intValue = 0; current->car = cdrVal; return Head; }