Keep your code simple as not all code constructs can be translated to other languages (yet). Microsoft Visual StudioJSC uses Microsoft Visual Studio to build applications as a .Net IDE to target other platforms. So building for multi-platform JSC applications is a lot like building ordinary .Net applications. JSC uses Managed Classes, library references, Namespaces, classes, etc. Certain things are not supported when converting code to other platforms, so make sure to read the Limitations section below.In building your projects, it is highly recommended you start with either a JSC Ultra Template or a sample application, both of which are available from this website. Go ahead and create a JSC project with a template or sample to help you follow along with these guidelines. Post-build events in Visual Studio can be found by opening the Project Properties, Events Tab, Post-Build events Tab. JSC Templates and samples use one of two methods to invoke post-build events: it may include the post-build commands directly in the post-build window or by calling a build.bat file which is found under Tools folder inside the project files. Post-build events are communicated to Visual Studio with either success of failure, and most of the post-build errors can be better understood from the Output window instead of the Error window listings. What's not Supported / Limitations
Adding Native ClassesA Native class is a class belonging to a platform such as java.awt.CheckBox in Java, or flash.display.Sprite for Flash. JSC requires stub files and classes to be defined in C#/VB in order to use these Native classes within Visual Studio. JSC ScriptCoreLib, ScriptCorelibJava and other JSC libraries are stubs to native classes of the various platforms. We plan to have most of the Native classes defined in JSC libraries, but there will always be some classes you will want to use that we have not yet included. The following example shows how this is done:Say you wanted to use Java CheckBox and you found that it was not available in ScriptCoreLib. First step is to find where CheckBox is in the namespace: java.awt.CheckBox. Next step it to find a similar class file within ScriptCoreLib and use it as a model template, such as Button: http://jsc.svn.sourceforge.net/viewvc/jsc/core/ScriptCoreLibJava/java/awt/Button.cs?view=markup. Search the CheckBox class on the Internet or vendor site (Java, for this example) to make sure you're creating the class correctly within JSC. Once you've created your new Native file, just add it to your project. You can now use the CheckBox class and methods you define normally. Useful links for this section: http://jsc.svn.sourceforge.net/viewvc/jsc/core/ScriptCoreLib/JavaScript/ http://jsc.svn.sourceforge.net/viewvc/jsc/core/ScriptCoreLibJava/ http://jsc.svn.sourceforge.net/viewvc/jsc/core/ScriptCoreLib/PHP/ http://jsc.svn.sourceforge.net/viewvc/jsc/core/ScriptCoreLib/ActionScript/ Sharing common Classes Among PlatformsWith JSC, your multi-platform solutions can share code seamlessly from any generic-coded Class. But sometimes it makes most sense to have a separate project within the multi-platform solution that contains this base or common code. This section describes how to use a separate Library Project, within a Visual Studio Solution, to contain all your Multi-Platform Common Classes that can be re-used and shared among all your target platforms. NOTE: You can share common code with other platforms without the use of such a Library Project as described here. This is simply one of the methodologies you may want to employ. The best way to do this is using a DLL Class Library project. Steps must be taken to ensure API or platform-dependent code isn't used within this shared code in order to provide seamless interoperability between platforms. Review our references and programming guidelines as to which types and APIs are available for all platforms (or your target platforms) and these are safe to use within your shared code. Take the following steps to enable your Shared/Common project to work with any of JSC supported platforms:
Working with External/3rd Party LibrariesSimilar to Native classes, external libraries can easily be included inside your project using the same stub method as for Adding Native Classes. The difference here is that JSC will need to be able to find the external libraries for the given platform. The FiNT Particle blog post shows how this is done. JSC Classic Templates and some sample projects currently support 3rd party libraries.JSC Ultra templates currently have not yet integrated using 3rd party libraries. See Roadmap for target for this feature. Basic Typesintthe type int is treated the same throughout all platforms. Managed code for int also includes int.parse method which is also supported throughout all JSC platforms. All int comparisons and arithmetic operations can also be used as normally. string the type string also exhibits common behavior. Using '+' or += for string concat is supported, and assignment within "quotes" are also as expected behaviors. JSC also supports using StringBuilder as a managed string class. Review the JSC Programming Reference module below to see all detailed methods supported for the various platforms for StringBuilder. bool this is another type that can be used among all platforms without reservations, treated equally. Programming with ScriptCoreLibScriptCoreLib contains all the API libraries for all platforms. You can use these libraries accordingly withing JSC projects. |
wiki > Documentation >