Screenshot instructions:
Windows
Mac
Red Hat Linux
Ubuntu
Click URL instructions:
Right-click on ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)
You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
(8) |
May
(109) |
Jun
(68) |
Jul
(83) |
Aug
(126) |
Sep
(117) |
Oct
(490) |
Nov
(410) |
Dec
(182) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(15) |
Feb
(135) |
Mar
(155) |
Apr
(99) |
May
(92) |
Jun
(144) |
Jul
(51) |
Aug
(96) |
Sep
(223) |
Oct
(367) |
Nov
(346) |
Dec
(421) |
2006 |
Jan
(827) |
Feb
(404) |
Mar
(213) |
Apr
(44) |
May
(106) |
Jun
(79) |
Jul
(88) |
Aug
(43) |
Sep
(191) |
Oct
(164) |
Nov
(150) |
Dec
(36) |
2007 |
Jan
(17) |
Feb
(5) |
Mar
(17) |
Apr
(65) |
May
(114) |
Jun
(16) |
Jul
(22) |
Aug
(57) |
Sep
(44) |
Oct
(126) |
Nov
(97) |
Dec
(23) |
2008 |
Jan
(32) |
Feb
(59) |
Mar
(45) |
Apr
(80) |
May
(113) |
Jun
(116) |
Jul
(109) |
Aug
(77) |
Sep
(80) |
Oct
(10) |
Nov
(65) |
Dec
(68) |
2009 |
Jan
(77) |
Feb
(37) |
Mar
(46) |
Apr
(35) |
May
(52) |
Jun
(93) |
Jul
(150) |
Aug
(188) |
Sep
(21) |
Oct
(20) |
Nov
(46) |
Dec
(40) |
2010 |
Jan
(33) |
Feb
(56) |
Mar
(67) |
Apr
(48) |
May
(65) |
Jun
(83) |
Jul
(32) |
Aug
(10) |
Sep
(37) |
Oct
(53) |
Nov
(34) |
Dec
(39) |
2011 |
Jan
(59) |
Feb
(93) |
Mar
(72) |
Apr
(65) |
May
(79) |
Jun
(25) |
Jul
(16) |
Aug
(28) |
Sep
(22) |
Oct
(12) |
Nov
(23) |
Dec
(36) |
2012 |
Jan
(15) |
Feb
(10) |
Mar
(49) |
Apr
(66) |
May
(108) |
Jun
(74) |
Jul
(268) |
Aug
(252) |
Sep
(121) |
Oct
(24) |
Nov
(66) |
Dec
(38) |
2013 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(9) |
Nov
(15) |
Dec
(48) |
2014 |
Jan
(18) |
Feb
(53) |
Mar
(81) |
Apr
(66) |
May
(70) |
Jun
(61) |
Jul
(38) |
Aug
(20) |
Sep
(49) |
Oct
(42) |
Nov
(13) |
Dec
(27) |
2015 |
Jan
(59) |
Feb
(27) |
Mar
(37) |
Apr
(20) |
May
(29) |
Jun
(17) |
Jul
(31) |
Aug
(27) |
Sep
(12) |
Oct
(12) |
Nov
(4) |
Dec
(24) |
2016 |
Jan
(14) |
Feb
(16) |
Mar
(38) |
Apr
(13) |
May
(30) |
Jun
(22) |
Jul
(6) |
Aug
(15) |
Sep
(23) |
Oct
(14) |
Nov
(19) |
Dec
(45) |
2017 |
Jan
(32) |
Feb
(14) |
Mar
(14) |
Apr
(8) |
May
(18) |
Jun
(21) |
Jul
(8) |
Aug
(17) |
Sep
(21) |
Oct
(22) |
Nov
(7) |
Dec
(5) |
2018 |
Jan
(15) |
Feb
(4) |
Mar
(7) |
Apr
(10) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
|
|
|
|
|
1
|
2
(3) |
3
(5) |
4
(5) |
5
(4) |
6
|
7
|
8
|
9
(1) |
10
(4) |
11
(4) |
12
(1) |
13
|
14
|
15
|
16
(6) |
17
(1) |
18
(14) |
19
(2) |
20
|
21
|
22
|
23
(1) |
24
(1) |
25
(3) |
26
(15) |
27
|
28
(1) |
29
(2) |
30
(1) |
From: <kabbi@us...> - 2012-06-18 19:31:41
|
Revision: 13185 http://swig.svn.sourceforge.net/swig/?rev=13185&view=rev Author: kabbi Date: 2012-06-18 19:31:35 +0000 (Mon, 18 Jun 2012) Log Message: ----------- Added doxygen switches doc Modified Paths: -------------- branches/gsoc2012-doxygen/Doc/Manual/Doxygen.html Modified: branches/gsoc2012-doxygen/Doc/Manual/Doxygen.html =================================================================== --- branches/gsoc2012-doxygen/Doc/Manual/Doxygen.html 2012-06-18 19:13:23 UTC (rev 13184) +++ branches/gsoc2012-doxygen/Doc/Manual/Doxygen.html 2012-06-18 19:31:35 UTC (rev 13185) @@ -114,8 +114,17 @@ <p> -NOT YET ADDED (current development branch has this feature automatically enabled). +There are switches like '-doxygen' and '-nodoxygen' in every module that supports converting +documentation comments. The first one is default, so that swig by default produces correct +proxy files with comments. Some comments in some target languages can be manually overriden by specific +swig's features, like <i>feature:docstring</i> or <i>feature:autodoc</i>, in this cases doxygen comments +have lowest priority. </p> +<p> +Switching off may be needed if swig cannot correctly parse your comments, for example showing <i>Error: +Syntax error in input(1).</i> message. Then it will just strip out every comment out of the code and +continue happily. +</p> <H3><a name="Doxygen_additional_options"></a>35.2.2 Additional Commandline Options</H3> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kabbi@us...> - 2012-06-18 19:13:30
|
Revision: 13184 http://swig.svn.sourceforge.net/swig/?rev=13184&view=rev Author: kabbi Date: 2012-06-18 19:13:23 +0000 (Mon, 18 Jun 2012) Log Message: ----------- Fixed enum comments generation, added testcases Modified Paths: -------------- branches/gsoc2012-doxygen/Examples/test-suite/doxygen_parsing.i branches/gsoc2012-doxygen/Examples/test-suite/java/Makefile.in branches/gsoc2012-doxygen/Examples/test-suite/java/doxygen_parsing_runme.java branches/gsoc2012-doxygen/Source/DoxygenTranslator/src/JavaDocConverter.cpp branches/gsoc2012-doxygen/Source/Modules/java.cxx Added Paths: ----------- branches/gsoc2012-doxygen/Examples/test-suite/doxygen_parsing_enums.i branches/gsoc2012-doxygen/Examples/test-suite/doxygen_parsing_enums_proper.i branches/gsoc2012-doxygen/Examples/test-suite/doxygen_parsing_enums_simple.i branches/gsoc2012-doxygen/Examples/test-suite/doxygen_parsing_enums_typesafe.i branches/gsoc2012-doxygen/Examples/test-suite/doxygen_parsing_enums_typeunsafe.i branches/gsoc2012-doxygen/Examples/test-suite/java/doxygen_parsing_enums_proper_runme.java branches/gsoc2012-doxygen/Examples/test-suite/java/doxygen_parsing_enums_simple_runme.java branches/gsoc2012-doxygen/Examples/test-suite/java/doxygen_parsing_enums_typesafe_runme.java branches/gsoc2012-doxygen/Examples/test-suite/java/doxygen_parsing_enums_typeunsafe_runme.java Modified: branches/gsoc2012-doxygen/Examples/test-suite/doxygen_parsing.i =================================================================== --- branches/gsoc2012-doxygen/Examples/test-suite/doxygen_parsing.i 2012-06-18 18:33:30 UTC (rev 13183) +++ branches/gsoc2012-doxygen/Examples/test-suite/doxygen_parsing.i 2012-06-18 19:13:23 UTC (rev 13184) @@ -55,15 +55,6 @@ } }; -/** Test enumeration */ -enum E_TEST -{ - /** the first item */ - E_TEST_ONE, - E_TEST_TWO = 2, /**< the second */ - E_TEST_THREE = 2+1 -}; - /** * Comment for template class */ Added: branches/gsoc2012-doxygen/Examples/test-suite/doxygen_parsing_enums.i =================================================================== --- branches/gsoc2012-doxygen/Examples/test-suite/doxygen_parsing_enums.i (rev 0) +++ branches/gsoc2012-doxygen/Examples/test-suite/doxygen_parsing_enums.i 2012-06-18 19:13:23 UTC (rev 13184) @@ -0,0 +1,15 @@ +%module doxygen_parsing_enums + +%inline %{ + + +/** Test enumeration */ +enum E_TEST +{ + /** the first item */ + E_TEST_ONE, + E_TEST_TWO = 2, /**< the second */ + E_TEST_THREE = 2+1 +}; + +%} \ No newline at end of file Added: branches/gsoc2012-doxygen/Examples/test-suite/doxygen_parsing_enums_proper.i =================================================================== --- branches/gsoc2012-doxygen/Examples/test-suite/doxygen_parsing_enums_proper.i (rev 0) +++ branches/gsoc2012-doxygen/Examples/test-suite/doxygen_parsing_enums_proper.i 2012-06-18 19:13:23 UTC (rev 13184) @@ -0,0 +1,7 @@ +%module "doxygen_parsing_enums_proper" + +// Test enum commenting using the proper enums in the target language +%include "enums.swg" + +%include "doxygen_parsing_enums.i" + Added: branches/gsoc2012-doxygen/Examples/test-suite/doxygen_parsing_enums_simple.i =================================================================== --- branches/gsoc2012-doxygen/Examples/test-suite/doxygen_parsing_enums_simple.i (rev 0) +++ branches/gsoc2012-doxygen/Examples/test-suite/doxygen_parsing_enums_simple.i 2012-06-18 19:13:23 UTC (rev 13184) @@ -0,0 +1,6 @@ +%module "doxygen_parsing_enums_simple" + +// Test enum commenting using simple constants (SWIG-1.3.21 and earlier default enum wrapping for C# and Java) +%include "enumsimple.swg" + +%include "doxygen_parsing_enums.i" \ No newline at end of file Added: branches/gsoc2012-doxygen/Examples/test-suite/doxygen_parsing_enums_typesafe.i =================================================================== --- branches/gsoc2012-doxygen/Examples/test-suite/doxygen_parsing_enums_typesafe.i (rev 0) +++ branches/gsoc2012-doxygen/Examples/test-suite/doxygen_parsing_enums_typesafe.i 2012-06-18 19:13:23 UTC (rev 13184) @@ -0,0 +1,8 @@ +%module "doxygen_parsing_enums_typesafe" + +// Test enum commenting using the typesafe enum pattern in the target language +%include "enumtypesafe.swg" + +#define SWIG_TEST_NOCSCONST // For C# typesafe enums + +%include "doxygen_parsing_enums.i" \ No newline at end of file Added: branches/gsoc2012-doxygen/Examples/test-suite/doxygen_parsing_enums_typeunsafe.i =================================================================== --- branches/gsoc2012-doxygen/Examples/test-suite/doxygen_parsing_enums_typeunsafe.i (rev 0) +++ branches/gsoc2012-doxygen/Examples/test-suite/doxygen_parsing_enums_typeunsafe.i 2012-06-18 19:13:23 UTC (rev 13184) @@ -0,0 +1,6 @@ +%module "doxygen_parsing_enums_typeunsafe" + +// Test enum commenting using a type unsafe enum pattern (constant integers in a class for the enum type) +%include "enumtypeunsafe.swg" + +%include "doxygen_parsing_enums.i" \ No newline at end of file Modified: branches/gsoc2012-doxygen/Examples/test-suite/java/Makefile.in =================================================================== --- branches/gsoc2012-doxygen/Examples/test-suite/java/Makefile.in 2012-06-18 18:33:30 UTC (rev 13183) +++ branches/gsoc2012-doxygen/Examples/test-suite/java/Makefile.in 2012-06-18 19:13:23 UTC (rev 13184) @@ -16,6 +16,10 @@ java_lib_various CPP_TEST_CASES = \ + doxygen_parsing_enums_simple \ + doxygen_parsing_enums_proper \ + doxygen_parsing_enums_typesafe \ + doxygen_parsing_enums_typeunsafe \ enum_thorough_proper \ enum_thorough_simple \ enum_thorough_typeunsafe \ Added: branches/gsoc2012-doxygen/Examples/test-suite/java/doxygen_parsing_enums_proper_runme.java =================================================================== --- branches/gsoc2012-doxygen/Examples/test-suite/java/doxygen_parsing_enums_proper_runme.java (rev 0) +++ branches/gsoc2012-doxygen/Examples/test-suite/java/doxygen_parsing_enums_proper_runme.java 2012-06-18 19:13:23 UTC (rev 13184) @@ -0,0 +1,93 @@ + +import doxygen_parsing_enums_proper.*; +import com.sun.javadoc.*; +import java.util.HashMap; +import java.util.Map.Entry; +import java.util.Iterator; + +public class doxygen_parsing_enums_proper_runme { + static { + try { + System.loadLibrary("doxygen_parsing_enums_proper"); + } catch (UnsatisfiedLinkError e) { + System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); + System.exit(1); + } + } + + static HashMap<String, String> parsedComments = new HashMap<String, String>(); + static HashMap<String, String> wantedComments = new HashMap<String, String>(); + + public static boolean start(RootDoc root) { + + /* + This method is called by 'javadoc' and gets the whole parsed + java file, we get comments and store them + */ + + ClassDoc[] classes = root.classes(); + + for (int i = 0; i < classes.length; i++) { + + if (classes[i].getRawCommentText().length() > 0) + parsedComments.put(classes[i].name(), classes[i].getRawCommentText()); + + MethodDoc[] methods = classes[i].methods(); + FieldDoc[] fields = classes[i].fields(); + FieldDoc[] constants = classes[i].enumConstants(); + + for (int j = 0; j < constants.length; j++) { + FieldDoc f = constants[j]; + if (f.getRawCommentText().length() > 0) + parsedComments.put(f.name(), f.getRawCommentText()); + } + for (int j = 0; j < fields.length; j++) { + FieldDoc f = fields[j]; + if (f.getRawCommentText().length() > 0) + parsedComments.put(f.name(), f.getRawCommentText()); + } + for (int j = 0; j < methods.length; j++) { + MethodDoc m = methods[j]; + if (m.getRawCommentText().length() > 0) + parsedComments.put(m.name(), m.getRawCommentText()); + } + } + return true; + } + + public static void main(String argv[]) + { + /* + Here we are using internal javadoc tool, it accepts the name of the class as paramterer, + and calls the start() method of that class with parsed information. + */ + com.sun.tools.javadoc.Main.execute("doxygen_parsing_enums_proper runtime test", + "doxygen_parsing_enums_proper_runme", new String[]{"-quiet", "doxygen_parsing_enums_proper"}); + + wantedComments.put("E_TEST", " Test enumeration \n"); + wantedComments.put("E_TEST_ONE", " the first item \n"); + wantedComments.put("E_TEST_TWO", " the second \n"); + + int errorCount=0; + Iterator< Entry<String, String> > it = parsedComments.entrySet().iterator(); + + while (it.hasNext()) + { + Entry<String, String> e = (Entry<String, String>) it.next(); + + if (!e.getValue().equals(wantedComments.get(e.getKey()))) { + System.out.println("Documentation comments for " + e.getKey() + " does not match: "); + System.out.println("\texpected:"+wantedComments.get(e.getKey())); + System.out.println("\tgot:\t"+e.getValue()); + errorCount++; + } + } + + if (parsedComments.size() != wantedComments.size()) { + System.out.println("Found " + (wantedComments.size()-parsedComments.size()) + " missed comment(s)!"); + errorCount++; + } + + System.exit(errorCount); + } +} Added: branches/gsoc2012-doxygen/Examples/test-suite/java/doxygen_parsing_enums_simple_runme.java =================================================================== --- branches/gsoc2012-doxygen/Examples/test-suite/java/doxygen_parsing_enums_simple_runme.java (rev 0) +++ branches/gsoc2012-doxygen/Examples/test-suite/java/doxygen_parsing_enums_simple_runme.java 2012-06-18 19:13:23 UTC (rev 13184) @@ -0,0 +1,93 @@ + +import doxygen_parsing_enums_simple.*; +import com.sun.javadoc.*; +import java.util.HashMap; +import java.util.Map.Entry; +import java.util.Iterator; + +public class doxygen_parsing_enums_simple_runme { + static { + try { + System.loadLibrary("doxygen_parsing_enums_simple"); + } catch (UnsatisfiedLinkError e) { + System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); + System.exit(1); + } + } + + static HashMap<String, String> parsedComments = new HashMap<String, String>(); + static HashMap<String, String> wantedComments = new HashMap<String, String>(); + + public static boolean start(RootDoc root) { + + /* + This method is called by 'javadoc' and gets the whole parsed + java file, we get comments and store them + */ + + ClassDoc[] classes = root.classes(); + + for (int i = 0; i < classes.length; i++) { + + if (classes[i].getRawCommentText().length() > 0) + parsedComments.put(classes[i].name(), classes[i].getRawCommentText()); + + MethodDoc[] methods = classes[i].methods(); + FieldDoc[] fields = classes[i].fields(); + FieldDoc[] constants = classes[i].enumConstants(); + + for (int j = 0; j < constants.length; j++) { + FieldDoc f = constants[j]; + if (f.getRawCommentText().length() > 0) + parsedComments.put(f.name(), f.getRawCommentText()); + } + for (int j = 0; j < fields.length; j++) { + FieldDoc f = fields[j]; + if (f.getRawCommentText().length() > 0) + parsedComments.put(f.name(), f.getRawCommentText()); + } + for (int j = 0; j < methods.length; j++) { + MethodDoc m = methods[j]; + if (m.getRawCommentText().length() > 0) + parsedComments.put(m.name(), m.getRawCommentText()); + } + } + return true; + } + + public static void main(String argv[]) + { + /* + Here we are using internal javadoc tool, it accepts the name of the class as paramterer, + and calls the start() method of that class with parsed information. + */ + com.sun.tools.javadoc.Main.execute("doxygen_parsing_enums_simple runtime test", + "doxygen_parsing_enums_simple_runme", new String[]{"-quiet", "doxygen_parsing_enums_simple"}); + + wantedComments.put("E_TEST", " Test enumeration \n"); + wantedComments.put("E_TEST_ONE", " the first item \n"); + wantedComments.put("E_TEST_TWO", " the second \n"); + + int errorCount=0; + Iterator< Entry<String, String> > it = parsedComments.entrySet().iterator(); + + while (it.hasNext()) + { + Entry<String, String> e = (Entry<String, String>) it.next(); + + if (!e.getValue().equals(wantedComments.get(e.getKey()))) { + System.out.println("Documentation comments for " + e.getKey() + " does not match: "); + System.out.println("\texpected:"+wantedComments.get(e.getKey())); + System.out.println("\tgot:\t"+e.getValue()); + errorCount++; + } + } + + if (parsedComments.size() != wantedComments.size()) { + System.out.println("Found " + (wantedComments.size()-parsedComments.size()) + " missed comment(s)!"); + errorCount++; + } + + System.exit(errorCount); + } +} Added: branches/gsoc2012-doxygen/Examples/test-suite/java/doxygen_parsing_enums_typesafe_runme.java =================================================================== --- branches/gsoc2012-doxygen/Examples/test-suite/java/doxygen_parsing_enums_typesafe_runme.java (rev 0) +++ branches/gsoc2012-doxygen/Examples/test-suite/java/doxygen_parsing_enums_typesafe_runme.java 2012-06-18 19:13:23 UTC (rev 13184) @@ -0,0 +1,93 @@ + +import doxygen_parsing_enums_typesafe.*; +import com.sun.javadoc.*; +import java.util.HashMap; +import java.util.Map.Entry; +import java.util.Iterator; + +public class doxygen_parsing_enums_typesafe_runme { + static { + try { + System.loadLibrary("doxygen_parsing_enums_typesafe"); + } catch (UnsatisfiedLinkError e) { + System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); + System.exit(1); + } + } + + static HashMap<String, String> parsedComments = new HashMap<String, String>(); + static HashMap<String, String> wantedComments = new HashMap<String, String>(); + + public static boolean start(RootDoc root) { + + /* + This method is called by 'javadoc' and gets the whole parsed + java file, we get comments and store them + */ + + ClassDoc[] classes = root.classes(); + + for (int i = 0; i < classes.length; i++) { + + if (classes[i].getRawCommentText().length() > 0) + parsedComments.put(classes[i].name(), classes[i].getRawCommentText()); + + MethodDoc[] methods = classes[i].methods(); + FieldDoc[] fields = classes[i].fields(); + FieldDoc[] constants = classes[i].enumConstants(); + + for (int j = 0; j < constants.length; j++) { + FieldDoc f = constants[j]; + if (f.getRawCommentText().length() > 0) + parsedComments.put(f.name(), f.getRawCommentText()); + } + for (int j = 0; j < fields.length; j++) { + FieldDoc f = fields[j]; + if (f.getRawCommentText().length() > 0) + parsedComments.put(f.name(), f.getRawCommentText()); + } + for (int j = 0; j < methods.length; j++) { + MethodDoc m = methods[j]; + if (m.getRawCommentText().length() > 0) + parsedComments.put(m.name(), m.getRawCommentText()); + } + } + return true; + } + + public static void main(String argv[]) + { + /* + Here we are using internal javadoc tool, it accepts the name of the class as paramterer, + and calls the start() method of that class with parsed information. + */ + com.sun.tools.javadoc.Main.execute("doxygen_parsing_enums_typesafe runtime test", + "doxygen_parsing_enums_typesafe_runme", new String[]{"-quiet", "doxygen_parsing_enums_typesafe"}); + + wantedComments.put("E_TEST", " Test enumeration \n"); + wantedComments.put("E_TEST_ONE", " the first item \n"); + wantedComments.put("E_TEST_TWO", " the second \n"); + + int errorCount=0; + Iterator< Entry<String, String> > it = parsedComments.entrySet().iterator(); + + while (it.hasNext()) + { + Entry<String, String> e = (Entry<String, String>) it.next(); + + if (!e.getValue().equals(wantedComments.get(e.getKey()))) { + System.out.println("Documentation comments for " + e.getKey() + " does not match: "); + System.out.println("\texpected:"+wantedComments.get(e.getKey())); + System.out.println("\tgot:\t"+e.getValue()); + errorCount++; + } + } + + if (parsedComments.size() != wantedComments.size()) { + System.out.println("Found " + (wantedComments.size()-parsedComments.size()) + " missed comment(s)!"); + errorCount++; + } + + System.exit(errorCount); + } +} Added: branches/gsoc2012-doxygen/Examples/test-suite/java/doxygen_parsing_enums_typeunsafe_runme.java =================================================================== --- branches/gsoc2012-doxygen/Examples/test-suite/java/doxygen_parsing_enums_typeunsafe_runme.java (rev 0) +++ branches/gsoc2012-doxygen/Examples/test-suite/java/doxygen_parsing_enums_typeunsafe_runme.java 2012-06-18 19:13:23 UTC (rev 13184) @@ -0,0 +1,93 @@ + +import doxygen_parsing_enums_typeunsafe.*; +import com.sun.javadoc.*; +import java.util.HashMap; +import java.util.Map.Entry; +import java.util.Iterator; + +public class doxygen_parsing_enums_typeunsafe_runme { + static { + try { + System.loadLibrary("doxygen_parsing_enums_typeunsafe"); + } catch (UnsatisfiedLinkError e) { + System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); + System.exit(1); + } + } + + static HashMap<String, String> parsedComments = new HashMap<String, String>(); + static HashMap<String, String> wantedComments = new HashMap<String, String>(); + + public static boolean start(RootDoc root) { + + /* + This method is called by 'javadoc' and gets the whole parsed + java file, we get comments and store them + */ + + ClassDoc[] classes = root.classes(); + + for (int i = 0; i < classes.length; i++) { + + if (classes[i].getRawCommentText().length() > 0) + parsedComments.put(classes[i].name(), classes[i].getRawCommentText()); + + MethodDoc[] methods = classes[i].methods(); + FieldDoc[] fields = classes[i].fields(); + FieldDoc[] constants = classes[i].enumConstants(); + + for (int j = 0; j < constants.length; j++) { + FieldDoc f = constants[j]; + if (f.getRawCommentText().length() > 0) + parsedComments.put(f.name(), f.getRawCommentText()); + } + for (int j = 0; j < fields.length; j++) { + FieldDoc f = fields[j]; + if (f.getRawCommentText().length() > 0) + parsedComments.put(f.name(), f.getRawCommentText()); + } + for (int j = 0; j < methods.length; j++) { + MethodDoc m = methods[j]; + if (m.getRawCommentText().length() > 0) + parsedComments.put(m.name(), m.getRawCommentText()); + } + } + return true; + } + + public static void main(String argv[]) + { + /* + Here we are using internal javadoc tool, it accepts the name of the class as paramterer, + and calls the start() method of that class with parsed information. + */ + com.sun.tools.javadoc.Main.execute("doxygen_parsing_enums_typeunsafe runtime test", + "doxygen_parsing_enums_typeunsafe_runme", new String[]{"-quiet", "doxygen_parsing_enums_typeunsafe"}); + + wantedComments.put("E_TEST", " Test enumeration \n"); + wantedComments.put("E_TEST_ONE", " the first item \n"); + wantedComments.put("E_TEST_TWO", " the second \n"); + + int errorCount=0; + Iterator< Entry<String, String> > it = parsedComments.entrySet().iterator(); + + while (it.hasNext()) + { + Entry<String, String> e = (Entry<String, String>) it.next(); + + if (!e.getValue().equals(wantedComments.get(e.getKey()))) { + System.out.println("Documentation comments for " + e.getKey() + " does not match: "); + System.out.println("\texpected:"+wantedComments.get(e.getKey())); + System.out.println("\tgot:\t"+e.getValue()); + errorCount++; + } + } + + if (parsedComments.size() != wantedComments.size()) { + System.out.println("Found " + (wantedComments.size()-parsedComments.size()) + " missed comment(s)!"); + errorCount++; + } + + System.exit(errorCount); + } +} Modified: branches/gsoc2012-doxygen/Examples/test-suite/java/doxygen_parsing_runme.java =================================================================== --- branches/gsoc2012-doxygen/Examples/test-suite/java/doxygen_parsing_runme.java 2012-06-18 18:33:30 UTC (rev 13183) +++ branches/gsoc2012-doxygen/Examples/test-suite/java/doxygen_parsing_runme.java 2012-06-18 19:13:23 UTC (rev 13184) @@ -33,6 +33,19 @@ parsedComments.put(classes[i].name(), classes[i].getRawCommentText()); MethodDoc[] methods = classes[i].methods(); + FieldDoc[] fields = classes[i].fields(); + FieldDoc[] constants = classes[i].enumConstants(); + + for (int j = 0; j < constants.length; j++) { + FieldDoc f = constants[j]; + if (f.getRawCommentText().length() > 0) + parsedComments.put(f.name(), f.getRawCommentText()); + } + for (int j = 0; j < fields.length; j++) { + FieldDoc f = fields[j]; + if (f.getRawCommentText().length() > 0) + parsedComments.put(f.name(), f.getRawCommentText()); + } for (int j = 0; j < methods.length; j++) { MethodDoc m = methods[j]; if (m.getRawCommentText().length() > 0) @@ -84,6 +97,11 @@ } } + if (parsedComments.size() != wantedComments.size()) { + System.out.println("Found " + (wantedComments.size()-parsedComments.size()) + " missed comment(s)!"); + errorCount++; + } + System.exit(errorCount); } } Modified: branches/gsoc2012-doxygen/Source/DoxygenTranslator/src/JavaDocConverter.cpp =================================================================== --- branches/gsoc2012-doxygen/Source/DoxygenTranslator/src/JavaDocConverter.cpp 2012-06-18 18:33:30 UTC (rev 13183) +++ branches/gsoc2012-doxygen/Source/DoxygenTranslator/src/JavaDocConverter.cpp 2012-06-18 19:13:23 UTC (rev 13184) @@ -13,7 +13,7 @@ #include "DoxygenParser.h" #include <iostream> #define APPROX_LINE_LENGTH 64 //characters per line allowed -#define TAB_SIZE 8 //characters per line allowed +#define TAB_SIZE 8 //current tab size in spaces int printSortedTree2 = 0; //TODO {@link} {@linkplain} {@docRoot}, and other useful doxy commands that are not a javadoc tag Modified: branches/gsoc2012-doxygen/Source/Modules/java.cxx =================================================================== --- branches/gsoc2012-doxygen/Source/Modules/java.cxx 2012-06-18 18:33:30 UTC (rev 13183) +++ branches/gsoc2012-doxygen/Source/Modules/java.cxx 2012-06-18 19:13:23 UTC (rev 13184) @@ -49,7 +49,7 @@ bool global_variable_flag; // Flag for when wrapping a global variable bool old_variable_names; // Flag for old style variable names in the intermediary class bool member_func_flag; // flag set when wrapping a member function - bool doxygen_javadoc_flag; //flag for converting found doxygen to javadoc + bool doxygen; //flag for converting found doxygen to javadoc bool comment_creation_chatter; //flag for getting information about where comments were created in java.cxx String *imclass_name; // intermediary class name @@ -123,7 +123,7 @@ global_variable_flag(false), old_variable_names(false), member_func_flag(false), - doxygen_javadoc_flag(true), + doxygen(true), comment_creation_chatter(false), imclass_name(NULL), module_class_name(NULL), @@ -255,6 +255,14 @@ Printf(stderr, "Deprecated command line option: %s. Proxy classes are now generated by default.\n", argv[i]); Swig_mark_arg(i); proxy_flag = true; + } else if ((strcmp(argv[i], "-doxygen") == 0)) { + Swig_mark_arg(i); + doxygen = true; + scan_doxygen_comments = true; + } else if ((strcmp(argv[i], "-nodoxygen") == 0)) { + Swig_mark_arg(i); + doxygen = false; + scan_doxygen_comments = false; } else if ((strcmp(argv[i], "-noproxy") == 0)) { Swig_mark_arg(i); proxy_flag = false; @@ -528,7 +536,7 @@ // Start writing out the module class file emitBanner(f_module); //Add any structural comments to the top - if(doxygen_javadoc_flag && structuralComments){ + if(doxygen && structuralComments){ Printf(f_module, "%s", structuralComments); } if (package) @@ -537,7 +545,7 @@ if (module_imports) Printf(f_module, "%s\n", module_imports); - if (doxygen_javadoc_flag){ + if (doxygen){ String *doxygen_comments; if(DoxygenTranslator::getDocumentation(n, JavaDoc,doxygen_comments)){ if(comment_creation_chatter) @@ -1292,17 +1300,6 @@ // Add extra indentation Replaceall(enum_code, "\n", "\n "); Replaceall(enum_code, " \n", "\n"); - - //translate and write javadoc comment if flagged - if (doxygen_javadoc_flag){ - String *doxygen_comments; - if(DoxygenTranslator::getDocumentation(n, JavaDoc,doxygen_comments)){ - if(comment_creation_chatter) - Printf(proxy_class_constants_code, "/* This was generated from enumvalueDeclaration() */"); - Printf(proxy_class_constants_code, Char(doxygen_comments)); - Delete(doxygen_comments); - } - } Printv(proxy_class_constants_code, " ", enum_code, "\n\n", NIL); } else { @@ -1418,30 +1415,29 @@ } if (!addSymbol(name, n, scope)) return SWIG_ERROR; + + //translate and write javadoc comment if flagged + if (doxygen){ + String *doxygen_comments; + if(DoxygenTranslator::getDocumentation(n, JavaDoc, doxygen_comments)){ + if(comment_creation_chatter) + Printf(enum_code, "/* This was generated from enumvalueDeclaration() */"); + Printf(enum_code, Char(doxygen_comments)); + Delete(doxygen_comments); + } + } if ((enum_feature == ProperEnum) && parent_name && !unnamedinstance) { // Wrap (non-anonymous) C/C++ enum with a proper Java enum // Emit the enum item. - if (!GetFlag(n, "firstenumitem")) - Printf(enum_code, ",\n"); - - //translate and write javadoc comment if flagged - if (doxygen_javadoc_flag){ - String *doxygen_comments; - if(DoxygenTranslator::getDocumentation(n, JavaDoc,doxygen_comments)){ - if(comment_creation_chatter) - Printf(enum_code, "/* This was generated from enumvalueDeclaration() */"); - Printf(enum_code, Char(doxygen_comments)); - Delete(doxygen_comments); - } - } - + Printf(enum_code, " %s", symname); if (Getattr(n, "enumvalue")) { String *value = enumValue(n); Printf(enum_code, "(%s)", value); Delete(value); } + Printf(enum_code, ",\n"); } else { // Wrap C/C++ enums with constant integers or use the typesafe enum pattern SwigType *typemap_lookup_type = parent_name ? parent_name : NewString("enum "); @@ -1493,7 +1489,7 @@ * file * ------------------------------------------------------------------------ */ virtual int doxygenComment(Node *n){ - if (doxygen_javadoc_flag){ + if (doxygen){ String *doxygen_comments; if(DoxygenTranslator::getDocumentation(n, JavaDoc, doxygen_comments)){ if(comment_creation_chatter) @@ -1527,7 +1523,7 @@ Swig_save("constantWrapper", n, "value", NIL); //translate and write javadoc comment if flagged - if (doxygen_javadoc_flag){ + if (doxygen){ String *doxygen_comments; if(DoxygenTranslator::getDocumentation(n, JavaDoc, doxygen_comments)){ if(comment_creation_chatter) @@ -1825,7 +1821,7 @@ const String *pure_interfaces = typemapLookup(n, "javainterfaces", typemap_lookup_type, WARN_NONE); //translate and write javadoc comment if flagged - if (doxygen_javadoc_flag){ + if (doxygen){ String *doxygen_comments; if(DoxygenTranslator::getDocumentation(n, JavaDoc, doxygen_comments)){ if(comment_creation_chatter) @@ -2231,7 +2227,7 @@ } //translate and write javadoc comment if flagged - if (doxygen_javadoc_flag){ + if (doxygen){ String *doxygen_comments; if(DoxygenTranslator::getDocumentation(n, JavaDoc, doxygen_comments)){ if(comment_creation_chatter) @@ -2464,7 +2460,7 @@ Printf(im_return_type, "%s", tm); //translate and write javadoc comment if flagged - if (doxygen_javadoc_flag){ + if (doxygen){ String *doxygen_comments; if(DoxygenTranslator::getDocumentation(n, JavaDoc, doxygen_comments)){ if(comment_creation_chatter) @@ -2736,7 +2732,7 @@ String *post_code = NewString(""); // translate and write javadoc comment if flagged - if (doxygen_javadoc_flag){ + if (doxygen){ String *doxygen_comments; if(DoxygenTranslator::getDocumentation(n, JavaDoc, doxygen_comments)) { if(comment_creation_chatter) @@ -4523,6 +4519,8 @@ const char *JAVA::usage = (char *) "\ Java Options (available with -java)\n\ + -doxygen - Convert C++ doxygen comments to JavaDoc comments in proxy classes (default)\n\ + -nodoxygen - Don't convert C++ doxygen comments to JavaDoc comments in proxy classes\n\ -nopgcpp - Suppress premature garbage collection prevention parameter\n\ -noproxy - Generate the low-level functional interface instead\n\ of proxy classes\n\ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kabbi@us...> - 2012-06-18 18:33:36
|
Revision: 13183 http://swig.svn.sourceforge.net/swig/?rev=13183&view=rev Author: kabbi Date: 2012-06-18 18:33:30 +0000 (Mon, 18 Jun 2012) Log Message: ----------- Fix integration of doxygen with autodoc feature, fixed autodoc test and some code refactored Modified Paths: -------------- branches/gsoc2012-doxygen/Examples/test-suite/python/autodoc_runme.py branches/gsoc2012-doxygen/Source/DoxygenTranslator/src/PyDocConverter.cpp branches/gsoc2012-doxygen/Source/Modules/python.cxx Modified: branches/gsoc2012-doxygen/Examples/test-suite/python/autodoc_runme.py =================================================================== --- branches/gsoc2012-doxygen/Examples/test-suite/python/autodoc_runme.py 2012-06-18 18:30:18 UTC (rev 13182) +++ branches/gsoc2012-doxygen/Examples/test-suite/python/autodoc_runme.py 2012-06-18 18:33:30 UTC (rev 13183) @@ -165,9 +165,9 @@ check(B.funk.__doc__, "funk(B self, int c, int d) -> int") check(funk.__doc__, "funk(A e, short arg2, int c, int d) -> int") check(funkdefaults.__doc__, "\n" -" funkdefaults(A e, short arg2, int c, int d, double f=2) -> int\n" -" funkdefaults(A e, short arg2, int c, int d) -> int\n" -" " +" funkdefaults(A e, short arg2, int c, int d, double f=2) -> int\n" +" funkdefaults(A e, short arg2, int c, int d) -> int\n" +" " ) check(func_input.__doc__, "func_input(int * INPUT) -> int") Modified: branches/gsoc2012-doxygen/Source/DoxygenTranslator/src/PyDocConverter.cpp =================================================================== --- branches/gsoc2012-doxygen/Source/DoxygenTranslator/src/PyDocConverter.cpp 2012-06-18 18:30:18 UTC (rev 13182) +++ branches/gsoc2012-doxygen/Source/DoxygenTranslator/src/PyDocConverter.cpp 2012-06-18 18:33:30 UTC (rev 13183) @@ -193,7 +193,7 @@ // if we got something log the result and construct DOH string to return if (pyDocString.length()) { - result = "\"\"\"\n" + pyDocString + "\"\"\"\n"; + result = pyDocString; if (debug) { std::cout << "\n---RESULT IN PYDOC---" << std::endl; Modified: branches/gsoc2012-doxygen/Source/Modules/python.cxx =================================================================== --- branches/gsoc2012-doxygen/Source/Modules/python.cxx 2012-06-18 18:30:18 UTC (rev 13182) +++ branches/gsoc2012-doxygen/Source/Modules/python.cxx 2012-06-18 18:33:30 UTC (rev 13183) @@ -21,6 +21,7 @@ #include <ctype.h> #include <sstream> #include "../DoxygenTranslator/src/DoxygenTranslator.h" +#include "../../../swig/bug.h" #define PYSHADOW_MEMBER 0x2 #define WARN_PYTHON_MULTIPLE_INH 405 @@ -120,7 +121,7 @@ -classptr - Generate shadow 'ClassPtr' as in older swig versions\n\ -cppcast - Enable C++ casting operators (default) \n\ -dirvtable - Generate a pseudo virtual table for directors for faster dispatch \n\ - -doxygen - Convert C++ doxygen comments to pydoc comments in proxy classes \n\ + -doxygen - Convert C++ doxygen comments to pydoc comments in proxy classes (default) \n\ -extranative - Return extra native C++ wraps for std containers when possible \n\ -fastinit - Use fast init mechanism for classes (default)\n\ -fastunpack - Use fast unpack mechanism to parse the argument functions \n\ @@ -139,6 +140,7 @@ -nocastmode - Disable the casting mode (default)\n\ -nocppcast - Disable C++ casting operators, useful for generating bugs\n\ -nodirvtable - Don't use the virtual table feature, resolve the python method each time (default)\n\ + -nodoxygen - Don't convert C++ doxygen comments to pydoc comments in proxy classes \n\ -noexcept - No automatic exception handling\n\ -noextranative - Don't use extra native C++ wraps for std containers when possible (default) \n\ -nofastinit - Use traditional init mechanism for classes \n\ @@ -418,11 +420,16 @@ } else if (strcmp(argv[i], "-dirvtable") == 0) { dirvtable = 1; Swig_mark_arg(i); + } else if (strcmp(argv[i], "-nodirvtable") == 0) { + dirvtable = 0; + Swig_mark_arg(i); } else if (strcmp(argv[i], "-doxygen") == 0) { doxygen = 1; + scan_doxygen_comments = 1; Swig_mark_arg(i); - } else if (strcmp(argv[i], "-nodirvtable") == 0) { - dirvtable = 0; + } else if (strcmp(argv[i], "-nodoxygen") == 0) { + doxygen = 0; + scan_doxygen_comments = 0; Swig_mark_arg(i); } else if (strcmp(argv[i], "-fastunpack") == 0) { fastunpack = 1; @@ -1194,7 +1201,10 @@ bool have_docstring(Node *n) { String *str = Getattr(n, "feature:docstring"); - return (str && Len(str) > 0) || (Getattr(n, "feature:autodoc") && !GetFlag(n, "feature:noautodoc")); + return ((str && Len(str) > 0) + || (Getattr(n, "feature:autodoc") && !GetFlag(n, "feature:noautodoc")) + || (doxygen && Getattr(n, "DoxygenComment")) + ); } /* ------------------------------------------------------------ @@ -1206,8 +1216,10 @@ String *docstring(Node *n, autodoc_t ad_type, const String *indent, bool use_triple = true) { String *str = Getattr(n, "feature:docstring"); + String *doxygen_comment = 0; bool have_ds = (str && Len(str) > 0); bool have_auto = (Getattr(n, "feature:autodoc") && !GetFlag(n, "feature:noautodoc")); + bool have_doxygen = doxygen && DoxygenTranslator::getDocumentation(n, PyDoc, doxygen_comment); const char *triple_double = use_triple ? "\"\"\"" : ""; String *autodoc = NULL; String *doc = NULL; @@ -1224,6 +1236,9 @@ autodoc = make_autodoc(n, ad_type); have_auto = (autodoc && Len(autodoc) > 0); } + if (have_doxygen) { + have_doxygen = (doxygen_comment && Len(doxygen_comment) > 0); + } // If there is more than one line then make docstrings like this: // // """ @@ -1250,8 +1265,12 @@ doc = NewString(""); Printv(doc, triple_double, "\n", pythoncode(autodoc, indent), indent, triple_double, NIL); } - } else + } else if (have_doxygen) { // the lowest priority doc = NewString(""); + Printv(doc, triple_double, "\n", pythoncode(doxygen_comment, indent), indent, triple_double, NIL); + } + else + doc = NewString(""); // Save the generated strings in the parse tree in case they are used later // by post processing tools @@ -1780,15 +1799,8 @@ String *callParms = make_pyParmList(n, false, true, kw); /* Make a wrapper function to insert the code into */ Printv(f_dest, "\ndef ", name, "(", parms, ")", returnTypeAnnotation(n), ":\n", NIL); - if (doxygen) { - String *doxygen_comments; - if (DoxygenTranslator::getDocumentation(n, PyDoc, doxygen_comments)) { - Printf(f_dest, Char(pythoncode(doxygen_comments, tab2))); - Delete(doxygen_comments); - } - } if (have_docstring(n)) - Printv(f_dest, " ", docstring(n, AUTODOC_FUNC, tab4), "\n", NIL); + Printv(f_dest, " ", docstring(n, AUTODOC_FUNC, tab2), "\n", NIL); if (have_pythonprepend(n)) Printv(f_dest, pythoncode(pythonprepend(n), " "), "\n", NIL); if (have_pythonappend(n)) { @@ -3700,16 +3712,7 @@ Printf(f_shadow, ":\n"); - // translate and write pydoc comment if flagged - if (doxygen){ - String *doxygen_comments; - if(DoxygenTranslator::getDocumentation(n, PyDoc, doxygen_comments)){ - Printf(f_shadow, Char(pythoncode(doxygen_comments, shadow_indent))); - Delete(doxygen_comments); - } - } - - // otherwise use default docstrings if requested + // write docstrings if requested if (have_docstring(n)) { String *str = docstring(n, AUTODOC_CLASS, tab4); if (str && Len(str)) @@ -3987,26 +3990,12 @@ if (!fastproxy || olddefs) { Printv(f_shadow, tab4, "def ", symname, "(", parms, ")", returnTypeAnnotation(n), ":", NIL); Printv(f_shadow, "\n", NIL); - if (doxygen) { - String *doxygen_comments; - if (DoxygenTranslator::getDocumentation(n, PyDoc, doxygen_comments)) { - Printf(f_shadow, Char(pythoncode(doxygen_comments, tab8))); - Delete(doxygen_comments); - } - } Printv(f_shadow, tab8, "return ", funcCall(fullname, callParms), "\n", NIL); } } else { Printv(f_shadow, tab4, "def ", symname, "(", parms, ")", returnTypeAnnotation(n), ":", NIL); Printv(f_shadow, "\n", NIL); - if (doxygen) { - String *doxygen_comments; - if(DoxygenTranslator::getDocumentation(n, PyDoc, doxygen_comments)){ - Printf(f_shadow, Char(pythoncode(doxygen_comments, tab8))); - Delete(doxygen_comments); - } - } - else if (have_docstring(n)) + if (have_docstring(n)) Printv(f_shadow, tab8, docstring(n, AUTODOC_METHOD, tab8), "\n", NIL); if (have_pythonprepend(n)) { fproxy = 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <kabbi@us...> - 2012-06-18 18:30:24
|
Revision: 13182 http://swig.svn.sourceforge.net/swig/?rev=13182&view=rev Author: kabbi Date: 2012-06-18 18:30:18 +0000 (Mon, 18 Jun 2012) Log Message: ----------- Implement toggling comment parsing feature on and off Modified Paths: -------------- branches/gsoc2012-doxygen/Source/CParse/cparse.h branches/gsoc2012-doxygen/Source/CParse/cscanner.c branches/gsoc2012-doxygen/Source/CParse/parser.y Modified: branches/gsoc2012-doxygen/Source/CParse/cparse.h =================================================================== --- branches/gsoc2012-doxygen/Source/CParse/cparse.h 2012-06-18 14:40:28 UTC (rev 13181) +++ branches/gsoc2012-doxygen/Source/CParse/cparse.h 2012-06-18 18:30:18 UTC (rev 13182) @@ -26,6 +26,7 @@ extern int cparse_line; extern int cparse_cplusplus; extern int cparse_start_line; + extern int scan_doxygen_comments; extern void Swig_cparse_cplusplus(int); extern void scanner_file(File *); Modified: branches/gsoc2012-doxygen/Source/CParse/cscanner.c =================================================================== --- branches/gsoc2012-doxygen/Source/CParse/cscanner.c 2012-06-18 14:40:28 UTC (rev 13181) +++ branches/gsoc2012-doxygen/Source/CParse/cscanner.c 2012-06-18 18:30:18 UTC (rev 13182) @@ -46,6 +46,9 @@ static int last_id = 0; static int rename_active = 0; +/* Doxygen comments scanning */ +int scan_doxygen_comments = 1; + /* ----------------------------------------------------------------------------- * Swig_cparse_cplusplus() * ----------------------------------------------------------------------------- */ @@ -337,16 +340,18 @@ if ((strncmp(loc,"/*@SWIG",7) == 0) && (loc[Len(cmt)-3] == '@')) { Scanner_locator(scan, cmt); } - if (strncmp(loc, "/**<", 4) == 0 || strncmp(loc, "///<", 4) == 0||strncmp(loc, "/*!<", 4) == 0||strncmp(loc, "//!<", 4) == 0) { - /* printf("Doxygen Post Comment: %s lines %d-%d [%s]\n", Char(Scanner_file(scan)), Scanner_start_line(scan), Scanner_line(scan), loc); */ - yylval.str = NewString(loc); - return DOXYGENPOSTSTRING; + if (scan_doxygen_comments) { /* else just skip this node, to avoid crashes in parser module*/ + if (strncmp(loc, "/**<", 4) == 0 || strncmp(loc, "///<", 4) == 0||strncmp(loc, "/*!<", 4) == 0||strncmp(loc, "//!<", 4) == 0) { + /* printf("Doxygen Post Comment: %s lines %d-%d [%s]\n", Char(Scanner_file(scan)), Scanner_start_line(scan), Scanner_line(scan), loc); */ + yylval.str = NewString(loc); + return DOXYGENPOSTSTRING; + } + if (strncmp(loc, "/**", 3) == 0 || strncmp(loc, "///", 3) == 0||strncmp(loc, "/*!", 3) == 0||strncmp(loc, "//!", 3) == 0) { + /* printf("Doxygen Comment: %s lines %d-%d [%s]\n", Char(Scanner_file(scan)), Scanner_start_line(scan), Scanner_line(scan), loc); */ + yylval.str = NewString(loc); + return DOXYGENSTRING; + } } - if (strncmp(loc, "/**", 3) == 0 || strncmp(loc, "///", 3) == 0||strncmp(loc, "/*!", 3) == 0||strncmp(loc, "//!", 3) == 0) { - /* printf("Doxygen Comment: %s lines %d-%d [%s]\n", Char(Scanner_file(scan)), Scanner_start_line(scan), Scanner_line(scan), loc); */ - yylval.str = NewString(loc); - return DOXYGENSTRING; - } } break; case SWIG_TOKEN_ENDLINE: Modified: branches/gsoc2012-doxygen/Source/CParse/parser.y =================================================================== --- branches/gsoc2012-doxygen/Source/CParse/parser.y 2012-06-18 14:40:28 UTC (rev 13181) +++ branches/gsoc2012-doxygen/Source/CParse/parser.y 2012-06-18 18:30:18 UTC (rev 13182) @@ -63,7 +63,6 @@ /* ----------------------------------------------------------------------------- * Doxygen Comment Globals and Assist Functions * ----------------------------------------------------------------------------- */ -int parseComments = 1; /* set this to activate Doxygen uptake into the parse tree */ String *currentComment; /* Location of the stored Doxygen Comment */ String *currentPostComment; /* Location of the stored Doxygen Post-Comment */ String *currentCComment; /* Location of the stored C Comment */ @@ -107,7 +106,7 @@ set_nodeType(n,tag); Setfile(n,cparse_file); Setline(n,cparse_line); - if(parseComments){ + if(scan_doxygen_comments){ /* Sets any post comments to the previous node */ if(previousNode != NULL && currentPostComment != 0){ String *copyPostComment = Copy(currentPostComment); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <neha1@us...> - 2012-06-18 14:40:37
|
Revision: 13181 http://swig.svn.sourceforge.net/swig/?rev=13181&view=rev Author: neha1 Date: 2012-06-18 14:40:28 +0000 (Mon, 18 Jun 2012) Log Message: ----------- Fixed syntax error in javascriptcode. Modified Paths: -------------- branches/gsoc2012-javascript/Lib/javascript/jsc/javascriptcode.swg Modified: branches/gsoc2012-javascript/Lib/javascript/jsc/javascriptcode.swg =================================================================== --- branches/gsoc2012-javascript/Lib/javascript/jsc/javascriptcode.swg 2012-06-18 14:39:52 UTC (rev 13180) +++ branches/gsoc2012-javascript/Lib/javascript/jsc/javascriptcode.swg 2012-06-18 14:40:28 UTC (rev 13181) @@ -25,11 +25,10 @@ %{ void $jsclassname_initialize(JSContextRef context, JSObjectRef thisObject)%} -%typemap (accessconstructorbody) +%fragment ("accessconstructorbody", "templates") { } - -%typemap ("accessdestructordecl", "templates") +%fragment ("accessdestructordecl", "templates") %{ void $jsclassname_finalize(JSObjectRef thisObject)%} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <neha1@us...> - 2012-06-18 14:39:58
|
Revision: 13180 http://swig.svn.sourceforge.net/swig/?rev=13180&view=rev Author: neha1 Date: 2012-06-18 14:39:52 +0000 (Mon, 18 Jun 2012) Log Message: ----------- Added additionally swg files for javascript JSCModule. Added Paths: ----------- branches/gsoc2012-javascript/Lib/javascript/jsc/javascripthelpers.swg branches/gsoc2012-javascript/Lib/javascript/jsc/javascriptruntime.swg Added: branches/gsoc2012-javascript/Lib/javascript/jsc/javascripthelpers.swg =================================================================== Added: branches/gsoc2012-javascript/Lib/javascript/jsc/javascriptruntime.swg =================================================================== --- branches/gsoc2012-javascript/Lib/javascript/jsc/javascriptruntime.swg (rev 0) +++ branches/gsoc2012-javascript/Lib/javascript/jsc/javascriptruntime.swg 2012-06-18 14:39:52 UTC (rev 13180) @@ -0,0 +1,19 @@ +/* ----------------------------------------------------------------------------- + * javascriptruntime.swg + * + * Javascript support code + * ----------------------------------------------------------------------------- */ + +%insert(runtime) %{ +#include <JavaScriptCore/JavaScript.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +%} + +%insert(runtime) %{ +typedef struct { + bool swigCMemOwn; + void *swigCObject; +}SWIG_PRV_DATA; +%} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <neha1@us...> - 2012-06-18 14:39:21
|
Revision: 13179 http://swig.svn.sourceforge.net/swig/?rev=13179&view=rev Author: neha1 Date: 2012-06-18 14:39:12 +0000 (Mon, 18 Jun 2012) Log Message: ----------- Added typemaps for primitives(Ashish sharma). These typemaps have been taken from the module prototype written by Ashish Sharma(ashishs99@...). Added Paths: ----------- branches/gsoc2012-javascript/Lib/javascript/jsc/javascriptprimitives.swg Added: branches/gsoc2012-javascript/Lib/javascript/jsc/javascriptprimitives.swg =================================================================== --- branches/gsoc2012-javascript/Lib/javascript/jsc/javascriptprimitives.swg (rev 0) +++ branches/gsoc2012-javascript/Lib/javascript/jsc/javascriptprimitives.swg 2012-06-18 14:39:12 UTC (rev 13179) @@ -0,0 +1,264 @@ +// Primitive types +%typemap(in) char, + signed char, + unsigned char, + short, + unsigned short, + int, + unsigned int, + long, + unsigned long, + long long, + unsigned long long, + float, + double +%{ $1 = ($1_ltype)JSValueToNumber(context, $input, NULL); %} + +%typemap(in) const bool &, bool &, + const char &, char &, + const signed char &, signed char &, + const unsigned char &, unsigned char &, + const short &, short &, + const unsigned short &, unsigned short &, + const int &, int &, + const unsigned int &, unsigned int &, + const long &, long &, + const unsigned long &, unsigned long &, + const long long &, long long &, + const unsigned long long &,unsigned long long &, + const float &, float &, + const double &, double & +%{ $1 = ($1_ltype)&$input; %} + +%typemap(out) char, + signed char, + unsigned char, + short, + unsigned short, + int, + unsigned int, + long, + unsigned long, + long long, + unsigned long long, + float, + double +%{ $result = JSValueMakeNumber(context, $1); %} + +%typemap(out) const bool &, bool &, + const char &, char &, + const signed char &, signed char &, + const unsigned char &, unsigned char &, + const short &, short &, + const unsigned short &, unsigned short &, + const int &, int &, + const unsigned int &, unsigned int &, + const long &, long &, + const unsigned long &, unsigned long &, + const long long &, long long &, + const unsigned long long &,unsigned long long &, + const float &, float &, + const double &, double & +%{ $result = JSValueMakeNumber(context,*$1); %} + + +%typemap(in) short *, + unsigned short *, + int *, + unsigned int *, + long *, + unsigned long *, + long long *, + unsigned long long *, + float *, + double * +%{ + JSObjectRef o$1 = JSValueToObject(context,$input, NULL); + SWIG_PRV_DATA *$1_privatedata = (SWIG_PRV_DATA *)JSObjectGetPrivate(o$1); + $1 = ($1_ltype)$1_privatedata->swigCObject; +%} + + +%typemap(out) short *, + unsigned short *, + int *, + unsigned int *, + long *, + unsigned long *, + long long *, + unsigned long long *, + float *, + double * +%{ + SWIG_PRV_DATA *privatedata = new SWIG_PRV_DATA(); + privatedata->swigCMemOwn = false; + privatedata->swigCObject = result; + $result = JSObjectMake(context, _wrap_swig_ptr_$*1_ltype_createJSClass(context), privatedata); +%} + +%typemap(in) bool +%{ + $1 = ($1_ltype)JSValueToBoolean(context, $input); +%} + +%typemap(out) bool +%{ + $result = JSValueMakeBoolean(context, $1); +%} + + +%typemap(out) void +%{ $result = JSValueMakeUndefined(context); %} + + +%typemap(in) char * +%{ + JSStringRef $1_str = JSValueToStringCopy(context, $input, NULL); + size_t $1_strsize = JSStringGetMaximumUTF8CStringSize($1_str); + $1 = (char *)malloc($1_strsize * sizeof(char)); + JSStringGetUTF8CString($1_str, $1, $1_strsize); +%} + +%typemap(out) char * +%{ + JSStringRef jsstring = JSStringCreateWithUTF8CString($1); + $result = JSValueMakeString(context, jsstring); + JSStringRelease(jsstring); +%} + +%typemap(arginit) char * "" + +%typemap(in) char *& ($*1_ltype temp = 0) %{ + temp = ($*1_ltype)$input; + JSStringRef $1_str = JSValueToStringCopy(context, $input, NULL); + size_t $1_strsize = JSStringGetMaximumUTF8CStringSize($1_str); + $1 = (char *)malloc($1_strsize * sizeof(char)); + JSStringGetUTF8CString($1_str, $1, $1_strsize); +%} + +%typemap(out) char *& +%{ + JSStringRef jsstring = JSStringCreateWithUTF8CString((const char *)*$1); + $result = JSValueMakeString(context, jsstring); + JSStringRelease(jsstring); +%} + +/* char arrays - treat as String */ +%typemap(in) char[ANY], char[] %{ + JSStringRef $1_str = JSValueToStringCopy(context, $input, NULL); + size_t $1_strsize = JSStringGetMaximumUTF8CStringSize($1_str); + JSStringGetUTF8CString($1_str, $1, $1_strsize); +%} + +%typemap(out) char[ANY], char[] +%{ + JSStringRef jsstring = JSStringCreateWithUTF8CString($1); + $result = JSValueMakeString(context, jsstring); + JSStringRelease(jsstring); +%} + +%typemap(freearg) char *, char *&, char[ANY], char[] //TODO: Not working: A memory leak +%{ free($1); %} + + +/* Typemaps for composite types */ +%typemap(in) SWIGTYPE ($&1_type argp) // Objects passed by value, convert to a pointer +%{ + JSObjectRef o$1 = JSValueToObject(context,$input, NULL); + SWIG_PRV_DATA *$1_privatedata = (SWIG_PRV_DATA *)JSObjectGetPrivate(o$1); + argp = ($&1_ltype)$1_privatedata->swigCObject; + $1 = *argp; +%} + +%typemap(out) SWIGTYPE ($&1_type temp) +#ifdef __cplusplus +%{ + temp = new $1_ltype((const $1_ltype &)$1); + SWIG_PRV_DATA *privatedata = new SWIG_PRV_DATA(); + privatedata->swigCMemOwn = false; + privatedata->swigCObject = temp; + $result = JSObjectMake(context, _wrap_$1_type_createJSClass(context), privatedata); + //$result = JSObjectMake(context, _wrap_$1_basetype_createJSClass(context), privatedata); + //$result = JSObjectMake(context, _wrap_$objecttype_createJSClass(context), privatedata); + // $1_mangle + // $1_descriptor +%} +#else +{ + $&1_ltype $1ptr = ($&1_ltype) malloc(sizeof($1_ltype)); + memmove($1ptr, &$1, sizeof($1_type)); + temp = $1ptr; + SWIG_PRV_DATA *privatedata = (SWIG_PRV_DATA *)malloc(sizeof(SWIG_PRV_DATA()); + privatedata->swigCMemOwn = false; + privatedata->swigCObject = temp; + $result = JSObjectMake(context, _wrap_$1_ltype_createJSClass(context), privatedata); + //$result = JSObjectMake(context, _wrap_$1_basetype_createJSClass(context), privatedata); + //$result = JSObjectMake(context, _wrap_$objecttype_createJSClass(context), privatedata); + // $1_mangle + // $1_descriptor +} +#endif + +%typemap(in) SWIGTYPE *, SWIGTYPE & +%{ + JSObjectRef o$1 = JSValueToObject(context,$input, NULL); + SWIG_PRV_DATA *$1_privatedata = (SWIG_PRV_DATA *)JSObjectGetPrivate(o$1); + $1 = ($1_ltype)$1_privatedata->swigCObject; +%} + +%typemap(out) SWIGTYPE *, SWIGTYPE & +%{ + SWIG_PRV_DATA *privatedata = new SWIG_PRV_DATA(); + privatedata->swigCMemOwn = false; + privatedata->swigCObject = result; + $result = JSObjectMake(context, _wrap_$*1_ltype_createJSClass(context), privatedata); + //$result = JSObjectMake(context, _wrap_$1_basetype_createJSClass(context), privatedata); + //$result = JSObjectMake(context, _wrap_$objecttype_createJSClass(context), privatedata); + // $1_mangle + // $1_descriptor +%} + +%typemap(arginit) SWIGTYPE * +%{ + // Sanity check if the call is not on the global object + if (!JSValueIsEqual(context, + JSValueToObject(context,thisObject,NULL), + JSValueToObject(context,JSContextGetGlobalObject(context), NULL), + NULL)) { + SWIG_PRV_DATA* $1_swigprivatedata = (SWIG_PRV_DATA*)JSObjectGetPrivate(thisObject); + $1 = ($1_ltype)$1_swigprivatedata->swigCObject; + } +%} + +%typemap(in) SWIGTYPE (CLASS::*) "" + +%typemap(out) SWIGTYPE (CLASS::*) +%{ + // Class* out typemap + $result = JSObjectMake(context, _wrap_$*1_ltype_createJSClass(context), result); +%} + + + +/* Typecheck typemaps - The purpose of these is merely to issue a warning for overloaded C++ functions + * that cannot be overloaded in Javascript as more than one C++ type maps to a single Javascript type */ +// TODO + + +// Default array handling +%typemap(in) SWIGTYPE [] %{ $1 = ($1_ltype)$input; %} +%typemap(out) SWIGTYPE [] %{ $result = $1; %} + + +// Javascript specific directives +//TODO + +// Some ANSI C typemaps */ +%apply unsigned long { size_t }; +%apply const unsigned long & { const size_t & }; + +// Array reference typemaps +%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) } + +// const pointers +%apply SWIGTYPE * { SWIGTYPE *const } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <neha1@us...> - 2012-06-18 14:38:47
|
Revision: 13178 http://swig.svn.sourceforge.net/swig/?rev=13178&view=rev Author: neha1 Date: 2012-06-18 14:38:36 +0000 (Mon, 18 Jun 2012) Log Message: ----------- Moved swg file containing code templates for JSC emitter. Added Paths: ----------- branches/gsoc2012-javascript/Lib/javascript/jsc/ branches/gsoc2012-javascript/Lib/javascript/jsc/javascriptcode.swg Removed Paths: ------------- branches/gsoc2012-javascript/Lib/javascript/javascriptcode.swg Deleted: branches/gsoc2012-javascript/Lib/javascript/javascriptcode.swg =================================================================== --- branches/gsoc2012-javascript/Lib/javascript/javascriptcode.swg 2012-06-18 14:37:55 UTC (rev 13177) +++ branches/gsoc2012-javascript/Lib/javascript/javascriptcode.swg 2012-06-18 14:38:36 UTC (rev 13178) @@ -1,227 +0,0 @@ -/* ---------------------------------------------------------------------------------------------- - * javascriptcode.swg - * - * Additional Javascript typemaps for generating code for classes, constants and variables - * ----------------------------------------------------------------------------- ----------------*/ - -/* Additional typemaps for the class code needed by the access layer. This code is copy-pasted into the wrapper header and source file */ -%fragment ("getpropertydecl", "templates") -%{ -JSValueRef $getname(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)%} - -%fragment ("setpropertydecl", "templates") -%{ -bool $setname(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef value, -JSValueRef* exception)%} - -%fragment ("functiondecl", "templates") -%{ -JSValueRef $functionname(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception)%} - - - - -%fragment ("accessconstructordecl", "templates") -%{ -void $jsclassname_initialize(JSContextRef context, JSObjectRef thisObject)%} - -%typemap (accessconstructorbody) -{ -} - -%typemap ("accessdestructordecl", "templates") -%{ -void $jsclassname_finalize(JSObjectRef thisObject)%} - -%fragment ("accessdestructorbody", "templates") -{ - SWIG_PRV_DATA* t = (SWIG_PRV_DATA*)JSObjectGetPrivate(thisObject); - if(t && t->swigCMemOwn) delete ($objecttype*)(t->swigCObject); - if(t) delete t; -} - -%fragment ("accessvariablesdefn", "templates") -%{ -JSStaticValue $jsclassname_staticValues[] = { -$jsstaticvaluescode - { 0, 0, 0, 0 } -}; - -JSStaticFunction $jsclassname_staticFunctions[] = { -$jsstaticfuncscode - { 0, 0, 0 } -}; -%} - -%fragment("accessfunctionsdecl", "templates") -%{ -bool $jsclassname_initClass(JSGlobalContextRef& context, JSObjectRef& parentObject, const char* className); -JSClassRef $jsclassname_createJSClass(JSContextRef context); -JSObjectRef $jsclassname_createcppObject(JSContextRef context, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], -JSValueRef* exception); -%} - -%fragment("accessfunctionsdefn", "templates") -%{ -JSClassRef $jsclassname_createJSClass(JSContextRef context) -{ - static JSClassRef jsClass = NULL; - if (!jsClass) - { - JSClassDefinition definition = kJSClassDefinitionEmpty; - definition.staticValues = $jsclassname_staticValues; - definition.staticFunctions = $jsclassname_staticFunctions; - definition.initialize = $jsclassname_initialize; - definition.finalize = $jsclassname_finalize; - jsClass = JSClassCreate(&definition); - } - return jsClass; -} - -JSObjectRef $jsclassname_createcppObject(JSContextRef context, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], -JSValueRef* exception) -{ - JSObjectRef jsresult; - $objecttype result = 0; - $jscreatecppobjectcode - SWIG_PRV_DATA *swigprivatedata = new SWIG_PRV_DATA(); - swigprivatedata->swigCMemOwn = true; - swigprivatedata->swigCObject = result; - - jsresult = JSObjectMake(context, $jsclassname_createJSClass(context), swigprivatedata); - return jsresult; -} - -bool $jsclassname_initClass(JSGlobalContextRef& context, JSObjectRef& parentObject, const char* className) -{ - JSStringRef jsstring = JSStringCreateWithUTF8CString(className); - JSObjectSetProperty(context, parentObject, jsstring, - JSObjectMakeConstructor(context, - $jsclassname_createJSClass(context), - $jsclassname_createcppObject), - kJSPropertyAttributeNone, - NULL); - JSStringRelease(jsstring); - return true; -} -%} - - -/* Additional typemaps needed for generating the code for handling constants as properties of the cconst object */ -%fragment ("constantdecl", "templates") -%{JSValueRef $constantgetname(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)%} - -%fragment ("constantbody", "templates") -%{ - SWIGUNUSEDPARM(thisObject); - SWIGUNUSEDPARM(exception); - JSValueRef jsresult; -%} - -%fragment ("cconstdecl", "templates") -%{ -bool cconst_initClass(JSGlobalContextRef& context, JSObjectRef& parentObject, const char* constclassname); -%} - -%fragment ("cconstdefn", "templates") -%{ - -JSStaticValue cconst_staticValues[] = { -$jsstaticconstscode - { 0, 0, 0, 0 } -}; - -JSClassRef cconst_createJSClass(JSContextRef context) -{ - static JSClassRef jsClass = NULL; - if (!jsClass) - { - JSClassDefinition definition = kJSClassDefinitionEmpty; - definition.staticValues = cconst_staticValues; - jsClass = JSClassCreate(&definition); - } - return jsClass; -} - -bool cconst_initClass(JSGlobalContextRef& context, JSObjectRef& parentObject, const char* constclassname) -{ - JSStringRef jsstring = JSStringCreateWithUTF8CString(constclassname); - static JSObjectRef cconstclassObject = JSObjectMake(context, cconst_createJSClass(context), NULL); - JSObjectSetProperty( - context, - parentObject, - jsstring, - cconstclassObject, - kJSPropertyAttributeNone, - NULL); - JSStringRelease(jsstring); - return true; -} -%} - - - -/* Additional typemaps needed for generating the code for handling C global variables as properties if the cvar object */ - -%fragment ("variablegetdecl", "templates") -%{ -JSValueRef $variablegetname(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)%} - -%fragment ("variablesetdecl", "templates") -%{ -bool $variablesetname(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef value, -JSValueRef* exception)%} - - -%fragment ("variablebody", "templates") -%{ - SWIGUNUSEDPARM(thisObject); - SWIGUNUSEDPARM(exception); - JSValueRef jsresult; -%} - -%fragment ("cvardecl", "tamplate") -%{ -bool cvar_initClass(JSGlobalContextRef& context, JSObjectRef& parentObject, const char* cvarclassname); -%} - -%fragment ("cvardefn", "templates") -%{ - -JSStaticValue cvar_staticValues[] = { -$jsstaticvarcode - { 0, 0, 0, 0 } -}; - -JSClassRef cvar_createJSClass(JSContextRef context) -{ - static JSClassRef jsClass = NULL; - if (!jsClass) - { - JSClassDefinition definition = kJSClassDefinitionEmpty; - definition.staticValues = cvar_staticValues; - jsClass = JSClassCreate(&definition); - } - return jsClass; -} - -bool cvar_initClass(JSGlobalContextRef& context, JSObjectRef& parentObject, const char* cvarclassname) -{ - JSStringRef jsstring = JSStringCreateWithUTF8CString(cvarclassname); - static JSObjectRef cvarclassObject = JSObjectMake(context, cvar_createJSClass(context), NULL); - JSObjectSetProperty( - context, - parentObject, - jsstring, - cvarclassObject, - kJSPropertyAttributeNone, - NULL); - JSStringRelease(jsstring); - return true; -} -%} - - - - - Copied: branches/gsoc2012-javascript/Lib/javascript/jsc/javascriptcode.swg (from rev 13177, branches/gsoc2012-javascript/Lib/javascript/javascriptcode.swg) =================================================================== --- branches/gsoc2012-javascript/Lib/javascript/jsc/javascriptcode.swg (rev 0) +++ branches/gsoc2012-javascript/Lib/javascript/jsc/javascriptcode.swg 2012-06-18 14:38:36 UTC (rev 13178) @@ -0,0 +1,227 @@ +/* ---------------------------------------------------------------------------------------------- + * javascriptcode.swg + * + * Additional Javascript typemaps for generating code for classes, constants and variables + * ----------------------------------------------------------------------------- ----------------*/ + +/* Additional typemaps for the class code needed by the access layer. This code is copy-pasted into the wrapper header and source file */ +%fragment ("getpropertydecl", "templates") +%{ +JSValueRef $getname(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)%} + +%fragment ("setpropertydecl", "templates") +%{ +bool $setname(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef value, +JSValueRef* exception)%} + +%fragment ("functiondecl", "templates") +%{ +JSValueRef $functionname(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], JSValueRef* exception)%} + + + + +%fragment ("accessconstructordecl", "templates") +%{ +void $jsclassname_initialize(JSContextRef context, JSObjectRef thisObject)%} + +%typemap (accessconstructorbody) +{ +} + +%typemap ("accessdestructordecl", "templates") +%{ +void $jsclassname_finalize(JSObjectRef thisObject)%} + +%fragment ("accessdestructorbody", "templates") +{ + SWIG_PRV_DATA* t = (SWIG_PRV_DATA*)JSObjectGetPrivate(thisObject); + if(t && t->swigCMemOwn) delete ($objecttype*)(t->swigCObject); + if(t) delete t; +} + +%fragment ("accessvariablesdefn", "templates") +%{ +JSStaticValue $jsclassname_staticValues[] = { +$jsstaticvaluescode + { 0, 0, 0, 0 } +}; + +JSStaticFunction $jsclassname_staticFunctions[] = { +$jsstaticfuncscode + { 0, 0, 0 } +}; +%} + +%fragment("accessfunctionsdecl", "templates") +%{ +bool $jsclassname_initClass(JSGlobalContextRef& context, JSObjectRef& parentObject, const char* className); +JSClassRef $jsclassname_createJSClass(JSContextRef context); +JSObjectRef $jsclassname_createcppObject(JSContextRef context, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], +JSValueRef* exception); +%} + +%fragment("accessfunctionsdefn", "templates") +%{ +JSClassRef $jsclassname_createJSClass(JSContextRef context) +{ + static JSClassRef jsClass = NULL; + if (!jsClass) + { + JSClassDefinition definition = kJSClassDefinitionEmpty; + definition.staticValues = $jsclassname_staticValues; + definition.staticFunctions = $jsclassname_staticFunctions; + definition.initialize = $jsclassname_initialize; + definition.finalize = $jsclassname_finalize; + jsClass = JSClassCreate(&definition); + } + return jsClass; +} + +JSObjectRef $jsclassname_createcppObject(JSContextRef context, JSObjectRef thisObject, size_t argc, const JSValueRef argv[], +JSValueRef* exception) +{ + JSObjectRef jsresult; + $objecttype result = 0; + $jscreatecppobjectcode + SWIG_PRV_DATA *swigprivatedata = new SWIG_PRV_DATA(); + swigprivatedata->swigCMemOwn = true; + swigprivatedata->swigCObject = result; + + jsresult = JSObjectMake(context, $jsclassname_createJSClass(context), swigprivatedata); + return jsresult; +} + +bool $jsclassname_initClass(JSGlobalContextRef& context, JSObjectRef& parentObject, const char* className) +{ + JSStringRef jsstring = JSStringCreateWithUTF8CString(className); + JSObjectSetProperty(context, parentObject, jsstring, + JSObjectMakeConstructor(context, + $jsclassname_createJSClass(context), + $jsclassname_createcppObject), + kJSPropertyAttributeNone, + NULL); + JSStringRelease(jsstring); + return true; +} +%} + + +/* Additional typemaps needed for generating the code for handling constants as properties of the cconst object */ +%fragment ("constantdecl", "templates") +%{JSValueRef $constantgetname(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)%} + +%fragment ("constantbody", "templates") +%{ + SWIGUNUSEDPARM(thisObject); + SWIGUNUSEDPARM(exception); + JSValueRef jsresult; +%} + +%fragment ("cconstdecl", "templates") +%{ +bool cconst_initClass(JSGlobalContextRef& context, JSObjectRef& parentObject, const char* constclassname); +%} + +%fragment ("cconstdefn", "templates") +%{ + +JSStaticValue cconst_staticValues[] = { +$jsstaticconstscode + { 0, 0, 0, 0 } +}; + +JSClassRef cconst_createJSClass(JSContextRef context) +{ + static JSClassRef jsClass = NULL; + if (!jsClass) + { + JSClassDefinition definition = kJSClassDefinitionEmpty; + definition.staticValues = cconst_staticValues; + jsClass = JSClassCreate(&definition); + } + return jsClass; +} + +bool cconst_initClass(JSGlobalContextRef& context, JSObjectRef& parentObject, const char* constclassname) +{ + JSStringRef jsstring = JSStringCreateWithUTF8CString(constclassname); + static JSObjectRef cconstclassObject = JSObjectMake(context, cconst_createJSClass(context), NULL); + JSObjectSetProperty( + context, + parentObject, + jsstring, + cconstclassObject, + kJSPropertyAttributeNone, + NULL); + JSStringRelease(jsstring); + return true; +} +%} + + + +/* Additional typemaps needed for generating the code for handling C global variables as properties if the cvar object */ + +%fragment ("variablegetdecl", "templates") +%{ +JSValueRef $variablegetname(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef* exception)%} + +%fragment ("variablesetdecl", "templates") +%{ +bool $variablesetname(JSContextRef context, JSObjectRef thisObject, JSStringRef propertyName, JSValueRef value, +JSValueRef* exception)%} + + +%fragment ("variablebody", "templates") +%{ + SWIGUNUSEDPARM(thisObject); + SWIGUNUSEDPARM(exception); + JSValueRef jsresult; +%} + +%fragment ("cvardecl", "tamplate") +%{ +bool cvar_initClass(JSGlobalContextRef& context, JSObjectRef& parentObject, const char* cvarclassname); +%} + +%fragment ("cvardefn", "templates") +%{ + +JSStaticValue cvar_staticValues[] = { +$jsstaticvarcode + { 0, 0, 0, 0 } +}; + +JSClassRef cvar_createJSClass(JSContextRef context) +{ + static JSClassRef jsClass = NULL; + if (!jsClass) + { + JSClassDefinition definition = kJSClassDefinitionEmpty; + definition.staticValues = cvar_staticValues; + jsClass = JSClassCreate(&definition); + } + return jsClass; +} + +bool cvar_initClass(JSGlobalContextRef& context, JSObjectRef& parentObject, const char* cvarclassname) +{ + JSStringRef jsstring = JSStringCreateWithUTF8CString(cvarclassname); + static JSObjectRef cvarclassObject = JSObjectMake(context, cvar_createJSClass(context), NULL); + JSObjectSetProperty( + context, + parentObject, + jsstring, + cvarclassObject, + kJSPropertyAttributeNone, + NULL); + JSStringRelease(jsstring); + return true; +} +%} + + + + + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <neha1@us...> - 2012-06-18 14:38:05
|
Revision: 13177 http://swig.svn.sourceforge.net/swig/?rev=13177&view=rev Author: neha1 Date: 2012-06-18 14:37:55 +0000 (Mon, 18 Jun 2012) Log Message: ----------- Fix error in javascript_jsc.h. Modified Paths: -------------- branches/gsoc2012-javascript/Source/Modules/javascript_jsc.h Modified: branches/gsoc2012-javascript/Source/Modules/javascript_jsc.h =================================================================== --- branches/gsoc2012-javascript/Source/Modules/javascript_jsc.h 2012-06-18 14:37:25 UTC (rev 13176) +++ branches/gsoc2012-javascript/Source/Modules/javascript_jsc.h 2012-06-18 14:37:55 UTC (rev 13177) @@ -48,7 +48,7 @@ // the output cpp file - File *f_wrap_cpp; + //File *f_wrap_cpp; // state variables This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <neha1@us...> - 2012-06-18 14:37:34
|
Revision: 13176 http://swig.svn.sourceforge.net/swig/?rev=13176&view=rev Author: neha1 Date: 2012-06-18 14:37:25 +0000 (Mon, 18 Jun 2012) Log Message: ----------- Adapted Makefile.am for building JSC target. Modified Paths: -------------- branches/gsoc2012-javascript/Source/Makefile.am Modified: branches/gsoc2012-javascript/Source/Makefile.am =================================================================== --- branches/gsoc2012-javascript/Source/Makefile.am 2012-06-18 14:37:00 UTC (rev 13175) +++ branches/gsoc2012-javascript/Source/Makefile.am 2012-06-18 14:37:25 UTC (rev 13176) @@ -51,6 +51,7 @@ Modules/lang.cxx \ Modules/javascript.cxx \ Modules/javascript_emitter.cxx \ + Modules/javascript_jsc.cxx \ Modules/lua.cxx \ Modules/main.cxx \ Modules/modula3.cxx \ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <neha1@us...> - 2012-06-18 14:37:06
|
Revision: 13175 http://swig.svn.sourceforge.net/swig/?rev=13175&view=rev Author: neha1 Date: 2012-06-18 14:37:00 +0000 (Mon, 18 Jun 2012) Log Message: ----------- Added JSC emitter implementation. Added Paths: ----------- branches/gsoc2012-javascript/Source/Modules/javascript_jsc.cxx branches/gsoc2012-javascript/Source/Modules/javascript_jsc.h Added: branches/gsoc2012-javascript/Source/Modules/javascript_jsc.cxx =================================================================== --- branches/gsoc2012-javascript/Source/Modules/javascript_jsc.cxx (rev 0) +++ branches/gsoc2012-javascript/Source/Modules/javascript_jsc.cxx 2012-06-18 14:37:00 UTC (rev 13175) @@ -0,0 +1,332 @@ +#include "javascript_jsc.h" +#include "swigmod.h" + +/* ----------------------------------------------------------------------- +* String constants that are used in Lib/javascript/JSC/javascriptcode.swg +*------------------------------------------------------------------------ */ + +// name of templates +#define JSC_GETPROPERTY_DECL "getpropertydecl" +#define JSC_SETPROPERTY_DECL "setpropertydecl" +#define JSC_FUNCTION_DECL "functiondecl" +#define JSC_ACCESS_CONSTRUCTOR_DECL "accessconstructordecl" +#define JSC_ACCESS_DESTRUCTOR_DECL "accessdestructordecl" +#define JSC_ACCESS_DESTRUCTOR_BODY "accessdestructorbody" +#define JSC_ACCESS_VARIABLE_DEFN "accessvariablesdefn" +#define JSC_ACCESS_FUNCTION_DECL "accessfunctionsdecl" +#define JSC_ACCESS_FUNCTION_DEFN "accessfunctionsdefn" +#define JSC_CONSTANT_DECL "constantdecl" +#define JSC_CONSTANT_BODY "constantbody" +#define JSC_CCONST_DECL "cconstdecl" +#define JSC_VARIABLE_GET_DECL "variablegetdecl" +#define JSC_VARIABLE_SET_DECL "variablesetdecl" +#define JSC_VARIABLE_BODY "variablebody" +#define JSC_CVAR_DECL "cvardecl" +#define JSC_CVAR_DEFN "cvardefn" +#define JSC_THIS_PTR "THIS_PTR" + +// keywords used in templates +#define KW_GET_NAME "${getname}" +#define KW_SET_NAME "${setname}" +#define KW_FUNCTION_NAME "${functionname}" +#define KW_CLASSNAME_INITIALIZE "${jsclassname_initialize}" +#define KW_CLASSNAME_STATICVALUES "${jsclassname_staticValues}" +#define KW_CLASSNAME_STATICFUNCTIONS "${jsclassname_staticFunctions}" +#define KW_INITCLASS "${jsclassname_initClass}" +#define KW_CREATEJSCLASS "${jsclassname_createJSClass}" +#define KW_CREATECPPOBJECT "${jsclassname_createcppObject}" +#define KW_INITCLASS "${jsclassname_initClass}" +#define KW_CONSTANT_GET_NAME "${constantgetname}" +#define KW_VARIABLE_GET_NAME "${variablegetname}" +#define KW_VARIABLE_SET_NAME "${variablesetname}" + + + +JSCEmitter::JSCEmitter() +{ +} + +JSCEmitter::~JSCEmitter() +{ +} + + +/* --------------------------------------------------------------------- + * skipIgnoredArgs() + * + * --------------------------------------------------------------------- */ + +Parm* JSCEmitter::skipIgnoredArgs(Parm *p) { + while (checkAttribute(p, "tmap:in:numinputs", "0")) { + p = Getattr(p, "tmap:in:next"); + } + return p; +} + +/* --------------------------------------------------------------------- + * marshalInputArgs() + * + * Process all of the arguments passed into the argv array + * and convert them into C/C++ function arguments using the + * supplied typemaps. + * --------------------------------------------------------------------- */ +void marshalInputArgs(Node *n, ParmList *parms, int numarg, Wrapper *wrapper) { + String *tm; + Parm *p; + int i = 0; + for (p = parms; p; p = nextSibling(p), i++) + { + SwigType *pt = Getattr(p, "type"); + String *ln = Getattr(p, "lname"); + String *arg = NewString(""); + Printf(arg, "argv[%d]", i); + if ((tm = Getattr(p, "tmap:in"))) // Get typemap for this argument + { + Replaceall(tm, "$input", arg); + Setattr(p, "emit:input", arg); + Printf(wrapper->code, "%s\n", tm); + } else { + Swig_warning(WARN_TYPEMAP_IN_UNDEF, input_file, line_number, "Unable to use type %s as a function argument.\n", SwigType_str(pt, 0)); + p = nextSibling(p); + } + Delete(arg); + } +} + + + +/* --------------------------------------------------------------------- +* marshalOutput() +* +* Process the return value of the C/C++ function call +* and convert them into the Javascript types using the +* supplied typemaps. +* --------------------------------------------------------------------- */ + +void JSCEmitter::marshalOutput(Node *n, String *actioncode, Wrapper *wrapper) { + SwigType *type = Getattr(n, "type"); + Setattr(n, "type", type); + String *tm; + if ((tm = Swig_typemap_lookup_out("out", n, "result", wrapper, actioncode))) + { + Replaceall(tm, "$result", "jsresult"); + // TODO: May not be the correct way + Replaceall(tm, "$objecttype", Swig_scopename_last(SwigType_str(SwigType_strip_qualifiers(type), 0))); + Printf(wrapper->code, "%s", tm); + if (Len(tm)) + Printf(wrapper->code, "\n"); + } else { + Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number, "Unable to use return type %s in function %s.\n", SwigType_str(type, 0), Getattr(n, "name")); + } + emit_return_variable(n, type, wrapper); +} + + +int JSCEmitter::Initialize(Node *n) { + /* Get the module name */ + String *module = Getattr(n,"name"); + /* Get the output file name */ + String *outfile = Getattr(n,"outfile"); + + /* Initialize I/O */ + String *outfile_h = Getattr(n, "outfile_h"); + f_wrap_h = NewFile(outfile_h, "w", SWIG_output_files()); + if (!f_wrap_h) { + FileErrorDisplay(outfile); + SWIG_exit(EXIT_FAILURE); + } + f_wrap_cpp = NewFile(outfile, "w", SWIG_output_files()); + if (!f_wrap_cpp) { + FileErrorDisplay(outfile); + SWIG_exit(EXIT_FAILURE); + } + + /* Initialization of members */ + f_runtime = NewString(""); + f_init = NewString(""); + f_header = NewString(""); + f_wrappers = NewString(""); + + + /* Register file targets with the SWIG file handler */ + Swig_register_filebyname("begin", f_wrap_cpp); + Swig_register_filebyname("header", f_header); + Swig_register_filebyname("wrapper", f_wrappers); + Swig_register_filebyname("runtime", f_runtime); + Swig_register_filebyname("init", f_init); + return SWIG_OK; +} + + +int JSCEmitter::Dump(Node *n) +{ + /* Get the module name */ + String* module = Getattr(n,"name"); + + // write the swig banner + Swig_banner(f_wrap_cpp); + + Printv(f_wrap_cpp, f_runtime, "\n", 0); + Printv(f_wrap_cpp, f_header, "\n", 0); + return SWIG_OK; +} +int JSCEmitter::Close() +{ + Delete(f_runtime); + Delete(f_header); + Delete(f_wrappers); + Delete(f_init); + + //strings + Delete(f_runtime); + Delete(f_header); + // Delete(f_class_templates); + // Delete(f_wrapper); + + + /* files */ + ::Close(f_wrap_cpp); + Delete(f_wrap_cpp); + + return SWIG_OK; +} + + +int JSCEmitter::EmitCtor(Node* n) +{ + + // TODO: handle overloaded ctors using a dispatcher + + return SWIG_OK; +} + +int JSCEmitter::EmitDtor(Node* n) +{ + + // TODO:find out how to register a dtor in JSC + return SWIG_OK; +} + +int JSCEmitter::EmitGetter(Node *n, bool is_member) { + + return SWIG_OK; +} + +int JSCEmitter::EmitSetter(Node* n, bool is_member) +{ + return SWIG_OK; +} + + +int JSCEmitter::EmitFunction(Node* n, bool is_member) +{ + +/* Get some useful attributes of this function */ + String *name = Getattr(n,"sym:name"); + SwigType *type = Getattr(n,"type"); + ParmList *parms = Getattr(n,"parms"); + String *parmstr= ParmList_str_defaultargs(parms); // to string + String *func = SwigType_str(type, NewStringf("%s(%s)", name, parmstr)); + String *action = Getattr(n,"wrap:action"); + String *tm; + Parm *p; + int i; + int num_arguments = 0; + int num_required = 0; + + /* create the wrapper object */ + Wrapper *wrapper = NewWrapper(); + + /* create the functions wrappered name */ + String *wname = Swig_name_wrapper(name); + + /* deal with overloading */ + + /* write the wrapper function definition */ + Printv(wrapper->def,"JSValueRef ", wname, "(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, \ + size_t argCount, const JSValueRef args[], JSValueRef* exception) \n{",NIL); + + /* if any additional local variable needed, add them now */ + Wrapper_add_local(wrapper, "jsresult", "JSValueRef jsresult"); + + /* write the list of locals/arguments required */ + emit_parameter_variables(parms, wrapper); + + /* check arguments */ + + /* write typemaps(in) */ + // Attach the standard typemaps + emit_attach_parmmaps(parms, wrapper); + + + // Get number of required and total arguments + num_arguments = emit_num_arguments(parms); + num_required = emit_num_required(parms); + + // Now walk the function parameter list and generate code to get arguments + for (i = 0, p = parms; i < num_arguments; i++) { + + while (checkAttribute(p, "tmap:in:numinputs", "0")) { + p = Getattr(p, "tmap:in:next"); + } + + SwigType *pt = Getattr(p, "type"); + String *ln = Getattr(p, "lname"); + String *arg = NewString(""); + + Printf(arg, "args[%d]", i); + + // Get typemap for this argument + if ((tm = Getattr(p, "tmap:in"))) { + Replaceall(tm, "$source", arg); /* deprecated */ + Replaceall(tm, "$target", ln); /* deprecated */ + Replaceall(tm, "$arg", arg); /* deprecated? */ + Replaceall(tm, "$input", arg); + Setattr(p, "emit:input", arg); + Printf(wrapper->code, "%s\n", tm); + p = Getattr(p, "tmap:in:next"); + } else { + Swig_warning(WARN_TYPEMAP_IN_UNDEF, input_file, line_number, "Unable to use type %s as a function argument.\n", SwigType_str(pt, 0)); + p = nextSibling(p); + } + Delete(arg); + } + + /* write constriants */ + + /* Emit the function call */ + Setattr(n, "wrap:name", wname); + String *actioncode = emit_action(n); + Printv(wrapper->code, actioncode, NIL); + + /* return value if necessary */ + + /* write typemaps(out) */ + + /* add cleanup code */ + + /* Close the function */ + Printv(wrapper->code, "return jsresult;\n}", NIL); + + /* final substititions if applicable */ + + /* Dump the function out */ + Wrapper_print(wrapper,f_wrappers); + + /* tidy up */ + Delete(wname); + DelWrapper(wrapper); + return SWIG_OK; + + + + +} + +JSEmitter* create_JSC_emitter() +{ + return new JSCEmitter(); +} + + + Property changes on: branches/gsoc2012-javascript/Source/Modules/javascript_jsc.cxx ___________________________________________________________________ Added: svn:executable + * Added: branches/gsoc2012-javascript/Source/Modules/javascript_jsc.h =================================================================== --- branches/gsoc2012-javascript/Source/Modules/javascript_jsc.h (rev 0) +++ branches/gsoc2012-javascript/Source/Modules/javascript_jsc.h 2012-06-18 14:37:00 UTC (rev 13175) @@ -0,0 +1,69 @@ +#ifndef JAVASCRIPT_JSC_H +#define JAVASCRIPT_JSC_H + +#include "javascript_emitter.h" + +class JSCEmitter: public JSEmitter { + +public: + + JSCEmitter(); + + virtual ~JSCEmitter(); + + virtual int Initialize(Node *n); + + virtual int Dump(Node *n); + + virtual int Close(); + + +protected: + + virtual int EmitCtor(Node *n); + + virtual int EmitDtor(Node *n); + + virtual int EmitFunction(Node *n, bool is_member); + + virtual int EmitGetter(Node *n, bool is_member); + + virtual int EmitSetter(Node *n, bool is_member); + + void marshalInputArgs(Node *n, ParmList *parms, int numarg, Wrapper *wrapper); + + void marshalOutput(Node *n, String *actioncode, Wrapper *wrapper); + + Parm *skipIgnoredArgs(Parm *p); + +private: + + File *f_wrap_h; + File *f_wrap_cpp; + File *f_runtime; + File *f_header; + File *f_wrappers; + File *f_init; + + +// the output cpp file + + File *f_wrap_cpp; + + // state variables + + String *wrap_h_code; + String *js_static_values_code; + String *js_static_funcs_code; + String *js_static_consts_code; + String *js_static_cvar_code; + String *js_create_cpp_object_code; + String *js_consts_decl_code; + String *current_class_name; + String *current_class_type; + String *variable_name; +}; + +#endif // JAVASCRIPT_JSC_H + + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <neha1@us...> - 2012-06-18 14:36:32
|
Revision: 13174 http://swig.svn.sourceforge.net/swig/?rev=13174&view=rev Author: neha1 Date: 2012-06-18 14:36:22 +0000 (Mon, 18 Jun 2012) Log Message: ----------- Added simple example for javascript JSC module. Added Paths: ----------- branches/gsoc2012-javascript/Examples/javascript/ branches/gsoc2012-javascript/Examples/javascript/simple/ branches/gsoc2012-javascript/Examples/javascript/simple/example.cpp branches/gsoc2012-javascript/Examples/javascript/simple/example.i branches/gsoc2012-javascript/Examples/javascript/simple/runme.cpp branches/gsoc2012-javascript/Examples/javascript/simple/runme.js Added: branches/gsoc2012-javascript/Examples/javascript/simple/example.cpp =================================================================== --- branches/gsoc2012-javascript/Examples/javascript/simple/example.cpp (rev 0) +++ branches/gsoc2012-javascript/Examples/javascript/simple/example.cpp 2012-06-18 14:36:22 UTC (rev 13174) @@ -0,0 +1,18 @@ +/* File : example.c */ + +/* A global variable */ +double Foo = 3.0; + +/* Compute the greatest common divisor of positive integers */ +int gcd(int x, int y) { + int g; + g = y; + while (x > 0) { + g = x; + x = y % x; + y = g; + } + return g; +} + + Added: branches/gsoc2012-javascript/Examples/javascript/simple/example.i =================================================================== --- branches/gsoc2012-javascript/Examples/javascript/simple/example.i (rev 0) +++ branches/gsoc2012-javascript/Examples/javascript/simple/example.i 2012-06-18 14:36:22 UTC (rev 13174) @@ -0,0 +1,7 @@ +/* File : example.i */ +%module example + +%inline %{ +extern int gcd(int x, int y); +extern double Foo; +%} Added: branches/gsoc2012-javascript/Examples/javascript/simple/runme.cpp =================================================================== --- branches/gsoc2012-javascript/Examples/javascript/simple/runme.cpp (rev 0) +++ branches/gsoc2012-javascript/Examples/javascript/simple/runme.cpp 2012-06-18 14:36:22 UTC (rev 13174) @@ -0,0 +1,133 @@ + +// Neha: Reference: http://opensource.apple.com/source/JavaScriptCore/JavaScriptCore-1C25/API/testapi.c + +#include "JavaScriptCore/JavaScript.h" +#include "examplejsc.h" +#include<stdlib.h> +#include<stdio.h> +#include<iostream> +using namespace std; + +static JSValueRef jsc_printstring(JSContextRef context,JSObjectRef object, JSObjectRef globalobj, size_t argc, const JSValueRef args[], JSValueRef* ex); +static char* jsccreateStringWithContentsOfFile(const char* fileName); +bool jscinitfunc(JSGlobalContextRef context, JSObjectRef object, const char* szFunctionName,JSObjectCallAsFunctionCallback cbFunction); + + +int main(int argc, char* argv[]) { + cout<<"main called\n"; + + const char *scriptPath = "test.js"; + + if (argc > 1) { + scriptPath = argv[1]; + } + + static int failed; + + JSGlobalContextRef context = JSGlobalContextCreate(NULL); + JSObjectRef globalObject = JSContextGetGlobalObject(context); + + jscinitfunc(context, globalObject, "print", jsc_printstring); // Utility print function + + // Define the globalvars object to access Global Variables + globalvars_initClass(context, globalObject, "globalvars"); + + // Define the functions + jscinitfunc(context, globalObject, "gcd", jsc_gcd); // overloaded + + // Evaluate the javascript + char* szString = jsccreateStringWithContentsOfFile(scriptPath); + JSStringRef Script; + + if(!szString) { + printf("FAIL: Test script could not be loaded.\n"); + failed = 1; + } + else { + Script = JSStringCreateWithUTF8CString(szString); + + JSValueRef ex; + JSValueRef Result = JSEvaluateScript(context,Script,NULL,NULL,0,&ex); + + if (Result) + printf("test.js executed successfully\n"); + + else { + printf("exception encountered in the script\n"); + JSStringRef exIString; + exIString = JSValueToStringCopy(context, ex, NULL); + char stringUTF8[256]; + JSStringGetUTF8CString(exIString, stringUTF8, 256); + printf(":%s\n",stringUTF8); + JSStringRelease(exIString); + } + } + if (szString != NULL) + free(szString); + + JSStringRelease(Script); + globalObject = 0; + JSGlobalContextRelease(context); + + if (failed) { + printf("FAIL: Some tests failed.\n"); + return 1; + } + + printf("PASS: Program exited normally.\n"); + return 0; +} + +bool jscinitfunc(JSGlobalContextRef context, JSObjectRef object, const char* szFunctionName,JSObjectCallAsFunctionCallback cbFunction) +{ + JSStringRef functionString = JSStringCreateWithUTF8CString(szFunctionName); + JSObjectSetProperty(context, object, functionString,JSObjectMakeFunctionWithCallback(context, functionString, cbFunction),kJSPropertyAttributeNone,NULL); + JSStringRelease(functionString); + return true; +} + +static JSValueRef jsc_printstring(JSContextRef context,JSObjectRef object, JSObjectRef globalobj, size_t argc, const JSValueRef args[], JSValueRef* ex) +{ + if (argc > 0) + { + JSStringRef string = JSValueToStringCopy(context, args[0], NULL); + size_t numChars = JSStringGetMaximumUTF8CStringSize(string); + char stringUTF8[numChars]; + JSStringGetUTF8CString(string, stringUTF8, numChars); + printf("%s\n", stringUTF8); + } + + return JSValueMakeUndefined(context); +} + +static char* jsccreateStringWithContentsOfFile(const char* fileName) +{ + char* buffer; + + size_t buffer_size = 0; + size_t buffer_capacity = 1024; + buffer = (char*)malloc(buffer_capacity); + + FILE* f = fopen(fileName, "r"); + if (!f) + { + fprintf(stderr, "Could not open file: %s\n", fileName); + return 0; + } + + while (!feof(f) && !ferror(f)) + { + buffer_size += fread(buffer + buffer_size, 1, buffer_capacity - buffer_size, f); + if (buffer_size == buffer_capacity) + { + // guarantees space for trailing '\0' + buffer_capacity *= 2; + buffer = (char*)realloc(buffer, buffer_capacity); + } + } + fclose(f); + buffer[buffer_size] = '\0'; + + return buffer; +} + Added: branches/gsoc2012-javascript/Examples/javascript/simple/runme.js =================================================================== --- branches/gsoc2012-javascript/Examples/javascript/simple/runme.js (rev 0) +++ branches/gsoc2012-javascript/Examples/javascript/simple/runme.js 2012-06-18 14:36:22 UTC (rev 13174) @@ -0,0 +1,6 @@ + print("Global variable Foo=" + globalvars.Foo); + globalvars.Foo = 5; + print("Variable Foo changed to " + globalvars.Foo); + print("GCD of number 6,18 is " + gcd(6,18)); + + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <neha1@us...> - 2012-06-18 14:35:42
|
Revision: 13173 http://swig.svn.sourceforge.net/swig/?rev=13173&view=rev Author: neha1 Date: 2012-06-18 14:35:36 +0000 (Mon, 18 Jun 2012) Log Message: ----------- Activate JSC emitter in javascript module. Modified Paths: -------------- branches/gsoc2012-javascript/Source/Modules/javascript.cxx Modified: branches/gsoc2012-javascript/Source/Modules/javascript.cxx =================================================================== --- branches/gsoc2012-javascript/Source/Modules/javascript.cxx 2012-06-18 09:40:16 UTC (rev 13172) +++ branches/gsoc2012-javascript/Source/Modules/javascript.cxx 2012-06-18 14:35:36 UTC (rev 13173) @@ -5,6 +5,7 @@ #include <ctype.h> #include "javascript_emitter.h" +extern JSEmitter* create_JSC_emitter(); /* ******************************************************************** * JAVASCRIPT @@ -205,7 +206,7 @@ } case JSEmitter::JavascriptCore: { - // TODO: emitter = create_jsc_emitter(); + emitter = create_JSC_emitter(); break; } case JSEmitter::QtScript: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <itawswati@us...> - 2012-06-18 09:40:26
|
Revision: 13172 http://swig.svn.sourceforge.net/swig/?rev=13172&view=rev Author: itawswati Date: 2012-06-18 09:40:16 +0000 (Mon, 18 Jun 2012) Log Message: ----------- Fixed Broken Example(Reference).Added code in runme.m file. Modified Paths: -------------- branches/gsoc2012-objc/Examples/objc/reference/runme.m Modified: branches/gsoc2012-objc/Examples/objc/reference/runme.m =================================================================== --- branches/gsoc2012-objc/Examples/objc/reference/runme.m 2012-06-17 05:53:29 UTC (rev 13171) +++ branches/gsoc2012-objc/Examples/objc/reference/runme.m 2012-06-18 09:40:16 UTC (rev 13172) @@ -2,5 +2,46 @@ #import "example_proxy.h" int main(int argc, char* argv[]) { - return 0; +NSAutoreleasePool *pool=[[NSAutoreleasePool alloc]init]; + //Object creation +Vector *v1 =[[Vector alloc]initWithX:3.0 y:4.0 z:5.0]; +Vector *v2 =[[Vector alloc]initWithX:10.0 y:11.0 z:12.0]; + +NSLog(@"Created v1 %@",[v1 print]); +NSLog(@"Created v2 %@",[v2 print]); + + //Call an overloaded operator + +NSLog(@"Adding a+b \n"); +Vector *v3 =addv(v1 ,v2); +NSLog(@"a+b = %@",[v3 print]); + + + //Create a vector Array +NSLog(@"Creating an array of vectors\n"); +VectorArray *va=[[VectorArray alloc]initWithMaxsize:10]; +NSLog(@" va:size %i",[va size]); + + //copy the value of v1 and v2 to a vector array +[va set:0 a:v1]; +[va set:1 a:v2]; +[va set:2 a:addv(v1,v2)]; + + //Get some values from the array + +NSLog(@"Getting some array values \n"); +int i =0; +for(i=0; i<5 ;i++) +{ +Vector *v4=[va get:i]; +NSLog(@"Array element %@",[v4 print]); +} + + //---Clean up +[v1 release]; +[v2 release]; +[va release]; +[pool drain]; + +return 0; } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |