Selaa lähdekoodia

Display more complicated examples for FieldVectors

Ole 9 vuotta sitten
vanhempi
commit
285ccc7085

+ 17 - 12
docs/mkdocs/user-types.md

@@ -81,16 +81,18 @@ luwra::registerUserType<Point(double, double)>(
 
     // Methods need to be declared here
     {
-        {"scale",       LUWRA_WRAP(Point::scale)},
-        {"x",           LUWRA_WRAP(Point::x)},
-        {"y",           LUWRA_WRAP(Point::y)},
-        {"magicNumber", 1337},
-        {"magicString", "Hello World"}
+        {"scale", LUWRA_WRAP(Point::scale)},
+        {"x",     LUWRA_WRAP(Point::x)},
+        {"y",     LUWRA_WRAP(Point::y)},
+        {"magic", luwra::FieldVector {
+            {"number", 1337},
+            {"string", "Hello World"}
+        }}
     },
 
     // Meta methods may be registered aswell
     {
-        LUWRA_MEMBER(Point, __tostring)
+        {"__tostring", LUWRA_WRAP(Point::__tostring)}
     }
 );
 ```
@@ -105,15 +107,18 @@ luwra::registerUserType<Point>(
 
     // Methods need to be declared here
     {
-        LUWRA_MEMBER(Point, scale),
-        LUWRA_MEMBER(Point, x),
-        LUWRA_MEMBER(Point, y),
-        {"magicNumber", 1337}
+        {"scale", LUWRA_WRAP(Point::scale)},
+        {"x",     LUWRA_WRAP(Point::x)},
+        {"y",     LUWRA_WRAP(Point::y)},
+        {"magic", luwra::FieldVector {
+            {"number", 1337},
+            {"string", "Hello World"}
+        }}
     },
 
     // Meta methods may be registered aswell
     {
-        LUWRA_MEMBER(Point, __tostring)
+        {"__tostring", LUWRA_WRAP(Point::__tostring)}
     }
 );
 ```
@@ -143,7 +148,7 @@ print(point)
 print(point:x(), point:y())
 
 -- Set property 'x'
-point:x(point.magicNumber)
+point:x(point.magic.number)
 ```
 
 ## Manually constructing a user type

+ 1 - 1
docs/output/index.html

@@ -193,5 +193,5 @@ your preference.</p>
 
 <!--
 MkDocs version : 0.15.3
-Build Date UTC : 2016-05-06 19:31:14.578668
+Build Date UTC : 2016-05-06 19:46:59.959773
 -->

File diff suppressed because it is too large
+ 0 - 0
docs/output/mkdocs/search_index.json


+ 17 - 12
docs/output/user-types/index.html

@@ -214,16 +214,18 @@ generates a <code>std::pair&lt;Pushable, Pushable&gt;</code> expression.</p>
 
     // Methods need to be declared here
     {
-        {&quot;scale&quot;,       LUWRA_WRAP(Point::scale)},
-        {&quot;x&quot;,           LUWRA_WRAP(Point::x)},
-        {&quot;y&quot;,           LUWRA_WRAP(Point::y)},
-        {&quot;magicNumber&quot;, 1337},
-        {&quot;magicString&quot;, &quot;Hello World&quot;}
+        {&quot;scale&quot;, LUWRA_WRAP(Point::scale)},
+        {&quot;x&quot;,     LUWRA_WRAP(Point::x)},
+        {&quot;y&quot;,     LUWRA_WRAP(Point::y)},
+        {&quot;magic&quot;, luwra::FieldVector {
+            {&quot;number&quot;, 1337},
+            {&quot;string&quot;, &quot;Hello World&quot;}
+        }}
     },
 
     // Meta methods may be registered aswell
     {
-        LUWRA_MEMBER(Point, __tostring)
+        {&quot;__tostring&quot;, LUWRA_WRAP(Point::__tostring)}
     }
 );
 </code></pre>
@@ -236,15 +238,18 @@ and name from the call to <code>registerUserType</code>.</p>
 
     // Methods need to be declared here
     {
-        LUWRA_MEMBER(Point, scale),
-        LUWRA_MEMBER(Point, x),
-        LUWRA_MEMBER(Point, y),
-        {&quot;magicNumber&quot;, 1337}
+        {&quot;scale&quot;, LUWRA_WRAP(Point::scale)},
+        {&quot;x&quot;,     LUWRA_WRAP(Point::x)},
+        {&quot;y&quot;,     LUWRA_WRAP(Point::y)},
+        {&quot;magic&quot;, luwra::FieldVector {
+            {&quot;number&quot;, 1337},
+            {&quot;string&quot;, &quot;Hello World&quot;}
+        }}
     },
 
     // Meta methods may be registered aswell
     {
-        LUWRA_MEMBER(Point, __tostring)
+        {&quot;__tostring&quot;, LUWRA_WRAP(Point::__tostring)}
     }
 );
 </code></pre>
@@ -270,7 +275,7 @@ print(point)
 print(point:x(), point:y())
 
 -- Set property 'x'
-point:x(point.magicNumber)
+point:x(point.magic.number)
 </code></pre>
 
 <h2 id="manually-constructing-a-user-type">Manually constructing a user type</h2>

+ 6 - 4
examples/usertypes.cpp

@@ -43,8 +43,10 @@ int main() {
 			LUWRA_MEMBER(Point, scale),
 			LUWRA_MEMBER(Point, x),
 			LUWRA_MEMBER(Point, y),
-			{"magicNumber", 1337},
-			{"magicString", "Hello World"}
+			{"magic", luwra::FieldVector {
+				{"number", 1337},
+				{"string", "Hello World"}
+			}}
 		},
 		// Meta methods may be registered aswell
 		{
@@ -71,8 +73,8 @@ int main() {
 		"p:x(10)\n"
 		"print('p.x =', p:x())\n"
 
-		"print('magicNumber', p.magicNumber)\n"
-		"print('magicString', p.magicString)"
+		"print('magicNumber', p.magic.number)\n"
+		"print('magicString', p.magic.string)"
 	);
 
 	// Invoke the attached script

Some files were not shown because too many files changed in this diff