MoinMoin Logo
  • Comments
  • Immutable Page
  • Menu
    • Navigation
    • RecentChanges
    • FindPage
    • Local Site Map
    • Help
    • HelpContents
    • HelpOnMoinWikiSyntax
    • Display
    • Attachments
    • Info
    • Raw Text
    • Print View
    • Edit
    • Load
    • Save
  • Login

Navigation

  • Start
  • Sitemap
Revision 14 as of 2013-07-30 08:38:27
  • Javascript
  • Cappuccino

Cappuccino

Cappuccino is a framework which makes it easy to create advanced web apps.

http://www.cappuccino-project.org/

Objective-J is a powerful object-oriented language which compiles to run in the browser.

Get the code

Clone it using git:

  • cd ~
  • mkdir gitCappuccino
  • cd gitCappuccino
  • git clone git://github.com/cappuccino/cappuccino.git
  • cd ~/gitCappuccino/cappuccino

Vim editor Objective-J plugin

Run the follwoing commands after fetching code from github:

  • mkdir -p ~/.vim/plugin
  • cd ~/gitCappuccino/cappuccino/Tools/Editors/Vim]
  • cp objj.vim ~/.vim/plugin

Emacs editor Objective-J plugin

  • mkdir ~/cappuccinoEmacs
  • cd ~/gitCappuccino/cappuccino/Tools/Editors/Emacs
  • cp *.el ~/cappuccinoEmacs/
  • touch ~/.emacs
  • nano ~/.emacs
  • (add-to-list 'load-path "~/cappuccinoEmacs")
  • (require 'objj-mode)

Init String, CPString

   1 var str1 = [CPString initWithString: @""];
   2 var str2 = [CPString initWithString: @""];

Mutable Array

   1 @import <Foundation/CPMutableArray.j>
   2 
   3 var arrayX = [[CPMutableArray alloc] init]; 

Callbacks

   1 @implementation TestObject : CPObject
   2 {
   3 }
   4 
   5 -(void)helloWorld{
   6   CPLogConsole("Called hello world");
   7 }
   8 //(...)
   9 @end
  10 
  11 //--------------------
  12 var selectorHelloWorld =  @selector(helloWorld) ;
  13 var signature = [self methodSignatureForSelector: aSelector];
  14 var invocation = [CPInvocation invocationWithMethodSignature:signature];
  15 [invocation setSelector: selectorHelloWorld];
  16 [invocation invokeWithTarget: self]; //self -> instance of TestObject
  17 

   1 @implementation TestObject : CPObject
   2 {
   3 }
   4 
   5 -(void)helloWorldMsg:(CPString) message p1:(int)intVal {
   6   CPLogConsole( message  );
   7   CPLogConsole( intVal  );
   8 }
   9 //(...)
  10 @end
  11 
  12 //--------------------
  13 var selectorHelloWorldMsg =  @selector(helloWorldMsg:p1:) ;
  14 var sig = [self methodSignatureForSelector: selectorHelloWorldMsg];
  15 var invocation = [CPInvocation invocationWithMethodSignature:sig];
  16 [invocation setSelector: selectorHelloWorldMsg];
  17 [invocation setArgument:@"Message" atIndex:2 ]; //0-> self 1->_cmd 
  18 [invocation setArgument: 1234 atIndex:3 ]; //0-> self 1->_cmd 
  19 [invocation invokeWithTarget: self]; 

Dates

   1 var datex = [CPDate dateWithTimeIntervalSince1970: dateInSeconds]; //set CPDate with seconds since 01-01-1970 UTC
   2 var strDate = [instanceCPDate description];// get string with date in format YYYY-MM-DD HH:MM:SS TZ±HHMM.               
   3 

Dictionary from JSON object

   1 - (void)connection:(CPURLConnection) connection didReceiveData:(CPString)data
   2 {
   3   var dict = [CPDictionary dictionaryWithJSObject: [data objectFromJSON]  ];    
   4   [textField setStringValue:  [dict valueForKey:@"lkeyx"] ];
   5 }
  • MoinMoin Powered
  • Python Powered
  • GPL licensed
  • Valid HTML 4.01