Changeset 13755
- Timestamp:
- 01/10/12 23:07:58 (11 years ago)
- Location:
- trunk/abcl/src/org/armedbear/lisp
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abcl/src/org/armedbear/lisp/jvm-class-file.lisp
r13739 r13755 1353 1353 elements) 1354 1354 1355 (defstruct annotation-element (name "value") value) 1356 1357 (defstruct annotation-element-value tag finalizer writer) 1358 1359 (defstruct (primitive-or-string-annotation-element-value 1360 (:conc-name primitive-or-string-annotation-element-) 1361 (:include annotation-element-value 1355 (defstruct annotation-element (name "value") tag finalizer writer) 1356 1357 (defstruct (primitive-or-string-annotation-element 1358 (:include annotation-element 1362 1359 (finalizer (lambda (self class) 1363 1360 (let ((value (primitive-or-string-annotation-element-value self))) 1364 1361 (etypecase value 1365 1362 (boolean 1366 (setf (annotation-element- value-tag self)1363 (setf (annotation-element-tag self) 1367 1364 (char-code #\Z) 1368 1365 (primitive-or-string-annotation-element-value self) 1369 1366 (pool-add-int (class-file-constants class) (if value 1 0)))) 1370 1367 (fixnum 1371 (setf (annotation-element- value-tag self)1368 (setf (annotation-element-tag self) 1372 1369 (char-code #\I) 1373 1370 (primitive-or-string-annotation-element-value self) 1374 1371 (pool-add-int (class-file-constants class) value))) 1375 1372 (string 1376 (setf (annotation-element- value-tag self)1373 (setf (annotation-element-tag self) 1377 1374 (char-code #\s) 1378 1375 (primitive-or-string-annotation-element-value self) 1379 1376 (pool-add-utf8 (class-file-constants class) value))))))) 1380 1377 (writer (lambda (self stream) 1381 (write-u1 (annotation-element- value-tag self) stream)1378 (write-u1 (annotation-element-tag self) stream) 1382 1379 (write-u2 (primitive-or-string-annotation-element-value self) stream))))) 1383 1380 value) 1384 1381 1385 (defstruct (enum-value-annotation-element -value1386 (: conc-name enum-value-annotation-element-)1387 (:include annotation-element-value1382 (defstruct (enum-value-annotation-element 1383 (:include annotation-element 1384 (tag (char-code #\e)) 1388 1385 (finalizer (lambda (self class) 1389 (setf (annotation-element-value-tag self) 1390 (char-code #\e) 1391 (enum-value-annotation-element-type self) 1386 (setf (enum-value-annotation-element-type self) 1392 1387 (pool-add-utf8 (class-file-constants class) 1393 1388 (enum-value-annotation-element-type self)) ;;Binary name as string 1394 (enum-value-annotation-element- name self)1389 (enum-value-annotation-element-value self) 1395 1390 (pool-add-utf8 (class-file-constants class) 1396 (enum-value-annotation-element- name self)))))1391 (enum-value-annotation-element-value self))))) 1397 1392 (writer (lambda (self stream) 1398 (write-u1 (annotation-element- value-tag self) stream)1393 (write-u1 (annotation-element-tag self) stream) 1399 1394 (write-u2 (enum-value-annotation-element-type self) stream) 1400 (write-u2 (enum-value-annotation-element- name self) stream)))))1395 (write-u2 (enum-value-annotation-element-value self) stream))))) 1401 1396 type 1402 name) 1397 value) 1398 1399 (defstruct (annotation-value-annotation-element 1400 (:include annotation-element 1401 (tag (char-code #\@)) 1402 (finalizer (lambda (self class) 1403 (finalize-annotation (annotation-value-annotation-element-value self) class))) 1404 (writer (lambda (self stream) 1405 (write-u1 (annotation-element-tag self) stream) 1406 (write-annotation (annotation-value-annotation-element-value self) stream))))) 1407 value) 1408 1409 (defstruct (array-annotation-element 1410 (:include annotation-element 1411 (tag (char-code #\[)) 1412 (finalizer (lambda (self class) 1413 (dolist (elem (array-annotation-element-values self)) 1414 (finalize-annotation-element elem class)))) 1415 (writer (lambda (self stream) 1416 (write-u1 (annotation-element-tag self) stream) 1417 (write-u2 (length (array-annotation-element-values self)) stream) 1418 (dolist (elem (array-annotation-element-values self)) 1419 (write-annotation-element elem stream)))))) 1420 values) ;;In proper order 1403 1421 1404 1422 (defstruct (runtime-visible-annotations-attribute … … 1419 1437 (declare (ignore code)) 1420 1438 (dolist (ann (annotations-list annotations)) 1421 (setf (annotation-type ann) 1422 (pool-add-class (class-file-constants class) (annotation-type ann))) 1423 (dolist (elem (annotation-elements ann)) 1424 (setf (annotation-element-name elem) 1425 (pool-add-utf8 (class-file-constants class) 1426 (annotation-element-name elem))) 1427 (funcall (annotation-element-value-finalizer (annotation-element-value elem)) 1428 (annotation-element-value elem) class)))) 1439 (finalize-annotation ann class))) 1440 1441 (defun finalize-annotation (ann class) 1442 (setf (annotation-type ann) 1443 (pool-add-class (class-file-constants class) (annotation-type ann))) 1444 (dolist (elem (annotation-elements ann)) 1445 (finalize-annotation-element elem class))) 1446 1447 (defun finalize-annotation-element (elem class) 1448 (when (annotation-element-name elem) 1449 (setf (annotation-element-name elem) 1450 (pool-add-utf8 (class-file-constants class) 1451 (annotation-element-name elem)))) 1452 (funcall (annotation-element-finalizer elem) 1453 elem class)) 1429 1454 1430 1455 (defun write-annotations (annotations stream) 1431 1456 (write-u2 (length (annotations-list annotations)) stream) 1432 1457 (dolist (annotation (reverse (annotations-list annotations))) 1433 (write-u2 (annotation-type annotation) stream) 1434 (write-u2 (length (annotation-elements annotation)) stream) 1435 (dolist (elem (reverse (annotation-elements annotation))) 1436 (write-u2 (annotation-element-name elem) stream) 1437 (funcall (annotation-element-value-writer (annotation-element-value elem)) 1438 (annotation-element-value elem) stream)))) 1458 (write-annotation annotation stream))) 1459 1460 (defun write-annotation (annotation stream) 1461 (write-u2 (annotation-type annotation) stream) 1462 (write-u2 (length (annotation-elements annotation)) stream) 1463 (dolist (elem (reverse (annotation-elements annotation))) 1464 (write-annotation-element elem stream))) 1465 1466 (defun write-annotation-element (elem stream) 1467 (when (annotation-element-name elem) 1468 (write-u2 (annotation-element-name elem) stream)) 1469 (funcall (annotation-element-writer elem) 1470 elem stream)) 1439 1471 1440 1472 #| -
trunk/abcl/src/org/armedbear/lisp/runtime-class.lisp
r13739 r13755 144 144 :annotations (list (make-annotation :type "java.lang.Deprecated") 145 145 (make-annotation :type "java.lang.annotation.Retention" 146 :elements (list (make-annotation-element 147 :value (make-enum-value-annotation-element-value 148 :type "java.lang.annotation.RetentionPolicy" 149 :name "RUNTIME")))) 146 :elements (list (make-enum-value-annotation-element 147 :type "java.lang.annotation.RetentionPolicy" 148 :value "RUNTIME"))) 150 149 (make-annotation :type "javax.xml.bind.annotation.XmlAttribute" 151 :elements (list (make- annotation-element150 :elements (list (make-primitive-or-string-annotation-element 152 151 :name "required" 153 :value (make-primitive-or-string-annotation-element-value :value t))))))152 :value t))))) 154 153 (list "bar" :int '("java.lang.Object") 155 154 (lambda (this that) (print (list this that)) 23))))
Note: See TracChangeset
for help on using the changeset viewer.