X-Git-Url: https://git.saurik.com/cycript.git/blobdiff_plain/f95d2598051e347460e028286ff2d33e5825e548..972562bf68a236b4580b6074415cbf4e07b0a0c6:/ObjectiveC/Output.cpp diff --git a/ObjectiveC/Output.cpp b/ObjectiveC/Output.cpp index 05e8ff8..76838d8 100644 --- a/ObjectiveC/Output.cpp +++ b/ObjectiveC/Output.cpp @@ -1,5 +1,5 @@ /* Cycript - Optimizing JavaScript Compiler/Runtime - * Copyright (C) 2009-2014 Jay Freeman (saurik) + * Copyright (C) 2009-2015 Jay Freeman (saurik) */ /* GNU Affero General Public License, Version 3 {{{ */ @@ -19,62 +19,36 @@ **/ /* }}} */ +#include + #include "Replace.hpp" -#include "ObjectiveC/Syntax.hpp" -#include +#include "ObjectiveC/Syntax.hpp" void CYCategory::Output(CYOutput &out, CYFlags flags) const { - out << "(function($cys,$cyp,$cyc,$cyn,$cyt){"; - out << "$cyp=object_getClass($cys);"; - out << "$cyc=$cys;"; - if (messages_ != NULL) - messages_->Output(out, true); - out << "})("; - name_->ClassName(out, true); - out << ')'; - out << ';'; -} + out << "@implementation" << ' ' << *name_ << ' ' << '(' << ')' << '\n'; + ++out.indent_; -void CYClass::Output(CYOutput &out, CYFlags flags) const { - // XXX: I don't necc. need the ()s - out << "(function($cys,$cyp,$cyc,$cyn,$cyt,$cym){"; - out << "$cyp=object_getClass($cys);"; - out << "$cyc=objc_allocateClassPair($cys,"; - if (name_ != NULL) - name_->ClassName(out, false); - else - out << "$cyq(\"CY$\")"; - out << ",0);"; - out << "$cym=object_getClass($cyc);"; - if (fields_ != NULL) - fields_->Output(out); - if (messages_ != NULL) - messages_->Output(out, false); - if (protocols_ != NULL) { - out << '<'; - out << *protocols_; - out << '>'; + CYForEach (message, messages_) { + message->Output(out); + out << '\n'; } - out << "objc_registerClassPair($cyc);"; - out << "return $cyc;"; - out << "}("; - if (super_ != NULL) - super_->Output(out, CYAssign::Precedence_, CYNoFlags); - else - out << "null"; - out << "))"; -} -void CYClassExpression::Output(CYOutput &out, CYFlags flags) const { - CYClass::Output(out, flags); + --out.indent_; + out << "@end"; } -void CYClassStatement::Output(CYOutput &out, CYFlags flags) const { - CYClass::Output(out, flags); +void CYImplementation::Output(CYOutput &out, CYFlags flags) const { + out << "@implementation" << ' ' << *name_ << '\n'; + ++out.indent_; + + // XXX: implement + + --out.indent_; + out << "@end"; } -void CYField::Output(CYOutput &out) const { +void CYImplementationField::Output(CYOutput &out) const { } void CYInstanceLiteral::Output(CYOutput &out, CYFlags flags) const { @@ -82,14 +56,14 @@ void CYInstanceLiteral::Output(CYOutput &out, CYFlags flags) const { number_->Output(out, CYRight(flags)); } -void CYMessage::Output(CYOutput &out, bool replace) const { +void CYMessage::Output(CYOutput &out) const { out << (instance_ ? '-' : '+'); CYForEach (parameter, parameters_) if (parameter->tag_ != NULL) { out << ' ' << *parameter->tag_; - if (parameter->name_ != NULL) - out << ':' << *parameter->name_; + if (parameter->type_ != NULL) + out << ':' << *parameter->type_->identifier_; } out << code_;