Changeset 184:0cd2857001e1 in livinglogic.java.ul4
- Timestamp:
- 12/28/08 22:17:58 (11 years ago)
- Author:
- Walter Doerwald <walter@…>
- Branch:
- default
- Message:
-
Add support for calling witha() as an UL4 method.
- Location:
- library/src/com/livinglogic/ul4
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
r182
|
r184
|
|
11 | 11 | Color c = new Color(0x00, 0x63, 0xa8, 0x33); |
12 | 12 | Color b = new Color(0x00, 0x00, 0x00, 0xff); |
13 | | Template tmpl = Compiler.compile("<?print #fc9.withlum(0.2)?>"); |
| 13 | Template tmpl = Compiler.compile("<?print repr(#fc9.witha(0x32))?>"); |
14 | 14 | System.out.println(tmpl); |
15 | 15 | long start = System.currentTimeMillis(); |
-
r182
|
r184
|
|
141 | 141 | public static final int CM1_GET = 10; |
142 | 142 | public static final int CM1_WITHLUM = 11; |
| 143 | public static final int CM1_WITHA = 12; |
143 | 144 | |
144 | 145 | public static final int CM2_SPLIT = 0; |
… |
… |
|
467 | 468 | else if (name.equals("withlum")) |
468 | 469 | return CM1_WITHLUM; |
| 470 | else if (name.equals("witha")) |
| 471 | return CM1_WITHA; |
469 | 472 | else |
470 | 473 | throw new UnknownMethodException(name); |
-
r182
|
r184
|
|
1315 | 1315 | reg[code.r1] = Utils.withlum(reg[code.r2], reg[code.r3]); |
1316 | 1316 | break; |
| 1317 | case Opcode.CM1_WITHA: |
| 1318 | reg[code.r1] = Utils.witha(reg[code.r2], reg[code.r3]); |
| 1319 | break; |
1317 | 1320 | } |
1318 | 1321 | break; |
… |
… |
|
2097 | 2100 | code(buffer, indent, "reg" + opcode.r1 + " = reg" + opcode.r2 + ".withlum(reg" + opcode.r3 + ")"); |
2098 | 2101 | break; |
| 2102 | case Opcode.CM1_WITHA: |
| 2103 | code(buffer, indent, "reg" + opcode.r1 + " = reg" + opcode.r2 + ".witha(reg" + opcode.r3 + ")"); |
| 2104 | break; |
2099 | 2105 | } |
2100 | 2106 | break; |
-
r182
|
r184
|
|
1337 | 1337 | } |
1338 | 1338 | |
| 1339 | private static int _getint(Object arg) |
| 1340 | { |
| 1341 | if (arg instanceof Integer) |
| 1342 | return ((Integer)arg).intValue(); |
| 1343 | else if (arg instanceof Double) |
| 1344 | return ((Double)arg).intValue(); |
| 1345 | else |
| 1346 | throw new UnsupportedOperationException("can't convert " + arg.getClass() + " to int!"); |
| 1347 | } |
| 1348 | |
1339 | 1349 | public static Color rgb(Object arg1, Object arg2, Object arg3) |
1340 | 1350 | { |
… |
… |
|
1370 | 1380 | { |
1371 | 1381 | return ((Color)arg1).withlum(_getdouble(arg2)); |
| 1382 | } |
| 1383 | |
| 1384 | public static Color witha(Object arg1, Object arg2) |
| 1385 | { |
| 1386 | return ((Color)arg1).witha(_getint(arg2)); |
1372 | 1387 | } |
1373 | 1388 | |